作者 liyuhang

gx

... ... @@ -2,7 +2,11 @@
namespace App\Http\Controllers\Aside\User;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\User\ProjectRoleLogic;
use App\Http\Requests\Aside\User\ProjectRoleRequest;
use App\Models\ProjectRole as ProjectRoleModel;
class ProjectRoleController extends BaseController
{
... ... @@ -13,6 +17,61 @@ class ProjectRoleController extends BaseController
* @method
*/
public function lists (){
$roleModel = new ProjectRoleModel();
$lists = $roleModel->lists($this->map,$this->page,$this->row,$this->order,['*']);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :添加角色
* @return void
* @author :liyuhang
* @method
*/
public function add(ProjectRoleRequest $request,ProjectRoleLogic $roleLogic){
$request->validated();
//TODO::添加
$this->response('success');
}
/**
* @name :编辑角色
* @return void
* @author :liyuhang
* @method
*/
public function edit(ProjectRoleRequest $request,ProjectRoleLogic $roleLogic){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
//TODO::编辑
$this->response('success');
}
public function info(ProjectRoleRequest $request,ProjectRoleLogic $roleLogic){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
//TODO::详情
$this->response('success');
}
/**
* @name :删除角色
* @return void
* @author :liyuhang
* @method
*/
public function del(ProjectRoleRequest $request,ProjectRoleLogic $roleLogic){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
//TODO::删除
$this->response('success');
}
}
... ...
... ... @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Aside\User;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\User\UserLogic;
use App\Http\Requests\Aside\User\UserRequest;
use App\Models\User as UserModel;
class ProjectUserController extends BaseController
... ... @@ -16,17 +18,67 @@ class ProjectUserController extends BaseController
*/
public function lists(){
$userModel = new UserModel();
$lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','mobile','name','created_at','updated_at','image','operator_id']);
$lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,
['id','mobile','name','created_at','updated_at','image','operator_id']);
$this->response('列表',Code::SUCCESS,$lists);
}
/**
* @name :详情
* @return void
* @author :liyuhang
* @method
*/
public function info(UserRequest $request,UserLogic $userLogic){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$userLogic->user_info();
$this->response('success');
}
/**
* @name :添加用户
* @return void
* @author :liyuhang
* @method
*/
public function add(){
public function add(UserRequest $request,UserLogic $userLogic){
$request->validated();
$userLogic->user_add();
$this->response('success');
}
/**
* @name : 编辑
* @return void
* @author :liyuhang
* @method
*/
public function edit(UserRequest $request,UserLogic $userLogic){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$userLogic->user_edit();
$this->response('success');
}
/**
* @name :批量删除
* @return void
* @author :liyuhang
* @method
*/
public function del(UserRequest $request,UserLogic $userLogic){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$userLogic->user_del();
$this->response('success');
}
}
... ...
... ... @@ -84,6 +84,12 @@ class BaseController extends Controller
case 'row':
$this->row = $v;
break;
case "status":
$this->map['status'] = $v;
break;
case "category_id":
$this->map['category_id'] = $v;
break;
case "name":
$this->map['name'] = ['like','%'.$v.'%'];
break;
... ... @@ -97,7 +103,9 @@ class BaseController extends Controller
$this->map['updated_at'] = ['between', $this->_btw];
break;
default:
if(!empty($v)){
$this->map[$k] = $v;
}
break;
}
}
... ...
... ... @@ -20,7 +20,7 @@ class BlogController extends BaseController
public function lists(BlogModel $blogModel){
//搜索条件
$this->map['project_id'] = $this->user['project_id'];
$lists = $blogModel->lists($this->map,$this->page,$this->row);
$lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$blogCategoryModel= new BlogCategoryModel();
... ...
... ... @@ -114,7 +114,7 @@ class ImageController
$filename = date('ymdHis').rand(10000,99999);
$res = $this->request->file('image')->move($url,$filename);
if ($res === false) {
return $this->fail($files->getError(), Code::USER_ERROR);
return $this->response($files->getError(), Code::USER_ERROR);
}
$imageModel = new ImageModel();
$data = [
... ... @@ -126,7 +126,7 @@ class ImageController
];
$rs = $imageModel->add($data);
if ($rs === false) {
return $this->fail('添加失败', Code::USER_ERROR);
return $this->response('添加失败', Code::USER_ERROR);
}
return $hash.$filename;
}
... ... @@ -161,7 +161,7 @@ class ImageController
$filename = date('ymdHis').rand(10000,99999);
$res = $file->move($url,$filename);
if ($res === false) {
return $this->fail($file->getError(), 400);
return $this->response($file->getError(), Code::USER_ERROR);
}
$save_data[] = [
'path' => $url.$filename,
... ... @@ -173,8 +173,8 @@ class ImageController
$data[] = $hash.$filename;
}
$imageModel = new ImageModel();
$imageModel->insertAll($data);
$this->response('上传成功!', 200, $data);
$imageModel->insertAll($save_data);
return $data;
}
/**
* @name 统一返回参数
... ...
<?php
namespace App\Http\Logic\Aside\User;
namespace App\Http\Logic\Aside;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Project;
class ProjectLogic extends BaseLogic
... ...
... ... @@ -3,7 +3,6 @@
namespace App\Http\Logic\Aside;
use App\Http\Logic\Aside\User\ProjectLogic;
use App\Models\ServerConfig;
use Illuminate\Support\Facades\DB;
... ...
... ... @@ -17,6 +17,19 @@ class UserLogic extends BaseLogic
}
/**
* @name :获取详情
* @return void
* @author :liyuhang
* @method
*/
public function user_info(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('添加失败');
}
return $this->success($info);
}
/**
* @name :添加会员
* @return void
* @author :liyuhang
... ... @@ -25,7 +38,47 @@ class UserLogic extends BaseLogic
public function user_add(){
$info = $this->model->read(['mobile'=>$this->param['mobile']]);
if($info !== false){
$this->fail('error',Code::USER_ERROR);
$this->fail('当前手机号码已存在');
}
//TODO::上传头像
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('添加失败');
}
return $this->success();
}
/**
* @name :编辑会员
* @return void
* @author :liyuhang
* @method
*/
public function user_edit(){
$info = $this->model->read(['mobile'=>$this->param['mobile'],'id'=>['!=',$this->param['id']]]);
if($info !== false){
$this->fail('当前手机号码已存在');
}
//TODO::上传头像
$rs = $this->model->edits($this->param);
if($rs === false){
$this->fail('添加失败');
}
return $this->success();
}
/**
* @name :删除会员
* @return void
* @author :liyuhang
* @method
*/
public function user_del(){
$this->param['id'] = ['in',$this->param['id']];
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('删除失败');
}
return $this->success();
}
}
... ...
... ... @@ -36,7 +36,7 @@ class MailLogic extends BaseLogic
if($read_info === false){
$rs = $mailUserModel->add($data);
if($rs === false){
$this->fail('error',Code::USER_ERROR);
$this->fail('添加失败');
}
}
return $this->success($info);
... ...
... ... @@ -59,7 +59,7 @@ class UserLogic extends BaseLogic
$this->param['operator_id'] = $this->user['id'];
try {
//上传图片
if(isset($this->param['image'])){
if(isset($this->param['image']) && is_file($this->param['image'])){
//查看当前用户是否已有头像
$info = $this->model->read(['id'=>$this->param['id']],['id','image']);
if($info !== false && !empty($info['image'])){
... ...
<?php
namespace App\Http\Requests\Aside\User;
use Illuminate\Foundation\Http\FormRequest;
class ProjectRoleRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
public function rules()
{
return [
'name'=>'required|max:11||unique:gl_project_role',
'role_menu'=>'required|string',
];
}
public function messages()
{
return [
'name.required'=>'名称必须填写',
'name.max' => '名称不大于11字符.',
'role_menu.required'=>'角色列表必须填写',
];
}
}
... ...
<?php
namespace App\Http\Requests\Aside\User;
use Illuminate\Foundation\Http\FormRequest;
class UserRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'mobile'=>'required|string|max:11||unique:gl_project_user',
'password'=>'required|string|min:5',
'name'=>'required|max:20',
'role_id'=>'required'
];
}
public function messages()
{
return [
'mobile.required'=>'号码必须填写',
'mobile.string'=>'号码中含有非法文字',
'mobile.max' => '号码不大于11字符.',
'password.required'=>'密码必须填写',
'password.string'=>'密码中含有非法文字',
'password.min' => '密码不小于5字符.',
'name.required'=>'名称必须填写',
'name.min' => '名称不小于5字符.',
'role_id.required'=>'角色必须填写',
];
}
}
... ...