Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev
正在显示
5 个修改的文件
包含
117 行增加
和
33 行删除
| @@ -85,14 +85,17 @@ class BaseController extends Controller | @@ -85,14 +85,17 @@ class BaseController extends Controller | ||
| 85 | case 'row': | 85 | case 'row': |
| 86 | $this->row = $v; | 86 | $this->row = $v; |
| 87 | break; | 87 | break; |
| 88 | + case "name": | ||
| 89 | + $this->map['name'] = ['like','%'.$v.'%']; | ||
| 90 | + break; | ||
| 88 | case "created_at": | 91 | case "created_at": |
| 89 | $this->_btw[0] = $v; | 92 | $this->_btw[0] = $v; |
| 90 | $this->_btw[1] = date('Y-m-d H:i:s',time()); | 93 | $this->_btw[1] = date('Y-m-d H:i:s',time()); |
| 91 | - $this->map['create_at'] = ['between', $this->_btw]; | 94 | + $this->map['created_at'] = ['between', $this->_btw]; |
| 92 | break; | 95 | break; |
| 93 | case "updated_at": | 96 | case "updated_at": |
| 94 | $this->_btw[1] = $v; | 97 | $this->_btw[1] = $v; |
| 95 | - $this->map['update_at'] = ['between', $this->_btw]; | 98 | + $this->map['updated_at'] = ['between', $this->_btw]; |
| 96 | break; | 99 | break; |
| 97 | default: | 100 | default: |
| 98 | if (!empty($v)) { | 101 | if (!empty($v)) { |
| @@ -101,7 +104,6 @@ class BaseController extends Controller | @@ -101,7 +104,6 @@ class BaseController extends Controller | ||
| 101 | break; | 104 | break; |
| 102 | } | 105 | } |
| 103 | } | 106 | } |
| 104 | - | ||
| 105 | } | 107 | } |
| 106 | /** | 108 | /** |
| 107 | * @name 统一返回参数 | 109 | * @name 统一返回参数 |
| @@ -8,6 +8,7 @@ use App\Http\Requests\Bside\News\NewsCategoryRequest; | @@ -8,6 +8,7 @@ use App\Http\Requests\Bside\News\NewsCategoryRequest; | ||
| 8 | use App\Models\News\News as NewsModel; | 8 | use App\Models\News\News as NewsModel; |
| 9 | use App\Models\News\NewsCategory as NewsCategoryModel; | 9 | use App\Models\News\NewsCategory as NewsCategoryModel; |
| 10 | use Illuminate\Http\Request; | 10 | use Illuminate\Http\Request; |
| 11 | +use Illuminate\Support\Facades\DB; | ||
| 11 | 12 | ||
| 12 | class NewsCategoryController extends BaseController | 13 | class NewsCategoryController extends BaseController |
| 13 | { | 14 | { |
| @@ -18,25 +19,64 @@ class NewsCategoryController extends BaseController | @@ -18,25 +19,64 @@ class NewsCategoryController extends BaseController | ||
| 18 | * @method | 19 | * @method |
| 19 | */ | 20 | */ |
| 20 | public function lists(NewsCategoryModel $newsCategory){ | 21 | public function lists(NewsCategoryModel $newsCategory){ |
| 22 | + //搜索条件 | ||
| 21 | $lists = $newsCategory->lists($this->map,$this->page,$this->row); | 23 | $lists = $newsCategory->lists($this->map,$this->page,$this->row); |
| 22 | $this->response('success',Code::SUCCESS,$lists); | 24 | $this->response('success',Code::SUCCESS,$lists); |
| 23 | } | 25 | } |
| 24 | 26 | ||
| 25 | /** | 27 | /** |
| 28 | + * @name :获取当前分类详情 | ||
| 29 | + * @return void | ||
| 30 | + * @author :liyuhang | ||
| 31 | + * @method | ||
| 32 | + */ | ||
| 33 | + public function info(Request $request,NewsCategoryModel $newsCategory){ | ||
| 34 | + $request->validate([ | ||
| 35 | + 'id'=>['required'] | ||
| 36 | + ],[ | ||
| 37 | + 'id.required' => 'ID不能为空' | ||
| 38 | + ]); | ||
| 39 | + $info = $newsCategory->read($this->param); | ||
| 40 | + if($info === false){ | ||
| 41 | + $this->response('error',Code::USER_ERROR); | ||
| 42 | + } | ||
| 43 | + $this->response('success',Code::SUCCESS,$info); | ||
| 44 | + } | ||
| 45 | + /** | ||
| 26 | * @name :添加分类 | 46 | * @name :添加分类 |
| 27 | * @return json | 47 | * @return json |
| 28 | * @author :liyuhang | 48 | * @author :liyuhang |
| 29 | * @method | 49 | * @method |
| 30 | */ | 50 | */ |
| 31 | - public function add(NewsCategoryRequest $request,NewsCategoryModel $newsCategory){ | 51 | + public function add(NewsCategoryRequest $request,NewsCategoryModel $newsCategory,NewsModel $news){ |
| 32 | $request->validated(); | 52 | $request->validated(); |
| 33 | $this->param['project_id'] = $this->user['project_id']; | 53 | $this->param['project_id'] = $this->user['project_id']; |
| 34 | $this->param['Operator_id'] = $this->uid; | 54 | $this->param['Operator_id'] = $this->uid; |
| 35 | $this->param['create_id'] = $this->uid; | 55 | $this->param['create_id'] = $this->uid; |
| 56 | + DB::beginTransaction(); | ||
| 36 | $rs = $newsCategory->add($this->param); | 57 | $rs = $newsCategory->add($this->param); |
| 37 | if($rs === false){ | 58 | if($rs === false){ |
| 59 | + DB::rollBack(); | ||
| 38 | $this->response('error',Code::USER_ERROR); | 60 | $this->response('error',Code::USER_ERROR); |
| 39 | } | 61 | } |
| 62 | + //TODO::判断当前分内是否为一级分类 | ||
| 63 | + if(isset($this->param['pid']) && !empty($this->param['pid'])){ | ||
| 64 | + //查看当前上级分类下是否有其他分类 | ||
| 65 | + $cate_info = $newsCategory->read(['pid'=>$this->param['pid'],'id'=>['!=',$newsCategory->id]]); | ||
| 66 | + if($cate_info === false){ | ||
| 67 | + //查看当前上一级分类下是否有商品 | ||
| 68 | + $news_info = $news->read(['category_id'=>$this->param['pid'],'pid'=>0]); | ||
| 69 | + if($news_info !== false){ | ||
| 70 | + //更新所有商品到当前分类 | ||
| 71 | + $rs = $news->edit(['category_id'=>$newsCategory->id],['category_id'=>$this->param['pid']]); | ||
| 72 | + if($rs === false){ | ||
| 73 | + DB::rollBack(); | ||
| 74 | + $this->response('error',Code::USER_ERROR); | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + } | ||
| 79 | + DB::commit(); | ||
| 40 | $this->response('success',Code::SUCCESS); | 80 | $this->response('success',Code::SUCCESS); |
| 41 | } | 81 | } |
| 42 | 82 |
| @@ -95,6 +95,7 @@ class NewsController extends BaseController | @@ -95,6 +95,7 @@ class NewsController extends BaseController | ||
| 95 | if($rs === false){ | 95 | if($rs === false){ |
| 96 | $this->response('error',Code::USER_ERROR); | 96 | $this->response('error',Code::USER_ERROR); |
| 97 | } | 97 | } |
| 98 | + //TODO::清空相关资源 | ||
| 98 | $this->response('success'); | 99 | $this->response('success'); |
| 99 | } | 100 | } |
| 100 | } | 101 | } |
| @@ -21,9 +21,9 @@ class UserController extends BaseController | @@ -21,9 +21,9 @@ class UserController extends BaseController | ||
| 21 | $this->map['project_id'] = $this->user['project_id']; | 21 | $this->map['project_id'] = $this->user['project_id']; |
| 22 | $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at']); | 22 | $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at']); |
| 23 | if(empty($lists)){ | 23 | if(empty($lists)){ |
| 24 | - $this->response('请求失败',Code::USER_ERROR,[]); | 24 | + $this->response('error',Code::USER_ERROR,[]); |
| 25 | } | 25 | } |
| 26 | - $this->response('列表',Code::SUCCESS,$lists); | 26 | + $this->response('success',Code::SUCCESS,$lists); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| @@ -39,7 +39,7 @@ class UserController extends BaseController | @@ -39,7 +39,7 @@ class UserController extends BaseController | ||
| 39 | if($rs === false){ | 39 | if($rs === false){ |
| 40 | $this->response('当前添加用户已存在或参数错误,添加失败',Code::USER_REGISTER_ERROE,[]); | 40 | $this->response('当前添加用户已存在或参数错误,添加失败',Code::USER_REGISTER_ERROE,[]); |
| 41 | } | 41 | } |
| 42 | - $this->response('添加成功',Code::SUCCESS,[]); | 42 | + $this->response('success',Code::SUCCESS); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| @@ -86,9 +86,28 @@ class UserController extends BaseController | @@ -86,9 +86,28 @@ class UserController extends BaseController | ||
| 86 | } | 86 | } |
| 87 | $this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功'); | 87 | $this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功'); |
| 88 | } | 88 | } |
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * @name :详情 | ||
| 92 | + * @return json | ||
| 93 | + * @author :liyuhang | ||
| 94 | + * @method | ||
| 95 | + */ | ||
| 96 | + public function info(Request $request,UserModel $userModel){ | ||
| 97 | + $request->validate([ | ||
| 98 | + 'id'=>['required', new Ids()], | ||
| 99 | + ],[ | ||
| 100 | + 'id.required' => 'ID不能为空', | ||
| 101 | + ]); | ||
| 102 | + $rs = $userModel->read($this->param); | ||
| 103 | + if($rs === false){ | ||
| 104 | + $this->response('error',Code::USER_ERROR); | ||
| 105 | + } | ||
| 106 | + $this->response('success'); | ||
| 107 | + } | ||
| 89 | /** | 108 | /** |
| 90 | * @name :删除管理员 | 109 | * @name :删除管理员 |
| 91 | - * @return void | 110 | + * @return json |
| 92 | * @author :liyuhang | 111 | * @author :liyuhang |
| 93 | * @method | 112 | * @method |
| 94 | */ | 113 | */ |
| @@ -100,8 +119,8 @@ class UserController extends BaseController | @@ -100,8 +119,8 @@ class UserController extends BaseController | ||
| 100 | ]); | 119 | ]); |
| 101 | $rs = $userModel->del($this->param); | 120 | $rs = $userModel->del($this->param); |
| 102 | if($rs === false){ | 121 | if($rs === false){ |
| 103 | - $this->response('删除失败',Code::USER_ERROR); | 122 | + $this->response('error',Code::USER_ERROR); |
| 104 | } | 123 | } |
| 105 | - $this->response('删除成功'); | 124 | + $this->response('success'); |
| 106 | } | 125 | } |
| 107 | } | 126 | } |
| @@ -14,32 +14,54 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -14,32 +14,54 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 14 | //获取当前登录用户项目详情 | 14 | //获取当前登录用户项目详情 |
| 15 | Route::any('/get_project', [\App\Http\Controllers\Bside\ComController::class, 'get_project'])->name('get_project'); | 15 | Route::any('/get_project', [\App\Http\Controllers\Bside\ComController::class, 'get_project'])->name('get_project'); |
| 16 | //用户相关路由 | 16 | //用户相关路由 |
| 17 | - Route::any('/user/add', [\App\Http\Controllers\Bside\UserController::class, 'add'])->name('user_add'); | ||
| 18 | - Route::any('/user/edit', [\App\Http\Controllers\Bside\UserController::class, 'edit'])->name('user_edit'); | ||
| 19 | - Route::any('/user/status', [\App\Http\Controllers\Bside\UserController::class, 'status'])->name('user_status'); | ||
| 20 | - Route::any('/user/lists', [\App\Http\Controllers\Bside\UserController::class, 'lists'])->name('user_lists'); | ||
| 21 | - Route::any('/user/del', [\App\Http\Controllers\Bside\UserController::class, 'del'])->name('user_del'); | 17 | + Route::prefix('user')->group(function () { |
| 18 | + Route::any('/', [\App\Http\Controllers\Bside\UserController::class, 'lists'])->name('user_lists'); | ||
| 19 | + Route::any('/add', [\App\Http\Controllers\Bside\UserController::class, 'add'])->name('user_add'); | ||
| 20 | + Route::any('/edit', [\App\Http\Controllers\Bside\UserController::class, 'edit'])->name('user_edit'); | ||
| 21 | + Route::any('/status', [\App\Http\Controllers\Bside\UserController::class, 'status'])->name('user_status'); | ||
| 22 | + Route::any('/info', [\App\Http\Controllers\Bside\UserController::class, 'info'])->name('user_info'); | ||
| 23 | + Route::any('/del', [\App\Http\Controllers\Bside\UserController::class, 'del'])->name('user_del'); | ||
| 24 | + }); | ||
| 25 | + | ||
| 22 | //用户角色相关路由 | 26 | //用户角色相关路由 |
| 23 | - Route::any('/project_role/lists', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'lists'])->name('project_role_lists'); | ||
| 24 | - Route::any('/project_role/get_role_menu', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'get_role_menu'])->name('project_get_role_add'); | ||
| 25 | - Route::any('/project_role/add', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'add'])->name('project_role_add'); | ||
| 26 | - Route::any('/project_role/edit', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'edit'])->name('project_role_edit'); | ||
| 27 | - Route::any('/project_role/status', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'status'])->name('project_role_status'); | ||
| 28 | - Route::any('/project_role/del', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'del'])->name('project_role_del'); | 27 | + Route::prefix('role')->group(function () { |
| 28 | + Route::any('/', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'lists'])->name('project_role_lists'); | ||
| 29 | + Route::any('/get_role_menu', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'get_role_menu'])->name('project_get_role_add'); | ||
| 30 | + Route::any('/add', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'add'])->name('project_role_add'); | ||
| 31 | + Route::any('/edit', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'edit'])->name('project_role_edit'); | ||
| 32 | + Route::any('/info', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'status'])->name('project_role_info'); | ||
| 33 | + Route::any('/status', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'status'])->name('project_role_status'); | ||
| 34 | + Route::any('/del', [\App\Http\Controllers\Bside\ProjectRoleController::class, 'del'])->name('project_role_del'); | ||
| 35 | + }); | ||
| 29 | 36 | ||
| 30 | - //group相关路由 | ||
| 31 | - Route::any('/project_group/add', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'add'])->name('project_group_add'); | ||
| 32 | - Route::any('/project_group/edit', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'edit'])->name('project_group_edit'); | ||
| 33 | - Route::any('/project_group/lists', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'lists'])->name('project_group_lists'); | ||
| 34 | - Route::any('/project_group/del', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'del'])->name('project_group_del'); | ||
| 35 | - Route::any('/project_group/get_user_lists', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'get_user_lists'])->name('project_group_get_user_lists'); | 37 | + //group相关路 |
| 38 | + Route::prefix('group')->group(function () { | ||
| 39 | + Route::any('/', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'lists'])->name('project_group_lists'); | ||
| 40 | + Route::any('/add', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'add'])->name('project_group_add'); | ||
| 41 | + Route::any('/edit', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'edit'])->name('project_group_edit'); | ||
| 42 | + Route::any('/info', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'info'])->name('project_group_info'); | ||
| 43 | + Route::any('/del', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'del'])->name('project_group_del'); | ||
| 44 | + Route::any('/get_user_lists', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'get_user_lists'])->name('project_group_get_user_lists'); | ||
| 45 | + | ||
| 46 | + //新闻相关路由 | ||
| 47 | + Route::prefix('news')->group(function () { | ||
| 48 | + //分类 | ||
| 49 | + Route::any('/category/add', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'add'])->name('news_category_add'); | ||
| 50 | + Route::any('/category/info', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'info'])->name('news_category_info'); | ||
| 51 | + Route::any('/category/edit', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'edit'])->name('news_category_edit'); | ||
| 52 | + Route::any('/category/lists', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'lists'])->name('news_category_lists'); | ||
| 53 | + Route::any('/category/del', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'del'])->name('news_category_del'); | ||
| 54 | + Route::any('/category/status', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'status'])->name('news_category_status'); | ||
| 55 | + | ||
| 56 | + //新闻 | ||
| 57 | + Route::any('/add', [\App\Http\Controllers\Bside\News\NewsController::class, 'add'])->name('news_category_add'); | ||
| 58 | + Route::any('/info', [\App\Http\Controllers\Bside\News\NewsController::class, 'info'])->name('news_category_info'); | ||
| 59 | + Route::any('/edit', [\App\Http\Controllers\Bside\News\NewsController::class, 'edit'])->name('news_category_edit'); | ||
| 60 | + Route::any('/lists', [\App\Http\Controllers\Bside\News\NewsController::class, 'lists'])->name('news_category_lists'); | ||
| 61 | + Route::any('/del', [\App\Http\Controllers\Bside\News\NewsController::class, 'del'])->name('news_category_del'); | ||
| 62 | + Route::any('/status', [\App\Http\Controllers\Bside\News\NewsController::class, 'status'])->name('news_category_status'); | ||
| 63 | + }); | ||
| 36 | 64 | ||
| 37 | - //新闻分类相关路由 | ||
| 38 | - Route::any('/news_category/add', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'add'])->name('news_category_add'); | ||
| 39 | - Route::any('/news_category/edit', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'edit'])->name('news_category_edit'); | ||
| 40 | - Route::any('/news_category/lists', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'lists'])->name('news_category_lists'); | ||
| 41 | - Route::any('/news_category/del', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'del'])->name('news_category_del'); | ||
| 42 | - Route::any('/news_category/status', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'get_user_lists'])->name('news_category_status'); | ||
| 43 | 65 | ||
| 44 | 66 | ||
| 45 | //产品 | 67 | //产品 |
-
请 注册 或 登录 后发表评论