作者 Your Name

gx

@@ -30,7 +30,6 @@ class BaseController extends Controller @@ -30,7 +30,6 @@ class BaseController extends Controller
30 { 30 {
31 $this->request = $request; 31 $this->request = $request;
32 $this->param = $this->request->all(); 32 $this->param = $this->request->all();
33 - $this->param['created_at'] = date("YmdHis");  
34 $this->token = $this->request->header('token'); 33 $this->token = $this->request->header('token');
35 $this->get_param(); 34 $this->get_param();
36 $this->auth_token(); 35 $this->auth_token();
@@ -101,12 +100,12 @@ class BaseController extends Controller @@ -101,12 +100,12 @@ class BaseController extends Controller
101 case 'row': 100 case 'row':
102 $this->row = $v; 101 $this->row = $v;
103 break; 102 break;
104 - case "create_at": 103 + case "created_at":
105 $this->_btw[0] = $v; 104 $this->_btw[0] = $v;
106 $this->_btw[1] = date('Y-m-d H:i:s',time()); 105 $this->_btw[1] = date('Y-m-d H:i:s',time());
107 $this->map['create_at'] = ['between', $this->_btw]; 106 $this->map['create_at'] = ['between', $this->_btw];
108 break; 107 break;
109 - case "update_at": 108 + case "updated_at":
110 $this->_btw[1] = $v; 109 $this->_btw[1] = $v;
111 $this->map['update_at'] = ['between', $this->_btw]; 110 $this->map['update_at'] = ['between', $this->_btw];
112 break; 111 break;
@@ -41,7 +41,7 @@ class ComController extends BaseController @@ -41,7 +41,7 @@ class ComController extends BaseController
41 $comLogic = new ComLogic(); 41 $comLogic = new ComLogic();
42 $res = $comLogic->login($this->param); 42 $res = $comLogic->login($this->param);
43 if($res === false){ 43 if($res === false){
44 - $this->response('请求失败',Code::USER_ERROR,[]); 44 + $this->response('当前用户不存在或者被禁用,登录失败',Code::USER_ERROR,[]);
45 } 45 }
46 $this->response('请求成功',Code::SUCCESS,$res); 46 $this->response('请求成功',Code::SUCCESS,$res);
47 } 47 }
@@ -23,6 +23,7 @@ class ProductClassifyController extends BaseController @@ -23,6 +23,7 @@ class ProductClassifyController extends BaseController
23 $this->map['project_id'] = $this->user['project_id']; 23 $this->map['project_id'] = $this->user['project_id'];
24 $productClassifyModel = new ProductClassifyModel(); 24 $productClassifyModel = new ProductClassifyModel();
25 $lists = $productClassifyModel->lists($this->map,$this->p,$this->row,$this->order); 25 $lists = $productClassifyModel->lists($this->map,$this->p,$this->row,$this->order);
  26 + $this->allCount = $productClassifyModel->allCount;
26 $this->result($lists); 27 $this->result($lists);
27 } 28 }
28 29
@@ -23,6 +23,7 @@ class ProductController extends BaseController @@ -23,6 +23,7 @@ class ProductController extends BaseController
23 $this->map['project_id'] = $this->user['project_id']; 23 $this->map['project_id'] = $this->user['project_id'];
24 $productModel = new ProductModel(); 24 $productModel = new ProductModel();
25 $lists = $productModel->lists($this->map,$this->p,$this->row,$this->order); 25 $lists = $productModel->lists($this->map,$this->p,$this->row,$this->order);
  26 + $this->allCount = $productModel->allCount;
26 $this->result($lists); 27 $this->result($lists);
27 } 28 }
28 29
@@ -19,6 +19,7 @@ class ProjectMenuController extends BaseController @@ -19,6 +19,7 @@ class ProjectMenuController extends BaseController
19 //根据角色获取菜单列表 19 //根据角色获取菜单列表
20 $projectMenuModel = new ProjectMenuModel(); 20 $projectMenuModel = new ProjectMenuModel();
21 $lists = $projectMenuModel->lists($this->param,$this->p,$this->row,$this->order); 21 $lists = $projectMenuModel->lists($this->param,$this->p,$this->row,$this->order);
  22 + $this->allCount = $projectMenuModel->allCount;
