正在显示
32 个修改的文件
包含
475 行增加
和
135 行删除
| @@ -10,6 +10,7 @@ use App\Utils\LogUtils; | @@ -10,6 +10,7 @@ use App\Utils\LogUtils; | ||
| 10 | use Illuminate\Database\Eloquent\ModelNotFoundException; | 10 | use Illuminate\Database\Eloquent\ModelNotFoundException; |
| 11 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | 11 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
| 12 | use Illuminate\Support\Arr; | 12 | use Illuminate\Support\Arr; |
| 13 | +use Illuminate\Support\Facades\Cache; | ||
| 13 | use Illuminate\Support\Facades\Route; | 14 | use Illuminate\Support\Facades\Route; |
| 14 | use Illuminate\Validation\ValidationException; | 15 | use Illuminate\Validation\ValidationException; |
| 15 | use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; | 16 | use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; |
| @@ -128,10 +129,18 @@ class Handler extends ExceptionHandler | @@ -128,10 +129,18 @@ class Handler extends ExceptionHandler | ||
| 128 | $exception->getLine(); | 129 | $exception->getLine(); |
| 129 | (new DingService())->handle(['keyword' => "ERROR", 'msg' => config('app.env') . '环境报错:' . $exceptionMessage, 'isAtAll' => false]); | 130 | (new DingService())->handle(['keyword' => "ERROR", 'msg' => config('app.env') . '环境报错:' . $exceptionMessage, 'isAtAll' => false]); |
| 130 | } | 131 | } |
| 132 | + $log = config('logging.operator_log'); | ||
| 133 | + if(isset($log,$log['log'],$log['action']) && $log['log'] == true){ | ||
| 134 | + if(empty($log['action']) || (strpos($log['action'],Route::currentRouteName()) < 0)){ | ||
| 135 | + $info = Cache::get($request->header('token')); | ||
| 136 | + if(!empty($info)){ | ||
| 137 | + \App\Helper\Common::set_user_log(['model'=>Route::currentRouteName(),'remark'=>'请求的参数:param = '.json_encode($request->all()),'operator_id'=>$info['id']]); | ||
| 138 | + } | ||
| 139 | + } | ||
| 140 | + } | ||
| 131 | //开启debug 错误原样输出 | 141 | //开启debug 错误原样输出 |
| 132 | $debub = config('app.debug'); | 142 | $debub = config('app.debug'); |
| 133 | $message = $debub ? $message : ($code->description ?? $message); | 143 | $message = $debub ? $message : ($code->description ?? $message); |
| 134 | - | ||
| 135 | $response = [ | 144 | $response = [ |
| 136 | 'code' => $code, | 145 | 'code' => $code, |
| 137 | 'message' => $message | 146 | 'message' => $message |
app/Helper/Common.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Helper; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Models\AiCommand as AiCommandModel; | ||
| 7 | +use App\Models\User\UserLog as UserLogModel; | ||
| 8 | +use App\Models\User\UserLogin as UserLoginModel; | ||
| 9 | + | ||
| 10 | +class Common | ||
| 11 | +{ | ||
| 12 | + /** | ||
| 13 | + * @name :生成用户操作日志 | ||
| 14 | + * @return void | ||
| 15 | + * @author :liyuhang | ||
| 16 | + * @method | ||
| 17 | + */ | ||
| 18 | + public static function set_user_log($param = []){ | ||
| 19 | + $data = [ | ||
| 20 | + 'operator_id'=>$param['operator_id'], | ||
| 21 | + 'model'=>$param['model'], | ||
| 22 | + 'remark'=>$param['remark'] | ||
| 23 | + ]; | ||
| 24 | + $model = new UserLogModel(); | ||
| 25 | + return $model->add($data); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * @name :写入登录日志 | ||
| 30 | + * @return void | ||
| 31 | + * @author :liyuhang | ||
| 32 | + * @method | ||
| 33 | + */ | ||
| 34 | + public static function set_user_login($param = []){ | ||
| 35 | + $data = [ | ||
| 36 | + 'user_id'=>$param['id'], | ||
| 37 | + 'ip'=>$param['ip'] | ||
| 38 | + ]; | ||
| 39 | + $model = new UserLoginModel(); | ||
| 40 | + return $model->add($data); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * @name :ai自动生成 | ||
| 45 | + * @return mixed | ||
| 46 | + * @author :liyuhang | ||
| 47 | + * @method | ||
| 48 | + */ | ||
| 49 | + public function send_openai_msg($url){ | ||
| 50 | + $url = HTTP_OPENAI_URL.$url; | ||
| 51 | + $aiCommandModel = New AiCommandModel(); | ||
| 52 | + //指定库获取指令 | ||
| 53 | + $info = $aiCommandModel->read(['key'=>$this->param['key']]); | ||
| 54 | + if($info === false){ | ||
| 55 | + response('指令不存在',400); | ||
| 56 | + } | ||
| 57 | + //替换关键字 | ||
| 58 | + $content = str_replace('$keyword$', $this->param['keywords'], $info['ai']); | ||
| 59 | + $data = [ | ||
| 60 | + 'messages'=>[ | ||
| 61 | + ['role'=>'system','content'=>$info['scene']], | ||
| 62 | + ['role'=>'assistant','content'=>$content], | ||
| 63 | + ] | ||
| 64 | + ]; | ||
| 65 | + return http_post($url,json_encode($data)); | ||
| 66 | + } | ||
| 67 | +} |
| @@ -4,8 +4,11 @@ namespace App\Http\Controllers\Aside\User; | @@ -4,8 +4,11 @@ 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\ProjectMenuLogic; | ||
| 7 | use App\Http\Requests\Aside\User\ProjectRoleRequest; | 8 | use App\Http\Requests\Aside\User\ProjectRoleRequest; |
| 9 | +use App\Models\User\ProjectMenu; | ||
| 8 | use App\Models\User\ProjectMenu as ProjectMenuModel; | 10 | use App\Models\User\ProjectMenu as ProjectMenuModel; |
| 11 | +use Illuminate\Http\Request; | ||
| 9 | 12 | ||
| 10 | class ProjectMenuController extends BaseController | 13 | class ProjectMenuController extends BaseController |
| 11 | { | 14 | { |
| @@ -27,12 +30,14 @@ class ProjectMenuController extends BaseController | @@ -27,12 +30,14 @@ class ProjectMenuController extends BaseController | ||
| 27 | * @author :liyuhang | 30 | * @author :liyuhang |
| 28 | * @method | 31 | * @method |
| 29 | */ | 32 | */ |
| 30 | - public function info(ProjectRoleRequest $request){ | 33 | + public function info(Request $request,ProjectMenuLogic $projectMenuLogic){ |
| 31 | $request->validate([ | 34 | $request->validate([ |
| 32 | 'id'=>'required' | 35 | 'id'=>'required' |
| 33 | ],[ | 36 | ],[ |
| 34 | 'id.required' => 'ID不能为空' | 37 | 'id.required' => 'ID不能为空' |
| 35 | ]); | 38 | ]); |
| 39 | + $info = $projectMenuLogic->menu_info(); | ||
| 40 | + $this->response('success',Code::SUCCESS,$info); | ||
| 36 | } | 41 | } |
| 37 | 42 | ||
| 38 | /** | 43 | /** |
| @@ -41,8 +46,10 @@ class ProjectMenuController extends BaseController | @@ -41,8 +46,10 @@ class ProjectMenuController extends BaseController | ||
| 41 | * @author :liyuhang | 46 | * @author :liyuhang |
| 42 | * @method | 47 | * @method |
| 43 | */ | 48 | */ |
| 44 | - public function add(){ | ||
| 45 | - | 49 | + public function add(ProjectRoleRequest $request,ProjectMenuLogic $projectMenuLogic){ |
| 50 | + $request->validated(); | ||
| 51 | + $projectMenuLogic->menu_add(); | ||
| 52 | + $this->response('success'); | ||
| 46 | } | 53 | } |
| 47 | 54 | ||
| 48 | /** | 55 | /** |
| @@ -51,8 +58,14 @@ class ProjectMenuController extends BaseController | @@ -51,8 +58,14 @@ class ProjectMenuController extends BaseController | ||
| 51 | * @author :liyuhang | 58 | * @author :liyuhang |
| 52 | * @method | 59 | * @method |
| 53 | */ | 60 | */ |
| 54 | - public function edit(){ | ||
| 55 | - | 61 | + public function edit(ProjectRoleRequest $request,ProjectMenuLogic $projectMenuLogic){ |
| 62 | + $request->validate([ | ||
| 63 | + 'id'=>'required' | ||
| 64 | + ],[ | ||
| 65 | + 'id.required' => 'ID不能为空' | ||
| 66 | + ]); | ||
| 67 | + $projectMenuLogic->menu_edit(); | ||
| 68 | + $this->response('success'); | ||
| 56 | } | 69 | } |
| 57 | 70 | ||
| 58 | /** | 71 | /** |
| @@ -61,7 +74,13 @@ class ProjectMenuController extends BaseController | @@ -61,7 +74,13 @@ class ProjectMenuController extends BaseController | ||
| 61 | * @author :liyuhang | 74 | * @author :liyuhang |
| 62 | * @method | 75 | * @method |
| 63 | */ | 76 | */ |
| 64 | - public function del(){ | ||
| 65 | - | 77 | + public function del(Request $request,ProjectMenuLogic $projectMenuLogic){ |
| 78 | + $request->validate([ | ||
| 79 | + 'id'=>'required' | ||
| 80 | + ],[ | ||
| 81 | + 'id.required' => 'ID不能为空' | ||
| 82 | + ]); | ||
| 83 | + $projectMenuLogic->menu_del(); | ||
| 84 | + $this->response('success'); | ||
| 66 | } | 85 | } |
| 67 | } | 86 | } |
| @@ -7,6 +7,7 @@ use App\Http\Controllers\Aside\BaseController; | @@ -7,6 +7,7 @@ use App\Http\Controllers\Aside\BaseController; | ||
| 7 | use App\Http\Logic\Aside\User\ProjectRoleLogic; | 7 | use App\Http\Logic\Aside\User\ProjectRoleLogic; |
| 8 | use App\Http\Requests\Aside\User\ProjectRoleRequest; | 8 | use App\Http\Requests\Aside\User\ProjectRoleRequest; |
| 9 | use App\Models\User\ProjectRole as ProjectRoleModel; | 9 | use App\Models\User\ProjectRole as ProjectRoleModel; |
| 10 | +use Illuminate\Http\Request; | ||
| 10 | 11 | ||
| 11 | class ProjectRoleController extends BaseController | 12 | class ProjectRoleController extends BaseController |
| 12 | { | 13 | { |
| @@ -23,6 +24,23 @@ class ProjectRoleController extends BaseController | @@ -23,6 +24,23 @@ class ProjectRoleController extends BaseController | ||
| 23 | } | 24 | } |
| 24 | 25 | ||
| 25 | /** | 26 | /** |
| 27 | + * @name :详情 | ||
| 28 | + * @return void | ||
| 29 | + * @author :liyuhang | ||
| 30 | + * @method | ||
| 31 | + */ | ||
| 32 | + public function info(Request $request,ProjectRoleLogic $roleLogic){ | ||
| 33 | + $request->validate([ | ||
| 34 | + 'id'=>'required' | ||
| 35 | + ],[ | ||
| 36 | + 'id.required' => 'ID不能为空' | ||
| 37 | + ]); | ||
| 38 | + //TODO::详情 | ||
| 39 | + $roleLogic->role_info(); | ||
| 40 | + $this->response('success'); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 26 | * @name :添加角色时获取菜单列表 | 44 | * @name :添加角色时获取菜单列表 |
| 27 | * @return void | 45 | * @return void |
| 28 | * @author :liyuhang | 46 | * @author :liyuhang |
| @@ -62,23 +80,13 @@ class ProjectRoleController extends BaseController | @@ -62,23 +80,13 @@ class ProjectRoleController extends BaseController | ||
| 62 | $this->response('success'); | 80 | $this->response('success'); |
| 63 | } | 81 | } |
| 64 | 82 | ||
| 65 | - public function info(ProjectRoleRequest $request,ProjectRoleLogic $roleLogic){ | ||
| 66 | - $request->validate([ | ||
| 67 | - 'id'=>'required' | ||
| 68 | - ],[ | ||
| 69 | - 'id.required' => 'ID不能为空' | ||
| 70 | - ]); | ||
| 71 | - //TODO::详情 | ||
| 72 | - $roleLogic->role_info(); | ||
| 73 | - $this->response('success'); | ||
| 74 | - } | ||
| 75 | /** | 83 | /** |
| 76 | * @name :删除角色 | 84 | * @name :删除角色 |
| 77 | * @return void | 85 | * @return void |
| 78 | * @author :liyuhang | 86 | * @author :liyuhang |
| 79 | * @method | 87 | * @method |
| 80 | */ | 88 | */ |
| 81 | - public function del(ProjectRoleRequest $request,ProjectRoleLogic $roleLogic){ | 89 | + public function del(Request $request,ProjectRoleLogic $roleLogic){ |
| 82 | $request->validate([ | 90 | $request->validate([ |
| 83 | 'id'=>'required' | 91 | 'id'=>'required' |
| 84 | ],[ | 92 | ],[ |
| @@ -7,6 +7,7 @@ use App\Http\Controllers\Aside\BaseController; | @@ -7,6 +7,7 @@ use App\Http\Controllers\Aside\BaseController; | ||
| 7 | use App\Http\Logic\Aside\User\UserLogic; | 7 | use App\Http\Logic\Aside\User\UserLogic; |
| 8 | use App\Http\Requests\Aside\User\UserRequest; | 8 | use App\Http\Requests\Aside\User\UserRequest; |
| 9 | use App\Models\User\User as UserModel; | 9 | use App\Models\User\User as UserModel; |
| 10 | +use Illuminate\Http\Request; | ||
| 10 | 11 | ||
| 11 | class ProjectUserController extends BaseController | 12 | class ProjectUserController extends BaseController |
| 12 | { | 13 | { |
| @@ -29,7 +30,7 @@ class ProjectUserController extends BaseController | @@ -29,7 +30,7 @@ class ProjectUserController extends BaseController | ||
| 29 | * @author :liyuhang | 30 | * @author :liyuhang |
| 30 | * @method | 31 | * @method |
| 31 | */ | 32 | */ |
| 32 | - public function info(UserRequest $request,UserLogic $userLogic){ | 33 | + public function info(Request $request,UserLogic $userLogic){ |
| 33 | $request->validate([ | 34 | $request->validate([ |
| 34 | 'id'=>'required' | 35 | 'id'=>'required' |
| 35 | ],[ | 36 | ],[ |
| @@ -72,7 +73,7 @@ class ProjectUserController extends BaseController | @@ -72,7 +73,7 @@ class ProjectUserController extends BaseController | ||
| 72 | * @author :liyuhang | 73 | * @author :liyuhang |
| 73 | * @method | 74 | * @method |
| 74 | */ | 75 | */ |
| 75 | - public function del(UserRequest $request,UserLogic $userLogic){ | 76 | + public function del(Request $request,UserLogic $userLogic){ |
| 76 | $request->validate([ | 77 | $request->validate([ |
| 77 | 'id'=>'required' | 78 | 'id'=>'required' |
| 78 | ],[ | 79 | ],[ |
| @@ -153,6 +153,13 @@ class BaseController extends Controller | @@ -153,6 +153,13 @@ class BaseController extends Controller | ||
| 153 | return $new_arr ? $new_arr : false; | 153 | return $new_arr ? $new_arr : false; |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | + /** | ||
| 157 | + * @param $data | ||
| 158 | + * @name :返回参数处理 | ||
| 159 | + * @return array|string | ||
| 160 | + * @author :liyuhang | ||
| 161 | + * @method | ||
| 162 | + */ | ||
| 156 | protected function _extents($data) { | 163 | protected function _extents($data) { |
| 157 | 164 | ||
| 158 | if (empty($data) || !is_array($data)) { | 165 | if (empty($data) || !is_array($data)) { |
| @@ -4,8 +4,8 @@ namespace App\Http\Controllers\Bside; | @@ -4,8 +4,8 @@ namespace App\Http\Controllers\Bside; | ||
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Logic\Bside\MailLogic; | 6 | use App\Http\Logic\Bside\MailLogic; |
| 7 | -use App\Models\Mail as MailModel; | ||
| 8 | -use App\Models\MailUser as MailUserModel; | 7 | +use App\Models\Mail\Mail as MailModel; |
| 8 | +use App\Models\Mail\MailUser as MailUserModel; | ||
| 9 | use Illuminate\Http\Request; | 9 | use Illuminate\Http\Request; |
| 10 | 10 | ||
| 11 | class MailController extends BaseController | 11 | class MailController extends BaseController |
| @@ -49,7 +49,6 @@ class NewsCategoryController extends BaseController | @@ -49,7 +49,6 @@ class NewsCategoryController extends BaseController | ||
| 49 | $request->validated(); | 49 | $request->validated(); |
| 50 | //添加时,验证分类上级分类是否有,有则更新到当前分类中,没有时直接添加 | 50 | //添加时,验证分类上级分类是否有,有则更新到当前分类中,没有时直接添加 |
| 51 | $newsCategoryLogic->add_news_category(); | 51 | $newsCategoryLogic->add_news_category(); |
| 52 | - //TODO::写入日志 | ||
| 53 | $this->response('success',Code::SUCCESS,[]); | 52 | $this->response('success',Code::SUCCESS,[]); |
| 54 | } | 53 | } |
| 55 | 54 | ||
| @@ -66,7 +65,6 @@ class NewsCategoryController extends BaseController | @@ -66,7 +65,6 @@ class NewsCategoryController extends BaseController | ||
| 66 | 'id.required' => 'ID不能为空' | 65 | 'id.required' => 'ID不能为空' |
| 67 | ]); | 66 | ]); |
| 68 | $newsCategoryLogic->edit_news_category(); | 67 | $newsCategoryLogic->edit_news_category(); |
| 69 | - //TODO::写入日志 | ||
| 70 | $this->response('success'); | 68 | $this->response('success'); |
| 71 | } | 69 | } |
| 72 | 70 |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Http\Controllers\Bside\News; | 3 | namespace App\Http\Controllers\Bside\News; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | +use App\Helper\Common; | ||
| 6 | use App\Http\Controllers\Bside\BaseController; | 7 | use App\Http\Controllers\Bside\BaseController; |
| 7 | use App\Http\Logic\Bside\News\NewsLogic; | 8 | use App\Http\Logic\Bside\News\NewsLogic; |
| 8 | use App\Http\Requests\Bside\News\NewsRequest; | 9 | use App\Http\Requests\Bside\News\NewsRequest; |
| @@ -64,7 +65,6 @@ class NewsController extends BaseController | @@ -64,7 +65,6 @@ class NewsController extends BaseController | ||
| 64 | 'id.required' => 'ID不能为空', | 65 | 'id.required' => 'ID不能为空', |
| 65 | ]); | 66 | ]); |
| 66 | $info = $newsLogic->news_info(); | 67 | $info = $newsLogic->news_info(); |
| 67 | - //TODO::清空相关资源 | ||
| 68 | $this->response('success',Code::SUCCESS,$info); | 68 | $this->response('success',Code::SUCCESS,$info); |
| 69 | } | 69 | } |
| 70 | /** | 70 | /** |
| @@ -76,7 +76,6 @@ class NewsController extends BaseController | @@ -76,7 +76,6 @@ class NewsController extends BaseController | ||
| 76 | public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){ | 76 | public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){ |
| 77 | $newsRequest->validated(); | 77 | $newsRequest->validated(); |
| 78 | $newsLogic->news_add(); | 78 | $newsLogic->news_add(); |
| 79 | - //TODO::写入日志 | ||
| 80 | $this->response('success'); | 79 | $this->response('success'); |
| 81 | } | 80 | } |
| 82 | 81 | ||
| @@ -93,7 +92,6 @@ class NewsController extends BaseController | @@ -93,7 +92,6 @@ class NewsController extends BaseController | ||
| 93 | 'id.required' => 'ID不能为空', | 92 | 'id.required' => 'ID不能为空', |
| 94 | ]); | 93 | ]); |
| 95 | $newsLogic->news_edit(); | 94 | $newsLogic->news_edit(); |
| 96 | - //TODO::写入日志 | ||
| 97 | $this->response('success',Code::SUCCESS); | 95 | $this->response('success',Code::SUCCESS); |
| 98 | } | 96 | } |
| 99 | 97 |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside\User; | ||
| 4 | + | ||
| 5 | +use App\Http\Controllers\Bside\BaseController; | ||
| 6 | +use App\Models\User\UserLogin as UserLoginModel; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * @name:用户登录日志 | ||
| 10 | + */ | ||
| 11 | +class UserLoginController extends BaseController | ||
| 12 | +{ | ||
| 13 | + public function lists(){ | ||
| 14 | + | ||
| 15 | + } | ||
| 16 | +} |
| @@ -14,4 +14,71 @@ class ProjectMenuLogic extends BaseLogic | @@ -14,4 +14,71 @@ class ProjectMenuLogic extends BaseLogic | ||
| 14 | $this->model = new ProjectMenu(); | 14 | $this->model = new ProjectMenu(); |
| 15 | $this->param = $this->requestAll; | 15 | $this->param = $this->requestAll; |
| 16 | } | 16 | } |
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * @name :获取详情 | ||
| 20 | + * @return void | ||
| 21 | + * @author :liyuhang | ||
| 22 | + * @method | ||
| 23 | + */ | ||
| 24 | + public function menu_info(){ | ||
| 25 | + $info = $this->model->read($this->param); | ||
| 26 | + if($info === false){ | ||
| 27 | + $this->fail('当前数据不存在'); | ||
| 28 | + } | ||
| 29 | + $this->success($info); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * @name :添加菜单 | ||
| 34 | + * @return void | ||
| 35 | + * @author :liyuhang | ||
| 36 | + * @method | ||
| 37 | + */ | ||
| 38 | + public function menu_add(){ | ||
| 39 | + //查询当前名称是否存在 | ||
| 40 | + $info = $this->model->read(['name'=>$this->param['name']]); | ||
| 41 | + if($info !== false){ | ||
| 42 | + $this->fail('当前菜单名称已存在'); | ||
| 43 | + } | ||
| 44 | + $rs = $this->model->add($this->param); | ||
| 45 | + if($rs === false){ | ||
| 46 | + $this->fail('添加失败'); | ||
| 47 | + } | ||
| 48 | + $this->success(); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * @name :编辑菜单 | ||
| 53 | + * @return void | ||
| 54 | + * @author :liyuhang | ||
| 55 | + * @method | ||
| 56 | + */ | ||
| 57 | + public function menu_edit(){ | ||
| 58 | + //查询当前名称是否存在 | ||
| 59 | + $info = $this->model->read(['name'=>$this->param['name'],'id'=>['!=',$this->param['id']]]); | ||
| 60 | + if($info !== false){ | ||
| 61 | + $this->fail('当前菜单名称已存在'); | ||
| 62 | + } | ||
| 63 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 64 | + if($rs === false){ | ||
| 65 | + $this->fail('编辑失败'); | ||
| 66 | + } | ||
| 67 | + $this->success(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * @name :删除菜单 | ||
| 72 | + * @return void | ||
| 73 | + * @author :liyuhang | ||
| 74 | + * @method | ||
| 75 | + */ | ||
| 76 | + public function menu_del(){ | ||
| 77 | + $this->param['id'] = ['in',$this->param['id']]; | ||
| 78 | + $rs = $this->model->del($this->param); | ||
| 79 | + if($rs === false){ | ||
| 80 | + $this->fail('编辑失败'); | ||
| 81 | + } | ||
| 82 | + $this->success(); | ||
| 83 | + } | ||
| 17 | } | 84 | } |
| @@ -5,6 +5,7 @@ namespace App\Http\Logic\Aside\User; | @@ -5,6 +5,7 @@ namespace App\Http\Logic\Aside\User; | ||
| 5 | use App\Http\Logic\Aside\BaseLogic; | 5 | use App\Http\Logic\Aside\BaseLogic; |
| 6 | use App\Models\User\ProjectMenu as ProjectMenuModel; | 6 | use App\Models\User\ProjectMenu as ProjectMenuModel; |
| 7 | use App\Models\User\ProjectRole; | 7 | use App\Models\User\ProjectRole; |
| 8 | +use App\Models\User\User as UserModel; | ||
| 8 | 9 | ||
| 9 | class ProjectRoleLogic extends BaseLogic | 10 | class ProjectRoleLogic extends BaseLogic |
| 10 | { | 11 | { |
| @@ -61,6 +62,11 @@ class ProjectRoleLogic extends BaseLogic | @@ -61,6 +62,11 @@ class ProjectRoleLogic extends BaseLogic | ||
| 61 | * @method | 62 | * @method |
| 62 | */ | 63 | */ |
| 63 | public function role_add(){ | 64 | public function role_add(){ |
| 65 | + //查询当前名称是否存在 | ||
| 66 | + $info = $this->model->read(['name'=>$this->param['name']]); | ||
| 67 | + if($info !== false){ | ||
| 68 | + $this->fail('当前菜单名称已存在'); | ||
| 69 | + } | ||
| 64 | $rs = $this->model->add($this->param); | 70 | $rs = $this->model->add($this->param); |
| 65 | if($rs === false){ | 71 | if($rs === false){ |
| 66 | $this->fail('添加失败'); | 72 | $this->fail('添加失败'); |
| @@ -75,6 +81,11 @@ class ProjectRoleLogic extends BaseLogic | @@ -75,6 +81,11 @@ class ProjectRoleLogic extends BaseLogic | ||
| 75 | * @method | 81 | * @method |
| 76 | */ | 82 | */ |
| 77 | public function role_edit(){ | 83 | public function role_edit(){ |
| 84 | + //查询当前名称是否存在 | ||
| 85 | + $info = $this->model->read(['name'=>$this->param['name'],'id'=>['!=',$this->param['id']]]); | ||
| 86 | + if($info !== false){ | ||
| 87 | + $this->fail('当前菜单名称已存在'); | ||
| 88 | + } | ||
| 78 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 89 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 79 | if($rs === false){ | 90 | if($rs === false){ |
| 80 | $this->fail('编辑失败'); | 91 | $this->fail('编辑失败'); |
| @@ -89,6 +100,14 @@ class ProjectRoleLogic extends BaseLogic | @@ -89,6 +100,14 @@ class ProjectRoleLogic extends BaseLogic | ||
| 89 | * @method | 100 | * @method |
| 90 | */ | 101 | */ |
| 91 | public function role_del(){ | 102 | public function role_del(){ |
| 103 | + //查询当前角色下是否有用户 | ||
| 104 | + $userModel = new UserModel(); | ||
| 105 | + foreach ($this->param['id'] as $v){ | ||
| 106 | + $user_info = $userModel->read(['role_id'=>$v]); | ||
| 107 | + if($user_info !== false){ | ||
| 108 | + $this->fail('id为{'.$v.'}'.'的角色拥有用户'.$user_info['name'].',不允许删除'); | ||
| 109 | + } | ||
| 110 | + } | ||
| 92 | $this->param['id'] = ['in',$this->param['id']]; | 111 | $this->param['id'] = ['in',$this->param['id']]; |
| 93 | $rs = $this->model->del($this->param); | 112 | $rs = $this->model->del($this->param); |
| 94 | if($rs === false){ | 113 | if($rs === false){ |
| @@ -98,14 +98,14 @@ class BaseLogic extends Logic | @@ -98,14 +98,14 @@ class BaseLogic extends Logic | ||
| 98 | public function upload(){ | 98 | public function upload(){ |
| 99 | $image = $this->request->file('image'); | 99 | $image = $this->request->file('image'); |
| 100 | if(empty($image)){ | 100 | if(empty($image)){ |
| 101 | - return $this->fail('没有上传图片',Code::USER_ERROR); | 101 | + return $this->fail('没有上传图片'); |
| 102 | } | 102 | } |
| 103 | $hash = hash_file('md5', $image->getPathname()); | 103 | $hash = hash_file('md5', $image->getPathname()); |
| 104 | $url = './../uploads/images/'; | 104 | $url = './../uploads/images/'; |
| 105 | $filename = date('ymdHis').rand(10000,99999); | 105 | $filename = date('ymdHis').rand(10000,99999); |
| 106 | $res = $this->request->file('image')->move($url,$filename); | 106 | $res = $this->request->file('image')->move($url,$filename); |
| 107 | if ($res === false) { | 107 | if ($res === false) { |
| 108 | - return $this->fail($image->getError(), Code::USER_ERROR); | 108 | + return $this->fail($image->getError()); |
| 109 | } | 109 | } |
| 110 | $imageModel = new ImageModel(); | 110 | $imageModel = new ImageModel(); |
| 111 | $data = [ | 111 | $data = [ |
| @@ -117,7 +117,7 @@ class BaseLogic extends Logic | @@ -117,7 +117,7 @@ class BaseLogic extends Logic | ||
| 117 | ]; | 117 | ]; |
| 118 | $rs = $imageModel->add($data); | 118 | $rs = $imageModel->add($data); |
| 119 | if ($rs === false) { | 119 | if ($rs === false) { |
| 120 | - return $this->fail('添加失败', Code::USER_ERROR); | 120 | + return $this->fail('error'); |
| 121 | } | 121 | } |
| 122 | return $hash.$filename; | 122 | return $hash.$filename; |
| 123 | } | 123 | } |
| @@ -27,17 +27,21 @@ class BlogCategoryLogic extends BaseLogic | @@ -27,17 +27,21 @@ class BlogCategoryLogic extends BaseLogic | ||
| 27 | * @method | 27 | * @method |
| 28 | */ | 28 | */ |
| 29 | public function add_blog_category(){ | 29 | public function add_blog_category(){ |
| 30 | - DB::beginTransaction(); | 30 | + $condition = [ |
| 31 | + 'name'=>$this->param['name'] | ||
| 32 | + ]; | ||
| 33 | + $info = $this->model->read($condition); | ||
| 34 | + if($info !== false){ | ||
| 35 | + $this->fail('当前分类名称已存在'); | ||
| 36 | + } | ||
| 31 | $this->param['project_id'] = $this->user['project_id']; | 37 | $this->param['project_id'] = $this->user['project_id']; |
| 32 | $this->param['operator_id'] = $this->user['id']; | 38 | $this->param['operator_id'] = $this->user['id']; |
| 33 | $this->param['create_id'] = $this->user['id']; | 39 | $this->param['create_id'] = $this->user['id']; |
| 34 | $this->param['created_at'] = date('Y-m-d H:i:s'); | 40 | $this->param['created_at'] = date('Y-m-d H:i:s'); |
| 35 | $this->param['updated_at'] = date('Y-m-d H:i:s'); | 41 | $this->param['updated_at'] = date('Y-m-d H:i:s'); |
| 42 | + DB::beginTransaction(); | ||
| 43 | + try { | ||
| 36 | $cate_id = $this->model->insertGetId($this->param); | 44 | $cate_id = $this->model->insertGetId($this->param); |
| 37 | - if($cate_id === false){ | ||
| 38 | - DB::rollBack(); | ||
| 39 | - $this->fail('error',Code::USER_ERROR); | ||
| 40 | - } | ||
| 41 | //判断为子分类时 | 45 | //判断为子分类时 |
| 42 | if(isset($this->param['pid']) && !empty($this->param['pid'])) { | 46 | if(isset($this->param['pid']) && !empty($this->param['pid'])) { |
| 43 | //查看当前上级分类下是否有其他分类 | 47 | //查看当前上级分类下是否有其他分类 |
| @@ -45,36 +49,44 @@ class BlogCategoryLogic extends BaseLogic | @@ -45,36 +49,44 @@ class BlogCategoryLogic extends BaseLogic | ||
| 45 | if ($cate_info === false) { | 49 | if ($cate_info === false) { |
| 46 | //查看当前上一级分类下是否有新闻 | 50 | //查看当前上一级分类下是否有新闻 |
| 47 | $blogModel = new BlogModel(); | 51 | $blogModel = new BlogModel(); |
| 48 | - $news_info = $blogModel->read(['category_id' => ['like', ',' . $this->param['pid'] . ',']]); | ||
| 49 | - if ($news_info !== false) { | 52 | + $blog_info = $blogModel->read(['category_id' => ['like', ',' . $this->param['pid'] . ',']]); |
| 53 | + if ($blog_info !== false) { | ||
| 50 | $replacement = ',' . $cate_id . ','; | 54 | $replacement = ',' . $cate_id . ','; |
| 51 | $old = ',' . $this->param['pid'] . ','; | 55 | $old = ',' . $this->param['pid'] . ','; |
| 52 | //更新所有商品到当前分类 | 56 | //更新所有商品到当前分类 |
| 53 | - $rs = DB::table('gl_Blog')->where('category_id', 'like', '%' . $old . '%') | 57 | + DB::table('gl_Blog')->where('category_id', 'like', '%' . $old . '%') |
| 54 | ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]); | 58 | ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]); |
| 55 | - if ($rs === false) { | ||
| 56 | - DB::rollBack(); | ||
| 57 | - $this->fail('error', Code::USER_ERROR); | ||
| 58 | - } | ||
| 59 | } | 59 | } |
| 60 | } | 60 | } |
| 61 | } | 61 | } |
| 62 | DB::commit(); | 62 | DB::commit(); |
| 63 | + }catch (\Exception $e){ | ||
| 64 | + DB::rollBack(); | ||
| 65 | + $this->fail('error'); | ||
| 66 | + } | ||
| 63 | return $this->success(); | 67 | return $this->success(); |
| 64 | } | 68 | } |
| 65 | 69 | ||
| 66 | /** | 70 | /** |
| 67 | * @name :编辑分类 | 71 | * @name :编辑分类 |
| 68 | * @return void | 72 | * @return void |
| 69 | - * @throws \App\Exceptions\BsideGlobalException | ||
| 70 | * @author :liyuhang | 73 | * @author :liyuhang |
| 71 | * @method | 74 | * @method |
| 72 | */ | 75 | */ |
| 73 | public function edit_blog_category(){ | 76 | public function edit_blog_category(){ |
| 77 | + $condition = [ | ||
| 78 | + 'id'=>['!=',$this->param['id']], | ||
| 79 | + 'name'=>$this->param['name'] | ||
| 80 | + ]; | ||
| 81 | + //查看当前分类名称是否存在 | ||
| 82 | + $info = $this->model->read($condition); | ||
| 83 | + if($info !== false){ | ||
| 84 | + $this->fail('当前分类名称已存在'); | ||
| 85 | + } | ||
| 74 | $this->param['operator_id'] = $this->user['id']; | 86 | $this->param['operator_id'] = $this->user['id']; |
| 75 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 87 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 76 | if($rs === false){ | 88 | if($rs === false){ |
| 77 | - $this->fail('error',Code::USER_ERROR); | 89 | + $this->fail('error'); |
| 78 | } | 90 | } |
| 79 | return $this->success(); | 91 | return $this->success(); |
| 80 | } | 92 | } |
| @@ -82,14 +94,13 @@ class BlogCategoryLogic extends BaseLogic | @@ -82,14 +94,13 @@ class BlogCategoryLogic extends BaseLogic | ||
| 82 | /** | 94 | /** |
| 83 | * @name :详情 | 95 | * @name :详情 |
| 84 | * @return array | 96 | * @return array |
| 85 | - * @throws \App\Exceptions\BsideGlobalException | ||
| 86 | * @author :liyuhang | 97 | * @author :liyuhang |
| 87 | * @method | 98 | * @method |
| 88 | */ | 99 | */ |
| 89 | public function info_blog_category(){ | 100 | public function info_blog_category(){ |
| 90 | $info = $this->model->read($this->param); | 101 | $info = $this->model->read($this->param); |
| 91 | if($info === false){ | 102 | if($info === false){ |
| 92 | - $this->fail('error',Code::USER_ERROR); | 103 | + $this->fail('error'); |
| 93 | } | 104 | } |
| 94 | return $this->success($info); | 105 | return $this->success($info); |
| 95 | } | 106 | } |
| @@ -104,7 +115,7 @@ class BlogCategoryLogic extends BaseLogic | @@ -104,7 +115,7 @@ class BlogCategoryLogic extends BaseLogic | ||
| 104 | $this->param['operator_id'] = $this->user['id']; | 115 | $this->param['operator_id'] = $this->user['id']; |
| 105 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 116 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 106 | if($rs === false){ | 117 | if($rs === false){ |
| 107 | - $this->fail('error',Code::USER_ERROR); | 118 | + $this->fail('error'); |
| 108 | } | 119 | } |
| 109 | return $this->success(); | 120 | return $this->success(); |
| 110 | } | 121 | } |
| @@ -115,24 +126,23 @@ class BlogCategoryLogic extends BaseLogic | @@ -115,24 +126,23 @@ class BlogCategoryLogic extends BaseLogic | ||
| 115 | * @method | 126 | * @method |
| 116 | */ | 127 | */ |
| 117 | public function del_blog_category(){ | 128 | public function del_blog_category(){ |
| 118 | - $this->param = $this->requestAll; | ||
| 119 | foreach ($this->param['id'] as $v){ | 129 | foreach ($this->param['id'] as $v){ |
| 120 | //查询是否有子分类 | 130 | //查询是否有子分类 |
| 121 | $rs = $this->model->read(['pid'=>$v],['id']); | 131 | $rs = $this->model->read(['pid'=>$v],['id']); |
| 122 | if($rs !== false){ | 132 | if($rs !== false){ |
| 123 | - $this->response('当前分类拥有子分类不允许删除',Code::USER_ERROR); | 133 | + $this->response('当前分类拥有子分类不允许删除'); |
| 124 | } | 134 | } |
| 125 | //查看当前分内下是否有博客 | 135 | //查看当前分内下是否有博客 |
| 126 | $blogModel = new BlogModel(); | 136 | $blogModel = new BlogModel(); |
| 127 | $rs = $blogModel->read(['category_id'=>$v],['id']); | 137 | $rs = $blogModel->read(['category_id'=>$v],['id']); |
| 128 | if($rs !== false){ | 138 | if($rs !== false){ |
| 129 | - $this->response('当前分类拥有博客',Code::USER_ERROR); | 139 | + $this->response('当前分类拥有博客'); |
| 130 | } | 140 | } |
| 131 | } | 141 | } |
| 132 | $this->param['id'] = ['in',$this->param['id']]; | 142 | $this->param['id'] = ['in',$this->param['id']]; |
| 133 | $rs = $this->model->del($this->param); | 143 | $rs = $this->model->del($this->param); |
| 134 | if($rs === false){ | 144 | if($rs === false){ |
| 135 | - $this->response('error',Code::USER_ERROR); | 145 | + $this->response('error'); |
| 136 | } | 146 | } |
| 137 | return $this->success(); | 147 | return $this->success(); |
| 138 | } | 148 | } |
| @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\Blog; | @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\Blog; | ||
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | +use App\Models\Blog\Blog as BlogModel; | ||
| 7 | use App\Models\Blog\BlogLabel as BlogLabelModel; | 8 | use App\Models\Blog\BlogLabel as BlogLabelModel; |
| 8 | 9 | ||
| 9 | class BlogLabelLogic extends BaseLogic | 10 | class BlogLabelLogic extends BaseLogic |
| @@ -23,12 +24,20 @@ class BlogLabelLogic extends BaseLogic | @@ -23,12 +24,20 @@ class BlogLabelLogic extends BaseLogic | ||
| 23 | * @method | 24 | * @method |
| 24 | */ | 25 | */ |
| 25 | public function add_blog_label(){ | 26 | public function add_blog_label(){ |
| 27 | + $condition = [ | ||
| 28 | + 'name'=>$this->param['name'] | ||
| 29 | + ]; | ||
| 30 | + //查看当前分类名称是否存在 | ||
| 31 | + $info = $this->model->read($condition); | ||
| 32 | + if($info !== false){ | ||
| 33 | + $this->fail('当前标签名称已存在'); | ||
| 34 | + } | ||
| 26 | $this->param['create_id'] = $this->user['id']; | 35 | $this->param['create_id'] = $this->user['id']; |
| 27 | $this->param['Operator_id'] = $this->user['id']; | 36 | $this->param['Operator_id'] = $this->user['id']; |
| 28 | $this->param['project_id'] = $this->user['project_id']; | 37 | $this->param['project_id'] = $this->user['project_id']; |
| 29 | $rs = $this->model->add($this->param); | 38 | $rs = $this->model->add($this->param); |
| 30 | if($rs === false){ | 39 | if($rs === false){ |
| 31 | - $this->fail('error',Code::USER_ERROR); | 40 | + $this->fail('error'); |
| 32 | } | 41 | } |
| 33 | return $this->success(); | 42 | return $this->success(); |
| 34 | } | 43 | } |
| @@ -40,11 +49,20 @@ class BlogLabelLogic extends BaseLogic | @@ -40,11 +49,20 @@ class BlogLabelLogic extends BaseLogic | ||
| 40 | * @method | 49 | * @method |
| 41 | */ | 50 | */ |
| 42 | public function edit_blog_label(){ | 51 | public function edit_blog_label(){ |
| 52 | + $condition = [ | ||
| 53 | + 'id'=>['!=',$this->param['id']], | ||
| 54 | + 'name'=>$this->param['name'] | ||
| 55 | + ]; | ||
| 56 | + //查看当前分类名称是否存在 | ||
| 57 | + $info = $this->model->read($condition); | ||
| 58 | + if($info !== false){ | ||
| 59 | + $this->fail('当前标签名称已存在'); | ||
| 60 | + } | ||
| 43 | $this->param['operator_id'] = $this->user['id']; | 61 | $this->param['operator_id'] = $this->user['id']; |
| 44 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 62 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 45 | //TODO::路由映射 | 63 | //TODO::路由映射 |
| 46 | if($rs === false){ | 64 | if($rs === false){ |
| 47 | - $this->fail('error',Code::USER_ERROR); | 65 | + $this->fail('error'); |
| 48 | } | 66 | } |
| 49 | return $this->success(); | 67 | return $this->success(); |
| 50 | } | 68 | } |
| @@ -56,10 +74,18 @@ class BlogLabelLogic extends BaseLogic | @@ -56,10 +74,18 @@ class BlogLabelLogic extends BaseLogic | ||
| 56 | * @method | 74 | * @method |
| 57 | */ | 75 | */ |
| 58 | public function del_blog_label(){ | 76 | public function del_blog_label(){ |
| 77 | + foreach ($this->param['id'] as $v){ | ||
| 78 | + //查看当前分内下是否有博客 | ||
| 79 | + $blogModel = new BlogModel(); | ||
| 80 | + $rs = $blogModel->read(['label_id'=>$v],['id']); | ||
| 81 | + if($rs !== false){ | ||
| 82 | + $this->response('当前标签拥有博客,不允许删除'); | ||
| 83 | + } | ||
| 84 | + } | ||
| 59 | $this->param['id'] = ['in',$this->param['id']]; | 85 | $this->param['id'] = ['in',$this->param['id']]; |
| 60 | $rs = $this->model->del($this->param); | 86 | $rs = $this->model->del($this->param); |
| 61 | if($rs === false){ | 87 | if($rs === false){ |
| 62 | - $this->fail('error',Code::USER_ERROR); | 88 | + $this->fail('error'); |
| 63 | } | 89 | } |
| 64 | return $this->success(); | 90 | return $this->success(); |
| 65 | } | 91 | } |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Http\Logic\Bside\Blog; | 3 | namespace App\Http\Logic\Bside\Blog; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | +use App\Helper\Common; | ||
| 6 | use App\Http\Logic\Bside\BaseLogic; | 7 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\Blog\Blog; | 8 | use App\Models\Blog\Blog; |
| 8 | use App\Models\Blog\BlogCategory as BlogCategoryModel; | 9 | use App\Models\Blog\BlogCategory as BlogCategoryModel; |
| @@ -12,6 +13,8 @@ use Illuminate\Support\Facades\DB; | @@ -12,6 +13,8 @@ use Illuminate\Support\Facades\DB; | ||
| 12 | 13 | ||
| 13 | class BlogLogic extends BaseLogic | 14 | class BlogLogic extends BaseLogic |
| 14 | { | 15 | { |
| 16 | + const STATUS_TWO = 2; | ||
| 17 | + | ||
| 15 | public function __construct() | 18 | public function __construct() |
| 16 | { | 19 | { |
| 17 | parent::__construct(); | 20 | parent::__construct(); |
| @@ -45,12 +48,20 @@ class BlogLogic extends BaseLogic | @@ -45,12 +48,20 @@ class BlogLogic extends BaseLogic | ||
| 45 | return $this->success($list); | 48 | return $this->success($list); |
| 46 | } | 49 | } |
| 47 | /** | 50 | /** |
| 48 | - * @name :添加博客 | 51 | + * @name :添加博客 |
| 49 | * @return void | 52 | * @return void |
| 50 | * @author :liyuhang | 53 | * @author :liyuhang |
| 51 | * @method | 54 | * @method |
| 52 | */ | 55 | */ |
| 53 | public function blog_add(){ | 56 | public function blog_add(){ |
| 57 | + $condition = [ | ||
| 58 | + 'name'=>$this->param['name'] | ||
| 59 | + ]; | ||
| 60 | + //查看当前名称是否存在 | ||
| 61 | + $info = $this->model->read($condition); | ||
| 62 | + if($info !== false){ | ||
| 63 | + $this->fail('当前名称已存在'); | ||
| 64 | + } | ||
| 54 | $this->param['create_id'] = $this->user['id']; | 65 | $this->param['create_id'] = $this->user['id']; |
| 55 | $this->param['operator_id'] = $this->user['id']; | 66 | $this->param['operator_id'] = $this->user['id']; |
| 56 | $this->param['project_id'] = $this->user['project_id']; | 67 | $this->param['project_id'] = $this->user['project_id']; |
| @@ -63,25 +74,32 @@ class BlogLogic extends BaseLogic | @@ -63,25 +74,32 @@ class BlogLogic extends BaseLogic | ||
| 63 | $data = $this->upload(); | 74 | $data = $this->upload(); |
| 64 | $this->param['image'] = $data; | 75 | $this->param['image'] = $data; |
| 65 | } | 76 | } |
| 66 | - $this->model->insertGetId($this->param); | 77 | + $rs = $this->model->insertGetId($this->param); |
| 67 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']); | 78 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']); |
| 68 | DB::commit(); | 79 | DB::commit(); |
| 69 | }catch (\Exception $e){ | 80 | }catch (\Exception $e){ |
| 70 | DB::rollBack(); | 81 | DB::rollBack(); |
| 71 | - $this->fail('error',Code::USER_ERROR); | 82 | + $this->fail('error'); |
| 72 | } | 83 | } |
| 73 | //TODO::写入日志 | 84 | //TODO::写入日志 |
| 74 | $this->success(); | 85 | $this->success(); |
| 75 | } | 86 | } |
| 76 | 87 | ||
| 77 | /** | 88 | /** |
| 78 | - * @name : 编辑用户 | 89 | + * @name : 编辑博客 |
| 79 | * @return void | 90 | * @return void |
| 80 | - * @throws \App\Exceptions\BsideGlobalException | ||
| 81 | * @author :liyuhang | 91 | * @author :liyuhang |
| 82 | * @method | 92 | * @method |
| 83 | */ | 93 | */ |
| 84 | public function blog_edit(){ | 94 | public function blog_edit(){ |
| 95 | + $condition = [ | ||
| 96 | + 'id'=>['!=',$this->param['id']], | ||
| 97 | + 'name'=>$this->param['name'] | ||
| 98 | + ]; | ||
| 99 | + $info = $this->model->read($condition); | ||
| 100 | + if($info !== false){ | ||
| 101 | + $this->fail('当前名称已存在'); | ||
| 102 | + } | ||
| 85 | $this->param['operator_id'] = $this->uid; | 103 | $this->param['operator_id'] = $this->uid; |
| 86 | DB::beginTransaction(); | 104 | DB::beginTransaction(); |
| 87 | try { | 105 | try { |
| @@ -102,8 +120,9 @@ class BlogLogic extends BaseLogic | @@ -102,8 +120,9 @@ class BlogLogic extends BaseLogic | ||
| 102 | DB::commit(); | 120 | DB::commit(); |
| 103 | }catch (\Exception $e){ | 121 | }catch (\Exception $e){ |
| 104 | DB::rollBack(); | 122 | DB::rollBack(); |
| 105 | - $this->fail('error',Code::USER_ERROR); | 123 | + $this->fail('error'); |
| 106 | } | 124 | } |
| 125 | + $this->success(); | ||
| 107 | } | 126 | } |
| 108 | /** | 127 | /** |
| 109 | * @name :获取数据详情 | 128 | * @name :获取数据详情 |
| @@ -114,6 +133,9 @@ class BlogLogic extends BaseLogic | @@ -114,6 +133,9 @@ class BlogLogic extends BaseLogic | ||
| 114 | */ | 133 | */ |
| 115 | public function blog_info(){ | 134 | public function blog_info(){ |
| 116 | $info = $this->model->read($this->param); | 135 | $info = $this->model->read($this->param); |
| 136 | + if($info === false){ | ||
| 137 | + $this->fail('error'); | ||
| 138 | + } | ||
| 117 | //获取分类名称 | 139 | //获取分类名称 |
| 118 | $info['category_id'] = explode(',',trim($info['category_id'],',')); | 140 | $info['category_id'] = explode(',',trim($info['category_id'],',')); |
| 119 | $blogCategoryModel = new BlogCategoryModel(); | 141 | $blogCategoryModel = new BlogCategoryModel(); |
| @@ -122,10 +144,7 @@ class BlogLogic extends BaseLogic | @@ -122,10 +144,7 @@ class BlogLogic extends BaseLogic | ||
| 122 | foreach ($category_list as $v){ | 144 | foreach ($category_list as $v){ |
| 123 | $str .= $v['name'].','; | 145 | $str .= $v['name'].','; |
| 124 | } | 146 | } |
| 125 | - $info['category_id'] = trim($str,','); | ||
| 126 | - if($info === false){ | ||
| 127 | - $this->fail('error',Code::USER_ERROR); | ||
| 128 | - } | 147 | + $info['category_name'] = trim($str,','); |
| 129 | return $this->success($info); | 148 | return $this->success($info); |
| 130 | } | 149 | } |
| 131 | 150 | ||
| @@ -153,7 +172,7 @@ class BlogLogic extends BaseLogic | @@ -153,7 +172,7 @@ class BlogLogic extends BaseLogic | ||
| 153 | */ | 172 | */ |
| 154 | public function blog_del(){ | 173 | public function blog_del(){ |
| 155 | $this->param['id'] = ['in',$this->param['id']]; | 174 | $this->param['id'] = ['in',$this->param['id']]; |
| 156 | - $rs = $this->model->edit(['status'=>2],$this->param); | 175 | + $rs = $this->model->edit(['status'=>$this::STATUS_TWO],$this->param); |
| 157 | if($rs === false){ | 176 | if($rs === false){ |
| 158 | $this->fail('error',Code::USER_ERROR); | 177 | $this->fail('error',Code::USER_ERROR); |
| 159 | } | 178 | } |
| @@ -3,8 +3,8 @@ | @@ -3,8 +3,8 @@ | ||
| 3 | namespace App\Http\Logic\Bside; | 3 | namespace App\Http\Logic\Bside; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | -use App\Models\Mail as MailModel; | ||
| 7 | -use App\Models\MailUser as MailUserModel; | 6 | +use App\Models\Mail\Mail as MailModel; |
| 7 | +use App\Models\Mail\MailUser as MailUserModel; | ||
| 8 | 8 | ||
| 9 | class MailLogic extends BaseLogic | 9 | class MailLogic extends BaseLogic |
| 10 | { | 10 | { |
| @@ -36,7 +36,7 @@ class MailLogic extends BaseLogic | @@ -36,7 +36,7 @@ class MailLogic extends BaseLogic | ||
| 36 | if($read_info === false){ | 36 | if($read_info === false){ |
| 37 | $rs = $mailUserModel->add($data); | 37 | $rs = $mailUserModel->add($data); |
| 38 | if($rs === false){ | 38 | if($rs === false){ |
| 39 | - $this->fail('添加失败'); | 39 | + $this->fail('error'); |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
| 42 | return $this->success($info); | 42 | return $this->success($info); |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Http\Logic\Bside\News; | 3 | namespace App\Http\Logic\Bside\News; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | +use App\Helper\Common; | ||
| 6 | use App\Http\Logic\Bside\BaseLogic; | 7 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\News\News as NewsModel; | 8 | use App\Models\News\News as NewsModel; |
| 8 | use App\Models\News\NewsCategory as NewsCategoryModel; | 9 | use App\Models\News\NewsCategory as NewsCategoryModel; |
| @@ -39,18 +40,21 @@ class NewsCategoryLogic extends BaseLogic | @@ -39,18 +40,21 @@ class NewsCategoryLogic extends BaseLogic | ||
| 39 | * @method | 40 | * @method |
| 40 | */ | 41 | */ |
| 41 | public function add_news_category(){ | 42 | public function add_news_category(){ |
| 43 | + $condition = [ | ||
| 44 | + 'name'=>$this->param['name'] | ||
| 45 | + ]; | ||
| 46 | + $info = $this->model->read($condition); | ||
| 47 | + if($info !== false){ | ||
| 48 | + $this->fail('当前分类名称已存在'); | ||
| 49 | + } | ||
| 42 | DB::beginTransaction(); | 50 | DB::beginTransaction(); |
| 43 | - | ||
| 44 | $this->param['project_id'] = $this->user['project_id']; | 51 | $this->param['project_id'] = $this->user['project_id']; |
| 45 | $this->param['operator_id'] = $this->user['id']; | 52 | $this->param['operator_id'] = $this->user['id']; |
| 46 | $this->param['create_id'] = $this->user['id']; | 53 | $this->param['create_id'] = $this->user['id']; |
| 47 | $this->param['created_at'] = date('Y-m-d H:i:s'); | 54 | $this->param['created_at'] = date('Y-m-d H:i:s'); |
| 48 | $this->param['updated_at'] = date('Y-m-d H:i:s'); | 55 | $this->param['updated_at'] = date('Y-m-d H:i:s'); |
| 56 | + try { | ||
| 49 | $cate_id = $this->model->insertGetId($this->param); | 57 | $cate_id = $this->model->insertGetId($this->param); |
| 50 | - if($cate_id === false){ | ||
| 51 | - DB::rollBack(); | ||
| 52 | - $this->fail('error',Code::USER_ERROR); | ||
| 53 | - } | ||
| 54 | //判断为子分类时 | 58 | //判断为子分类时 |
| 55 | if(isset($this->param['pid']) && !empty($this->param['pid'])) { | 59 | if(isset($this->param['pid']) && !empty($this->param['pid'])) { |
| 56 | //查看当前上级分类下是否有其他分类 | 60 | //查看当前上级分类下是否有其他分类 |
| @@ -63,16 +67,16 @@ class NewsCategoryLogic extends BaseLogic | @@ -63,16 +67,16 @@ class NewsCategoryLogic extends BaseLogic | ||
| 63 | $replacement = ',' . $cate_id . ','; | 67 | $replacement = ',' . $cate_id . ','; |
| 64 | $old = ',' . $this->param['pid'] . ','; | 68 | $old = ',' . $this->param['pid'] . ','; |
| 65 | //更新所有商品到当前分类 | 69 | //更新所有商品到当前分类 |
| 66 | - $rs = DB::table('gl_news')->where('category_id', 'like', '%' . $old . '%') | 70 | + DB::table('gl_news')->where('category_id', 'like', '%' . $old . '%') |
| 67 | ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]); | 71 | ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]); |
| 68 | - if ($rs === false) { | ||
| 69 | - DB::rollBack(); | ||
| 70 | - $this->fail('error', Code::USER_ERROR); | ||
| 71 | - } | ||
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| 74 | } | 74 | } |
| 75 | DB::commit(); | 75 | DB::commit(); |
| 76 | + }catch (\Exception $e){ | ||
| 77 | + DB::rollBack(); | ||
| 78 | + $this->fail('error'); | ||
| 79 | + } | ||
| 76 | return $this->success(); | 80 | return $this->success(); |
| 77 | } | 81 | } |
| 78 | 82 | ||
| @@ -83,10 +87,19 @@ class NewsCategoryLogic extends BaseLogic | @@ -83,10 +87,19 @@ class NewsCategoryLogic extends BaseLogic | ||
| 83 | * @method | 87 | * @method |
| 84 | */ | 88 | */ |
| 85 | public function edit_news_category(){ | 89 | public function edit_news_category(){ |
| 90 | + $condition = [ | ||
| 91 | + 'id'=>['!=',$this->param['id']], | ||
| 92 | + 'name'=>$this->param['name'] | ||
| 93 | + ]; | ||
| 94 | + //查看当前分类名称是否存在 | ||
| 95 | + $info = $this->model->read($condition); | ||
| 96 | + if($info !== false){ | ||
| 97 | + $this->fail('当前分类名称已存在'); | ||
| 98 | + } | ||
| 86 | $this->param['operator_id'] = $this->user['id']; | 99 | $this->param['operator_id'] = $this->user['id']; |
| 87 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 100 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 88 | if($rs === false){ | 101 | if($rs === false){ |
| 89 | - $this->fail('error',Code::USER_ERROR); | 102 | + $this->fail('error'); |
| 90 | } | 103 | } |
| 91 | return $this->success(); | 104 | return $this->success(); |
| 92 | } | 105 | } |
| @@ -102,7 +115,7 @@ class NewsCategoryLogic extends BaseLogic | @@ -102,7 +115,7 @@ class NewsCategoryLogic extends BaseLogic | ||
| 102 | $this->param['operator_id'] = $this->user['id']; | 115 | $this->param['operator_id'] = $this->user['id']; |
| 103 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 116 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 104 | if($rs === false){ | 117 | if($rs === false){ |
| 105 | - $this->fail('error',Code::USER_ERROR); | 118 | + $this->fail('error'); |
| 106 | } | 119 | } |
| 107 | return $this->success(); | 120 | return $this->success(); |
| 108 | } | 121 | } |
| @@ -114,24 +127,23 @@ class NewsCategoryLogic extends BaseLogic | @@ -114,24 +127,23 @@ class NewsCategoryLogic extends BaseLogic | ||
| 114 | * @method | 127 | * @method |
| 115 | */ | 128 | */ |
| 116 | public function del_news_category(){ | 129 | public function del_news_category(){ |
| 117 | - $this->param = $this->requestAll; | ||
| 118 | foreach ($this->param['id'] as $v){ | 130 | foreach ($this->param['id'] as $v){ |
| 119 | //查询是否有子分类 | 131 | //查询是否有子分类 |
| 120 | $rs = $this->model->read(['pid'=>$v],['id']); | 132 | $rs = $this->model->read(['pid'=>$v],['id']); |
| 121 | if($rs !== false){ | 133 | if($rs !== false){ |
| 122 | - $this->fail('当前分类拥有子分类不允许删除',Code::USER_ERROR); | 134 | + $this->fail('当前分类拥有子分类不允许删除'); |
| 123 | } | 135 | } |
| 124 | //查看当前分内下是否有商品 | 136 | //查看当前分内下是否有商品 |
| 125 | $newsModel = new NewsModel(); | 137 | $newsModel = new NewsModel(); |
| 126 | $rs = $newsModel->read(['category_id'=>$v],['id']); | 138 | $rs = $newsModel->read(['category_id'=>$v],['id']); |
| 127 | if($rs !== false){ | 139 | if($rs !== false){ |
| 128 | - $this->fail('当前分类拥有商品',Code::USER_ERROR); | 140 | + $this->fail('当前分类拥有商品'); |
| 129 | } | 141 | } |
| 130 | } | 142 | } |
| 131 | $this->param['id'] = ['in',$this->param['id']]; | 143 | $this->param['id'] = ['in',$this->param['id']]; |
| 132 | $rs = $this->model->del($this->param); | 144 | $rs = $this->model->del($this->param); |
| 133 | if($rs === false){ | 145 | if($rs === false){ |
| 134 | - $this->fail('error',Code::USER_ERROR); | 146 | + $this->fail('error'); |
| 135 | } | 147 | } |
| 136 | return $this->success(); | 148 | return $this->success(); |
| 137 | } | 149 | } |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Http\Logic\Bside\News; | 3 | namespace App\Http\Logic\Bside\News; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | +use App\Helper\Common; | ||
| 6 | use App\Http\Logic\Bside\BaseLogic; | 7 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\Image; | 8 | use App\Models\Image; |
| 8 | use App\Models\News\News; | 9 | use App\Models\News\News; |
| @@ -59,31 +60,37 @@ class NewsLogic extends BaseLogic | @@ -59,31 +60,37 @@ class NewsLogic extends BaseLogic | ||
| 59 | $this->param['created_at'] = date('Y-m-d H:i:s',time()); | 60 | $this->param['created_at'] = date('Y-m-d H:i:s',time()); |
| 60 | $this->param['updated_at'] = date('Y-m-d H:i:s',time()); | 61 | $this->param['updated_at'] = date('Y-m-d H:i:s',time()); |
| 61 | $this->param['category_id'] = ','.$this->param['category_id'].','; | 62 | $this->param['category_id'] = ','.$this->param['category_id'].','; |
| 62 | -// DB::beginTransaction(); | ||
| 63 | -// try { | 63 | + DB::beginTransaction(); |
| 64 | + try { | ||
| 64 | if(isset($this->param['image'])){ | 65 | if(isset($this->param['image'])){ |
| 65 | $data = $this->upload(); | 66 | $data = $this->upload(); |
| 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); |
| 69 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); | 70 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); |
| 70 | -// DB::commit(); | ||
| 71 | -// }catch (\Exception $e){ | ||
| 72 | -// DB::rollBack(); | ||
| 73 | -// $this->fail('添加失败',Code::USER_ERROR); | ||
| 74 | -// } | ||
| 75 | - //TODO::写入日志 | 71 | + DB::commit(); |
| 72 | + }catch (\Exception $e){ | ||
| 73 | + DB::rollBack(); | ||
| 74 | + $this->fail('添加失败'); | ||
| 75 | + } | ||
| 76 | $this->success(); | 76 | $this->success(); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | /** | 79 | /** |
| 80 | * @name :编辑 | 80 | * @name :编辑 |
| 81 | * @return void | 81 | * @return void |
| 82 | - * @throws \App\Exceptions\BsideGlobalException | ||
| 83 | * @author :liyuhang | 82 | * @author :liyuhang |
| 84 | * @method | 83 | * @method |
| 85 | */ | 84 | */ |
| 86 | public function news_edit(){ | 85 | public function news_edit(){ |
| 86 | + $condition = [ | ||
| 87 | + 'id'=>['!=',$this->param['id']], | ||
| 88 | + 'name'=>$this->param['name'] | ||
| 89 | + ]; | ||
| 90 | + $info = $this->model->read($condition); | ||
| 91 | + if($info !== false){ | ||
| 92 | + $this->fail('当前名称已存在'); | ||
| 93 | + } | ||
| 87 | $this->param['operator_id'] = $this->user['id']; | 94 | $this->param['operator_id'] = $this->user['id']; |
| 88 | //多个分类按逗号隔开 | 95 | //多个分类按逗号隔开 |
| 89 | $this->param['category_id'] = ','.$this->param['category_id'].','; | 96 | $this->param['category_id'] = ','.$this->param['category_id'].','; |
| @@ -108,7 +115,7 @@ class NewsLogic extends BaseLogic | @@ -108,7 +115,7 @@ class NewsLogic extends BaseLogic | ||
| 108 | DB::commit(); | 115 | DB::commit(); |
| 109 | }catch (\exception $e){ | 116 | }catch (\exception $e){ |
| 110 | DB::rollBack(); | 117 | DB::rollBack(); |
| 111 | - $this->fail('参数错误或其他服务器原因,编辑失败',Code::USER_ERROR,[]); | 118 | + $this->fail('参数错误或其他服务器原因,编辑失败'); |
| 112 | } | 119 | } |
| 113 | //TODO::写入日志 | 120 | //TODO::写入日志 |
| 114 | $this->success(); | 121 | $this->success(); |
| @@ -127,7 +134,6 @@ class NewsLogic extends BaseLogic | @@ -127,7 +134,6 @@ class NewsLogic extends BaseLogic | ||
| 127 | if($rs === false){ | 134 | if($rs === false){ |
| 128 | $this->fail('error',Code::USER_ERROR); | 135 | $this->fail('error',Code::USER_ERROR); |
| 129 | } | 136 | } |
| 130 | - //TODO::写入日志 | ||
| 131 | $this->success(); | 137 | $this->success(); |
| 132 | } | 138 | } |
| 133 | /** | 139 | /** |
| @@ -138,7 +144,6 @@ class NewsLogic extends BaseLogic | @@ -138,7 +144,6 @@ class NewsLogic extends BaseLogic | ||
| 138 | * @method | 144 | * @method |
| 139 | */ | 145 | */ |
| 140 | public function news_info(){ | 146 | public function news_info(){ |
| 141 | - $this->param = $this->requestAll; | ||
| 142 | $info = $this->model->read($this->param); | 147 | $info = $this->model->read($this->param); |
| 143 | //获取分类名称 | 148 | //获取分类名称 |
| 144 | $info['category_id'] = explode(',',trim($info['category_id'],',')); | 149 | $info['category_id'] = explode(',',trim($info['category_id'],',')); |
| @@ -150,7 +155,7 @@ class NewsLogic extends BaseLogic | @@ -150,7 +155,7 @@ class NewsLogic extends BaseLogic | ||
| 150 | } | 155 | } |
| 151 | $info['category_id'] = trim($str,','); | 156 | $info['category_id'] = trim($str,','); |
| 152 | if($info === false){ | 157 | if($info === false){ |
| 153 | - $this->fail('error',Code::USER_ERROR); | 158 | + $this->fail('error'); |
| 154 | } | 159 | } |
| 155 | return $this->success($info); | 160 | return $this->success($info); |
| 156 | } | 161 | } |
| @@ -165,7 +170,7 @@ class NewsLogic extends BaseLogic | @@ -165,7 +170,7 @@ class NewsLogic extends BaseLogic | ||
| 165 | $this->param['id'] = ['in',$this->param['id']]; | 170 | $this->param['id'] = ['in',$this->param['id']]; |
| 166 | $rs = $this->model->edit(['status'=>2,'operator_id'=>$this->user['id']],$this->param); | 171 | $rs = $this->model->edit(['status'=>2,'operator_id'=>$this->user['id']],$this->param); |
| 167 | if($rs === false){ | 172 | if($rs === false){ |
| 168 | - $this->fail('error',Code::USER_ERROR); | 173 | + $this->fail('error'); |
| 169 | } | 174 | } |
| 170 | return $this->success(); | 175 | return $this->success(); |
| 171 | } | 176 | } |
| @@ -6,7 +6,7 @@ use App\Enums\Common\Code; | @@ -6,7 +6,7 @@ use App\Enums\Common\Code; | ||
| 6 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\User\ProjectMenu as ProjectMenuModel; | 7 | use App\Models\User\ProjectMenu as ProjectMenuModel; |
| 8 | use App\Models\User\ProjectRole as ProjectRoleModel; | 8 | use App\Models\User\ProjectRole as ProjectRoleModel; |
| 9 | -use App\Models\User\User; | 9 | +use App\Models\User\User as UserModel; |
| 10 | 10 | ||
| 11 | class RoleLogic extends BaseLogic | 11 | class RoleLogic extends BaseLogic |
| 12 | { | 12 | { |
| @@ -24,17 +24,25 @@ class RoleLogic extends BaseLogic | @@ -24,17 +24,25 @@ class RoleLogic extends BaseLogic | ||
| 24 | * @method | 24 | * @method |
| 25 | */ | 25 | */ |
| 26 | public function role_add(){ | 26 | public function role_add(){ |
| 27 | + $condition = [ | ||
| 28 | + 'name'=>$this->param['name'], | ||
| 29 | + 'project_id'=>$this->user['project_id'], | ||
| 30 | + ]; | ||
| 31 | + $info = $this->model->read($condition); | ||
| 32 | + if($info !== false){ | ||
| 33 | + $this->fail('当前添加的角色已存在'); | ||
| 34 | + } | ||
| 27 | $this->param['create_id'] = $this->user['id']; | 35 | $this->param['create_id'] = $this->user['id']; |
| 28 | $this->param['operator_id'] = $this->user['id']; | 36 | $this->param['operator_id'] = $this->user['id']; |
| 29 | $this->param['project_id'] = $this->user['project_id']; | 37 | $this->param['project_id'] = $this->user['project_id']; |
| 30 | //验证当前角色是否存在 | 38 | //验证当前角色是否存在 |
| 31 | $info = $this->model->read(['name'=>$this->param['name']]); | 39 | $info = $this->model->read(['name'=>$this->param['name']]); |
| 32 | if($info !== false){ | 40 | if($info !== false){ |
| 33 | - $this->fail('当前添加的角色已存在',Code::USER_ERROR); | 41 | + $this->fail('当前添加的角色已存在'); |
| 34 | } | 42 | } |
| 35 | $rs = $this->model->add($this->param); | 43 | $rs = $this->model->add($this->param); |
| 36 | if($rs === false){ | 44 | if($rs === false){ |
| 37 | - $this->fail('添加失败',Code::USER_PARAMS_ERROE); | 45 | + $this->fail('添加失败'); |
| 38 | } | 46 | } |
| 39 | return $this->success(); | 47 | return $this->success(); |
| 40 | } | 48 | } |
| @@ -54,11 +62,11 @@ class RoleLogic extends BaseLogic | @@ -54,11 +62,11 @@ class RoleLogic extends BaseLogic | ||
| 54 | ]; | 62 | ]; |
| 55 | $info = $this->model->read($condition); | 63 | $info = $this->model->read($condition); |
| 56 | if($info !== false){ | 64 | if($info !== false){ |
| 57 | - $this->fail('当前添加的角色已存在',Code::USER_PARAMS_ERROE); | 65 | + $this->fail('当前添加的角色已存在'); |
| 58 | } | 66 | } |
| 59 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 67 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 60 | if($rs === false){ | 68 | if($rs === false){ |
| 61 | - $this->fail('编辑失败',Code::USER_PARAMS_ERROE); | 69 | + $this->fail('error'); |
| 62 | } | 70 | } |
| 63 | return $this->success(); | 71 | return $this->success(); |
| 64 | } | 72 | } |
| @@ -84,7 +92,7 @@ class RoleLogic extends BaseLogic | @@ -84,7 +92,7 @@ class RoleLogic extends BaseLogic | ||
| 84 | */ | 92 | */ |
| 85 | public function role_del(){ | 93 | public function role_del(){ |
| 86 | //查询当前角色下是否有用户 | 94 | //查询当前角色下是否有用户 |
| 87 | - $userModel = new User(); | 95 | + $userModel = new UserModel(); |
| 88 | //批量删除 | 96 | //批量删除 |
| 89 | foreach ($this->param['id'] as $v){ | 97 | foreach ($this->param['id'] as $v){ |
| 90 | $user_info = $userModel->read(['role_id'=>$v]); | 98 | $user_info = $userModel->read(['role_id'=>$v]); |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Http\Logic\Bside\User; | 3 | namespace App\Http\Logic\Bside\User; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | +use App\Helper\Common; | ||
| 6 | use App\Http\Logic\Bside\BaseLogic; | 7 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\Image; | 8 | use App\Models\Image; |
| 8 | use App\Models\User\User; | 9 | use App\Models\User\User; |
| @@ -16,20 +17,32 @@ class UserLogic extends BaseLogic | @@ -16,20 +17,32 @@ class UserLogic extends BaseLogic | ||
| 16 | $this->model = new User(); | 17 | $this->model = new User(); |
| 17 | $this->param = $this->requestAll; | 18 | $this->param = $this->requestAll; |
| 18 | } | 19 | } |
| 19 | - | 20 | + /** |
| 21 | + * @name :用户详情 | ||
| 22 | + * @return void | ||
| 23 | + * @author :liyuhang | ||
| 24 | + * @method | ||
| 25 | + */ | ||
| 26 | + public function user_info(){ | ||
| 27 | + $info = $this->model->read($this->param); | ||
| 28 | + if($info === false){ | ||
| 29 | + $this->fail('error',Code::USER_ERROR); | ||
| 30 | + } | ||
| 31 | + return $this->success($info); | ||
| 32 | + } | ||
| 20 | /** | 33 | /** |
| 21 | * @name :添加会员 | 34 | * @name :添加会员 |
| 22 | * @author :liyuhang | 35 | * @author :liyuhang |
| 23 | */ | 36 | */ |
| 24 | public function user_add(){ | 37 | public function user_add(){ |
| 25 | - $this->param['create_id'] = $this->user['id']; | ||
| 26 | - $this->param['operator_id'] = $this->user['id']; | ||
| 27 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 28 | //验证当前用户是否存在 | 38 | //验证当前用户是否存在 |
| 29 | $info = $this->model->read(['mobile'=>$this->param['mobile']]); | 39 | $info = $this->model->read(['mobile'=>$this->param['mobile']]); |
| 30 | if($info !== false){ | 40 | if($info !== false){ |
| 31 | - $this->fail('error',Code::USER_ERROR); | 41 | + $this->fail('当前手机号码已注册'); |
| 32 | } | 42 | } |
| 43 | + $this->param['create_id'] = $this->user['id']; | ||
| 44 | + $this->param['operator_id'] = $this->user['id']; | ||
| 45 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 33 | //上传图片 | 46 | //上传图片 |
| 34 | if(isset($this->param['image'])){ | 47 | if(isset($this->param['image'])){ |
| 35 | $this->param['image'] = $this->upload(); | 48 | $this->param['image'] = $this->upload(); |
| @@ -38,7 +51,7 @@ class UserLogic extends BaseLogic | @@ -38,7 +51,7 @@ class UserLogic extends BaseLogic | ||
| 38 | $this->param['password'] = base64_encode(md5($this->param['password'])); | 51 | $this->param['password'] = base64_encode(md5($this->param['password'])); |
| 39 | $rs = $this->model->add($this->param); | 52 | $rs = $this->model->add($this->param); |
| 40 | if($rs === false){ | 53 | if($rs === false){ |
| 41 | - $this->fail('error',Code::USER_ERROR); | 54 | + $this->fail('error'); |
| 42 | } | 55 | } |
| 43 | return $this->success(); | 56 | return $this->success(); |
| 44 | } | 57 | } |
| @@ -54,7 +67,7 @@ class UserLogic extends BaseLogic | @@ -54,7 +67,7 @@ class UserLogic extends BaseLogic | ||
| 54 | ]; | 67 | ]; |
| 55 | $info = $this->model->read($condition); | 68 | $info = $this->model->read($condition); |
| 56 | if($info !== false){ | 69 | if($info !== false){ |
| 57 | - $this->fail('当前编辑的手机号码已存在',Code::USER_PARAMS_ERROE); | 70 | + $this->fail('当前编辑的手机号码已存在'); |
| 58 | } | 71 | } |
| 59 | $this->param['operator_id'] = $this->user['id']; | 72 | $this->param['operator_id'] = $this->user['id']; |
| 60 | try { | 73 | try { |
| @@ -73,7 +86,7 @@ class UserLogic extends BaseLogic | @@ -73,7 +86,7 @@ class UserLogic extends BaseLogic | ||
| 73 | $this->model->edits($this->param); | 86 | $this->model->edits($this->param); |
| 74 | } | 87 | } |
| 75 | }catch (\exception $e){ | 88 | }catch (\exception $e){ |
| 76 | - $this->fail('参数错误或其他服务器原因,编辑失败',Code::USER_ERROR,[]); | 89 | + $this->fail('参数错误或其他服务器原因,编辑失败'); |
| 77 | } | 90 | } |
| 78 | return $this->success(); | 91 | return $this->success(); |
| 79 | } | 92 | } |
| @@ -92,20 +105,6 @@ class UserLogic extends BaseLogic | @@ -92,20 +105,6 @@ class UserLogic extends BaseLogic | ||
| 92 | } | 105 | } |
| 93 | 106 | ||
| 94 | /** | 107 | /** |
| 95 | - * @name :用户详情 | ||
| 96 | - * @return void | ||
| 97 | - * @author :liyuhang | ||
| 98 | - * @method | ||
| 99 | - */ | ||
| 100 | - public function user_info(){ | ||
| 101 | - $info = $this->model->read($this->param); | ||
| 102 | - if($info === false){ | ||
| 103 | - $this->fail('error',Code::USER_ERROR); | ||
| 104 | - } | ||
| 105 | - return $this->success($info); | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - /** | ||
| 109 | * @name :删除用户(逻辑删除) | 108 | * @name :删除用户(逻辑删除) |
| 110 | * @return void | 109 | * @return void |
| 111 | * @author :liyuhang | 110 | * @author :liyuhang |
app/Http/Logic/Bside/User/UserLoginLogic.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Bside\User; | ||
| 4 | + | ||
| 5 | +use App\Http\Logic\Bside\BaseLogic; | ||
| 6 | +use App\Models\User\UserLogin; | ||
| 7 | + | ||
| 8 | +class UserLoginLogic extends BaseLogic | ||
| 9 | +{ | ||
| 10 | + public function __construct() | ||
| 11 | + { | ||
| 12 | + parent::__construct(); | ||
| 13 | + | ||
| 14 | + $this->model = new UserLogin(); | ||
| 15 | + $this->param = $this->requestAll; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | +} |
| @@ -24,7 +24,7 @@ class NewsCategoryRequest extends FormRequest | @@ -24,7 +24,7 @@ class NewsCategoryRequest extends FormRequest | ||
| 24 | public function rules() | 24 | public function rules() |
| 25 | { | 25 | { |
| 26 | return [ | 26 | return [ |
| 27 | - 'name'=>'required|max:100||unique:gl_news_category', | 27 | + 'name'=>'required|max:100', |
| 28 | ]; | 28 | ]; |
| 29 | } | 29 | } |
| 30 | 30 |
| @@ -19,7 +19,7 @@ class ProjectGroupRequest extends FormRequest | @@ -19,7 +19,7 @@ class ProjectGroupRequest extends FormRequest | ||
| 19 | public function rules() | 19 | public function rules() |
| 20 | { | 20 | { |
| 21 | return [ | 21 | return [ |
| 22 | - 'name' => 'required|max:255||unique:gl_project_group', | 22 | + 'name' => 'required|max:255', |
| 23 | ]; | 23 | ]; |
| 24 | } | 24 | } |
| 25 | 25 |
| @@ -19,7 +19,7 @@ class ProjectRoleRequest extends FormRequest | @@ -19,7 +19,7 @@ class ProjectRoleRequest extends FormRequest | ||
| 19 | public function rules() | 19 | public function rules() |
| 20 | { | 20 | { |
| 21 | return [ | 21 | return [ |
| 22 | - 'name'=>'required|max:11||unique:gl_project_role', | 22 | + 'name'=>'required|max:11', |
| 23 | 'role_menu'=>'required|string', | 23 | 'role_menu'=>'required|string', |
| 24 | ]; | 24 | ]; |
| 25 | } | 25 | } |
| @@ -24,7 +24,7 @@ class UserRequest extends FormRequest | @@ -24,7 +24,7 @@ class UserRequest extends FormRequest | ||
| 24 | public function rules() | 24 | public function rules() |
| 25 | { | 25 | { |
| 26 | return [ | 26 | return [ |
| 27 | - 'mobile'=>'required|string|max:11||unique:gl_project_user', | 27 | + 'mobile'=>'required|string|max:11', |
| 28 | 'password'=>'required|string|min:5', | 28 | 'password'=>'required|string|min:5', |
| 29 | 'name'=>'required|max:20', | 29 | 'name'=>'required|max:20', |
| 30 | 'role_id'=>'required' | 30 | 'role_id'=>'required' |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Models\User; | 3 | namespace App\Models\User; |
| 4 | 4 | ||
| 5 | //use Illuminate\Contracts\Auth\MustVerifyEmail; | 5 | //use Illuminate\Contracts\Auth\MustVerifyEmail; |
| 6 | +use App\Helper\Common; | ||
| 6 | use App\Models\Base; | 7 | use App\Models\Base; |
| 7 | use App\Models\User\ProjectRole as ProjectRoleModel; | 8 | use App\Models\User\ProjectRole as ProjectRoleModel; |
| 8 | use Illuminate\Database\Eloquent\Factories\HasFactory; | 9 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| @@ -89,7 +90,8 @@ class User extends Base | @@ -89,7 +90,8 @@ class User extends Base | ||
| 89 | if($rs === false){ | 90 | if($rs === false){ |
| 90 | return false; | 91 | return false; |
| 91 | } | 92 | } |
| 92 | - unset($info['password']); | 93 | + //写入日志 |
| 94 | + Common::set_user_login(['user_id'=>$info['id'],'ip'=>request()->ip()]); | ||
| 93 | return $info; | 95 | return $info; |
| 94 | } | 96 | } |
| 95 | 97 |
app/Models/User/UserLog.php
0 → 100644
app/Models/User/UserLogin.php
0 → 100644
| @@ -127,5 +127,9 @@ return [ | @@ -127,5 +127,9 @@ return [ | ||
| 127 | 'path' => storage_path('logs/laravel.log'), | 127 | 'path' => storage_path('logs/laravel.log'), |
| 128 | ], | 128 | ], |
| 129 | ], | 129 | ], |
| 130 | - | 130 | + //操作日志 |
| 131 | + 'operator_log' =>[ | ||
| 132 | + 'log'=>true,//true开启 | ||
| 133 | + 'action' => [],//不需要写入日志的方法 | ||
| 134 | + ], | ||
| 131 | ]; | 135 | ]; |
-
请 注册 或 登录 后发表评论