Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev
正在显示
22 个修改的文件
包含
371 行增加
和
43 行删除
| @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Aside\User; | @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Aside\User; | ||
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Controllers\Aside\BaseController; | 6 | use App\Http\Controllers\Aside\BaseController; |
| 7 | +use App\Http\Logic\Aside\User\ProjectGroupLogic; | ||
| 8 | +use App\Http\Requests\Aside\User\ProjectGroupRequest; | ||
| 7 | use App\Models\ProjectGroup as ProjectGroupModel; | 9 | use App\Models\ProjectGroup as ProjectGroupModel; |
| 8 | 10 | ||
| 9 | class ProjectGroupController extends BaseController | 11 | class ProjectGroupController extends BaseController |
| @@ -15,4 +17,64 @@ class ProjectGroupController extends BaseController | @@ -15,4 +17,64 @@ class ProjectGroupController extends BaseController | ||
| 15 | $lists = $projectGroupModel->lists($this->map,$this->page,$this->row,$this->order); | 17 | $lists = $projectGroupModel->lists($this->map,$this->page,$this->row,$this->order); |
| 16 | $this->response('success',Code::SUCCESS,$lists); | 18 | $this->response('success',Code::SUCCESS,$lists); |
| 17 | } | 19 | } |
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * @name :添加用户组 | ||
| 23 | + * @return void | ||
| 24 | + * @author :liyuhang | ||
| 25 | + * @method | ||
| 26 | + */ | ||
| 27 | + public function add(ProjectGroupRequest $request,ProjectGroupLogic $projectGroupLogic){ | ||
| 28 | + $request->validated(); | ||
| 29 | + $projectGroupLogic->group_add(); | ||
| 30 | + $this->response('success'); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * @name :编辑用户组 | ||
| 35 | + * @return void | ||
| 36 | + * @author :liyuhang | ||
| 37 | + * @method | ||
| 38 | + */ | ||
| 39 | + public function edit(ProjectGroupRequest $request,ProjectGroupLogic $projectGroupLogic){ | ||
| 40 | + $request->validate([ | ||
| 41 | + 'id'=>'required' | ||
| 42 | + ],[ | ||
| 43 | + 'id.required' => 'ID不能为空' | ||
| 44 | + ]); | ||
| 45 | + $projectGroupLogic->group_edit(); | ||
| 46 | + $this->response('success'); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * @name :用户组详情 | ||
| 51 | + * @return void | ||
| 52 | + * @author :liyuhang | ||
| 53 | + * @method | ||
| 54 | + */ | ||
| 55 | + public function info(ProjectGroupLogic $projectGroupLogic){ | ||
| 56 | + $this->request->validate([ | ||
| 57 | + 'id'=>'required' | ||
| 58 | + ],[ | ||
| 59 | + 'id.required' => 'ID不能为空' | ||
| 60 | + ]); | ||
| 61 | + $projectGroupLogic->group_info(); | ||
| 62 | + $this->success('success'); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * @name :删除用户组 | ||
| 67 | + * @return void | ||
| 68 | + * @author :liyuhang | ||
| 69 | + * @method | ||
| 70 | + */ | ||
| 71 | + public function del(ProjectGroupLogic $projectGroupLogic){ | ||
| 72 | + $this->request->validate([ | ||
| 73 | + 'id'=>'required' | ||
| 74 | + ],[ | ||
| 75 | + 'id.required' => 'ID不能为空' | ||
| 76 | + ]); | ||
| 77 | + $projectGroupLogic->group_del(); | ||
| 78 | + $this->success('success'); | ||
| 79 | + } | ||
| 18 | } | 80 | } |
| @@ -30,8 +30,8 @@ class ProjectUserController extends BaseController | @@ -30,8 +30,8 @@ class ProjectUserController extends BaseController | ||
| 30 | * @author :liyuhang | 30 | * @author :liyuhang |
| 31 | * @method | 31 | * @method |
| 32 | */ | 32 | */ |
| 33 | - public function info(Request $request,UserLogic $userLogic){ | ||
| 34 | - $request->validate([ | 33 | + public function info(UserLogic $userLogic){ |
| 34 | + $this->request->validate([ | ||
| 35 | 'id'=>'required' | 35 | 'id'=>'required' |
| 36 | ],[ | 36 | ],[ |
| 37 | 'id.required' => 'ID不能为空' | 37 | 'id.required' => 'ID不能为空' |
| @@ -73,7 +73,7 @@ class ProjectUserController extends BaseController | @@ -73,7 +73,7 @@ class ProjectUserController extends BaseController | ||
| 73 | * @author :liyuhang | 73 | * @author :liyuhang |
| 74 | * @method | 74 | * @method |
| 75 | */ | 75 | */ |
| 76 | - public function del(Request $request,UserLogic $userLogic){ | 76 | + public function del(UserLogic $userLogic){ |
| 77 | $this->request->validate([ | 77 | $this->request->validate([ |
| 78 | 'id'=>['required','array'], | 78 | 'id'=>['required','array'], |
| 79 | ],[ | 79 | ],[ |
| @@ -10,6 +10,7 @@ use App\Models\Ai\AiLog; | @@ -10,6 +10,7 @@ use App\Models\Ai\AiLog; | ||
| 10 | 10 | ||
| 11 | class AiCommandController extends BaseController | 11 | class AiCommandController extends BaseController |
| 12 | { | 12 | { |
| 13 | + //获取文本内容 | ||
| 13 | public $chat_url = 'v2/openai_chat'; | 14 | public $chat_url = 'v2/openai_chat'; |
| 14 | /** | 15 | /** |
| 15 | * @name :ai生成 | 16 | * @name :ai生成 |
| @@ -19,7 +19,8 @@ class BlogCategoryController extends BaseController | @@ -19,7 +19,8 @@ class BlogCategoryController extends BaseController | ||
| 19 | public function lists(BlogCategoryModel $blogCategoryModel){ | 19 | public function lists(BlogCategoryModel $blogCategoryModel){ |
| 20 | //搜索条件 | 20 | //搜索条件 |
| 21 | $this->map['project_id'] = $this->user['project_id']; | 21 | $this->map['project_id'] = $this->user['project_id']; |
| 22 | - $lists = $blogCategoryModel->lists($this->map,$this->page,$this->row); | 22 | + $lists = $blogCategoryModel->lists($this->map,$this->page,$this->row,$this->order, |
| 23 | + ['id','pid','name','num','status','sort','remark','created_at','updated_at']); | ||
| 23 | $this->response('success',Code::SUCCESS,$lists); | 24 | $this->response('success',Code::SUCCESS,$lists); |
| 24 | } | 25 | } |
| 25 | 26 |
| @@ -21,7 +21,8 @@ class BlogController extends BaseController | @@ -21,7 +21,8 @@ class BlogController extends BaseController | ||
| 21 | public function lists(BlogModel $blogModel,BlogCategoryLogic $blogCategoryLogic,BlogLabelLogic $blogLabelLogic){ | 21 | public function lists(BlogModel $blogModel,BlogCategoryLogic $blogCategoryLogic,BlogLabelLogic $blogLabelLogic){ |
| 22 | //搜索条件 | 22 | //搜索条件 |
| 23 | $this->map['project_id'] = $this->user['project_id']; | 23 | $this->map['project_id'] = $this->user['project_id']; |
| 24 | - $lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order); | 24 | + $lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order, |
| 25 | + ['id','category_id','operator_id','status','created_at','label_id','updated_at','name','sort','url']); | ||
| 25 | if(!empty($lists['list'])){ | 26 | if(!empty($lists['list'])){ |
| 26 | foreach ($lists['list'] as $k => $v){ | 27 | foreach ($lists['list'] as $k => $v){ |
| 27 | //获取分类名称 | 28 | //获取分类名称 |
| @@ -22,7 +22,7 @@ class MailController extends BaseController | @@ -22,7 +22,7 @@ class MailController extends BaseController | ||
| 22 | $mailModel = new MailModel(); | 22 | $mailModel = new MailModel(); |
| 23 | //获取当前用户下的所有站内信 | 23 | //获取当前用户下的所有站内信 |
| 24 | $this->map['user_list'] = ['like','%,'.$this->uid.',%']; | 24 | $this->map['user_list'] = ['like','%,'.$this->uid.',%']; |
| 25 | - $this->map['status'] = $this::STATUS_ZERO; | 25 | + $this->map['user_list'] = ['or',null]; |
| 26 | $lists = $mailModel->lists($this->map,$this->page,$this->row); | 26 | $lists = $mailModel->lists($this->map,$this->page,$this->row); |
| 27 | if(!empty($lists['list'])){ | 27 | if(!empty($lists['list'])){ |
| 28 | foreach ($lists['list'] as $k => $v){ | 28 | foreach ($lists['list'] as $k => $v){ |
| @@ -20,7 +20,8 @@ class NewsCategoryController extends BaseController | @@ -20,7 +20,8 @@ class NewsCategoryController extends BaseController | ||
| 20 | public function lists(NewsCategoryModel $newsCategory){ | 20 | public function lists(NewsCategoryModel $newsCategory){ |
| 21 | //搜索条件 | 21 | //搜索条件 |
| 22 | $this->map['project_id'] = $this->user['project_id']; | 22 | $this->map['project_id'] = $this->user['project_id']; |
| 23 | - $lists = $newsCategory->lists($this->map,$this->page,$this->row,'sort'); | 23 | + $lists = $newsCategory->lists($this->map,$this->page,$this->row,$this->order, |
| 24 | + ['id','pid','name','num','status','sort','remark','created_at','updated_at']); | ||
| 24 | $this->response('success',Code::SUCCESS,$lists); | 25 | $this->response('success',Code::SUCCESS,$lists); |
| 25 | } | 26 | } |
| 26 | 27 |
| @@ -24,7 +24,8 @@ class NewsController extends BaseController | @@ -24,7 +24,8 @@ class NewsController extends BaseController | ||
| 24 | */ | 24 | */ |
| 25 | public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){ | 25 | public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){ |
| 26 | $this->map['project_id'] = $this->user['project_id']; | 26 | $this->map['project_id'] = $this->user['project_id']; |
| 27 | - $lists = $news->lists($this->map,$this->page,$this->row,$this->order); | 27 | + $lists = $news->lists($this->map,$this->page,$this->row,$this->order, |
| 28 | + ['id','category_id','operator_id','status','created_at','updated_at','name','sort','url']); | ||
| 28 | if(!empty($lists['list'])){ | 29 | if(!empty($lists['list'])){ |
| 29 | foreach ($lists['list'] as $k => $v){ | 30 | foreach ($lists['list'] as $k => $v){ |
| 30 | $v = $newsCategoryLogic->get_category_name($v); | 31 | $v = $newsCategoryLogic->get_category_name($v); |
| @@ -22,7 +22,7 @@ class UserController extends BaseController | @@ -22,7 +22,7 @@ class UserController extends BaseController | ||
| 22 | public function lists(UserModel $userModel){ | 22 | public function lists(UserModel $userModel){ |
| 23 | //TODO::搜索参数统一处理 | 23 | //TODO::搜索参数统一处理 |
| 24 | $this->map['project_id'] = $this->user['project_id']; | 24 | $this->map['project_id'] = $this->user['project_id']; |
| 25 | - $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at']); | 25 | + $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at','wechat','status']); |
| 26 | if(empty($lists)){ | 26 | if(empty($lists)){ |
| 27 | $this->response('error',Code::USER_ERROR,[]); | 27 | $this->response('error',Code::USER_ERROR,[]); |
| 28 | } | 28 | } |
| @@ -8,6 +8,7 @@ use Illuminate\Http\Exceptions\HttpResponseException; | @@ -8,6 +8,7 @@ use Illuminate\Http\Exceptions\HttpResponseException; | ||
| 8 | use Illuminate\Http\JsonResponse; | 8 | use Illuminate\Http\JsonResponse; |
| 9 | use Illuminate\Http\Request; | 9 | use Illuminate\Http\Request; |
| 10 | use Illuminate\Support\Facades\DB; | 10 | use Illuminate\Support\Facades\DB; |
| 11 | +use Illuminate\Support\Facades\Storage; | ||
| 11 | use Intervention\Image\Facades\Image; | 12 | use Intervention\Image\Facades\Image; |
| 12 | 13 | ||
| 13 | class ImageController | 14 | class ImageController |
| @@ -173,9 +174,15 @@ class ImageController | @@ -173,9 +174,15 @@ class ImageController | ||
| 173 | $data[] = $hash.$filename; | 174 | $data[] = $hash.$filename; |
| 174 | } | 175 | } |
| 175 | $imageModel = new ImageModel(); | 176 | $imageModel = new ImageModel(); |
| 176 | - $imageModel->insertAll($save_data); | 177 | + $imageModel->insert($save_data); |
| 177 | return $data; | 178 | return $data; |
| 178 | } | 179 | } |
| 180 | + | ||
| 181 | + //下载 | ||
| 182 | + public function download($filename){ | ||
| 183 | + $path = Storage::path($filename); | ||
| 184 | + return response()->download($path,time().rand(1,100000)); | ||
| 185 | + } | ||
| 179 | /** | 186 | /** |
| 180 | * @name 统一返回参数 | 187 | * @name 统一返回参数 |
| 181 | * @return JsonResponse | 188 | * @return JsonResponse |
| @@ -5,6 +5,7 @@ namespace App\Http\Logic\Aside; | @@ -5,6 +5,7 @@ namespace App\Http\Logic\Aside; | ||
| 5 | 5 | ||
| 6 | use App\Enums\Common\Common; | 6 | use App\Enums\Common\Common; |
| 7 | use App\Http\Logic\Logic; | 7 | use App\Http\Logic\Logic; |
| 8 | +use Illuminate\Support\Facades\Session; | ||
| 8 | 9 | ||
| 9 | /** | 10 | /** |
| 10 | * @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常 | 11 | * @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常 |
| @@ -17,9 +18,12 @@ class BaseLogic extends Logic | @@ -17,9 +18,12 @@ class BaseLogic extends Logic | ||
| 17 | 18 | ||
| 18 | protected $side = Common::A; | 19 | protected $side = Common::A; |
| 19 | 20 | ||
| 21 | + protected $user = []; | ||
| 22 | + | ||
| 20 | public function __construct() | 23 | public function __construct() |
| 21 | { | 24 | { |
| 22 | $this->requestAll = request()->all(); | 25 | $this->requestAll = request()->all(); |
| 26 | + $this->user = Session::get('manage'); | ||
| 23 | } | 27 | } |
| 24 | 28 | ||
| 25 | } | 29 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Aside\User; | ||
| 4 | + | ||
| 5 | +use App\Http\Logic\Aside\BaseLogic; | ||
| 6 | +use App\Models\User\ProjectMenu; | ||
| 7 | + | ||
| 8 | +class ProjectGroupLogic extends BaseLogic | ||
| 9 | +{ | ||
| 10 | + public function __construct() | ||
| 11 | + { | ||
| 12 | + parent::__construct(); | ||
| 13 | + | ||
| 14 | + $this->model = new ProjectMenu(); | ||
| 15 | + $this->param = $this->requestAll; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * @name :详情 | ||
| 20 | + * @return void | ||
| 21 | + * @author :liyuhang | ||
| 22 | + * @method | ||
| 23 | + */ | ||
| 24 | + public function group_info(){ | ||
| 25 | + $info = $this->info($this->param); | ||
| 26 | + return $this->success($info); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * @name :添加 | ||
| 31 | + * @return void | ||
| 32 | + * @author :liyuhang | ||
| 33 | + * @method | ||
| 34 | + */ | ||
| 35 | + public function group_add(){ | ||
| 36 | + //查看当前用户组是否存在 | ||
| 37 | + $this->model->read(['name'=>$this->param['name'],'create_id'=>1]); | ||
| 38 | + $rs = $this->model->add($this->param); | ||
| 39 | + if($rs === false){ | ||
| 40 | + $this->fail('error'); | ||
| 41 | + } | ||
| 42 | + return $this->success(); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * @name :编辑 | ||
| 47 | + * @return void | ||
| 48 | + * @author :liyuhang | ||
| 49 | + * @method | ||
| 50 | + */ | ||
| 51 | + public function group_edit(){ | ||
| 52 | + //查看当前用户组是否存在 | ||
| 53 | + $this->model->read(['name'=>$this->param['name'],'create_id'=>1]); | ||
| 54 | + return $this->success(); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * @name :删除 | ||
| 59 | + * @return void | ||
| 60 | + * @author :liyuhang | ||
| 61 | + * @method | ||
| 62 | + */ | ||
| 63 | + public function group_del(){ | ||
| 64 | + return $this->success(); | ||
| 65 | + } | ||
| 66 | +} |
| @@ -22,11 +22,8 @@ class ProjectMenuLogic extends BaseLogic | @@ -22,11 +22,8 @@ class ProjectMenuLogic extends BaseLogic | ||
| 22 | * @method | 22 | * @method |
| 23 | */ | 23 | */ |
| 24 | public function menu_info(){ | 24 | public function menu_info(){ |
| 25 | - $info = $this->model->read($this->param); | ||
| 26 | - if($info === false){ | ||
| 27 | - $this->fail('当前数据不存在'); | ||
| 28 | - } | ||
| 29 | - $this->success($info); | 25 | + $info = $this->info($this->param); |
| 26 | + return $this->success($info); | ||
| 30 | } | 27 | } |
| 31 | 28 | ||
| 32 | /** | 29 | /** |
| @@ -45,7 +42,7 @@ class ProjectMenuLogic extends BaseLogic | @@ -45,7 +42,7 @@ class ProjectMenuLogic extends BaseLogic | ||
| 45 | if($rs === false){ | 42 | if($rs === false){ |
| 46 | $this->fail('添加失败'); | 43 | $this->fail('添加失败'); |
| 47 | } | 44 | } |
| 48 | - $this->success(); | 45 | + return $this->success(); |
| 49 | } | 46 | } |
| 50 | 47 | ||
| 51 | /** | 48 | /** |
| @@ -60,11 +57,8 @@ class ProjectMenuLogic extends BaseLogic | @@ -60,11 +57,8 @@ class ProjectMenuLogic extends BaseLogic | ||
| 60 | if($info !== false){ | 57 | if($info !== false){ |
| 61 | $this->fail('当前菜单名称已存在'); | 58 | $this->fail('当前菜单名称已存在'); |
| 62 | } | 59 | } |
| 63 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 64 | - if($rs === false){ | ||
| 65 | - $this->fail('编辑失败'); | ||
| 66 | - } | ||
| 67 | - $this->success(); | 60 | + $this->edit($this->param,['id'=>$this->param['id']]); |
| 61 | + return $this->success(); | ||
| 68 | } | 62 | } |
| 69 | 63 | ||
| 70 | /** | 64 | /** |
| @@ -74,11 +68,19 @@ class ProjectMenuLogic extends BaseLogic | @@ -74,11 +68,19 @@ class ProjectMenuLogic extends BaseLogic | ||
| 74 | * @method | 68 | * @method |
| 75 | */ | 69 | */ |
| 76 | public function menu_del(){ | 70 | public function menu_del(){ |
| 71 | + $ids = $this->param['id']; | ||
| 72 | + //查看当前菜单是否有子菜单 | ||
| 73 | + foreach ($ids as $v){ | ||
| 74 | + $info = $this->model->read(['pid'=>$v],['id','name']); | ||
| 75 | + if($info !== false){ | ||
| 76 | + $this->fail('当前分类存在子分类:'.$info['name'].',不允许删除'); | ||
| 77 | + } | ||
| 78 | + } | ||
| 77 | $this->param['id'] = ['in',$this->param['id']]; | 79 | $this->param['id'] = ['in',$this->param['id']]; |
| 78 | - $rs = $this->model->del($this->param); | 80 | + $rs = $this->del($this->param); |
| 79 | if($rs === false){ | 81 | if($rs === false){ |
| 80 | $this->fail('编辑失败'); | 82 | $this->fail('编辑失败'); |
| 81 | } | 83 | } |
| 82 | - $this->success(); | 84 | + return $this->success(); |
| 83 | } | 85 | } |
| 84 | } | 86 | } |
| @@ -39,7 +39,7 @@ class ProjectRoleLogic extends BaseLogic | @@ -39,7 +39,7 @@ class ProjectRoleLogic extends BaseLogic | ||
| 39 | } | 39 | } |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
| 42 | - $this->success($menu); | 42 | + return $this->success($menu); |
| 43 | } | 43 | } |
| 44 | /** | 44 | /** |
| 45 | * @name :详情 | 45 | * @name :详情 |
| @@ -48,11 +48,8 @@ class ProjectRoleLogic extends BaseLogic | @@ -48,11 +48,8 @@ class ProjectRoleLogic extends BaseLogic | ||
| 48 | * @method | 48 | * @method |
| 49 | */ | 49 | */ |
| 50 | public function role_info(){ | 50 | public function role_info(){ |
| 51 | - $info = $this->model->read($this->param); | ||
| 52 | - if($info === false){ | ||
| 53 | - $this->fail('当前数据不存在'); | ||
| 54 | - } | ||
| 55 | - $this->success($info); | 51 | + $info = $this->info($this->param); |
| 52 | + return $this->success($info); | ||
| 56 | } | 53 | } |
| 57 | 54 | ||
| 58 | /** | 55 | /** |
| @@ -71,7 +68,7 @@ class ProjectRoleLogic extends BaseLogic | @@ -71,7 +68,7 @@ class ProjectRoleLogic extends BaseLogic | ||
| 71 | if($rs === false){ | 68 | if($rs === false){ |
| 72 | $this->fail('添加失败'); | 69 | $this->fail('添加失败'); |
| 73 | } | 70 | } |
| 74 | - $this->success(); | 71 | + return $this->success(); |
| 75 | } | 72 | } |
| 76 | 73 | ||
| 77 | /** | 74 | /** |
| @@ -86,11 +83,8 @@ class ProjectRoleLogic extends BaseLogic | @@ -86,11 +83,8 @@ class ProjectRoleLogic extends BaseLogic | ||
| 86 | if($info !== false){ | 83 | if($info !== false){ |
| 87 | $this->fail('当前菜单名称已存在'); | 84 | $this->fail('当前菜单名称已存在'); |
| 88 | } | 85 | } |
| 89 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 90 | - if($rs === false){ | ||
| 91 | - $this->fail('编辑失败'); | ||
| 92 | - } | ||
| 93 | - $this->success(); | 86 | + $this->edit($this->param,['id'=>$this->param['id']]); |
| 87 | + return $this->success(); | ||
| 94 | } | 88 | } |
| 95 | 89 | ||
| 96 | /** | 90 | /** |
| @@ -102,17 +96,15 @@ class ProjectRoleLogic extends BaseLogic | @@ -102,17 +96,15 @@ class ProjectRoleLogic extends BaseLogic | ||
| 102 | public function role_del(){ | 96 | public function role_del(){ |
| 103 | //查询当前角色下是否有用户 | 97 | //查询当前角色下是否有用户 |
| 104 | $userModel = new UserModel(); | 98 | $userModel = new UserModel(); |
| 105 | - foreach ($this->param['id'] as $v){ | 99 | + $ids = $this->param['id']; |
| 100 | + foreach ($ids as $v){ | ||
| 106 | $user_info = $userModel->read(['role_id'=>$v]); | 101 | $user_info = $userModel->read(['role_id'=>$v]); |
| 107 | if($user_info !== false){ | 102 | if($user_info !== false){ |
| 108 | $this->fail('id为{'.$v.'}'.'的角色拥有用户'.$user_info['name'].',不允许删除'); | 103 | $this->fail('id为{'.$v.'}'.'的角色拥有用户'.$user_info['name'].',不允许删除'); |
| 109 | } | 104 | } |
| 110 | } | 105 | } |
| 111 | $this->param['id'] = ['in',$this->param['id']]; | 106 | $this->param['id'] = ['in',$this->param['id']]; |
| 112 | - $rs = $this->model->del($this->param); | ||
| 113 | - if($rs === false){ | ||
| 114 | - $this->fail('编辑失败'); | ||
| 115 | - } | ||
| 116 | - $this->success(); | 107 | + $this->del($this->param,$ids); |
| 108 | + return $this->success(); | ||
| 117 | } | 109 | } |
| 118 | } | 110 | } |
| @@ -124,4 +124,23 @@ class BaseLogic extends Logic | @@ -124,4 +124,23 @@ class BaseLogic extends Logic | ||
| 124 | return $hash.$filename; | 124 | return $hash.$filename; |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | + /** | ||
| 128 | + * @name :自增或自减 | ||
| 129 | + * @return bool | ||
| 130 | + * @author :liyuhang | ||
| 131 | + * @method | ||
| 132 | + */ | ||
| 133 | + public function set_num($model,$data,$type = 'add',$num = 1){ | ||
| 134 | + if(is_array($data)){ | ||
| 135 | + foreach ($data as $v){ | ||
| 136 | + $this->set_num($model,$v,$type,$num); | ||
| 137 | + } | ||
| 138 | + } | ||
| 139 | + if($type == 'del'){ | ||
| 140 | + $model::where('id',$data)->decrement('num',$num); | ||
| 141 | + }else{ | ||
| 142 | + $model::where('id',$data)->increment('num',$num); | ||
| 143 | + } | ||
| 144 | + return true; | ||
| 145 | + } | ||
| 127 | } | 146 | } |
| @@ -75,6 +75,9 @@ class BlogLogic extends BaseLogic | @@ -75,6 +75,9 @@ class BlogLogic extends BaseLogic | ||
| 75 | $this->param['image'] = $data; | 75 | $this->param['image'] = $data; |
| 76 | } | 76 | } |
| 77 | $rs = $this->model->insertGetId($this->param); | 77 | $rs = $this->model->insertGetId($this->param); |
| 78 | + //分类计数 | ||
| 79 | + $category_data = explode(',',trim($this->param['category_id'],',')); | ||
| 80 | + $this->set_num(BlogCategoryModel::class,$category_data); | ||
| 78 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']); | 81 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']); |
| 79 | DB::commit(); | 82 | DB::commit(); |
| 80 | }catch (\Exception $e){ | 83 | }catch (\Exception $e){ |
| @@ -190,9 +193,35 @@ class BlogLogic extends BaseLogic | @@ -190,9 +193,35 @@ class BlogLogic extends BaseLogic | ||
| 190 | */ | 193 | */ |
| 191 | public function blog_del(){ | 194 | public function blog_del(){ |
| 192 | $ids = $this->param['id']; | 195 | $ids = $this->param['id']; |
| 196 | + $str = $this->get_category_id($ids); | ||
| 197 | + DB::beginTransaction(); | ||
| 198 | + try { | ||
| 199 | + if(!empty($str)){ | ||
| 200 | + $category_data = explode(',',$str); | ||
| 201 | + $this->set_num(BlogCategoryModel::class,$category_data,'del'); | ||
| 193 | $this->param['id'] = ['in',$this->param['id']]; | 202 | $this->param['id'] = ['in',$this->param['id']]; |
| 194 | $this->del($this->param,$ids); | 203 | $this->del($this->param,$ids); |
| 204 | + } | ||
| 205 | + DB::commit(); | ||
| 206 | + }catch (Exception $e){ | ||
| 207 | + DB::rollBack(); | ||
| 208 | + $this->fail('当前数据不存在'); | ||
| 209 | + } | ||
| 195 | return $this->success(); | 210 | return $this->success(); |
| 196 | } | 211 | } |
| 197 | - | 212 | + /** |
| 213 | + * @param $ids | ||
| 214 | + * @name :删除数据时获取所有数据的分类id | ||
| 215 | + * @return void | ||
| 216 | + * @author :liyuhang | ||
| 217 | + * @method | ||
| 218 | + */ | ||
| 219 | + public function get_category_id($ids = []){ | ||
| 220 | + $str = ''; | ||
| 221 | + $list = $this->model->list(['id'=>['in',$ids]],'id',['id','category_id']); | ||
| 222 | + foreach ($list as $v){ | ||
| 223 | + $str .= trim($v['category_id'],',').','; | ||
| 224 | + } | ||
| 225 | + return trim($str,','); | ||
| 226 | + } | ||
| 198 | } | 227 | } |
| @@ -10,6 +10,7 @@ use App\Models\News\News; | @@ -10,6 +10,7 @@ use App\Models\News\News; | ||
| 10 | use App\Models\News\NewsCategory as NewsCategoryModel; | 10 | use App\Models\News\NewsCategory as NewsCategoryModel; |
| 11 | use App\Models\RouteMap; | 11 | use App\Models\RouteMap; |
| 12 | use Illuminate\Support\Facades\DB; | 12 | use Illuminate\Support\Facades\DB; |
| 13 | +use mysql_xdevapi\Exception; | ||
| 13 | 14 | ||
| 14 | class NewsLogic extends BaseLogic | 15 | class NewsLogic extends BaseLogic |
| 15 | { | 16 | { |
| @@ -66,6 +67,9 @@ class NewsLogic extends BaseLogic | @@ -66,6 +67,9 @@ class NewsLogic extends BaseLogic | ||
| 66 | $this->param['image'] = $data; | 67 | $this->param['image'] = $data; |
| 67 | } | 68 | } |
| 68 | $rs = $this->model->insertGetId($this->param); | 69 | $rs = $this->model->insertGetId($this->param); |
| 70 | + //产品计数 | ||
| 71 | + $category_data = explode(',',trim($this->param['category_id'],',')); | ||
| 72 | + $this->set_num(NewsCategoryModel::class,$category_data); | ||
| 69 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); | 73 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); |
| 70 | DB::commit(); | 74 | DB::commit(); |
| 71 | }catch (\Exception $e){ | 75 | }catch (\Exception $e){ |
| @@ -92,7 +96,7 @@ class NewsLogic extends BaseLogic | @@ -92,7 +96,7 @@ class NewsLogic extends BaseLogic | ||
| 92 | } | 96 | } |
| 93 | $this->param['operator_id'] = $this->user['id']; | 97 | $this->param['operator_id'] = $this->user['id']; |
| 94 | //多个分类按逗号隔开 | 98 | //多个分类按逗号隔开 |
| 95 | - $this->param['category_id'] = ','.$this->param['category_id'].','; | 99 | + $this->param['category_id'] = $this->param['category_id']; |
| 96 | DB::beginTransaction(); | 100 | DB::beginTransaction(); |
| 97 | try { | 101 | try { |
| 98 | //上传图片 | 102 | //上传图片 |
| @@ -109,6 +113,7 @@ class NewsLogic extends BaseLogic | @@ -109,6 +113,7 @@ class NewsLogic extends BaseLogic | ||
| 109 | } | 113 | } |
| 110 | $this->param['image'] = $this->upload(); | 114 | $this->param['image'] = $this->upload(); |
| 111 | } | 115 | } |
| 116 | + //设置路由 | ||
| 112 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']); | 117 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']); |
| 113 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 118 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 114 | DB::commit(); | 119 | DB::commit(); |
| @@ -178,8 +183,36 @@ class NewsLogic extends BaseLogic | @@ -178,8 +183,36 @@ class NewsLogic extends BaseLogic | ||
| 178 | */ | 183 | */ |
| 179 | public function news_del(){ | 184 | public function news_del(){ |
| 180 | $ids = $this->param['id']; | 185 | $ids = $this->param['id']; |
| 186 | + $str = $this->get_category_id($ids); | ||
| 187 | + DB::beginTransaction(); | ||
| 188 | + try { | ||
| 189 | + if(!empty($str)){ | ||
| 190 | + $category_data = explode(',',$str); | ||
| 191 | + $this->set_num(NewsCategoryModel::class,$category_data,'del'); | ||
| 181 | $this->param['id'] = ['in',$this->param['id']]; | 192 | $this->param['id'] = ['in',$this->param['id']]; |
| 182 | $this->del($this->param,$ids); | 193 | $this->del($this->param,$ids); |
| 194 | + } | ||
| 195 | + DB::commit(); | ||
| 196 | + }catch (Exception $e){ | ||
| 197 | + DB::rollBack(); | ||
| 198 | + $this->fail('当前数据不存在'); | ||
| 199 | + } | ||
| 183 | return $this->success(); | 200 | return $this->success(); |
| 184 | } | 201 | } |
| 202 | + | ||
| 203 | + /** | ||
| 204 | + * @param $ids | ||
| 205 | + * @name :删除数据时获取所有数据的分类id | ||
| 206 | + * @return void | ||
| 207 | + * @author :liyuhang | ||
| 208 | + * @method | ||
| 209 | + */ | ||
| 210 | + public function get_category_id($ids){ | ||
| 211 | + $str = ''; | ||
| 212 | + $list = $this->model->list(['id'=>['in',$ids]],'id',['id','category_id']); | ||
| 213 | + foreach ($list as $v){ | ||
| 214 | + $str .= trim($v['category_id'],',').','; | ||
| 215 | + } | ||
| 216 | + return trim($str,','); | ||
| 217 | + } | ||
| 185 | } | 218 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Aside\User; | ||
| 4 | + | ||
| 5 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | + | ||
| 7 | +class ProjectGroupRequest extends FormRequest | ||
| 8 | +{ | ||
| 9 | + /** | ||
| 10 | + * Determine if the user is authorized to make this request. | ||
| 11 | + * | ||
| 12 | + * @return bool | ||
| 13 | + */ | ||
| 14 | + public function authorize() | ||
| 15 | + { | ||
| 16 | + return true; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * Get the validation rules that apply to the request. | ||
| 21 | + * | ||
| 22 | + * @return array | ||
| 23 | + */ | ||
| 24 | + public function rules() | ||
| 25 | + { | ||
| 26 | + return [ | ||
| 27 | + 'name'=>'required|string', | ||
| 28 | + ]; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public function messages() | ||
| 32 | + { | ||
| 33 | + return [ | ||
| 34 | + 'name.required'=>'名称必须填写', | ||
| 35 | + ]; | ||
| 36 | + } | ||
| 37 | +} |
| @@ -25,6 +25,8 @@ class BlogCategoryRequest extends FormRequest | @@ -25,6 +25,8 @@ class BlogCategoryRequest extends FormRequest | ||
| 25 | { | 25 | { |
| 26 | return [ | 26 | return [ |
| 27 | 'name'=>'required|max:100', | 27 | 'name'=>'required|max:100', |
| 28 | + 'remark'=>'required|max:255', | ||
| 29 | + 'alias'=>'required|max:10', | ||
| 28 | ]; | 30 | ]; |
| 29 | } | 31 | } |
| 30 | 32 | ||
| @@ -33,6 +35,10 @@ class BlogCategoryRequest extends FormRequest | @@ -33,6 +35,10 @@ class BlogCategoryRequest extends FormRequest | ||
| 33 | return [ | 35 | return [ |
| 34 | 'name.required'=>'请填写名称', | 36 | 'name.required'=>'请填写名称', |
| 35 | 'name.max'=>'名称最大100字', | 37 | 'name.max'=>'名称最大100字', |
| 38 | + 'remark.required'=>'请填写简介', | ||
| 39 | + 'remark.max'=>'简介最大255字', | ||
| 40 | + 'remark.required'=>'请填写别名', | ||
| 41 | + 'remark.max'=>'别名最大10字', | ||
| 36 | ]; | 42 | ]; |
| 37 | } | 43 | } |
| 38 | } | 44 | } |
| @@ -25,6 +25,8 @@ class NewsCategoryRequest extends FormRequest | @@ -25,6 +25,8 @@ class NewsCategoryRequest extends FormRequest | ||
| 25 | { | 25 | { |
| 26 | return [ | 26 | return [ |
| 27 | 'name'=>'required|max:100', | 27 | 'name'=>'required|max:100', |
| 28 | + 'remark'=>'required|max:255', | ||
| 29 | + 'alias'=>'required|max:10', | ||
| 28 | ]; | 30 | ]; |
| 29 | } | 31 | } |
| 30 | 32 | ||
| @@ -33,6 +35,10 @@ class NewsCategoryRequest extends FormRequest | @@ -33,6 +35,10 @@ class NewsCategoryRequest extends FormRequest | ||
| 33 | return [ | 35 | return [ |
| 34 | 'name.required'=>'请填写名称', | 36 | 'name.required'=>'请填写名称', |
| 35 | 'name.max'=>'名称最大100字', | 37 | 'name.max'=>'名称最大100字', |
| 38 | + 'remark.required'=>'请填写简介', | ||
| 39 | + 'remark.max'=>'简介最大255字', | ||
| 40 | + 'remark.required'=>'请填写别名', | ||
| 41 | + 'remark.max'=>'别名最大10字', | ||
| 36 | ]; | 42 | ]; |
| 37 | } | 43 | } |
| 38 | } | 44 | } |
| @@ -179,6 +179,10 @@ class Base extends Model | @@ -179,6 +179,10 @@ class Base extends Model | ||
| 179 | // in查询 ['id'=>['in',[1,2,3]]] | 179 | // in查询 ['id'=>['in',[1,2,3]]] |
| 180 | $query->whereIn($k, $v[1]); | 180 | $query->whereIn($k, $v[1]); |
| 181 | break; | 181 | break; |
| 182 | + case 'or': | ||
| 183 | + // in查询 ['id'=>['in',[1,2,3]]] | ||
| 184 | + $query->orWhere($k, $v[1]); | ||
| 185 | + break; | ||
| 182 | case 'no in': | 186 | case 'no in': |
| 183 | // in查询 ['id'=>['not in',[1,2,3]]] | 187 | // in查询 ['id'=>['not in',[1,2,3]]] |
| 184 | $query->whereNotIn($k, $v[1]); | 188 | $query->whereNotIn($k, $v[1]); |
| @@ -9,6 +9,62 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | @@ -9,6 +9,62 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | ||
| 9 | Route::middleware(['aloginauth'])->group(function () { | 9 | Route::middleware(['aloginauth'])->group(function () { |
| 10 | Route::get('/', [Aside\IndexController::class, 'index'])->name('admin.home.white'); | 10 | Route::get('/', [Aside\IndexController::class, 'index'])->name('admin.home.white'); |
| 11 | Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white'); | 11 | Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white'); |
| 12 | + //会员相关 | ||
| 13 | + Route::prefix('user')->group(function () { | ||
| 14 | + //会员管理 | ||
| 15 | + Route::any('/', [Aside\User\ProjectUserController::class, 'lists'])->name('admin.user_lists'); | ||
| 16 | + Route::any('/info', [Aside\User\ProjectUserController::class, 'info'])->name('admin.user_info'); | ||
| 17 | + Route::any('/add', [Aside\User\ProjectUserController::class, 'add'])->name('admin.user_add'); | ||
| 18 | + Route::any('/edit', [Aside\User\ProjectUserController::class, 'edit'])->name('admin.user_edit'); | ||
| 19 | + Route::any('/del', [Aside\User\ProjectUserController::class, 'del'])->name('admin.user_del'); | ||
| 20 | + | ||
| 21 | + //角色管理 | ||
| 22 | + Route::prefix('role')->group(function () { | ||
| 23 | + Route::any('/', [Aside\User\ProjectRoleController::class, 'lists'])->name('admin.role_lists'); | ||
| 24 | + Route::any('/info', [Aside\User\ProjectRoleController::class, 'info'])->name('admin.role_info'); | ||
| 25 | + Route::any('/get_menu', [Aside\User\ProjectRoleController::class, 'get_menu'])->name('admin.get_menu'); | ||
| 26 | + Route::any('/add', [Aside\User\ProjectRoleController::class, 'add'])->name('admin.role_add'); | ||
| 27 | + Route::any('/edit', [Aside\User\ProjectRoleController::class, 'edit'])->name('admin.role_edit'); | ||
| 28 | + Route::any('/del', [Aside\User\ProjectRoleController::class, 'del'])->name('admin.role_del'); | ||
| 29 | + }); | ||
| 30 | + | ||
| 31 | + //栏目管理 | ||
| 32 | + Route::prefix('menu')->group(function () { | ||
| 33 | + Route::any('/', [Aside\User\ProjectMenuController::class, 'lists'])->name('admin.menu_lists'); | ||
| 34 | + Route::any('/info', [Aside\User\ProjectMenuController::class, 'info'])->name('admin.menu_info'); | ||
| 35 | + Route::any('/add', [Aside\User\ProjectMenuController::class, 'add'])->name('admin.menu_add'); | ||
| 36 | + Route::any('/edit', [Aside\User\ProjectMenuController::class, 'edit'])->name('admin.menu_edit'); | ||
| 37 | + Route::any('/del', [Aside\User\ProjectMenuController::class, 'del'])->name('admin.menu_del'); | ||
| 38 | + }); | ||
| 39 | + | ||
| 40 | + //用户组 | ||
| 41 | + Route::prefix('group')->group(function () { | ||
| 42 | + Route::any('/', [Aside\User\ProjectGroupController::class, 'lists'])->name('admin.group_lists'); | ||
| 43 | + Route::any('/info', [Aside\User\ProjectGroupController::class, 'info'])->name('admin.group_info'); | ||
| 44 | + Route::any('/add', [Aside\User\ProjectGroupController::class, 'add'])->name('admin.group_add'); | ||
| 45 | + Route::any('/edit', [Aside\User\ProjectGroupController::class, 'edit'])->name('admin.group_edit'); | ||
| 46 | + Route::any('/del', [Aside\User\ProjectGroupController::class, 'del'])->name('admin.group_del'); | ||
| 47 | + }); | ||
| 48 | + | ||
| 49 | + }); | ||
| 50 | + | ||
| 51 | + //ai指令 | ||
| 52 | + Route::prefix('ai')->group(function () { | ||
| 53 | + Route::any('/', [Aside\Ai\AiCommandController::class, 'lists'])->name('admin.ai_lists'); | ||
| 54 | + Route::any('/info', [Aside\Ai\AiCommandController::class, 'info'])->name('admin.ai_info'); | ||
| 55 | + Route::any('/add', [Aside\Ai\AiCommandController::class, 'add'])->name('admin.ai_add'); | ||
| 56 | + Route::any('/edit', [Aside\Ai\AiCommandController::class, 'edit'])->name('admin.ai_edit'); | ||
| 57 | + Route::any('/del', [Aside\Ai\AiCommandController::class, 'del'])->name('admin.ai_del'); | ||
| 58 | + }); | ||
| 59 | + | ||
| 60 | + //站内信 | ||
| 61 | + Route::prefix('mail')->group(function () { | ||
| 62 | + Route::any('/', [Aside\Mail\MailController::class, 'lists'])->name('admin.mail_lists'); | ||
| 63 | + Route::any('/info', [Aside\Mail\MailController::class, 'info'])->name('admin.mail_info'); | ||
| 64 | + Route::any('/add', [Aside\Mail\MailController::class, 'add'])->name('admin.mail_add'); | ||
| 65 | + Route::any('/edit', [Aside\Mail\MailController::class, 'edit'])->name('admin.mail_edit'); | ||
| 66 | + Route::any('/del', [Aside\Mail\MailController::class, 'del'])->name('admin.mail_del'); | ||
| 67 | + }); | ||
| 12 | 68 | ||
| 13 | //管理员 | 69 | //管理员 |
| 14 | Route::prefix('manage')->group(function () { | 70 | Route::prefix('manage')->group(function () { |
-
请 注册 或 登录 后发表评论