|
...
|
...
|
@@ -9,17 +9,96 @@ |
|
|
|
|
|
|
|
namespace App\Http\Controllers\Bside\ExtensionModule;
|
|
|
|
|
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Http\Controllers\Bside\BaseController;
|
|
|
|
use App\Models\ExtentModule\ExtensionModuleField;
|
|
|
|
use App\Models\ExtentModule\ExtensionModuleValue;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
|
|
class Extension3915ModuleController extends BaseController
|
|
|
|
{
|
|
|
|
public function __construct(Request $request)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取列表数据
|
|
|
|
* @name :lists
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/11/20 14:38
|
|
|
|
*/
|
|
|
|
public function lists(){
|
|
|
|
$this->request->validate([
|
|
|
|
'module_id'=>'required',
|
|
|
|
],[
|
|
|
|
'module_id.required' => '模块id不能为空',
|
|
|
|
]);
|
|
|
|
$searchParam = [
|
|
|
|
'module_id'=>$this->param['module_id'],
|
|
|
|
];
|
|
|
|
$resultData = Cache::get('extension_module_list_3915_'.$this->param['module_id']);
|
|
|
|
if(empty($resultData)){
|
|
|
|
$data = [];
|
|
|
|
$moduleValueModel = new ExtensionModuleValue();
|
|
|
|
if(isset($this->param['field_id']) && ($this->param['field_id'] != 0) && isset($this->param['value'])){
|
|
|
|
$uuidArr = $moduleValueModel->formatQuery(['field_id'=>$this->param['field_id'],'value'=>$this->param['value'],'module_id'=>$this->param['module_id']])->distinct()->pluck('uuid')->toArray();
|
|
|
|
if(!empty($uuidArr)){
|
|
|
|
$searchParam['uuid'] = ['in',$uuidArr];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($this->param['start_time']) && !empty($this->param['start_time']) && isset($this->param['end_time']) && !empty($this->param['end_time'])){
|
|
|
|
$searchParam['created_at'] = ['between',[$this->param['start_time'],$this->param['end_time']]];
|
|
|
|
}
|
|
|
|
$lists = $moduleValueModel->list($searchParam);
|
|
|
|
if(!empty($lists)){
|
|
|
|
foreach ($lists as $k => $v){
|
|
|
|
$data[$v['uuid']][$v['field_id']] = $v['value'];
|
|
|
|
$data[$v['uuid']]['created_at'] = $v['created_at'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$resultData = [];
|
|
|
|
foreach ($data as $k => $v){
|
|
|
|
$v['uuid'] = $k;
|
|
|
|
$resultData[] = $v;
|
|
|
|
}
|
|
|
|
Cache::add('extension_module_list_3915_'.$this->param['module_id'],$resultData);
|
|
|
|
}
|
|
|
|
$resultData = $this->formatPaginate($resultData,$this->row,$this->page);
|
|
|
|
//执行分页
|
|
|
|
$this->response('success',Code::SUCCESS,$resultData);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :分页
|
|
|
|
* @name :simplePaginate
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/11/20 14:50
|
|
|
|
*/
|
|
|
|
public function formatPaginate($data, $size = 20, $page = 1)
|
|
|
|
{
|
|
|
|
Parent::__construct($request);
|
|
|
|
$this->valueModel = new ExtensionModuleValue();
|
|
|
|
$this->filedModel = new ExtensionModuleField();
|
|
|
|
$collection = collect($data);
|
|
|
|
$total = $collection->count();
|
|
|
|
$totalPage = max(1, ceil($total / $size));
|
|
|
|
// 确保页码在有效范围内
|
|
|
|
$page = max(1, min($page, $totalPage));
|
|
|
|
$list = $collection->forPage($page, $size)->values()->toArray();
|
|
|
|
return [
|
|
|
|
'list' => $list,
|
|
|
|
'page' => (int)$page,
|
|
|
|
'size' => (string)$size,
|
|
|
|
'total' => $total,
|
|
|
|
'total_page' => $totalPage
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :导入数据
|
|
|
|
* @name :importData
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/11/20 14:40
|
|
|
|
*/
|
|
|
|
public function importData()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|