|
@@ -0,0 +1,103 @@
|
|
|
+<?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();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|