22 $this->result($lists); 23 $this->result($lists);
23 } 24 }
24 25
@@ -4,7 +4,7 @@ namespace App\Http\Controllers\Bside; @@ -4,7 +4,7 @@ namespace App\Http\Controllers\Bside;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Models\ProjectRole as ProjectRoleModel; 6 use App\Models\ProjectRole as ProjectRoleModel;
7 -use Illuminate\Support\Facades\DB; 7 +use App\Models\User as UserModel;
8 use Illuminate\Support\Facades\Validator; 8 use Illuminate\Support\Facades\Validator;
9 9
10 class ProjectRoleController extends BaseController 10 class ProjectRoleController extends BaseController
@@ -18,7 +18,9 @@ class ProjectRoleController extends BaseController @@ -18,7 +18,9 @@ class ProjectRoleController extends BaseController
18 public function lists(){ 18 public function lists(){
19 //TODO::根据当前登录用户返回 19 //TODO::根据当前登录用户返回
20 $projectRoleModel = new ProjectRoleModel(); 20 $projectRoleModel = new ProjectRoleModel();
21 - $lists = $projectRoleModel->lists($this->param,$this->p,$this->row,$this->order); 21 + $this->map['status'] = 0;
  22 + $lists = $projectRoleModel->lists($this->map,$this->p,$this->row,$this->order);
  23 + $this->allCount = $projectRoleModel->allCount;
22 $this->result($lists); 24 $this->result($lists);
23 } 25 }
24 26
@@ -86,7 +88,7 @@ class ProjectRoleController extends BaseController @@ -86,7 +88,7 @@ class ProjectRoleController extends BaseController
86 } 88 }
87 $projectRoleModel = new ProjectRoleModel(); 89 $projectRoleModel = new ProjectRoleModel();
88 //TODO::查询当前名称是否重复 90 //TODO::查询当前名称是否重复
89 - $info = DB::table($projectRoleModel->getTable())->where('id','<>',$this->param['id']) 91 + $info = $projectRoleModel->where('id','<>',$this->param['id'])
90 ->where(['name'=>$this->param['name'],'project_id'=>$this->user['project_id']])->first(); 92 ->where(['name'=>$this->param['name'],'project_id'=>$this->user['project_id']])->first();
91 if(!empty($info)){ 93 if(!empty($info)){
92 $this->response('当前添加的角色已存在',Code::USER_PARAMS_ERROE); 94 $this->response('当前添加的角色已存在',Code::USER_PARAMS_ERROE);
@@ -126,4 +128,37 @@ class ProjectRoleController extends BaseController @@ -126,4 +128,37 @@ class ProjectRoleController extends BaseController
126 } 128 }
127 $this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功',Code::SUCCESS); 129 $this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功',Code::SUCCESS);
128 } 130 }
  131 +
  132 + /**
  133 + * @name :删除角色
  134 + * @return void
  135 + * @author :liyuhang
  136 + * @method
  137 + */
  138 + public function del(){
  139 + //参数验证
  140 + $rules = [
  141 + 'id'=>'required',
  142 + ];
  143 + //验证的提示信息
  144 + $message = [
  145 + 'id.required'=>'主键必须填写',
  146 + ];
  147 + $validate = Validator::make($this->param, $rules, $message);
  148 + if($validate->fails()){
  149 + return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);
  150 + }
  151 + $projectRoleModel = new ProjectRoleModel();
  152 + //查询当前角色下是否有用户
  153 + $userModel = new UserModel();
  154 + $user_info = $userModel->read(['role_id'=>$this->param['id']]);
  155 + if(!empty($user_info)){
  156 + $this->response('当前角色下有用户存在,不允许删除',Code::USER_ERROR);
  157 + }
  158 + $rs = $projectRoleModel->del(['id'=>$this->param['id']]);
  159 + if($rs === false){
  160 + $this->response('error',Code::USER_ERROR);
  161 + }
  162 + $this->response('success',Code::SUCCESS);
  163 + }
129 } 164 }
@@ -19,12 +19,12 @@ class UserController extends BaseController @@ -19,12 +19,12 @@ class UserController extends BaseController
19 */ 19 */
20 public function lists(){ 20 public function lists(){
21 //TODO::搜索参数处理 21 //TODO::搜索参数处理
22 - $userLogic = new UserLogic();  
23 - $lists = $userLogic->lists($this->map,$this->p,$this->row,$this->order,['id','name','mobile']); 22 + $userModel = new UserModel();
  23 + $lists = $userModel->lists($this->map,$this->p,$this->row,$this->order,['id','name','mobile']);
24 if(empty($lists)){ 24 if(empty($lists)){
25 $this->response('请求失败',Code::USER_ERROR,[]); 25 $this->response('请求失败',Code::USER_ERROR,[]);
26 } 26 }
27 - return response()->json($lists); 27 + $this->allCount = $userModel->allCount;
28 $this->result($lists); 28 $this->result($lists);
29 } 29 }
30 30
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace App\Http\Logic\Bside; 3 namespace App\Http\Logic\Bside;
4 4
  5 +use App\Models\ProjectRole as ProjectRoleModel;
