正在显示
5 个修改的文件
包含
60 行增加
和
4 行删除
| @@ -22,6 +22,7 @@ class BaseController extends Controller | @@ -22,6 +22,7 @@ class BaseController extends Controller | ||
| 22 | protected $order = 'id'; | 22 | protected $order = 'id'; |
| 23 | protected $map = [];//处理后的参数 | 23 | protected $map = [];//处理后的参数 |
| 24 | protected $uid = 0; | 24 | protected $uid = 0; |
| 25 | + protected $user = [];//当前登录用户详情 | ||
| 25 | /** | 26 | /** |
| 26 | * 获取所有参数 | 27 | * 获取所有参数 |
| 27 | */ | 28 | */ |
| @@ -43,6 +44,7 @@ class BaseController extends Controller | @@ -43,6 +44,7 @@ class BaseController extends Controller | ||
| 43 | public function auth_token(){ | 44 | public function auth_token(){ |
| 44 | $info = Cache::get($this->token); | 45 | $info = Cache::get($this->token); |
| 45 | if(isset($info) && !empty($info)){ | 46 | if(isset($info) && !empty($info)){ |
| 47 | + $this->user = $info; | ||
| 46 | $this->uid = $info['id']; | 48 | $this->uid = $info['id']; |
| 47 | } | 49 | } |
| 48 | } | 50 | } |
| @@ -157,4 +159,26 @@ class BaseController extends Controller | @@ -157,4 +159,26 @@ class BaseController extends Controller | ||
| 157 | $this->header['Per-Page'] = $this->row; //每页条数 | 159 | $this->header['Per-Page'] = $this->row; //每页条数 |
| 158 | return $this->header; | 160 | return $this->header; |
| 159 | } | 161 | } |
| 162 | + | ||
| 163 | + /** | ||
| 164 | + * @name :上传图片 | ||
| 165 | + * @return void | ||
| 166 | + * @author :liyuhang | ||
| 167 | + * @method | ||
| 168 | + */ | ||
| 169 | + public function uploads(){ | ||
| 170 | + $files = $this->request->file('file'); | ||
| 171 | + if(empty($files)){ | ||
| 172 | + return $this->response('没有上传文件',Code::USER_ERROR); | ||
| 173 | + } | ||
| 174 | + $url = './uploads/images/'; | ||
| 175 | + $param = $this->request->post(); | ||
| 176 | + if($this->request->hasFile('image') && $files->isValid()){ | ||
| 177 | + $filename = date('ymdHis').rand(10000,99999).$this->request->file('image'); | ||
| 178 | + $this->request->file('image')->move('./uploads/images/',$filename); | ||
| 179 | + }else{ | ||
| 180 | + return false; | ||
| 181 | + } | ||
| 182 | + return $url.$filename; | ||
| 183 | + } | ||
| 160 | } | 184 | } |
| @@ -15,6 +15,7 @@ class ProjectRoleController extends BaseController | @@ -15,6 +15,7 @@ class ProjectRoleController extends BaseController | ||
| 15 | * @method | 15 | * @method |
| 16 | */ | 16 | */ |
| 17 | public function lists(){ | 17 | public function lists(){ |
| 18 | + //TODO::根据当前登录用户返回 | ||
| 18 | $projectRoleModel = new ProjectRoleModel(); | 19 | $projectRoleModel = new ProjectRoleModel(); |
| 19 | $lists = $projectRoleModel->lists($this->param,$this->p,$this->row,$this->order); | 20 | $lists = $projectRoleModel->lists($this->param,$this->p,$this->row,$this->order); |
| 20 | $this->result($lists); | 21 | $this->result($lists); |
| @@ -27,6 +28,7 @@ class ProjectRoleController extends BaseController | @@ -27,6 +28,7 @@ class ProjectRoleController extends BaseController | ||
| 27 | * @method | 28 | * @method |
| 28 | */ | 29 | */ |
| 29 | public function add(){ | 30 | public function add(){ |
| 31 | + //TODO::获取当前用户的所在项目组 | ||
| 30 | //参数验证 | 32 | //参数验证 |
| 31 | $rules = [ | 33 | $rules = [ |
| 32 | 'name'=>'required|max:11', | 34 | 'name'=>'required|max:11', |
| @@ -69,6 +71,7 @@ class ProjectRoleController extends BaseController | @@ -69,6 +71,7 @@ class ProjectRoleController extends BaseController | ||
| 69 | * @method | 71 | * @method |
| 70 | */ | 72 | */ |
| 71 | public function edit(){ | 73 | public function edit(){ |
| 74 | + //TODO::根据当前登录用户返回 | ||
| 72 | //参数验证 | 75 | //参数验证 |
| 73 | $rules = [ | 76 | $rules = [ |
| 74 | 'id'=>'required', | 77 | 'id'=>'required', |
| @@ -89,6 +92,7 @@ class ProjectRoleController extends BaseController | @@ -89,6 +92,7 @@ class ProjectRoleController extends BaseController | ||
| 89 | $data['pid'] = 0; | 92 | $data['pid'] = 0; |
| 90 | } | 93 | } |
| 91 | $data = [ | 94 | $data = [ |
| 95 | + //TODO::自动写入当前用户 | ||
| 92 | 'name' => $this->param['name'], | 96 | 'name' => $this->param['name'], |
| 93 | 'pid' => $this->param['pid'], | 97 | 'pid' => $this->param['pid'], |
| 94 | ]; | 98 | ]; |
| @@ -93,7 +93,7 @@ class UserController extends BaseController | @@ -93,7 +93,7 @@ class UserController extends BaseController | ||
| 93 | return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); | 93 | return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); |
| 94 | } | 94 | } |
| 95 | $userLogic = new UserLogic(); | 95 | $userLogic = new UserLogic(); |
| 96 | - $rs = $userLogic->edit($this->param); | 96 | + $rs = $userLogic->edits($this->param); |
| 97 | if($rs === false){ | 97 | if($rs === false){ |
| 98 | $this->response('参数错误或其他服务器原因,编辑失败',Code::USER_ERROR,[]); | 98 | $this->response('参数错误或其他服务器原因,编辑失败',Code::USER_ERROR,[]); |
| 99 | } | 99 | } |
| @@ -101,6 +101,34 @@ class UserController extends BaseController | @@ -101,6 +101,34 @@ class UserController extends BaseController | ||
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | /** | 103 | /** |
| 104 | + * @name :修改当前用户状态 | ||
| 105 | + * @return void | ||
| 106 | + * @author :liyuhang | ||
| 107 | + * @method | ||
| 108 | + */ | ||
| 109 | + public function status(){ | ||
| 110 | + //参数验证 | ||
| 111 | + $rules = [ | ||
| 112 | + 'id'=>'required', | ||
| 113 | + 'status'=>'required', | ||
| 114 | + ]; | ||
| 115 | + //验证的提示信息 | ||
| 116 | + $message = [ | ||
| 117 | + 'id.required'=>'主键必须填写', | ||
| 118 | + 'status.required'=>'状态必须填写', | ||
| 119 | + ]; | ||
| 120 | + $validate = Validator::make($this->param, $rules, $message); | ||
| 121 | + if($validate->fails()){ | ||
| 122 | + return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); | ||
| 123 | + } | ||
| 124 | + $userLogic = new UserModel(); | ||
| 125 | + $rs = $userLogic->edit($this->param,['id'=>$this->param['id']]); | ||
| 126 | + if($rs === false){ | ||
| 127 | + $this->response('error',Code::USER_ERROR); | ||
| 128 | + } | ||
| 129 | + $this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功',Code::SUCCESS); | ||
| 130 | + } | ||
| 131 | + /** | ||
| 104 | * @name :删除管理员 | 132 | * @name :删除管理员 |
| 105 | * @return void | 133 | * @return void |
| 106 | * @author :liyuhang | 134 | * @author :liyuhang |
| @@ -41,7 +41,7 @@ class UserLogic extends BaseLogic | @@ -41,7 +41,7 @@ class UserLogic extends BaseLogic | ||
| 41 | * @author :liyuhang | 41 | * @author :liyuhang |
| 42 | * @method | 42 | * @method |
| 43 | */ | 43 | */ |
| 44 | - public function edit($param){ | 44 | + public function edits($param){ |
| 45 | $userModel = new UserModel(); | 45 | $userModel = new UserModel(); |
| 46 | //验证当前用户是否存在 | 46 | //验证当前用户是否存在 |
| 47 | $info = $userModel->read(['mobile'=>$param['mobile']]); | 47 | $info = $userModel->read(['mobile'=>$param['mobile']]); |
| @@ -67,7 +67,7 @@ class Base extends Model | @@ -67,7 +67,7 @@ class Base extends Model | ||
| 67 | * @author :liyuhang | 67 | * @author :liyuhang |
| 68 | * @method | 68 | * @method |
| 69 | */ | 69 | */ |
| 70 | - public function del(){ | ||
| 71 | - | 70 | + public function del($condition){ |
| 71 | + return DB::table($this->table)->where($condition)->delete(); | ||
| 72 | } | 72 | } |
| 73 | } | 73 | } |
-
请 注册 或 登录 后发表评论