Systemroles.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace app\admin\controller\base;
  3. /**
  4. * @title: 系统角色类型
  5. */
  6. use app\admin\controller\Base;
  7. use app\common\model\base\org\Org as orgModel;
  8. use app\common\model\base\Systemroles as SystemRole;
  9. class Systemroles extends Base
  10. {
  11. protected $systemrolesModel = null;
  12. protected $noNeedAuth = ['getList','getListNoPage'];
  13. protected $orgModel = null;
  14. public function initialize()
  15. {
  16. parent::initialize();
  17. $this->systemrolesModel = new SystemRole;
  18. $this->orgModel = new orgModel;
  19. }
  20. /**
  21. * @title: 统一创建查询条件
  22. * @desc:
  23. * @param {*}
  24. * @return {*}
  25. * @Author: Rock
  26. * @Date: 2022-04-07 14:17:11
  27. * @LastEditTime: Do not edit
  28. */
  29. private function createWhere()
  30. {
  31. $data = $this->request->param();
  32. $where = [];
  33. if(!$this->userinfo['is_developer']){
  34. $codeNotIn = ['DEVELOPER'];
  35. $where[] = ['code','NOT IN',$codeNotIn];
  36. }
  37. if(!empty($data['keyword'])){
  38. $where[] = ['type_name','LIKE',"%".$data['keyword']."%"];
  39. }
  40. return $where;
  41. }
  42. /**
  43. * @title: 系统角色类型列表
  44. * @param {int} {pageNo} {非必填,默认值为1} {页码}
  45. * @param {int} {pageSize} {非必填,默认值为10} {每页数量}
  46. * @param {string} {keyword} {非必填} {类型名称搜索}
  47. * @return array
  48. * @Author: wangkewei
  49. * @Date: 2021/5/18 10:10
  50. */
  51. public function getList($pageNo=1,$pageSize=10)
  52. {
  53. $where = $this->createWhere();
  54. $list = $this->systemrolesModel->where($where)->paginate(['page'=>$pageNo,'list_rows'=>$pageSize]);
  55. return pageRes(1,"获取成功",$list->total(),$list->items());
  56. }
  57. /**
  58. * @title: 获取系统角色类型列表,不分页
  59. * @desc:
  60. * @param {*}
  61. * @return {*}
  62. * @Author: Rock
  63. * @Date: 2021-09-06 21:01:55
  64. * @LastEditTime: Do not edit
  65. */
  66. public function getListNoPage()
  67. {
  68. $data = $this->request->param();
  69. $where = $this->createWhere();
  70. $list = $this->systemrolesModel->where($where)->select();
  71. return res(1,"获取成功",$list);
  72. }
  73. /**
  74. * @title: 系统角色类型编辑
  75. * @param array
  76. * @return array
  77. * @Author: wangkewei
  78. * @Date: 2021/5/18 10:11
  79. */
  80. public function doEdit()
  81. {
  82. $data = $this->request->param();
  83. $this->systemrolesModel->replace()->save($data);
  84. slog(1,"编辑了系统角色类型".$data['type_name']);
  85. return res(1,"保存成功");
  86. }
  87. /**
  88. * @title: 系统角色类型删除
  89. * @param {int} {type_id} {必填} {类型ID}
  90. * @return array
  91. * @Author: wangkewei
  92. * @Date: 2021/5/18 10:12
  93. */
  94. public function doDelete(int $type_id=0)
  95. {
  96. $info = $this->systemrolesModel->where("type_id",$type_id)->find();
  97. if(empty($info)){
  98. return res(1,"删除成功");
  99. }
  100. $info->delete();
  101. slog(1,"删除了系统角色类型".$info->type_name);
  102. return res(1,"删除成功");
  103. }
  104. }