ArticleCateService.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Services\Common;
  12. use App\Models\AcceptorModel;
  13. use App\Models\AccountLogModel;
  14. use App\Models\ArticleCateModel;
  15. use App\Models\ArticleModel;
  16. use App\Models\GoodsCategoryModel;
  17. use App\Models\GoodsModel;
  18. use App\Models\TradeModel;
  19. use App\Services\BaseService;
  20. use Illuminate\Support\Facades\DB;
  21. /**
  22. * 承兑商管理-服务类
  23. * @author laravel开发员
  24. * @since 2020/11/11
  25. * @package App\Services\Common
  26. */
  27. class ArticleCateService extends BaseService
  28. {
  29. /**
  30. * 构造函数
  31. * @author laravel开发员
  32. * @since 2020/11/11
  33. */
  34. public function __construct()
  35. {
  36. $this->model = new ArticleCateModel();
  37. }
  38. /**
  39. * 获取列表
  40. * @param $params 参数
  41. * @param int $pageSize 分页大小:默认 15
  42. * @return array
  43. */
  44. public function getDataList($params, $pageSize = 10, $field=[])
  45. {
  46. $where = ['a.mark' => 1];
  47. $query = $this->model
  48. ->from('article_cate as a')
  49. ->where($where)
  50. ->select($field ? $field : ['a.*']);
  51. if (isset($params['name']) && $params['name'] != '') {
  52. $query->where('a.name','like',"%{$params['name']}%");
  53. }
  54. if (isset($params['type'])) {
  55. if(is_array($params['type'])){
  56. $query->whereIn('a.type',$params['type']);
  57. }else{
  58. if($params['type'] != ''){
  59. $query->where('a.type',$params['type']);
  60. }
  61. }
  62. }
  63. $list = $query->paginate($pageSize > 0 ? $pageSize : 9999999);
  64. $list = $list ? $list->toArray() : [];
  65. if ($list) {
  66. foreach ($list['data'] as &$item) {
  67. $item['icon'] = $item['icon'] ? get_image_url($item['icon']) : $item['icon'];
  68. }
  69. }
  70. return [
  71. 'pageSize'=> $pageSize,
  72. 'total'=>isset($list['total'])? $list['total'] : 0,
  73. 'list'=> isset($list['data'])? $list['data'] : []
  74. ];
  75. }
  76. /**
  77. * 添加会编辑会员
  78. * @return array
  79. * @since 2020/11/11
  80. * @author laravel开发员
  81. */
  82. public function edit()
  83. {
  84. // 请求参数
  85. $data = request()->all();
  86. if(!empty($data['cover'])){
  87. $data['cover'] = $data['cover'] ? remove_image_url($data['cover']) : $data['cover'];
  88. }
  89. return parent::edit($data); // TODO: Change the autogenerated stub
  90. }
  91. }