|
...
|
...
|
@@ -6,6 +6,7 @@ namespace App\Http\Logic\Aside\Manage; |
|
|
|
use App\Helper\Common;
|
|
|
|
use App\Http\Logic\Aside\BaseLogic;
|
|
|
|
use App\Models\Manage\Manage;
|
|
|
|
use App\Models\Manage\ManageHr;
|
|
|
|
use App\Models\Manage\Menu;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use Illuminate\Support\Facades\Hash;
|
|
...
|
...
|
@@ -35,22 +36,65 @@ class ManageLogic extends BaseLogic |
|
|
|
public function managerSave(){
|
|
|
|
try {
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
if(isset($this->param['password']) && !empty($this->param['password'])){
|
|
|
|
$this->param['password'] = Hash::make($this->param['password']);
|
|
|
|
}
|
|
|
|
$this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
$this->editManager();
|
|
|
|
Common::del_user_cache('manager',$this->param['id'],'A');
|
|
|
|
}else{
|
|
|
|
$this->param['password'] = Hash::make($this->param['password']);
|
|
|
|
$this->model->add($this->param);
|
|
|
|
$this->addManager();
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :添加管理员
|
|
|
|
* @name :addManager
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/20 15:49
|
|
|
|
*/
|
|
|
|
public function addManager(){
|
|
|
|
$managerInfo = $this->model->read(['mobile'=>$this->param['mobile']]);
|
|
|
|
if($managerInfo !== false){
|
|
|
|
$this->fail('当前手机号码已存在');
|
|
|
|
}
|
|
|
|
$this->param['password'] = Hash::make(isset($this->param['password']) ?? 'globalsov6');
|
|
|
|
$this->model->add($this->param);
|
|
|
|
$this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :编辑管理员
|
|
|
|
* @name :editManager
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/20 15:51
|
|
|
|
*/
|
|
|
|
public function editManager(){
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
if($info['mobile'] != $this->param['mobile']){
|
|
|
|
$mobileInfo = $this->model->read(['mobile'=>$this->param['mobile']]);
|
|
|
|
if($mobileInfo !== false){
|
|
|
|
$this->fail('当前手机号码在管理员信息中已存在');
|
|
|
|
}
|
|
|
|
//查看人事信息中是否关联当前管理员账号
|
|
|
|
$hrManagerModel = new ManageHr();
|
|
|
|
$hrInfo = $hrManagerModel->read(['manage_id'=>$this->param['id']]);
|
|
|
|
if($hrInfo !== false){
|
|
|
|
//查看是否号码在存在人事表中
|
|
|
|
$hrMobileInfo = $hrManagerModel->read(['mobile'=>$this->param['mobile']]);
|
|
|
|
if($hrMobileInfo !== false){
|
|
|
|
$this->fail('当前号码已存在人事信息中');
|
|
|
|
}
|
|
|
|
$hrManagerModel->edit(['mobile'=>$this->param['mobile']],['manage_id'=>$this->param['id']]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($this->param['password']) && !empty($this->param['password'])){
|
|
|
|
$this->param['password'] = Hash::make($this->param['password']);
|
|
|
|
}
|
|
|
|
$this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :设置排序
|
|
...
|
...
|
@@ -75,15 +119,11 @@ class ManageLogic extends BaseLogic |
|
|
|
* @time :2023/8/28 16:10
|
|
|
|
*/
|
|
|
|
public function getManagerInfo(){
|
|
|
|
$info = Common::get_user_cache('manager',$this->param['id'],'A');
|
|
|
|
if(empty($info)){
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']],
|
|
|
|
['id','name','email','mobile','status','gid','sort','dept_id','is_dept_manager','created_at','role','updated_at']);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('error');
|
|
|
|
}
|
|
|
|
Common::set_user_cache($info,'manager',$this->param['id'],'A');
|
|
|
|
}
|
|
|
|
return $this->success($info);
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|