正在显示
1 个修改的文件
包含
37 行增加
和
4 行删除
| @@ -7,7 +7,9 @@ use App\Http\Logic\Aside\BaseLogic; | @@ -7,7 +7,9 @@ use App\Http\Logic\Aside\BaseLogic; | ||
| 7 | use App\Models\Manage\BelongingGroup; | 7 | use App\Models\Manage\BelongingGroup; |
| 8 | use App\Models\Manage\EntryPosition; | 8 | use App\Models\Manage\EntryPosition; |
| 9 | use App\Models\Manage\JobLevel; | 9 | use App\Models\Manage\JobLevel; |
| 10 | +use App\Models\Manage\Manage; | ||
| 10 | use App\Models\Manage\ManageHr; | 11 | use App\Models\Manage\ManageHr; |
| 12 | +use Illuminate\Support\Facades\Hash; | ||
| 11 | 13 | ||
| 12 | /** | 14 | /** |
| 13 | * Class ManageHrLogic | 15 | * Class ManageHrLogic |
| @@ -36,18 +38,27 @@ class HrLogic extends BaseLogic | @@ -36,18 +38,27 @@ class HrLogic extends BaseLogic | ||
| 36 | return $this->success($lists); | 38 | return $this->success($lists); |
| 37 | } | 39 | } |
| 38 | 40 | ||
| 41 | + /** | ||
| 42 | + * @remark :保存数据 | ||
| 43 | + * @name :hrSave | ||
| 44 | + * @author :lyh | ||
| 45 | + * @method :post | ||
| 46 | + * @time :2023/9/6 10:17 | ||
| 47 | + */ | ||
| 39 | public function hrSave(){ | 48 | public function hrSave(){ |
| 49 | + try { | ||
| 40 | //处理参数 | 50 | //处理参数 |
| 41 | foreach ($this->model::specieField() as $v){ | 51 | foreach ($this->model::specieField() as $v){ |
| 42 | $this->param = $this->setJson($v,$this->param); | 52 | $this->param = $this->setJson($v,$this->param); |
| 43 | } | 53 | } |
| 44 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 54 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 45 | - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($this->param, true) . PHP_EOL, FILE_APPEND); | ||
| 46 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 55 | + $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 47 | }else{ | 56 | }else{ |
| 48 | - $rs = $this->model->add($this->param); | 57 | + //添加管理员账号 |
| 58 | + $this->param['manage_id'] = $this->addManager($this->param['mobile'],$this->param['name']); | ||
| 59 | + $this->model->add($this->param); | ||
| 49 | } | 60 | } |
| 50 | - if($rs === false){ | 61 | + }catch (\Exception $e){ |
| 51 | $this->fail('error'); | 62 | $this->fail('error'); |
| 52 | } | 63 | } |
| 53 | return $this->success(); | 64 | return $this->success(); |
| @@ -180,4 +191,26 @@ class HrLogic extends BaseLogic | @@ -180,4 +191,26 @@ class HrLogic extends BaseLogic | ||
| 180 | ]; | 191 | ]; |
| 181 | return $this->success($data); | 192 | return $this->success($data); |
| 182 | } | 193 | } |
| 194 | + | ||
| 195 | + /** | ||
| 196 | + * @remark :添加人事信息时 同步添加管理员账号 | ||
| 197 | + * @name :addManager | ||
| 198 | + * @author :lyh | ||
| 199 | + * @method :post | ||
| 200 | + * @time :2023/9/6 10:18 | ||
| 201 | + */ | ||
| 202 | + public function addManager($mobile,$name){ | ||
| 203 | + $managerModel = new Manage(); | ||
| 204 | + $info = $managerModel->read(['mobile'=>$mobile]); | ||
| 205 | + if($info === false){ | ||
| 206 | + $this->fail('当前号码已存在'); | ||
| 207 | + } | ||
| 208 | + $data = [ | ||
| 209 | + 'name'=>$name, | ||
| 210 | + 'mobile'=>$mobile, | ||
| 211 | + 'password'=>Hash::make('123456'), | ||
| 212 | + 'gid'=>4, | ||
| 213 | + ]; | ||
| 214 | + return $managerModel->addReturnId($data); | ||
| 215 | + } | ||
| 183 | } | 216 | } |
-
请 注册 或 登录 后发表评论