Roles.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\Db;
  6. class Roles extends Base
  7. {
  8. // 新增
  9. public function save(){
  10. model('Roles')->add();
  11. HelpHander::success([],'操作成功');
  12. }
  13. // 编辑
  14. public function update(){
  15. model('Roles')->add();
  16. HelpHander::success([],'操作成功');
  17. }
  18. // 详情
  19. public function detail(){
  20. $id = input('id/d',0);
  21. $ret = model('Roles')->info($id);
  22. HelpHander::success($ret);
  23. }
  24. // 列表
  25. public function list(){
  26. $page = input('page/d',1);
  27. $size = input('size/d',10);
  28. $name = input('name','','trim');
  29. $code = input('code','','trim');
  30. $ret = model('Roles')->lists($page,$size,$name,$code);
  31. HelpHander::success($ret);
  32. }
  33. // 删除
  34. public function del(){
  35. $id = input('id/d',0);
  36. model('Roles')->del($id);
  37. HelpHander::success([],'操作成功');
  38. }
  39. // 公共角色列表
  40. public function queryCommonRoles(){
  41. $ret = model('Roles')->queryCommonRoles();
  42. HelpHander::success($ret);
  43. }
  44. // 查询用户的所有普通角色
  45. public function queryUserRoles(){
  46. $page = input('page/d',1);
  47. $size = input('size/d',10);
  48. $name = input('name','','trim');
  49. $code = input('code','','trim');
  50. $phone = input('phone','','trim');
  51. $depId = input('depId/d',0);
  52. $jobId = input('jobId/d',0);
  53. $orgId = input('orgId/d',0);
  54. $ret = model('Roles')->queryUserRoles($page,$size,$name,$code,$phone,$depId,$jobId,$orgId);
  55. HelpHander::success($ret);
  56. }
  57. // 分配人员组织默认角色(不同组织调人)
  58. public function saveUserRoles(){
  59. $uId = input('uId/d',0);
  60. $orgId = input('orgId/d',0);
  61. model('Roles')->saveUserRoles($uId,$orgId);
  62. HelpHander::success([],'操作成功');
  63. }
  64. // 获取机构管理员列表
  65. public function queryUserByRoles(){
  66. $page = input('page/d',1);
  67. $size = input('size/d',10);
  68. $account = input('account','','trim');
  69. $code = input('code','','trim');
  70. $oId = input('oId/d',0);
  71. $ret = model('Roles')->queryUserByRoles($page,$size,$account,$code,$oId);
  72. HelpHander::success($ret);
  73. }
  74. // 保存权限
  75. public function saveRules(){
  76. model('Roles')->saveRules();
  77. HelpHander::success([],'操作成功');
  78. }
  79. }