123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- namespace app\admin\controller;
- use app\admin\common\User as UserCommon;
- use think\facade\Validate;
- //【公司账号管理】
- class UserCompanyBasic extends Base
- {
- //列表
- public function getList()
- {
- $param = $this->request->only(['nickname' => '', 'username' => '', 'status' => '', 'page' => 1, 'size' => 10], 'post', 'trim');
- $userCommon = new UserCommon();
- $rs = json_decode($userCommon->handle('userCompanyBasicList', $param), true);
- return json_show($rs['code'], $rs['message'], $rs['data']);
- }
- //添加
- public function add()
- {
- $param = $this->request->only(['nickname', 'mobile', 'email' => '', 'companyArr' => []], 'post', 'trim');
- $val = Validate::rule([
- 'nickname|真实姓名' => 'require|min:2|max:200',
- 'mobile|手机号' => 'require|number|length:11|mobile',
- 'email|邮箱' => 'email',
- 'companyArr|关联业务公司' => 'array|max:100',
- ]);
- if (!$val->check($param)) return json_show(1004, $val->getError());
- $val_company = Validate::rule([
- 'companyCode|公司编码' => 'require|length:18',
- 'companyName|公司名称' => 'require',
- 'company_type|公司类型' => 'require|number',
- 'is_main|是否默认公司' => 'require|in:0,1',
- ]);
- foreach ($param['companyArr'] as $company) {
- if (!$val_company->check($company)) {
- return json_show(1004, $val_company->getError());
- break;
- }
- }
- $userCommon = new UserCommon();
- $rs = json_decode($userCommon->handle('userCompanyBasicAdd', $param), true);
- return json_show($rs['code'], $rs['message'], $rs['data']);
- }
- //删除
- public function delete()
- {
- $param = $this->request->only(['ids'], 'post', 'trim');
- $val = Validate::rule(['ids|账号ID' => 'require|array|max:100']);
- if (!$val->check($param)) return json_show(1004, $val->getError());
- $userCommon = new UserCommon();
- $rs = json_decode($userCommon->handle('userCompanyBasicDelete', $param), true);
- return json_show($rs['code'], $rs['message'], $rs['data']);
- }
- //编辑
- public function update()
- {
- $param = $this->request->only(['id', 'nickname', 'mobile', 'email' => '', 'portrait' => '', 'sex' => '',], 'post');
- $userCommon = new UserCommon();
- $rs = json_decode($userCommon->handle('userCompanyBasicUpdate', $param), true);
- return json_show($rs['code'], $rs['message'], $rs['data']);
- }
- //启禁用
- public function status()
- {
- $param = $this->request->only(['id', 'status'], 'post', 'trim');
- $userCommon = new UserCommon();
- $rs = json_decode($userCommon->handle('userCompanyBasicStatus', $param), true);
- return json_show($rs['code'], $rs['message'], $rs['data']);
- }
- //修改密码
- public function password()
- {
- $param = $this->request->only(['id', 'password'], 'post', 'trim');
- $userCommon = new UserCommon();
- $rs = json_decode($userCommon->handle('setpasswd', $param), true);
- return json_show($rs['code'], $rs['message'], $rs['data']);
- }
- //详情
- public function info(){
- $param = $this->request->post(['id'], 'post', 'trim');
- $userCommon = new UserCommon();
- $rs = json_decode($userCommon->handle('userCompanyBasicInfo', $param), true);
- return json_show($rs['code'], $rs['message'], $rs['data']);
- }
- }
|