UserCompanyBasic.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\User as UserCommon;
  4. use think\facade\Validate;
  5. //【公司账号管理】
  6. class UserCompanyBasic extends Base
  7. {
  8. //列表
  9. public function getList()
  10. {
  11. $param = $this->request->only(['nickname' => '', 'username' => '', 'status' => '', 'page' => 1, 'size' => 10], 'post', 'trim');
  12. $userCommon = new UserCommon();
  13. $rs = json_decode($userCommon->handle('userCompanyBasicList', $param), true);
  14. return json_show($rs['code'], $rs['message'], $rs['data']);
  15. }
  16. //添加
  17. public function add()
  18. {
  19. $param = $this->request->only(['nickname', 'mobile', 'email' => '', 'companyArr' => []], 'post', 'trim');
  20. $val = Validate::rule([
  21. 'nickname|真实姓名' => 'require|min:2|max:200',
  22. 'mobile|手机号' => 'require|number|length:11|mobile',
  23. 'email|邮箱' => 'email',
  24. 'companyArr|关联业务公司' => 'array|max:100',
  25. ]);
  26. if (!$val->check($param)) return json_show(1004, $val->getError());
  27. $val_company = Validate::rule([
  28. 'companyCode|公司编码' => 'require|length:18',
  29. 'companyName|公司名称' => 'require',
  30. 'company_type|公司类型' => 'require|number',
  31. 'is_main|是否默认公司' => 'require|in:0,1',
  32. ]);
  33. foreach ($param['companyArr'] as $company) {
  34. if (!$val_company->check($company)) {
  35. return json_show(1004, $val_company->getError());
  36. break;
  37. }
  38. }
  39. $userCommon = new UserCommon();
  40. $rs = json_decode($userCommon->handle('userCompanyBasicAdd', $param), true);
  41. return json_show($rs['code'], $rs['message'], $rs['data']);
  42. }
  43. //删除
  44. public function delete()
  45. {
  46. $param = $this->request->only(['ids'], 'post', 'trim');
  47. $val = Validate::rule(['ids|账号ID' => 'require|array|max:100']);
  48. if (!$val->check($param)) return json_show(1004, $val->getError());
  49. $userCommon = new UserCommon();
  50. $rs = json_decode($userCommon->handle('userCompanyBasicDelete', $param), true);
  51. return json_show($rs['code'], $rs['message'], $rs['data']);
  52. }
  53. //编辑
  54. public function update()
  55. {
  56. $param = $this->request->only(['id', 'nickname', 'mobile', 'email' => '', 'portrait' => '', 'sex' => '',], 'post');
  57. $userCommon = new UserCommon();
  58. $rs = json_decode($userCommon->handle('userCompanyBasicUpdate', $param), true);
  59. return json_show($rs['code'], $rs['message'], $rs['data']);
  60. }
  61. //启禁用
  62. public function status()
  63. {
  64. $param = $this->request->only(['id', 'status'], 'post', 'trim');
  65. $userCommon = new UserCommon();
  66. $rs = json_decode($userCommon->handle('userCompanyBasicStatus', $param), true);
  67. return json_show($rs['code'], $rs['message'], $rs['data']);
  68. }
  69. //修改密码
  70. public function password()
  71. {
  72. $param = $this->request->only(['id', 'password'], 'post', 'trim');
  73. $userCommon = new UserCommon();
  74. $rs = json_decode($userCommon->handle('setpasswd', $param), true);
  75. return json_show($rs['code'], $rs['message'], $rs['data']);
  76. }
  77. //详情
  78. public function info(){
  79. $param = $this->request->post(['id'], 'post', 'trim');
  80. $userCommon = new UserCommon();
  81. $rs = json_decode($userCommon->handle('userCompanyBasicInfo', $param), true);
  82. return json_show($rs['code'], $rs['message'], $rs['data']);
  83. }
  84. }