|
|
|
<?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\Http\Logic\Aside\Com\OaNoticeLogic;
|
|
|
|
use App\Models\Manage\Manage;
|
|
|
|
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){
|
|
|
|
$project_str = trim($v['project_str'],',');
|
|
|
|
if(strtolower($v['project_str']) != 'all'){
|
|
|
|
$v['project_title'] = $projectModel->formatQuery(['id'=>['in',explode(',',$project_str)]])->pluck('title')->toArray();
|
|
|
|
}else{
|
|
|
|
$v['project_title'] = '所有';
|
|
|
|
}
|
|
|
|
$v['operator_name'] = (new Manage())->getName($v['operator_id']);
|
|
|
|
$lists['list'][$k] = $v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$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]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($this->map['title']) && !empty($this->map['title'])){
|
|
|
|
$query->where('title','like','%'.$this->map['title'].'%');
|
|
|
|
}
|
|
|
|
if(isset($this->map['operator_id']) && !empty($this->map['operator_id'])){
|
|
|
|
$query->where('operator_id',$this->map['operator_id']);
|
|
|
|
}
|
|
|
|
if(isset($this->map['start_time']) && isset($this->map['end_time'])){
|
|
|
|
$query->whereBetween('end_time',[$this->map['start_time'],$this->map['end_time']]);
|
|
|
|
}
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取详情
|
|
|
|
* @name :info
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/6/20 16:04
|
|
|
|
*/
|
|
|
|
public function info(OaNoticeLogic $oaNoticeLogic){
|
|
|
|
$this->request->validate([
|
|
|
|
'id'=>'required',
|
|
|
|
],[
|
|
|
|
'id.required' => 'ID不能为空',
|
|
|
|
]);
|
|
|
|
$data = $oaNoticeLogic->infoOaNotice();
|
|
|
|
$this->response('success',Code::SUCCESS,$data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存数据
|
|
|
|
* @name :save
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/6/20 10:49
|
|
|
|
*/
|
|
|
|
public function save(OaNoticeLogic $oaNoticeLogic){
|
|
|
|
$this->request->validate([
|
|
|
|
'project_str'=>'required',
|
|
|
|
'title'=>'required',
|
|
|
|
'remark'=>'required',
|
|
|
|
'start_time'=>'required',
|
|
|
|
'end_time'=>'required',
|
|
|
|
],[
|
|
|
|
'project_str.required' => 'project_str不能为空',
|
|
|
|
'title.required' => 'title不能为空',
|
|
|
|
'remark.required' => 'remark不能为空',
|
|
|
|
'start_time.required' => 'start_time不能为空',
|
|
|
|
'end_time.required' => 'end_time不能为空',
|
|
|
|
]);
|
|
|
|
$data = $oaNoticeLogic->saveOaNotice();
|
|
|
|
$this->response('success',Code::SUCCESS,$data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :修改状态
|
|
|
|
* @name :status
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/6/20 10:50
|
|
|
|
*/
|
|
|
|
public function status(OaNoticeLogic $oaNoticeLogic){
|
|
|
|
$this->request->validate([
|
|
|
|
'id'=>'required',
|
|
|
|
'status'=>'required'
|
|
|
|
],[
|
|
|
|
'id.required' => 'ID不能为空',
|
|
|
|
'status.required' => 'status不能为空'
|
|
|
|
]);
|
|
|
|
$data = $oaNoticeLogic->statusOaNotice();
|
|
|
|
$this->response('success',Code::SUCCESS,$data);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|