|
@@ -9,17 +9,96 @@ |
|
@@ -9,17 +9,96 @@ |
|
9
|
|
9
|
|
|
10
|
namespace App\Http\Controllers\Bside\ExtensionModule;
|
10
|
namespace App\Http\Controllers\Bside\ExtensionModule;
|
|
11
|
|
11
|
|
|
|
|
12
|
+use App\Enums\Common\Code;
|
|
12
|
use App\Http\Controllers\Bside\BaseController;
|
13
|
use App\Http\Controllers\Bside\BaseController;
|
|
13
|
-use App\Models\ExtentModule\ExtensionModuleField;
|
|
|
|
14
|
use App\Models\ExtentModule\ExtensionModuleValue;
|
14
|
use App\Models\ExtentModule\ExtensionModuleValue;
|
|
15
|
-use Illuminate\Http\Request;
|
15
|
+use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
|
16
|
+use Illuminate\Support\Facades\Cache;
|
|
16
|
|
17
|
|
|
17
|
class Extension3915ModuleController extends BaseController
|
18
|
class Extension3915ModuleController extends BaseController
|
|
18
|
{
|
19
|
{
|
|
19
|
- public function __construct(Request $request)
|
20
|
+
|
|
|
|
21
|
+ /**
|
|
|
|
22
|
+ * @remark :获取列表数据
|
|
|
|
23
|
+ * @name :lists
|
|
|
|
24
|
+ * @author :lyh
|
|
|
|
25
|
+ * @method :post
|
|
|
|
26
|
+ * @time :2025/11/20 14:38
|
|
|
|
27
|
+ */
|
|
|
|
28
|
+ public function lists(){
|
|
|
|
29
|
+ $this->request->validate([
|
|
|
|
30
|
+ 'module_id'=>'required',
|
|
|
|
31
|
+ ],[
|
|
|
|
32
|
+ 'module_id.required' => '模块id不能为空',
|
|
|
|
33
|
+ ]);
|
|
|
|
34
|
+ $searchParam = [
|
|
|
|
35
|
+ 'module_id'=>$this->param['module_id'],
|
|
|
|
36
|
+ ];
|
|
|
|
37
|
+ $resultData = Cache::get('extension_module_list_3915_'.$this->param['module_id']);
|
|
|
|
38
|
+ if(empty($resultData)){
|
|
|
|
39
|
+ $data = [];
|
|
|
|
40
|
+ $moduleValueModel = new ExtensionModuleValue();
|
|
|
|
41
|
+ if(isset($this->param['field_id']) && ($this->param['field_id'] != 0) && isset($this->param['value'])){
|
|
|
|
42
|
+ $uuidArr = $moduleValueModel->formatQuery(['field_id'=>$this->param['field_id'],'value'=>$this->param['value'],'module_id'=>$this->param['module_id']])->distinct()->pluck('uuid')->toArray();
|
|
|
|
43
|
+ if(!empty($uuidArr)){
|
|
|
|
44
|
+ $searchParam['uuid'] = ['in',$uuidArr];
|
|
|
|
45
|
+ }
|
|
|
|
46
|
+ }
|
|
|
|
47
|
+ if(isset($this->param['start_time']) && !empty($this->param['start_time']) && isset($this->param['end_time']) && !empty($this->param['end_time'])){
|
|
|
|
48
|
+ $searchParam['created_at'] = ['between',[$this->param['start_time'],$this->param['end_time']]];
|
|
|
|
49
|
+ }
|
|
|
|
50
|
+ $lists = $moduleValueModel->list($searchParam);
|
|
|
|
51
|
+ if(!empty($lists)){
|
|
|
|
52
|
+ foreach ($lists as $k => $v){
|
|
|
|
53
|
+ $data[$v['uuid']][$v['field_id']] = $v['value'];
|
|
|
|
54
|
+ $data[$v['uuid']]['created_at'] = $v['created_at'];
|
|
|
|
55
|
+ }
|
|
|
|
56
|
+ }
|
|
|
|
57
|
+ $resultData = [];
|
|
|
|
58
|
+ foreach ($data as $k => $v){
|
|
|
|
59
|
+ $v['uuid'] = $k;
|
|
|
|
60
|
+ $resultData[] = $v;
|
|
|
|
61
|
+ }
|
|
|
|
62
|
+ Cache::add('extension_module_list_3915_'.$this->param['module_id'],$resultData);
|
|
|
|
63
|
+ }
|
|
|
|
64
|
+ $resultData = $this->formatPaginate($resultData,$this->row,$this->page);
|
|
|
|
65
|
+ //执行分页
|
|
|
|
66
|
+ $this->response('success',Code::SUCCESS,$resultData);
|
|
|
|
67
|
+ }
|
|
|
|
68
|
+
|
|
|
|
69
|
+ /**
|
|
|
|
70
|
+ * @remark :分页
|
|
|
|
71
|
+ * @name :simplePaginate
|
|
|
|
72
|
+ * @author :lyh
|
|
|
|
73
|
+ * @method :post
|
|
|
|
74
|
+ * @time :2025/11/20 14:50
|
|
|
|
75
|
+ */
|
|
|
|
76
|
+ public function formatPaginate($data, $size = 20, $page = 1)
|
|
20
|
{
|
77
|
{
|
|
21
|
- Parent::__construct($request);
|
|
|
|
22
|
- $this->valueModel = new ExtensionModuleValue();
|
|
|
|
23
|
- $this->filedModel = new ExtensionModuleField();
|
78
|
+ $collection = collect($data);
|
|
|
|
79
|
+ $total = $collection->count();
|
|
|
|
80
|
+ $totalPage = max(1, ceil($total / $size));
|
|
|
|
81
|
+ // 确保页码在有效范围内
|
|
|
|
82
|
+ $page = max(1, min($page, $totalPage));
|
|
|
|
83
|
+ $list = $collection->forPage($page, $size)->values()->toArray();
|
|
|
|
84
|
+ return [
|
|
|
|
85
|
+ 'list' => $list,
|
|
|
|
86
|
+ 'page' => (int)$page,
|
|
|
|
87
|
+ 'size' => (string)$size,
|
|
|
|
88
|
+ 'total' => $total,
|
|
|
|
89
|
+ 'total_page' => $totalPage
|
|
|
|
90
|
+ ];
|
|
|
|
91
|
+ }
|
|
|
|
92
|
+
|
|
|
|
93
|
+ /**
|
|
|
|
94
|
+ * @remark :导入数据
|
|
|
|
95
|
+ * @name :importData
|
|
|
|
96
|
+ * @author :lyh
|
|
|
|
97
|
+ * @method :post
|
|
|
|
98
|
+ * @time :2025/11/20 14:40
|
|
|
|
99
|
+ */
|
|
|
|
100
|
+ public function importData()
|
|
|
|
101
|
+ {
|
|
|
|
102
|
+
|
|
24
|
}
|
103
|
}
|
|
25
|
} |
104
|
} |