123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace app\company\controller;
- use app\common\controller\Apic;
- use Symfony\Component\Cache\Adapter\NullAdapter;
- use think\Db;
- class Worker extends Apic
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = [];
- protected $table = 'worker';
- public function index(){
- $list = Db::name($this->table)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->select();
- $list = list_domain_image($list,['avatar']);
- $this->success(1,$list);
- }
- public function add(){
- $mobile = input('mobile','');
- if(empty($mobile)){
- $this->error();
- }
- $check = Db::name($this->table)->where('mobile',$mobile)->where('deletetime',NULL)->find();
- if($check){
- $this->error('该手机号已被他人注册');
- }
- $data = [
- 'avatar' => input('avatar',''),
- 'truename' => input('truename',''),
- 'gonghao' => input('gonghao',''),
- 'mobile' => $mobile,
- 'password' => input('password',''),
- 'company_id' => $this->auth->company_id,
- ];
- Db::name($this->table)->insertGetId($data);
- $this->success();
- }
- public function info(){
- $id = input('id',0);
- $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find();
- $info = info_domain_image($info,['avatar']);
- $this->success(1,$info);
- }
- public function edit(){
- $id = input('id',0);
- $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find();
- if(empty($info)){
- $this->error('没找到该信息,请刷新重试');
- }
- $mobile = input('mobile','');
- if(empty($mobile)){
- $this->error();
- }
- $check = Db::name($this->table)->where('mobile',$mobile)->where('id','NEQ',$id)->where('deletetime',NULL)->find();
- if($check){
- $this->error('该手机号已被他人注册');
- }
- $data = [
- 'avatar' => input('avatar',''),
- 'truename' => input('truename',''),
- 'gonghao' => input('gonghao',''),
- 'mobile' => $mobile,
- 'password' => input('password',''),
- ];
- Db::name($this->table)->where('id',$id)->update($data);
- $this->success();
- }
- public function del(){
- $ids = input('ids','');
- $ids = explode(',',$ids);
- if (empty($ids)) {
- $this->error();
- }
- Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->update(['deletetime'=>time()]);
- $this->success();
- }
- }
|