123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- namespace app\admin\controller\msgPushConfig;
- use app\admin\controller\Base;
- use app\common\model\base\org\OrgRole;
- use app\common\model\msgPushConfig\MsgPushConfig as MsgPushConfigModel;
- class MsgPushConfig extends Base
- {
- protected $model = null;
- public function initialize()
- {
- parent::initialize();
- $this->model = new MsgPushConfigModel;
- }
- /**
- * @title:创建统一查询条件
- * @desc: 描述
- * @param {string} {keyword} {} {搜索关键词,可搜索角色类型分类|角色分类名称|关联角色类型}
- * @return {*}
- * @author: 系统开发
- * @method: POST
- * @Date: 2025-01-18 16:58:47
- */
- private function createWhere()
- {
- $data = $this->request->param();
- $where = [];
- $whereOr = [];
- if (!empty($data['org_id'])) {
- $where[] = ['org_id', '=', $data['org_id']];
- }
- return ['where' => $where, 'whereOr' => $whereOr];
- }
- /**
- * @title:查询数据列表
- * @desc: 描述
- * @param {string} {keyword} {} {搜索关键词,可搜索角色类型分类|角色分类名称|关联角色类型}
- * @param {int} {pageNo} {0} {页码}
- * @param {int} {pageSize} {10} {每页数量}
- * @return {*}
- * @author: 系统开发
- * @method: POST
- * @Date: 2025-01-18 16:58:47
- */
- public function getList(int $pageNo = 0, int $pageSize = 10)
- {
- $whereAry = $this->createWhere();
- if (!empty($pageNo)) {
- $res = $this->model->where($whereAry['where'])->with([
- "org" => function ($query) {
- $query->field('org_id,name');
- },
- ])->paginate(['page' => $pageNo, 'list_rows' => $pageSize]);
- $list = $res->items();
- foreach ($list as $k => $v) {
- $v['role_name'] = OrgRole::where('role_id', 'in', $v['role_ids'])->column('name');
- $v['role_name'] = implode(',', $v['role_name'] );
- }
- return pageRes(1, '获取成功', $res->total(), $list);
- } else {
- $list = $this->model->where($whereAry['where'])->select();
- return res(1, '获取成功', $list);
- }
- }
- /**
- * @title:新增/编辑信息
- * @desc: 描述
- * @param {int} {id} {} {主键ID,不传或传0表示新增,大于0表示修改}
- * @return {*}
- * @author: 系统开发
- * @method: POST
- * @Date: 2025-01-18 16:58:47
- */
- public function doEdit()
- {
- $data = $this->request->param();
- if (empty($data['org_id'])) return res(2, '请选择组织');
- if (empty($data['role_ids'])) return res(2, '请选择角色');
- if (is_array($data['role_ids'])) {
- $data['role_ids'] = implode(',', $data['role_ids']);
- }
- $res = $this->model->replace()->save($data);
- return res(1, '编辑成功');
- }
- /**
- * @title:删除信息
- * @desc: 描述
- * @param {int} id {} {信息ID}
- * @return {*}
- * @author: 系统开发
- * @method: POST
- * @Date: 2025-01-18 16:58:47
- */
- public function doDelete(int $id = 0)
- {
- $info = $this->model->find($id);
- $info->delete();
- return res(1, '删除成功');
- }
- }
|