OaNoticeController.php
2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* @remark :
* @name :OaNoticeController.php
* @author :lyh
* @method :post
* @time :2024/6/20 10:47
*/
namespace App\Http\Controllers\Aside\Com;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\OaNotice\OaNotice;
use App\Models\Project\Project;
use Illuminate\Support\Facades\DB;
class OaNoticeController extends BaseController
{
/**
* @remark :通知消息
* @name :lists
* @author :lyh
* @method :post
* @time :2024/6/20 10:49
*/
public function lists(){
$oaNoticeModel = new OaNotice();
$query = $oaNoticeModel->sortOrder($oaNoticeModel,'created_at','desc');
$query = $this->searchMap($query);
$lists = $query->paginate($this->row, ['*'], 'page', $this->page)->toArray();
if(!empty($lists) && !empty($lists['list'])){
$projectModel = new Project();
foreach ($lists['list'] as $k => $v){
if(strtolower($v['project_str']) != 'all'){
$v['project_title'] = $projectModel->formatQuery(['id'=>['in',explode(',',$v['project_str'])]])->pluck('title')->toArray();
}else{
$v['project_title'] = '所有';
}
$lists['list'][$k] = $v;
}
}
$lists = [];
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :参数搜索
* @name :searchMap
* @author :lyh
* @method :post
* @time :2024/6/20 11:09
*/
public function searchMap(&$query){
if(isset($this->map['project_title']) && !empty($this->map['project_title'])){
$projectModel = new Project();
$project_id_arr = $projectModel->formatQuery(['title'=>['like','%'.$this->map['project_title'].'%']])->pluck('id')->toArray();
if(!empty($project_id_arr)){
$query->where(function ($subQuery) use ($project_id_arr) {
foreach ($project_id_arr as $v) {
$subQuery->orWhereRaw("FIND_IN_SET(?, project_str) > 0", [$v]);
}
});
}
}
return $query;
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2024/6/20 10:49
*/
public function save(){
$data = [];
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :修改状态
* @name :status
* @author :lyh
* @method :post
* @time :2024/6/20 10:50
*/
public function status(){
$data = [];
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :删除数据
* @name :del
* @author :lyh
* @method :post
* @time :2024/6/20 10:50
*/
public function del(){
$this->response('success');
}
}