|
...
|
...
|
@@ -14,7 +14,6 @@ class UserLogic extends BaseLogic |
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->model = new User();
|
|
|
|
$this->param = $this->requestAll;
|
|
|
|
}
|
|
...
|
...
|
@@ -25,36 +24,48 @@ class UserLogic extends BaseLogic |
|
|
|
* @author :liyuhang
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
public function user_info(){
|
|
|
|
$info = Common::get_user_cache($this->model,$this->param['id'],'A');
|
|
|
|
if(empty($info)){
|
|
|
|
$info = $this->model->read($this->param,['id','project_id','name','status','mobile','operator_id']);
|
|
|
|
if($info === false){
|
|
|
|
public function user_info()
|
|
|
|
{
|
|
|
|
$info = Common::get_user_cache($this->model, $this->param['id'], 'A');
|
|
|
|
if (empty($info)) {
|
|
|
|
$info = $this->model->read($this->param, ['id', 'project_id', 'name', 'status', 'mobile', 'operator_id']);
|
|
|
|
if ($info === false) {
|
|
|
|
$this->fail('当前数据不存在');
|
|
|
|
}
|
|
|
|
$userModel = new UserModel();
|
|
|
|
$info['operator_name'] = $userModel->read(['id'=>$info['operator_id']],['name'])['name'];
|
|
|
|
$info['project_name'] = (new Project())->read(['id'=>$info['project_id']],['title'])['title'];
|
|
|
|
Common::set_user_cache($info,$this->model,$this->param['id'],'A');
|
|
|
|
$info['project_name'] = (new Project())->read(['id' => $info['project_id']], ['title'])['title'];
|
|
|
|
Common::set_user_cache($info, $this->model, $this->param['id'], 'A');
|
|
|
|
}
|
|
|
|
return $this->success($info);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :添加会员
|
|
|
|
* @return void
|
|
|
|
* @author :liyuhang
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
public function user_add(){
|
|
|
|
//验证当前项目是否已存在超级管理员
|
|
|
|
$info = $this->model->read(['project_id'=>$this->param['project_id'],'role_id'=>0]);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('一个项目只允许一个超级管理员');
|
|
|
|
public function projectUserSave()
|
|
|
|
{
|
|
|
|
if (isset($this->param['id']) && !empty($this->param['id'])) {
|
|
|
|
$info = $this->model->read(['mobile' => $this->param['mobile'], 'id' => ['!=', $this->param['id']]]);
|
|
|
|
if ($info !== false) {
|
|
|
|
$this->fail('当前手机号码已存在');
|
|
|
|
}
|
|
|
|
$this->param = $this->editPassword($this->param);
|
|
|
|
$rs = $this->model->edit($this->param, ['id' => $this->param['id']]);
|
|
|
|
} else {
|
|
|
|
$info = $this->model->read(['mobile'=>$this->param['mobile']]);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前手机号码已存在');
|
|
|
|
}
|
|
|
|
$info = $this->model->read(['project_id'=>$this->param['id'],'role_id'=>0]);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前项目已存在超级管理员,请选择其他项目');
|
|
|
|
}
|
|
|
|
$this->param['password'] = base64_encode(md5($this->param['password']));
|
|
|
|
$rs = $this->model->add($this->param);
|
|
|
|
}
|
|
|
|
$this->verifyMobile();//验证手机号
|
|
|
|
$this->param['password'] = base64_encode(md5($this->param['password']));
|
|
|
|
$rs = $this->model->add($this->param);
|
|
|
|
if($rs === false){
|
|
|
|
if ($rs === false) {
|
|
|
|
$this->fail('添加失败');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
...
|
...
|
@@ -66,21 +77,16 @@ class UserLogic extends BaseLogic |
|
|
|
* @author :liyuhang
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
public function user_edit(){
|
|
|
|
$this->verifyMobile();//验证手机号
|
|
|
|
public function editPassword($param)
|
|
|
|
{
|
|
|
|
//验证密码是否更改
|
|
|
|
if(isset($this->param['password']) && !empty($this->param['password'])){
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
if($info['password'] != $this->param['password']){
|
|
|
|
$this->param['password'] = base64_encode(md5($this->param['password']));
|
|
|
|
if (isset($param['password']) && !empty($param['password'])) {
|
|
|
|
$info = $this->model->read(['id' => $param['id']]);
|
|
|
|
if ($info['password'] != $param['password']) {
|
|
|
|
$param['password'] = base64_encode(md5($param['password']));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
if($rs === false){
|
|
|
|
$this->fail('编辑失败');
|
|
|
|
}
|
|
|
|
Common::del_user_cache($this->model,$this->param['id'],'A');
|
|
|
|
return $this->success();
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -89,36 +95,15 @@ class UserLogic extends BaseLogic |
|
|
|
* @author :liyuhang
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
public function user_del(){
|
|
|
|
public function user_del()
|
|
|
|
{
|
|
|
|
$ids = $this->param['id'];
|
|
|
|
$this->param['id'] = ['in',$this->param['id']];
|
|
|
|
$this->param['id'] = ['in', $this->param['id']];
|
|
|
|
$rs = $this->model->del($this->param);
|
|
|
|
if($rs === false){
|
|
|
|
if ($rs === false) {
|
|
|
|
$this->fail('删除失败');
|
|
|
|
}
|
|
|
|
Common::del_user_cache($this->model,$ids,'A');
|
|
|
|
Common::del_user_cache($this->model, $ids, 'A');
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :验证手机号
|
|
|
|
* @name :verifyMobile
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/25 9:47
|
|
|
|
*/
|
|
|
|
public function verifyMobile(){
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$info = $this->model->read(['mobile'=>$this->param['mobile'],'id'=>['!=',$this->param['id']]]);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前手机号码已存在');
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$info = $this->model->read(['mobile'=>$this->param['mobile']]);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前手机号码已存在');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|