|
@@ -223,67 +223,6 @@ class EmployeeService extends Service
|
|
|
return [true,''];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public function teamEdit($data){
|
|
|
- list($status,$msg) = $this->teamRule($data,false);
|
|
|
- if(!$status) return [$status,$msg];
|
|
|
-
|
|
|
- $model = new Team();
|
|
|
- $model = $model->where('id',$data['id'])->first();
|
|
|
- $model->title = $data['title'];
|
|
|
- $model->code = $data['code'];
|
|
|
- $model->save();
|
|
|
-
|
|
|
- return [true,'保存成功!'];
|
|
|
- }
|
|
|
-
|
|
|
- public function teamAdd($data,$user){
|
|
|
- list($status,$msg) = $this->teamRule($data);
|
|
|
- if(!$status) return [$status,$msg];
|
|
|
-
|
|
|
- $model = new Team();
|
|
|
- $model->title = $data['title'] ;
|
|
|
- $model->code = $data['code'];
|
|
|
- $model->save();
|
|
|
-
|
|
|
- return [true,'保存成功!'];
|
|
|
- }
|
|
|
-
|
|
|
- public function teamDel($data){
|
|
|
- if($this->isEmpty($data,'id')) return [false,'ID必须!'];
|
|
|
-
|
|
|
- Team::where('id',$data['id'])->update([
|
|
|
- 'del_time'=>time()
|
|
|
- ]);
|
|
|
-
|
|
|
- return [true,'删除成功'];
|
|
|
- }
|
|
|
-
|
|
|
- public function teamList($data){
|
|
|
- $list = Team::where('del_time',0)->select('title','id','crt_time','upd_time','code')->orderBy('id','desc');
|
|
|
-
|
|
|
- $list = $this->limit($list,'',$data);
|
|
|
-
|
|
|
- return [200,$list];
|
|
|
- }
|
|
|
-
|
|
|
- public function teamRule($data,$is_add = true){
|
|
|
- if($this->isEmpty($data,'title')) return [false,'名称不存在!'];
|
|
|
- if($this->isEmpty($data,'code')) return [false,'编码不存在'];
|
|
|
-
|
|
|
- $model = Team::where('title',$data['title'])
|
|
|
- ->where('code',$data['code'])
|
|
|
- ->where('del_time',0);
|
|
|
- if(! $is_add){
|
|
|
- if($this->isEmpty($data,'id')) return [false,'ID不能为空'];
|
|
|
- $model->where('id','<>',$data['id']);
|
|
|
- }
|
|
|
- $bool = $model->exists();
|
|
|
- if($bool) return [false,'名称和编码已存在!'];
|
|
|
-
|
|
|
- return [true,''];
|
|
|
- }
|
|
|
-
|
|
|
public function employeeRole($data){
|
|
|
$role_ids = [];
|
|
|
$employee_ids = [];
|
|
@@ -342,37 +281,6 @@ class EmployeeService extends Service
|
|
|
return [true,'保存成功!'];
|
|
|
}
|
|
|
|
|
|
- public function employeeTeam($data){
|
|
|
- if($this->isEmpty($data,'insert')) return [false,'数据不能为空!'];
|
|
|
-
|
|
|
- DB::beginTransaction();
|
|
|
- try {
|
|
|
- if($data['type'] == 1){
|
|
|
- EmployeeTeamPermission::whereIn('team_id',$data['insert']['team_id'])->delete();
|
|
|
- }else{
|
|
|
- EmployeeTeamPermission::whereIn('employee_id',$data['insert']['employee_id'])->delete();
|
|
|
- }
|
|
|
-
|
|
|
- $insert = [];
|
|
|
- foreach ($data['insert']['team_id'] as $t){
|
|
|
- foreach ($data['insert']['employee_id'] as $e){
|
|
|
- $insert[] = [
|
|
|
- 'team_id' => $t,
|
|
|
- 'employee_id' => $e
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- EmployeeTeamPermission::insert($insert);
|
|
|
-
|
|
|
- DB::commit();
|
|
|
- }catch (\Throwable $exception){
|
|
|
- DB::rollBack();
|
|
|
- return [false,$exception->getMessage()];
|
|
|
- }
|
|
|
-
|
|
|
- return [true,'保存成功!'];
|
|
|
- }
|
|
|
-
|
|
|
public function loginRule($data){
|
|
|
if($this->isEmpty($data,'account')) return [false,'账号不能为空!'];
|
|
|
if($this->isEmpty($data,'password')) return [false,'密码不存在!'];
|