| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 | <?phpnamespace app\api\controller\company;use app\common\controller\Apic;use think\Db;/** * 员工管理 */class Staff extends Apic{    protected $noNeedLogin = [];    protected $noNeedRight = '*';    //列表    public function lists(){        $list = Db::name('company_staff')->where('company_id',$this->auth->id)->autopage()->select();        $this->success('success',$list);    }    //新增    public function add(){        $data = [            'truename' => input('truename',''),            'mobile' => input('mobile',''),            'company_id' => $this->auth->id,        ];        //检查        $check1 = Db::name('company')->where('mobile',$data['mobile'])->find();        $check2 = Db::name('company_staff')->where('mobile',$data['mobile'])->find();        if($check1 || $check2){            $this->error('该手机已经被注册为员工或商户管理员');        }        Db::name('company_staff')->insertGetId($data);        $this->success('添加成功');    }    //详情    public function info(){        $id = input('id',0);        $info = Db::name('company_staff')->where('id',$id)->find();        $this->success(1,$info);    }    //编辑    public function edit(){        $id = input('id',0);        $data = [            'truename' => input('truename',''),            'mobile' => input('mobile',''),        ];        //检查        $check1 = Db::name('company')->where('mobile',$data['mobile'])->find();        $check2 = Db::name('company_staff')->where('id','neq',$id)->where('mobile',$data['mobile'])->find();        if($check1 || $check2){            $this->error('该手机已经被注册为员工或商户管理员');        }        Db::name('company_staff')->where('id',$id)->update($data);        $this->success('编辑成功');    }}
 |