5 use App\Models\User as UserModel; 6 use App\Models\User as UserModel;
6 use Illuminate\Support\Facades\Cache; 7 use Illuminate\Support\Facades\Cache;
7 8
@@ -14,12 +15,11 @@ class ComLogic extends BaseLogic @@ -14,12 +15,11 @@ class ComLogic extends BaseLogic
14 * @method 15 * @method
15 */ 16 */
16 public function login($param){ 17 public function login($param){
17 - #TODO 查询mobile, 验证密码 true->return; false-> 查询sms发送记录 验证code  
18 $userModel = new UserModel(); 18 $userModel = new UserModel();
19 if(!isset($param['login_method'])){ 19 if(!isset($param['login_method'])){
20 //密码加密 20 //密码加密
21 $param['password'] = base64_encode(md5($param['password'])); 21 $param['password'] = base64_encode(md5($param['password']));
22 - $info = $userModel->read(['mobile'=>$param['mobile'],'password'=>$param['password']], ['*']); 22 + $info = $userModel->read(['mobile'=>$param['mobile'],'password'=>$param['password'],'status'=>0], ['*']);
23 }else{ 23 }else{
24 //TODO::验证验证码是否正确 24 //TODO::验证验证码是否正确
25 $info = $userModel->read(['mobile'=>$param['mobile']],['*']); 25 $info = $userModel->read(['mobile'=>$param['mobile']],['*']);
@@ -27,8 +27,13 @@ class ComLogic extends BaseLogic @@ -27,8 +27,13 @@ class ComLogic extends BaseLogic
27 if(empty($info)){ 27 if(empty($info)){
28 return false; 28 return false;
29 } 29 }
  30 + //当前用户角色是否被禁用
  31 + $projectRoleModel = new ProjectRoleModel();
  32 + $role_info = $projectRoleModel->read(['id'=>$info['role_id'],'status'=>0]);
  33 + if(empty($role_info)){
  34 + return false;
  35 + }
30 //验证码登录 36 //验证码登录
31 -  
32 if(isset($info['token']) && !empty($info['token'])){ 37 if(isset($info['token']) && !empty($info['token'])){
33 //清除上一次用户缓存 38 //清除上一次用户缓存
34 Cache::pull($info['token']); 39 Cache::pull($info['token']);
@@ -38,7 +43,6 @@ class ComLogic extends BaseLogic @@ -38,7 +43,6 @@ class ComLogic extends BaseLogic
38 //存储缓存 43 //存储缓存
39 Cache::add($token,$info); 44 Cache::add($token,$info);
40 //更新数据库 45 //更新数据库
41 -  
42 $data = [ 46 $data = [
43 'id'=>$info['id'], 47 'id'=>$info['id'],
44 'mobile'=>$info['mobile'], 48 'mobile'=>$info['mobile'],
@@ -19,9 +19,10 @@ class Base extends Model @@ -19,9 +19,10 @@ class Base extends Model
19 //TODO::where(['id'=>'','name'=>'']) 19 //TODO::where(['id'=>'','name'=>''])
20 $lists = $this->select($fields)->where($map)->forPage($p,$row)->orderBy($order)->get(); 20 $lists = $this->select($fields)->where($map)->forPage($p,$row)->orderBy($order)->get();
21 if ($lists->isEmpty() === false) { 21 if ($lists->isEmpty() === false) {
22 - $lists = $lists->toArray();  
23 - $this->allCount = $this->where($map)->count(); 22 + return false;
24 } 23 }
  24 + $lists = $lists->toArray();
  25 + $this->allCount = $this->where($map)->count();
25 return $lists; 26 return $lists;
26 } 27 }
27 28
@@ -38,8 +39,9 @@ class Base extends Model @@ -38,8 +39,9 @@ class Base extends Model
38 public function list($map,$order = 'id',$fields = ['*']){ 39 public function list($map,$order = 'id',$fields = ['*']){
39 $lists = $this->select($fields)->where($map)->orderBy($order)->get(); 40 $lists = $this->select($fields)->where($map)->orderBy($order)->get();
40 if ($lists->isEmpty() === false) { 41 if ($lists->isEmpty() === false) {
41 - $lists = $lists->toArray(); 42 + return false;
42 } 43 }
  44 + $lists = $lists->toArray();
43 return $lists; 45 return $lists;
44 } 46 }
45 /** 47 /**
@@ -16,6 +16,10 @@ Route::group([], function () { @@ -16,6 +16,10 @@ Route::group([], function () {
16 Route::any('/get_project', [\App\Http\Controllers\Bside\ComController::class, 'get_project'])->name('get_project'); 16 Route::any('/get_project', [\App\Http\Controllers\Bside\ComController::class, 'get_project'])->name('get_project');
17 Route::any('/user/lists', [\App\Http\Controllers\Bside\UserController::class, 'lists'])->name('user_lists'); 17 Route::any('/user/lists', [\App\Http\Controllers\Bside\UserController::class, 'lists'])->name('user_lists');
18 Route::any('/project/page_lists', [\App\Http\Controllers\Bside\ProjectController::class, 'page_lists'])->name('page_lists'); 18 Route::any('/project/page_lists', [\App\Http\Controllers\Bside\ProjectController::class, 'page_lists'])->name('page_lists');
  19 + //用户角色相关路由
  20 + Route::any('/project_role/lists', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'lists'])->name('project_role_lists');
19 Route::any('/project_role/add', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'add'])->name('project_role_add'); 21 Route::any('/project_role/add', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'add'])->name('project_role_add');
20 Route::any('/project_role/edit', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'edit'])->name('project_role_edit'); 22 Route::any('/project_role/edit', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'edit'])->name('project_role_edit');
  23 + Route::any('/project_role/status', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'status'])->name('project_role_status');
  24 + Route::any('/project_role/del', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'del'])->name('project_role_del');
21 }); 25 });