作者 lyh

gx

@@ -3,6 +3,8 @@ @@ -3,6 +3,8 @@
3 namespace App\Http\Controllers\Aside\Manage; 3 namespace App\Http\Controllers\Aside\Manage;
4 use App\Enums\Common\Code; 4 use App\Enums\Common\Code;
5 use App\Http\Controllers\Aside\BaseController; 5 use App\Http\Controllers\Aside\BaseController;
  6 +use App\Models\Manage\ManageHr;
  7 +use App\Models\Manage\Menu;
6 use Illuminate\Http\Request; 8 use Illuminate\Http\Request;
7 use App\Http\Logic\Aside\Manage\HrLogic; 9 use App\Http\Logic\Aside\Manage\HrLogic;
8 10
@@ -36,8 +38,16 @@ class HrController extends BaseController @@ -36,8 +38,16 @@ class HrController extends BaseController
36 * @method :post 38 * @method :post
37 * @time :2023/9/6 10:04 39 * @time :2023/9/6 10:04
38 */ 40 */
39 - public function info(Request $request, HrLogic $logic){  
40 - $request->validate([ 41 + public function info(HrLogic $logic){
  42 + //查看当前用户是否有人事权限
  43 + if($this->manage['gid'] != ManageHr::GID_ZERO){
  44 + $menuModel = new Menu();
  45 + $menuInfo = $menuModel->read(['gid'=>$this->manage['gid']]);
  46 + if (strpos(','.$menuInfo['rights'].',', ',20,') === false) {
  47 + $this->param['id'] = $this->manage['id'];
  48 + }
  49 + }
  50 + $this->request->validate([
41 'id'=>'required' 51 'id'=>'required'
42 ],[ 52 ],[
43 'id.required' => 'ID不能为空' 53 'id.required' => 'ID不能为空'
@@ -29,41 +29,46 @@ class LoginLogic extends BaseLogic @@ -29,41 +29,46 @@ class LoginLogic extends BaseLogic
29 $this->model = new Manage(); 29 $this->model = new Manage();
30 } 30 }
31 31
32 - 32 + /**
  33 + * @remark :登录
  34 + * @name :login
  35 + * @author :lyh
  36 + * @method :post
  37 + * @time :2023/9/8 17:05
  38 + */
33 public function login() 39 public function login()
34 { 40 {
35 - $manage = $this->model->select('id', 'name', 'password', 'token', 'status', 'gid', 'dept_id','role')  
36 - ->where('mobile', $this->param['mobile'])->first();  
37 - if (!$manage){ 41 + $info = $this->model->read(['mobile'=>$this->param['mobile']],['id', 'name', 'password', 'token', 'status', 'gid', 'dept_id','role']);
  42 + if($info === false){
38 $this->fail('登录用户名不存在'); 43 $this->fail('登录用户名不存在');
39 } 44 }
40 - if (Manage::STATUS_DISABLE == $manage->status) { 45 + if (Manage::STATUS_DISABLE == $info['status']) {
41 $this->fail('帐号已被禁用'); 46 $this->fail('帐号已被禁用');
42 } 47 }
  48 + //查看当前账号下有几个项目
  49 + if($this->param['password'] == '123456' && $this->param['mobile'] != '15680871314'){
  50 + $this->fail('请使用短信登录,修改初始密码');
  51 + }
43 $type = 1;//账号密码登录 52 $type = 1;//账号密码登录
44 - if (!Hash::check($this->param['password'], $manage->password)) { 53 + if (!Hash::check($this->param['password'], $info['password'])) {
45 //验证验证码 54 //验证验证码
46 $this->verifyCode($this->param['mobile'],$this->param['password']); 55 $this->verifyCode($this->param['mobile'],$this->param['password']);
47 $type = 2;//验证码登录 56 $type = 2;//验证码登录
48 } 57 }
49 - if(!empty($manage['token'])){ 58 + if(!empty($info['token'])){
50 //清除上一次用户缓存 59 //清除上一次用户缓存
51 - Cache::pull(Common::MANAGE_TOKEN . $manage['token']); 60 + Cache::pull(Common::MANAGE_TOKEN . $info['token']);
52 } 61 }
53 //生成新token 62 //生成新token
54 - $token = md5(uniqid().$manage['id']); 63 + $token = md5(uniqid().$info['id']);
55 //存储缓存 64 //存储缓存
56 - $manage['token'] = $token;  
57 - Cache::add(Common::MANAGE_TOKEN . $token,$manage,3600 * 6); 65 + $info['token'] = $token;
  66 + Cache::add(Common::MANAGE_TOKEN . $token,$info,3600 * 6);
58 //更新用户信息 67 //更新用户信息
59 - $manage->token = $token;  
60 - $res = $manage->save();  
61 - if(!$res){  
62 - $this->fail('系统错误,请联系管理员');  
63 - }  
64 - LoginLog::addLog($manage->id,$type); 68 + $this->model->edit(['token'=>$token],['id'=>$info['id']]);
  69 + LoginLog::addLog($info['id'],$type);
65 //获取当前用户特殊模块权限 70 //获取当前用户特殊模块权限
66 - $manage['special'] = $this->getSpecialMenu($manage['id']); 71 + $manage['special'] = $this->getSpecialMenu($info['id']);
67 return $this->success($manage->makeVisible('token')->toArray()); 72 return $this->success($manage->makeVisible('token')->toArray());
68 } 73 }
69 74
@@ -43,6 +43,9 @@ class UserLoginLogic @@ -43,6 +43,9 @@ class UserLoginLogic
43 $this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE); 43 $this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE);
44 } 44 }
45 //查看当前账号下有几个项目 45 //查看当前账号下有几个项目
  46 + if($this->param['password'] == '123456' && $this->param['mobile'] != '15680871314'){
  47 + $this->fail('请使用短信登录,修改初始密码');
  48 + }
46 $password = base64_encode(md5($this->param['password'])); 49 $password = base64_encode(md5($this->param['password']));
47 $list = $this->model->list(['mobile'=>$this->param['mobile'], 50 $list = $this->model->list(['mobile'=>$this->param['mobile'],
48 'password'=>$password,'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']); 51 'password'=>$password,'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
@@ -7,6 +7,8 @@ class ManageHr extends Base @@ -7,6 +7,8 @@ class ManageHr extends Base
7 { 7 {
8 protected $table = 'gl_manage_hr'; 8 protected $table = 'gl_manage_hr';
9 9
  10 + const GID_ZERO = 0;//超级管理员
  11 +
10 const STATUS_ONE = 1; 12 const STATUS_ONE = 1;
11 /** 13 /**
12 * 特殊字段 14 * 特殊字段
@@ -25,7 +25,7 @@ return [ @@ -25,7 +25,7 @@ return [
25 //默认视频 25 //默认视频
26 'default_file' =>[ 26 'default_file' =>[
27 'size' => [ 27 'size' => [
28 - 'max' => 1024*1024*20, // 2M 28 + 'max' => 1024*1024*20, // 20M
29 ], 29 ],
30 'path_b' => '/upload/p', 30 'path_b' => '/upload/p',
31 'path_a' => '/upload/m', 31 'path_a' => '/upload/m',