正在显示
21 个修改的文件
包含
564 行增加
和
309 行删除
app/Files/Image.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Files; | ||
| 4 | - | ||
| 5 | -use Illuminate\Http\Request; | ||
| 6 | - | ||
| 7 | -class Image | ||
| 8 | -{ | ||
| 9 | - protected $request = []; | ||
| 10 | - | ||
| 11 | - public function __construct(Request $request) | ||
| 12 | - { | ||
| 13 | - $this->request = $request; | ||
| 14 | - } | ||
| 15 | - | ||
| 16 | - /** | ||
| 17 | - * @name :上传图片 | ||
| 18 | - * @return void | ||
| 19 | - * @author :liyuhang | ||
| 20 | - * @method | ||
| 21 | - */ | ||
| 22 | - public function uploads(){ | ||
| 23 | - $url = './uploads/images/'; | ||
| 24 | - $param = $this->request->post(); | ||
| 25 | - if($this->request->hasFile('image') && $this->request->file('image')->isValid()){ | ||
| 26 | - $filename = date('ymdHis').rand(10000,99999).$this->request->file('image'); | ||
| 27 | - $this->request->file('image')->move('./uploads/images/',$filename); | ||
| 28 | - }else{ | ||
| 29 | - return false; | ||
| 30 | - } | ||
| 31 | - return $url.$filename; | ||
| 32 | - } | ||
| 33 | -} |
app/Helper/common.php
0 → 100644
| 1 | +<?php | ||
| 2 | +use Illuminate\Support\Facades\Log; | ||
| 3 | + | ||
| 4 | + | ||
| 5 | +if(!function_exists('http_post')){ | ||
| 6 | + /** | ||
| 7 | + * 发送http post请求 | ||
| 8 | + * @param type $url | ||
| 9 | + * @param type $post_data | ||
| 10 | + */ | ||
| 11 | + function http_post($url, $post_data) | ||
| 12 | + { | ||
| 13 | + $header[] = "charset = UTF-8"; | ||
| 14 | + $ch = curl_init(); | ||
| 15 | + curl_setopt($ch, CURLOPT_URL, $url); | ||
| 16 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | ||
| 17 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | ||
| 18 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | ||
| 19 | + curl_setopt($ch, CURLOPT_HTTPHEADER, $header); | ||
| 20 | + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)'); | ||
| 21 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | ||
| 22 | + curl_setopt($ch, CURLOPT_AUTOREFERER, 1); | ||
| 23 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); | ||
| 24 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
| 25 | + $res = curl_exec($ch); | ||
| 26 | + if (curl_errno($ch)) { | ||
| 27 | + Log::write(print_r(curl_errno($ch),1),'debug---1'); | ||
| 28 | + } | ||
| 29 | + curl_close($ch); | ||
| 30 | + return json_decode($res, true); | ||
| 31 | + } | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +if(!function_exists('http_get')){ | ||
| 35 | + /** | ||
| 36 | + * 发送http get请求 | ||
| 37 | + * @param type $url | ||
| 38 | + * @return type | ||
| 39 | + */ | ||
| 40 | + function http_get($url) | ||
| 41 | + { | ||
| 42 | + $header[] = "content-type: application/x-www-form-urlencoded; | ||
| 43 | + charset = UTF-8"; | ||
| 44 | + $ch1 = curl_init(); | ||
| 45 | + $timeout = 5; | ||
| 46 | + curl_setopt($ch1, CURLOPT_URL, $url); | ||
| 47 | + curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); | ||
| 48 | + curl_setopt($ch1, CURLOPT_HTTPHEADER, $header); | ||
| 49 | + curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout); | ||
| 50 | + curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false); | ||
| 51 | + curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, false); | ||
| 52 | + $access_txt = curl_exec($ch1); | ||
| 53 | + curl_close($ch1); | ||
| 54 | + return json_decode($access_txt, true); | ||
| 55 | + } | ||
| 56 | +} | ||
| 57 | + | ||
| 58 | +if(!function_exists('_get_child')){ | ||
| 59 | + /** | ||
| 60 | + * 菜单权限->得到子级数组 | ||
| 61 | + * @param int | ||
| 62 | + * @return array | ||
| 63 | + */ | ||
| 64 | + function _get_child($my_id, $arr) | ||
| 65 | + { | ||
| 66 | + $new_arr = array(); | ||
| 67 | + foreach ($arr as $k => $v) { | ||
| 68 | + $v = (array)$v; | ||
| 69 | + if ($v['pid'] == $my_id) { | ||
| 70 | + $v['sub'] = _get_child($v['id'],$arr); | ||
| 71 | + $new_arr[] = $v; | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + return $new_arr ? $new_arr : false; | ||
| 75 | + } | ||
| 76 | +} | ||
| 77 | + |
| @@ -9,13 +9,13 @@ use Illuminate\Http\JsonResponse; | @@ -9,13 +9,13 @@ use Illuminate\Http\JsonResponse; | ||
| 9 | use Illuminate\Http\Request; | 9 | use Illuminate\Http\Request; |
| 10 | use Illuminate\Http\Exceptions\HttpResponseException; | 10 | use Illuminate\Http\Exceptions\HttpResponseException; |
| 11 | use Illuminate\Support\Facades\Cache; | 11 | use Illuminate\Support\Facades\Cache; |
| 12 | +use Illuminate\Support\Facades\Log; | ||
| 12 | 13 | ||
| 13 | class BaseController extends Controller | 14 | class BaseController extends Controller |
| 14 | { | 15 | { |
| 15 | protected $param = [];//所有请求参数 | 16 | protected $param = [];//所有请求参数 |
| 16 | protected $token = ''; //token | 17 | protected $token = ''; //token |
| 17 | protected $request = [];//助手函数 | 18 | protected $request = [];//助手函数 |
| 18 | - protected $allCount = 0;//总条数 | ||
| 19 | protected $page = 1;//当前页 | 19 | protected $page = 1;//当前页 |
| 20 | protected $row = 20;//每页条数 | 20 | protected $row = 20;//每页条数 |
| 21 | protected $header = [];//设置请求头参数 | 21 | protected $header = [];//设置请求头参数 |
| @@ -144,25 +144,5 @@ class BaseController extends Controller | @@ -144,25 +144,5 @@ class BaseController extends Controller | ||
| 144 | return $new_arr ? $new_arr : false; | 144 | return $new_arr ? $new_arr : false; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | - /** | ||
| 148 | - * @name :上传图片 | ||
| 149 | - * @return void | ||
| 150 | - * @author :liyuhang | ||
| 151 | - * @method | ||
| 152 | - */ | ||
| 153 | - public function uploads(){ | ||
| 154 | - $files = $this->request->file('file'); | ||
| 155 | - if(empty($files)){ | ||
| 156 | - return $this->response('没有上传文件',Code::USER_ERROR); | ||
| 157 | - } | ||
| 158 | - $url = './uploads/images/'; | ||
| 159 | - $param = $this->request->post(); | ||
| 160 | - if($this->request->hasFile('image') && $files->isValid()){ | ||
| 161 | - $filename = date('ymdHis').rand(10000,99999).$this->request->file('image'); | ||
| 162 | - $this->request->file('image')->move('./uploads/images/',$filename); | ||
| 163 | - }else{ | ||
| 164 | - return false; | ||
| 165 | - } | ||
| 166 | - return $url.$filename; | ||
| 167 | - } | 147 | + |
| 168 | } | 148 | } |
| @@ -30,16 +30,13 @@ class BlogCategoryController extends BaseController | @@ -30,16 +30,13 @@ class BlogCategoryController extends BaseController | ||
| 30 | * @author :liyuhang | 30 | * @author :liyuhang |
| 31 | * @method | 31 | * @method |
| 32 | */ | 32 | */ |
| 33 | - public function info(Request $request,BlogCategoryModel $blogCategoryModel){ | 33 | + public function info(Request $request,BlogCategoryLogic $blogCategoryLogic){ |
| 34 | $request->validate([ | 34 | $request->validate([ |
| 35 | 'id'=>['required'] | 35 | 'id'=>['required'] |
| 36 | ],[ | 36 | ],[ |
| 37 | 'id.required' => 'ID不能为空' | 37 | 'id.required' => 'ID不能为空' |
| 38 | ]); | 38 | ]); |
| 39 | - $info = $blogCategoryModel->read($this->param); | ||
| 40 | - if($info === false){ | ||
| 41 | - $this->response('error',Code::USER_ERROR); | ||
| 42 | - } | 39 | + $info = $blogCategoryLogic->info_blog_category(); |
| 43 | $this->response('success',Code::SUCCESS,$info); | 40 | $this->response('success',Code::SUCCESS,$info); |
| 44 | } | 41 | } |
| 45 | /** | 42 | /** |
| @@ -61,19 +58,15 @@ class BlogCategoryController extends BaseController | @@ -61,19 +58,15 @@ class BlogCategoryController extends BaseController | ||
| 61 | * @author :liyuhang | 58 | * @author :liyuhang |
| 62 | * @method | 59 | * @method |
| 63 | */ | 60 | */ |
| 64 | - public function edit(BlogCategoryRequest $request,BlogCategoryModel $blogCategoryModel){ | 61 | + public function edit(BlogCategoryRequest $request,BlogCategoryLogic $blogCategoryLogic){ |
| 65 | $request->validate([ | 62 | $request->validate([ |
| 66 | 'id'=>['required'] | 63 | 'id'=>['required'] |
| 67 | ],[ | 64 | ],[ |
| 68 | 'id.required' => 'ID不能为空' | 65 | 'id.required' => 'ID不能为空' |
| 69 | ]); | 66 | ]); |
| 70 | - $this->param['operator_id'] = $this->uid; | ||
| 71 | - $rs = $blogCategoryModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 72 | - if($rs === false){ | ||
| 73 | - $this->response('error',Code::USER_ERROR); | ||
| 74 | - } | 67 | + $blogCategoryLogic->edit_blog_category(); |
| 75 | //TODO::写入日志 | 68 | //TODO::写入日志 |
| 76 | - $this->response('success',Code::SUCCESS); | 69 | + $this->response('success'); |
| 77 | } | 70 | } |
| 78 | 71 | ||
| 79 | /** | 72 | /** |
| @@ -82,17 +75,13 @@ class BlogCategoryController extends BaseController | @@ -82,17 +75,13 @@ class BlogCategoryController extends BaseController | ||
| 82 | * @author :liyuhang | 75 | * @author :liyuhang |
| 83 | * @method | 76 | * @method |
| 84 | */ | 77 | */ |
| 85 | - public function status(Request $request,BlogCategoryModel $blogCategoryModel){ | 78 | + public function status(Request $request,BlogCategoryLogic $blogCategoryLogic){ |
| 86 | $request->validate([ | 79 | $request->validate([ |
| 87 | 'id'=>['required'], | 80 | 'id'=>['required'], |
| 88 | ],[ | 81 | ],[ |
| 89 | 'id.required' => 'ID不能为空', | 82 | 'id.required' => 'ID不能为空', |
| 90 | ]); | 83 | ]); |
| 91 | - $this->param['operator_id'] = $this->uid; | ||
| 92 | - $rs = $blogCategoryModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 93 | - if($rs === false){ | ||
| 94 | - $this->response('error',Code::USER_ERROR); | ||
| 95 | - } | 84 | + $blogCategoryLogic->status_blog_category(); |
| 96 | $this->response('success'); | 85 | $this->response('success'); |
| 97 | } | 86 | } |
| 98 | 87 |
| @@ -4,9 +4,10 @@ namespace App\Http\Controllers\Bside\Blog; | @@ -4,9 +4,10 @@ namespace App\Http\Controllers\Bside\Blog; | ||
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Controllers\Bside\BaseController; | 6 | use App\Http\Controllers\Bside\BaseController; |
| 7 | +use App\Http\Logic\Bside\Blog\BlogLogic; | ||
| 7 | use App\Http\Requests\Bside\Blog\BlogRequest; | 8 | use App\Http\Requests\Bside\Blog\BlogRequest; |
| 8 | use App\Models\Blog\Blog as BlogModel; | 9 | use App\Models\Blog\Blog as BlogModel; |
| 9 | -use App\Models\Blog\BlogCategory as BlogCategoryModel; | 10 | +use App\Models\RouteMap; |
| 10 | use Illuminate\Http\Request; | 11 | use Illuminate\Http\Request; |
| 11 | 12 | ||
| 12 | class BlogController extends BaseController | 13 | class BlogController extends BaseController |
| @@ -24,39 +25,40 @@ class BlogController extends BaseController | @@ -24,39 +25,40 @@ class BlogController extends BaseController | ||
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | /** | 27 | /** |
| 27 | - * @name :获取当前博客详情 | 28 | + * @name :获取分页列表 |
| 28 | * @return void | 29 | * @return void |
| 30 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 31 | + * @author :liyuhang | ||
| 32 | + * @method | ||
| 33 | + */ | ||
| 34 | + public function get_category_list(BlogLogic $blogLogic){ | ||
| 35 | + $list = $blogLogic->blog_get_category_list(); | ||
| 36 | + $this->response('success',Code::SUCCESS,$list); | ||
| 37 | + } | ||
| 38 | + /** | ||
| 39 | + * @name :获取当前博客详情 | ||
| 40 | + * @return json | ||
| 29 | * @author :liyuhang | 41 | * @author :liyuhang |
| 30 | * @method | 42 | * @method |
| 31 | */ | 43 | */ |
| 32 | - public function info(Request $request,BlogModel $blogModel){ | 44 | + public function info(Request $request,BlogLogic $blogLogic){ |
| 33 | $request->validate([ | 45 | $request->validate([ |
| 34 | 'id'=>['required'] | 46 | 'id'=>['required'] |
| 35 | ],[ | 47 | ],[ |
| 36 | 'id.required' => 'ID不能为空' | 48 | 'id.required' => 'ID不能为空' |
| 37 | ]); | 49 | ]); |
| 38 | - $info = $blogModel->read($this->param); | ||
| 39 | - if($info === false){ | ||
| 40 | - $this->response('error',Code::USER_ERROR); | ||
| 41 | - } | 50 | + $info = $blogLogic->blog_info(); |
| 42 | $this->response('success',Code::SUCCESS,$info); | 51 | $this->response('success',Code::SUCCESS,$info); |
| 43 | } | 52 | } |
| 44 | /** | 53 | /** |
| 45 | * @name :添加博客 | 54 | * @name :添加博客 |
| 46 | - * @return json | 55 | + * @return void |
| 47 | * @author :liyuhang | 56 | * @author :liyuhang |
| 48 | * @method | 57 | * @method |
| 49 | */ | 58 | */ |
| 50 | - public function add(BlogRequest $request,BlogModel $blogModel){ | 59 | + public function add(BlogRequest $request,BlogLogic $blogLogic){ |
| 51 | $request->validated(); | 60 | $request->validated(); |
| 52 | - $this->param['create_id'] = $this->uid; | ||
| 53 | - $this->param['operator_id'] = $this->uid; | ||
| 54 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 55 | - //TODO::路由映射 | ||
| 56 | - $rs = $blogModel->add($this->param); | ||
| 57 | - if($rs === false){ | ||
| 58 | - $this->response('error',Code::USER_ERROR); | ||
| 59 | - } | 61 | + $blogLogic->blog_add(); |
| 60 | //TODO::写入日志 | 62 | //TODO::写入日志 |
| 61 | $this->response('success'); | 63 | $this->response('success'); |
| 62 | } | 64 | } |
| @@ -67,18 +69,13 @@ class BlogController extends BaseController | @@ -67,18 +69,13 @@ class BlogController extends BaseController | ||
| 67 | * @author :liyuhang | 69 | * @author :liyuhang |
| 68 | * @method | 70 | * @method |
| 69 | */ | 71 | */ |
| 70 | - public function edit(BlogRequest $request,BlogModel $blogModel){ | 72 | + public function edit(BlogRequest $request,BlogLogic $blogLogic){ |
| 71 | $request->validate([ | 73 | $request->validate([ |
| 72 | 'id'=>['required'] | 74 | 'id'=>['required'] |
| 73 | ],[ | 75 | ],[ |
| 74 | 'id.required' => 'ID不能为空' | 76 | 'id.required' => 'ID不能为空' |
| 75 | ]); | 77 | ]); |
| 76 | - $this->param['operator_id'] = $this->uid; | ||
| 77 | - $rs = $blogModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 78 | - //TODO::路由映射 | ||
| 79 | - if($rs === false){ | ||
| 80 | - $this->response('error',Code::USER_ERROR); | ||
| 81 | - } | 78 | + $blogLogic->blog_edit(); |
| 82 | //TODO::写入日志 | 79 | //TODO::写入日志 |
| 83 | $this->response('success'); | 80 | $this->response('success'); |
| 84 | } | 81 | } |
| @@ -89,17 +86,13 @@ class BlogController extends BaseController | @@ -89,17 +86,13 @@ class BlogController extends BaseController | ||
| 89 | * @author :liyuhang | 86 | * @author :liyuhang |
| 90 | * @method | 87 | * @method |
| 91 | */ | 88 | */ |
| 92 | - public function status(Request $request,BlogModel $blogModel){ | 89 | + public function status(Request $request,BlogLogic $blogLogic){ |
| 93 | $request->validate([ | 90 | $request->validate([ |
| 94 | 'id'=>['required'], | 91 | 'id'=>['required'], |
| 95 | ],[ | 92 | ],[ |
| 96 | 'id.required' => 'ID不能为空', | 93 | 'id.required' => 'ID不能为空', |
| 97 | ]); | 94 | ]); |
| 98 | - $this->param['operator_id'] = $this->uid; | ||
| 99 | - $rs = $blogModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 100 | - if($rs === false){ | ||
| 101 | - $this->response('error',Code::USER_ERROR); | ||
| 102 | - } | 95 | + $blogLogic->blog_status(); |
| 103 | //TODO::写入日志 | 96 | //TODO::写入日志 |
| 104 | $this->response('success'); | 97 | $this->response('success'); |
| 105 | } | 98 | } |
| @@ -110,17 +103,13 @@ class BlogController extends BaseController | @@ -110,17 +103,13 @@ class BlogController extends BaseController | ||
| 110 | * @author :liyuhang | 103 | * @author :liyuhang |
| 111 | * @method | 104 | * @method |
| 112 | */ | 105 | */ |
| 113 | - public function del(Request $request,BlogModel $blogModel){ | 106 | + public function del(Request $request,BlogLogic $blogLogic){ |
| 114 | $request->validate([ | 107 | $request->validate([ |
| 115 | 'id'=>['required'], | 108 | 'id'=>['required'], |
| 116 | ],[ | 109 | ],[ |
| 117 | 'id.required' => 'ID不能为空', | 110 | 'id.required' => 'ID不能为空', |
| 118 | ]); | 111 | ]); |
| 119 | - $this->param['id'] = ['in',$this->param['id']]; | ||
| 120 | - $rs = $blogModel->edit(['status'=>2],$this->param); | ||
| 121 | - if($rs === false){ | ||
| 122 | - $this->response('error',Code::USER_ERROR); | ||
| 123 | - } | 112 | + $blogLogic->blog_del(); |
| 124 | $this->response('success'); | 113 | $this->response('success'); |
| 125 | } | 114 | } |
| 126 | } | 115 | } |
| @@ -32,16 +32,13 @@ class NewsCategoryController extends BaseController | @@ -32,16 +32,13 @@ class NewsCategoryController extends BaseController | ||
| 32 | * @author :liyuhang | 32 | * @author :liyuhang |
| 33 | * @method | 33 | * @method |
| 34 | */ | 34 | */ |
| 35 | - public function info(Request $request,NewsCategoryModel $newsCategory){ | 35 | + public function info(Request $request,NewsCategoryLogic $newsCategoryLogic){ |
| 36 | $request->validate([ | 36 | $request->validate([ |
| 37 | 'id'=>['required'] | 37 | 'id'=>['required'] |
| 38 | ],[ | 38 | ],[ |
| 39 | 'id.required' => 'ID不能为空' | 39 | 'id.required' => 'ID不能为空' |
| 40 | ]); | 40 | ]); |
| 41 | - $info = $newsCategory->read($this->param); | ||
| 42 | - if($info === false){ | ||
| 43 | - $this->response('error',Code::USER_ERROR); | ||
| 44 | - } | 41 | + $info = $newsCategoryLogic->info_news_category(); |
| 45 | $this->response('success',Code::SUCCESS,$info); | 42 | $this->response('success',Code::SUCCESS,$info); |
| 46 | } | 43 | } |
| 47 | /** | 44 | /** |
| @@ -64,17 +61,13 @@ class NewsCategoryController extends BaseController | @@ -64,17 +61,13 @@ class NewsCategoryController extends BaseController | ||
| 64 | * @author :liyuhang | 61 | * @author :liyuhang |
| 65 | * @method | 62 | * @method |
| 66 | */ | 63 | */ |
| 67 | - public function edit(NewsCategoryRequest $request,NewsCategoryModel $newsCategory){ | 64 | + public function edit(NewsCategoryRequest $request,NewsCategoryLogic $newsCategoryLogic){ |
| 68 | $request->validate([ | 65 | $request->validate([ |
| 69 | 'id'=>['required'] | 66 | 'id'=>['required'] |
| 70 | ],[ | 67 | ],[ |
| 71 | 'id.required' => 'ID不能为空' | 68 | 'id.required' => 'ID不能为空' |
| 72 | ]); | 69 | ]); |
| 73 | - $this->param['operator_id'] = $this->uid; | ||
| 74 | - $rs = $newsCategory->edit($this->param,['id'=>$this->param['id']]); | ||
| 75 | - if($rs === false){ | ||
| 76 | - $this->response('error',Code::USER_ERROR); | ||
| 77 | - } | 70 | + $newsCategoryLogic->edit_news_category(); |
| 78 | //TODO::写入日志 | 71 | //TODO::写入日志 |
| 79 | $this->response('success'); | 72 | $this->response('success'); |
| 80 | } | 73 | } |
| @@ -85,17 +78,13 @@ class NewsCategoryController extends BaseController | @@ -85,17 +78,13 @@ class NewsCategoryController extends BaseController | ||
| 85 | * @author :liyuhang | 78 | * @author :liyuhang |
| 86 | * @method | 79 | * @method |
| 87 | */ | 80 | */ |
| 88 | - public function status(Request $request,NewsCategoryModel $newsCategory){ | 81 | + public function status(Request $request,NewsCategoryLogic $newsCategoryLogic){ |
| 89 | $request->validate([ | 82 | $request->validate([ |
| 90 | 'id'=>['required'], | 83 | 'id'=>['required'], |
| 91 | ],[ | 84 | ],[ |
| 92 | 'id.required' => 'ID不能为空', | 85 | 'id.required' => 'ID不能为空', |
| 93 | ]); | 86 | ]); |
| 94 | - $this->param['operator_id'] = $this->uid; | ||
| 95 | - $rs = $newsCategory->edit($this->param,['id'=>$this->param['id']]); | ||
| 96 | - if($rs === false){ | ||
| 97 | - $this->response('error',Code::USER_ERROR); | ||
| 98 | - } | 87 | + $newsCategoryLogic->status_news_category(); |
| 99 | $this->response('success'); | 88 | $this->response('success'); |
| 100 | } | 89 | } |
| 101 | 90 |
| @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Bside\News; | @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Bside\News; | ||
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Controllers\Bside\BaseController; | 6 | use App\Http\Controllers\Bside\BaseController; |
| 7 | +use App\Http\Logic\Bside\News\NewsLogic; | ||
| 7 | use App\Http\Requests\Bside\News\NewsRequest; | 8 | use App\Http\Requests\Bside\News\NewsRequest; |
| 8 | use App\Models\News\News as NewsModel; | 9 | use App\Models\News\News as NewsModel; |
| 9 | use App\Models\News\NewsCategory as NewsCategoryModel; | 10 | use App\Models\News\NewsCategory as NewsCategoryModel; |
| @@ -32,21 +33,8 @@ class NewsController extends BaseController | @@ -32,21 +33,8 @@ class NewsController extends BaseController | ||
| 32 | * @author :liyuhang | 33 | * @author :liyuhang |
| 33 | * @method | 34 | * @method |
| 34 | */ | 35 | */ |
| 35 | - public function get_category_list(NewsCategoryModel $newsCategoryModel){ | ||
| 36 | - $this->map['status'] = 0; | ||
| 37 | - $this->map['project_id'] = $this->user['project_id']; | ||
| 38 | - $cate_list = $newsCategoryModel->list($this->map,'sort'); | ||
| 39 | - if($cate_list === false){ | ||
| 40 | - $this->response('error',Code::USER_ERROR); | ||
| 41 | - } | ||
| 42 | - $list = []; | ||
| 43 | - foreach ($cate_list as $k => $v){ | ||
| 44 | - $v = (array)$v; | ||
| 45 | - if ($v['pid'] == 0) { | ||
| 46 | - $v['sub'] = $this->_get_child($v['id'], $cate_list); | ||
| 47 | - $list[] = $v; | ||
| 48 | - } | ||
| 49 | - } | 36 | + public function get_category_list(NewsLogic $newsLogic){ |
| 37 | + $list = $newsLogic->news_get_category_list(); | ||
| 50 | $this->response('success',Code::SUCCESS,$list); | 38 | $this->response('success',Code::SUCCESS,$list); |
| 51 | } | 39 | } |
| 52 | /** | 40 | /** |
| @@ -55,18 +43,15 @@ class NewsController extends BaseController | @@ -55,18 +43,15 @@ class NewsController extends BaseController | ||
| 55 | * @author :liyuhang | 43 | * @author :liyuhang |
| 56 | * @method | 44 | * @method |
| 57 | */ | 45 | */ |
| 58 | - public function info(Request $request,NewsModel $news){ | 46 | + public function info(Request $request,NewsLogic $newsLogic){ |
| 59 | $request->validate([ | 47 | $request->validate([ |
| 60 | 'id'=>['required'], | 48 | 'id'=>['required'], |
| 61 | ],[ | 49 | ],[ |
| 62 | 'id.required' => 'ID不能为空', | 50 | 'id.required' => 'ID不能为空', |
| 63 | ]); | 51 | ]); |
| 64 | - $rs = $news->read($this->param); | ||
| 65 | - if($rs === false){ | ||
| 66 | - $this->response('error',Code::USER_ERROR); | ||
| 67 | - } | 52 | + $info = $newsLogic->news_info(); |
| 68 | //TODO::清空相关资源 | 53 | //TODO::清空相关资源 |
| 69 | - $this->response('success'); | 54 | + $this->response('success',Code::SUCCESS,$info); |
| 70 | } | 55 | } |
| 71 | /** | 56 | /** |
| 72 | * @name :添加新闻 | 57 | * @name :添加新闻 |
| @@ -74,18 +59,9 @@ class NewsController extends BaseController | @@ -74,18 +59,9 @@ class NewsController extends BaseController | ||
| 74 | * @author :liyuhang | 59 | * @author :liyuhang |
| 75 | * @method | 60 | * @method |
| 76 | */ | 61 | */ |
| 77 | - public function add(NewsRequest $newsRequest,NewsModel $news){ | 62 | + public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){ |
| 78 | $newsRequest->validated(); | 63 | $newsRequest->validated(); |
| 79 | - $this->param['create_id'] = $this->uid; | ||
| 80 | - $this->param['operator_id'] = $this->uid; | ||
| 81 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 82 | - //多个分类按逗号隔开 | ||
| 83 | - $this->param['category_id'] = ','.$this->param['category_id'].','; | ||
| 84 | - //TODO::路由映射 | ||
| 85 | - $rs = $news->add($this->param); | ||
| 86 | - if($rs === false){ | ||
| 87 | - $this->response('error',Code::USER_ERROR); | ||
| 88 | - } | 64 | + $newsLogic->news_add(); |
| 89 | //TODO::写入日志 | 65 | //TODO::写入日志 |
| 90 | $this->response('success'); | 66 | $this->response('success'); |
| 91 | } | 67 | } |
| @@ -96,19 +72,13 @@ class NewsController extends BaseController | @@ -96,19 +72,13 @@ class NewsController extends BaseController | ||
| 96 | * @author :liyuhang | 72 | * @author :liyuhang |
| 97 | * @method | 73 | * @method |
| 98 | */ | 74 | */ |
| 99 | - public function edit(NewsRequest $newsRequest,NewsModel $news){ | 75 | + public function edit(NewsRequest $newsRequest,NewsLogic $newsLogic){ |
| 100 | $newsRequest->validate([ | 76 | $newsRequest->validate([ |
| 101 | 'id'=>['required'], | 77 | 'id'=>['required'], |
| 102 | ],[ | 78 | ],[ |
| 103 | 'id.required' => 'ID不能为空', | 79 | 'id.required' => 'ID不能为空', |
| 104 | ]); | 80 | ]); |
| 105 | - $this->param['operator_id'] = $this->uid; | ||
| 106 | - //多个分类按逗号隔开 | ||
| 107 | - $this->param['category_id'] = ','.$this->param['category_id'].','; | ||
| 108 | - $rs = $news->edit($this->param,['id'=>$this->param['id']]); | ||
| 109 | - if($rs === false){ | ||
| 110 | - $this->response('error',Code::USER_ERROR); | ||
| 111 | - } | 81 | + $newsLogic->news_edit(); |
| 112 | //TODO::写入日志 | 82 | //TODO::写入日志 |
| 113 | $this->response('success',Code::SUCCESS); | 83 | $this->response('success',Code::SUCCESS); |
| 114 | } | 84 | } |
| @@ -119,17 +89,13 @@ class NewsController extends BaseController | @@ -119,17 +89,13 @@ class NewsController extends BaseController | ||
| 119 | * @author :liyuhang | 89 | * @author :liyuhang |
| 120 | * @method | 90 | * @method |
| 121 | */ | 91 | */ |
| 122 | - public function status(Request $request,NewsModel $news){ | 92 | + public function status(Request $request,NewsLogic $newsLogic){ |
| 123 | $request->validate([ | 93 | $request->validate([ |
| 124 | 'id'=>['required'], | 94 | 'id'=>['required'], |
| 125 | ],[ | 95 | ],[ |
| 126 | 'id.required' => 'ID不能为空', | 96 | 'id.required' => 'ID不能为空', |
| 127 | ]); | 97 | ]); |
| 128 | - $this->param['operator_id'] = $this->uid; | ||
| 129 | - $rs = $news->edit($this->param,['id'=>$this->param['id']]); | ||
| 130 | - if($rs === false){ | ||
| 131 | - $this->response('error',Code::USER_ERROR); | ||
| 132 | - } | 98 | + $newsLogic->news_status(); |
| 133 | //TODO::写入日志 | 99 | //TODO::写入日志 |
| 134 | $this->response('success'); | 100 | $this->response('success'); |
| 135 | } | 101 | } |
| @@ -139,17 +105,13 @@ class NewsController extends BaseController | @@ -139,17 +105,13 @@ class NewsController extends BaseController | ||
| 139 | * @author :liyuhang | 105 | * @author :liyuhang |
| 140 | * @method | 106 | * @method |
| 141 | */ | 107 | */ |
| 142 | - public function del(Request $request,NewsModel $news){ | 108 | + public function del(Request $request,NewsLogic $newsLogic){ |
| 143 | $request->validate([ | 109 | $request->validate([ |
| 144 | 'id'=>['required'], | 110 | 'id'=>['required'], |
| 145 | ],[ | 111 | ],[ |
| 146 | 'id.required' => 'ID不能为空', | 112 | 'id.required' => 'ID不能为空', |
| 147 | ]); | 113 | ]); |
| 148 | - $this->param['id'] = ['in',$this->param['id']];d; | ||
| 149 | - $rs = $news->edit(['status'=>2,'operator_id'=>$this->uid],$this->param); | ||
| 150 | - if($rs === false){ | ||
| 151 | - $this->response('error',Code::USER_ERROR); | ||
| 152 | - } | 114 | + $newsLogic->news_del(); |
| 153 | //TODO::清空相关资源/写入日志 | 115 | //TODO::清空相关资源/写入日志 |
| 154 | $this->response('success'); | 116 | $this->response('success'); |
| 155 | } | 117 | } |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Http\Controllers\Bside; | 3 | 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\RoleLogic; | ||
| 6 | use App\Http\Requests\Bside\ProjectRoleRequest; | 7 | use App\Http\Requests\Bside\ProjectRoleRequest; |
| 7 | use App\Models\ProjectMenu as ProjectMenuModel; | 8 | use App\Models\ProjectMenu as ProjectMenuModel; |
| 8 | use App\Models\ProjectRole as ProjectRoleModel; | 9 | use App\Models\ProjectRole as ProjectRoleModel; |
| @@ -33,17 +34,14 @@ class ProjectRoleController extends BaseController | @@ -33,17 +34,14 @@ class ProjectRoleController extends BaseController | ||
| 33 | * @author :liyuhang | 34 | * @author :liyuhang |
| 34 | * @method | 35 | * @method |
| 35 | */ | 36 | */ |
| 36 | - public function info(Request $request,ProjectRoleModel $projectRoleModel){ | 37 | + public function info(Request $request,RoleLogic $roleLogic){ |
| 37 | $request->validate([ | 38 | $request->validate([ |
| 38 | 'id'=>['required', new Ids()], | 39 | 'id'=>['required', new Ids()], |
| 39 | ],[ | 40 | ],[ |
| 40 | 'id.required' => 'ID不能为空', | 41 | 'id.required' => 'ID不能为空', |
| 41 | ]); | 42 | ]); |
| 42 | - $rs = $projectRoleModel->read($this->param); | ||
| 43 | - if($rs === false){ | ||
| 44 | - $this->response('error',Code::USER_ERROR); | ||
| 45 | - } | ||
| 46 | - $this->response('success'); | 43 | + $info = $roleLogic->role_info(); |
| 44 | + $this->response('success',Code::SUCCESS,$info); | ||
| 47 | } | 45 | } |
| 48 | /** | 46 | /** |
| 49 | * @name :添加/编辑角色时获取菜单列表 | 47 | * @name :添加/编辑角色时获取菜单列表 |
| @@ -51,20 +49,8 @@ class ProjectRoleController extends BaseController | @@ -51,20 +49,8 @@ class ProjectRoleController extends BaseController | ||
| 51 | * @author :liyuhang | 49 | * @author :liyuhang |
| 52 | * @method | 50 | * @method |
| 53 | */ | 51 | */ |
| 54 | - public function get_role_menu(ProjectRoleModel $projectRoleModel,ProjectMenuModel $projectMenuModel){ | ||
| 55 | - //根据当前登录用户角色返回用户菜单列表 | ||
| 56 | - $info = $projectRoleModel->read(['id'=>$this->user['role_id']]); | ||
| 57 | - $info['role_menu'] = trim($info['role_menu'],','); | ||
| 58 | - $lists = $projectMenuModel->where(['status'=>0])->whereIn('id',explode(',',$info['role_menu']))->get(); | ||
| 59 | - $lists = $lists->toArray(); | ||
| 60 | - $menu = array(); | ||
| 61 | - foreach ($lists as $k => $v){ | ||
| 62 | - $v = (array)$v; | ||
| 63 | - if ($v['pid'] == 0) { | ||
| 64 | - $v['sub'] = $this->_get_child($v['id'], $lists); | ||
| 65 | - $menu[] = $v; | ||
| 66 | - } | ||
| 67 | - } | 52 | + public function get_role_menu(RoleLogic $roleLogic){ |
| 53 | + $menu = $roleLogic->role_get_menu(); | ||
| 68 | $this->response('当前用户菜单列表',Code::SUCCESS,$menu); | 54 | $this->response('当前用户菜单列表',Code::SUCCESS,$menu); |
| 69 | } | 55 | } |
| 70 | /** | 56 | /** |
| @@ -73,20 +59,9 @@ class ProjectRoleController extends BaseController | @@ -73,20 +59,9 @@ class ProjectRoleController extends BaseController | ||
| 73 | * @author :liyuhang | 59 | * @author :liyuhang |
| 74 | * @method | 60 | * @method |
| 75 | */ | 61 | */ |
| 76 | - public function add(ProjectRoleRequest $request){ | 62 | + public function add(ProjectRoleRequest $request,RoleLogic $roleLogic){ |
| 77 | $request->validated(); | 63 | $request->validated(); |
| 78 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 79 | - //获取当前项目下的角色超级管理员 | ||
| 80 | - $projectRoleModel = new ProjectRoleModel(); | ||
| 81 | - //验证当前角色是否存在 | ||
| 82 | - $info = $projectRoleModel->read(['name'=>$this->param['name']]); | ||
| 83 | - if(!empty($info)){ | ||
| 84 | - $this->response('当前添加的角色已存在',Code::USER_PARAMS_ERROE); | ||
| 85 | - } | ||
| 86 | - $rs = $projectRoleModel->add($this->param); | ||
| 87 | - if($rs === false){ | ||
| 88 | - $this->response('添加失败',Code::USER_PARAMS_ERROE); | ||
| 89 | - } | 64 | + $roleLogic->role_add(); |
| 90 | $this->response('添加成功'); | 65 | $this->response('添加成功'); |
| 91 | } | 66 | } |
| 92 | 67 | ||
| @@ -96,26 +71,13 @@ class ProjectRoleController extends BaseController | @@ -96,26 +71,13 @@ class ProjectRoleController extends BaseController | ||
| 96 | * @author :liyuhang | 71 | * @author :liyuhang |
| 97 | * @method | 72 | * @method |
| 98 | */ | 73 | */ |
| 99 | - public function edit(ProjectRoleRequest $request,ProjectRoleModel $projectRoleModel){ | 74 | + public function edit(ProjectRoleRequest $request,RoleLogic $roleLogic){ |
| 100 | $request->validate([ | 75 | $request->validate([ |
| 101 | 'id'=>['required'] | 76 | 'id'=>['required'] |
| 102 | ],[ | 77 | ],[ |
| 103 | 'id.required' => 'ID不能为空' | 78 | 'id.required' => 'ID不能为空' |
| 104 | ]); | 79 | ]); |
| 105 | - //TODO::查询当前名称是否重复 | ||
| 106 | - $condition = [ | ||
| 107 | - ['id'=>['!=',$this->param['id']]], | ||
| 108 | - ['name'=>$this->param['name']], | ||
| 109 | - ['project_id'=>$this->user['project_id']], | ||
| 110 | - ]; | ||
| 111 | - $info = $projectRoleModel->formatQuery($condition)->first(); | ||
| 112 | - if(!empty($info)){ | ||
| 113 | - $this->response('当前添加的角色已存在',Code::USER_PARAMS_ERROE); | ||
| 114 | - } | ||
| 115 | - $rs = $projectRoleModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 116 | - if($rs === false){ | ||
| 117 | - $this->response('编辑失败',Code::USER_PARAMS_ERROE); | ||
| 118 | - } | 80 | + $roleLogic->role_edit(); |
| 119 | $this->response('编辑成功'); | 81 | $this->response('编辑成功'); |
| 120 | } | 82 | } |
| 121 | 83 | ||
| @@ -125,19 +87,14 @@ class ProjectRoleController extends BaseController | @@ -125,19 +87,14 @@ class ProjectRoleController extends BaseController | ||
| 125 | * @author :liyuhang | 87 | * @author :liyuhang |
| 126 | * @method | 88 | * @method |
| 127 | */ | 89 | */ |
| 128 | - public function status(Request $request,ProjectRoleModel $projectRoleModel){ | 90 | + public function status(Request $request,RoleLogic $roleLogic){ |
| 129 | $request->validate([ | 91 | $request->validate([ |
| 130 | 'id'=>['required'], | 92 | 'id'=>['required'], |
| 131 | - 'status'=>['required'], | ||
| 132 | ],[ | 93 | ],[ |
| 133 | 'id.required' => 'ID不能为空', | 94 | 'id.required' => 'ID不能为空', |
| 134 | - 'status.required' => 'status不能为空' | ||
| 135 | ]); | 95 | ]); |
| 136 | - $rs = $projectRoleModel->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]); | ||
| 137 | - if($rs === false){ | ||
| 138 | - $this->response('编辑失败',Code::USER_PARAMS_ERROE); | ||
| 139 | - } | ||
| 140 | - $this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功',Code::SUCCESS); | 96 | + $roleLogic->role_status(); |
| 97 | + $this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功'); | ||
| 141 | } | 98 | } |
| 142 | 99 | ||
| 143 | /** | 100 | /** |
| @@ -146,22 +103,13 @@ class ProjectRoleController extends BaseController | @@ -146,22 +103,13 @@ class ProjectRoleController extends BaseController | ||
| 146 | * @author :liyuhang | 103 | * @author :liyuhang |
| 147 | * @method | 104 | * @method |
| 148 | */ | 105 | */ |
| 149 | - public function del(Request $request,ProjectRoleModel $projectRoleModel){ | 106 | + public function del(Request $request,RoleLogic $roleLogic){ |
| 150 | $request->validate([ | 107 | $request->validate([ |
| 151 | 'id'=>['required'] | 108 | 'id'=>['required'] |
| 152 | ],[ | 109 | ],[ |
| 153 | 'id.required' => 'ID不能为空' | 110 | 'id.required' => 'ID不能为空' |
| 154 | ]); | 111 | ]); |
| 155 | - //查询当前角色下是否有用户 | ||
| 156 | - $userModel = new UserModel(); | ||
| 157 | - $user_info = $userModel->read(['role_id'=>$this->param['id']]); | ||
| 158 | - if(!empty($user_info)){ | ||
| 159 | - $this->response('当前角色下有用户存在,不允许删除',Code::USER_ERROR); | ||
| 160 | - } | ||
| 161 | - $rs = $projectRoleModel->del(['id'=>$this->param['id']]); | ||
| 162 | - if($rs === false){ | ||
| 163 | - $this->response('error',Code::USER_ERROR); | ||
| 164 | - } | 112 | + $roleLogic->role_del(); |
| 165 | $this->response('success'); | 113 | $this->response('success'); |
| 166 | } | 114 | } |
| 167 | } | 115 | } |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Http\Controllers\Bside; | 3 | 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\UserLogic; | ||
| 6 | use App\Http\Requests\Bside\UserRequest; | 7 | use App\Http\Requests\Bside\UserRequest; |
| 7 | use App\Models\User as UserModel; | 8 | use App\Models\User as UserModel; |
| 8 | use App\Rules\Ids; | 9 | use App\Rules\Ids; |
| @@ -32,14 +33,10 @@ class UserController extends BaseController | @@ -32,14 +33,10 @@ class UserController extends BaseController | ||
| 32 | * @author :liyuhang | 33 | * @author :liyuhang |
| 33 | * @method | 34 | * @method |
| 34 | */ | 35 | */ |
| 35 | - public function add(UserRequest $request,UserModel $userModel){ | 36 | + public function add(UserRequest $request,UserLogic $userLogic){ |
| 36 | $request->validated(); | 37 | $request->validated(); |
| 37 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 38 | - $rs = $userModel->adds($this->param); | ||
| 39 | - if($rs === false){ | ||
| 40 | - $this->response('当前添加用户已存在或参数错误,添加失败',Code::USER_REGISTER_ERROE,[]); | ||
| 41 | - } | ||
| 42 | - $this->response('success',Code::SUCCESS); | 38 | + $userLogic->user_add(); |
| 39 | + $this->response('success'); | ||
| 43 | } | 40 | } |
| 44 | 41 | ||
| 45 | /** | 42 | /** |
| @@ -48,22 +45,14 @@ class UserController extends BaseController | @@ -48,22 +45,14 @@ class UserController extends BaseController | ||
| 48 | * @author :liyuhang | 45 | * @author :liyuhang |
| 49 | * @method | 46 | * @method |
| 50 | */ | 47 | */ |
| 51 | - public function edit(UserRequest $request,UserModel $userModel){ | 48 | + public function edit(UserRequest $request,UserLogic $userLogic){ |
| 52 | $request->validate([ | 49 | $request->validate([ |
| 53 | 'id'=>['required'] | 50 | 'id'=>['required'] |
| 54 | ],[ | 51 | ],[ |
| 55 | 'id.required' => 'ID不能为空' | 52 | 'id.required' => 'ID不能为空' |
| 56 | ]); | 53 | ]); |
| 57 | - $info = $userModel->where('id','<>',$this->param['id']) | ||
| 58 | - ->where(['mobile'=>$this->param['mobile']])->first(); | ||
| 59 | - if(!empty($info)){ | ||
| 60 | - $this->response('当前编辑的手机号码已存在',Code::USER_PARAMS_ERROE); | ||
| 61 | - } | ||
| 62 | - $rs = $userModel->edits($this->param); | ||
| 63 | - if($rs === false){ | ||
| 64 | - $this->response('参数错误或其他服务器原因,编辑失败',Code::USER_ERROR,[]); | ||
| 65 | - } | ||
| 66 | - $this->response('编辑成功',Code::SUCCESS,[]); | 54 | + $userLogic->user_edit(); |
| 55 | + $this->response('success'); | ||
| 67 | } | 56 | } |
| 68 | 57 | ||
| 69 | /** | 58 | /** |
| @@ -72,18 +61,13 @@ class UserController extends BaseController | @@ -72,18 +61,13 @@ class UserController extends BaseController | ||
| 72 | * @author :liyuhang | 61 | * @author :liyuhang |
| 73 | * @method | 62 | * @method |
| 74 | */ | 63 | */ |
| 75 | - public function status(Request $request,UserModel $userModel){ | 64 | + public function status(Request $request,UserLogic $userLogic){ |
| 76 | $request->validate([ | 65 | $request->validate([ |
| 77 | 'id'=>['required'], | 66 | 'id'=>['required'], |
| 78 | - 'status'=>['required'], | ||
| 79 | ],[ | 67 | ],[ |
| 80 | 'id.required' => 'ID不能为空', | 68 | 'id.required' => 'ID不能为空', |
| 81 | - 'status.required' => 'status不能为空' | ||
| 82 | ]); | 69 | ]); |
| 83 | - $rs = $userModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 84 | - if($rs === false){ | ||
| 85 | - $this->response('error',Code::USER_ERROR); | ||
| 86 | - } | 70 | + $userLogic->user_status(); |
| 87 | $this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功'); | 71 | $this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功'); |
| 88 | } | 72 | } |
| 89 | 73 | ||
| @@ -93,16 +77,13 @@ class UserController extends BaseController | @@ -93,16 +77,13 @@ class UserController extends BaseController | ||
| 93 | * @author :liyuhang | 77 | * @author :liyuhang |
| 94 | * @method | 78 | * @method |
| 95 | */ | 79 | */ |
| 96 | - public function info(Request $request,UserModel $userModel){ | 80 | + public function info(Request $request,UserLogic $userLogic){ |
| 97 | $request->validate([ | 81 | $request->validate([ |
| 98 | - 'id'=>['required', new Ids()], | 82 | + 'id'=>['required'], |
| 99 | ],[ | 83 | ],[ |
| 100 | 'id.required' => 'ID不能为空', | 84 | 'id.required' => 'ID不能为空', |
| 101 | ]); | 85 | ]); |
| 102 | - $rs = $userModel->read($this->param); | ||
| 103 | - if($rs === false){ | ||
| 104 | - $this->response('error',Code::USER_ERROR); | ||
| 105 | - } | 86 | + $userLogic->user_info(); |
| 106 | $this->response('success'); | 87 | $this->response('success'); |
| 107 | } | 88 | } |
| 108 | /** | 89 | /** |
| @@ -111,16 +92,13 @@ class UserController extends BaseController | @@ -111,16 +92,13 @@ class UserController extends BaseController | ||
| 111 | * @author :liyuhang | 92 | * @author :liyuhang |
| 112 | * @method | 93 | * @method |
| 113 | */ | 94 | */ |
| 114 | - public function del(Request $request,UserModel $userModel){ | 95 | + public function del(Request $request,UserLogic $userLogic){ |
| 115 | $request->validate([ | 96 | $request->validate([ |
| 116 | - 'id'=>['required', new Ids()], | 97 | + 'id'=>['required'], |
| 117 | ],[ | 98 | ],[ |
| 118 | 'id.required' => 'ID不能为空', | 99 | 'id.required' => 'ID不能为空', |
| 119 | ]); | 100 | ]); |
| 120 | - $rs = $userModel->del($this->param); | ||
| 121 | - if($rs === false){ | ||
| 122 | - $this->response('error',Code::USER_ERROR); | ||
| 123 | - } | 101 | + $userLogic->user_del(); |
| 124 | $this->response('success'); | 102 | $this->response('success'); |
| 125 | } | 103 | } |
| 126 | } | 104 | } |
| @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside; | @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside; | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Exceptions\BsideGlobalException; | 6 | use App\Exceptions\BsideGlobalException; |
| 7 | use App\Helper\Arr; | 7 | use App\Helper\Arr; |
| 8 | +use Illuminate\Http\Request; | ||
| 8 | use Illuminate\Support\Facades\Cache; | 9 | use Illuminate\Support\Facades\Cache; |
| 9 | 10 | ||
| 10 | /** | 11 | /** |
| @@ -16,6 +17,8 @@ class BaseLogic | @@ -16,6 +17,8 @@ class BaseLogic | ||
| 16 | 17 | ||
| 17 | protected $requestAll; | 18 | protected $requestAll; |
| 18 | 19 | ||
| 20 | + protected $param; | ||
| 21 | + | ||
| 19 | protected $user; | 22 | protected $user; |
| 20 | 23 | ||
| 21 | protected $is_cache = true; //是否缓存数据 | 24 | protected $is_cache = true; //是否缓存数据 |
| @@ -304,4 +307,28 @@ class BaseLogic | @@ -304,4 +307,28 @@ class BaseLogic | ||
| 304 | }); | 307 | }); |
| 305 | return $query; | 308 | return $query; |
| 306 | } | 309 | } |
| 310 | + /** | ||
| 311 | + * @name :上传图片 | ||
| 312 | + * @return void | ||
| 313 | + * @author :liyuhang | ||
| 314 | + * @method | ||
| 315 | + */ | ||
| 316 | + public function upload(Request $request){ | ||
| 317 | + $image = $request->file('image'); | ||
| 318 | + if(empty($image)){ | ||
| 319 | + return $this->fail('没有上传图片',Code::USER_ERROR); | ||
| 320 | + } | ||
| 321 | + $url = './../uploads/images/'; | ||
| 322 | + $filename = date('ymdHis').rand(10000,99999); | ||
| 323 | + $res = $request->file('image')->move($url,$filename); | ||
| 324 | + if ($res === false) { | ||
| 325 | + return $this->fail($image->getError(), 400); | ||
| 326 | + } | ||
| 327 | + $data = [ | ||
| 328 | + 'path' => $url.$filename, | ||
| 329 | + 'create_time' => date('Y-m-d H:i:s',time()), | ||
| 330 | + 'size' => $res->getSize(), | ||
| 331 | + ]; | ||
| 332 | + return data; | ||
| 333 | + } | ||
| 307 | } | 334 | } |
| @@ -6,6 +6,7 @@ use App\Enums\Common\Code; | @@ -6,6 +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\Blog\BlogCategory as BlogCategoryModel; | 7 | use App\Models\Blog\BlogCategory as BlogCategoryModel; |
| 8 | use App\Models\Blog\Blog as BlogModel; | 8 | use App\Models\Blog\Blog as BlogModel; |
| 9 | +use App\Models\News\NewsCategory as NewsCategoryModel; | ||
| 9 | use Illuminate\Support\Facades\DB; | 10 | use Illuminate\Support\Facades\DB; |
| 10 | 11 | ||
| 11 | class BlogCategoryLogic extends BaseLogic | 12 | class BlogCategoryLogic extends BaseLogic |
| @@ -15,8 +16,10 @@ class BlogCategoryLogic extends BaseLogic | @@ -15,8 +16,10 @@ class BlogCategoryLogic extends BaseLogic | ||
| 15 | parent::__construct(); | 16 | parent::__construct(); |
| 16 | 17 | ||
| 17 | $this->model = new BlogCategoryModel(); | 18 | $this->model = new BlogCategoryModel(); |
| 19 | + $this->param = $this->requestAll; | ||
| 18 | } | 20 | } |
| 19 | 21 | ||
| 22 | + | ||
| 20 | /** | 23 | /** |
| 21 | * @name :添加时验证上级分类是否有商品,有则替换带当前分类下 | 24 | * @name :添加时验证上级分类是否有商品,有则替换带当前分类下 |
| 22 | * @return void | 25 | * @return void |
| @@ -25,7 +28,6 @@ class BlogCategoryLogic extends BaseLogic | @@ -25,7 +28,6 @@ class BlogCategoryLogic extends BaseLogic | ||
| 25 | */ | 28 | */ |
| 26 | public function add_blog_category(){ | 29 | public function add_blog_category(){ |
| 27 | DB::beginTransaction(); | 30 | DB::beginTransaction(); |
| 28 | - $this->param = $this->requestAll; | ||
| 29 | $this->param['project_id'] = $this->user['project_id']; | 31 | $this->param['project_id'] = $this->user['project_id']; |
| 30 | $this->param['operator_id'] = $this->user['id']; | 32 | $this->param['operator_id'] = $this->user['id']; |
| 31 | $this->param['create_id'] = $this->user['id']; | 33 | $this->param['create_id'] = $this->user['id']; |
| @@ -62,6 +64,51 @@ class BlogCategoryLogic extends BaseLogic | @@ -62,6 +64,51 @@ class BlogCategoryLogic extends BaseLogic | ||
| 62 | } | 64 | } |
| 63 | 65 | ||
| 64 | /** | 66 | /** |
| 67 | + * @name :编辑分类 | ||
| 68 | + * @return void | ||
| 69 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 70 | + * @author :liyuhang | ||
| 71 | + * @method | ||
| 72 | + */ | ||
| 73 | + public function edit_blog_category(){ | ||
| 74 | + $this->param['operator_id'] = $this->user['id']; | ||
| 75 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 76 | + if($rs === false){ | ||
| 77 | + $this->fail('error',Code::USER_ERROR); | ||
| 78 | + } | ||
| 79 | + return $this->success(); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * @name :详情 | ||
| 84 | + * @return array | ||
| 85 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 86 | + * @author :liyuhang | ||
| 87 | + * @method | ||
| 88 | + */ | ||
| 89 | + public function info_blog_category(){ | ||
| 90 | + $info = $this->model->read($this->param); | ||
| 91 | + if($info === false){ | ||
| 92 | + $this->fail('error',Code::USER_ERROR); | ||
| 93 | + } | ||
| 94 | + return $this->success($info); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * @name :编辑状态与排序 | ||
| 99 | + * @return void | ||
| 100 | + * @author :liyuhang | ||
| 101 | + * @method | ||
| 102 | + */ | ||
| 103 | + public function status_blog_category(){ | ||
| 104 | + $this->param['operator_id'] = $this->user['id']; | ||
| 105 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 106 | + if($rs === false){ | ||
| 107 | + $this->fail('error',Code::USER_ERROR); | ||
| 108 | + } | ||
| 109 | + return $this->success(); | ||
| 110 | + } | ||
| 111 | + /** | ||
| 65 | * @name :删除博客分类 | 112 | * @name :删除博客分类 |
| 66 | * @return void | 113 | * @return void |
| 67 | * @author :liyuhang | 114 | * @author :liyuhang |
| @@ -87,5 +134,6 @@ class BlogCategoryLogic extends BaseLogic | @@ -87,5 +134,6 @@ class BlogCategoryLogic extends BaseLogic | ||
| 87 | if($rs === false){ | 134 | if($rs === false){ |
| 88 | $this->response('error',Code::USER_ERROR); | 135 | $this->response('error',Code::USER_ERROR); |
| 89 | } | 136 | } |
| 137 | + return $this->success(); | ||
| 90 | } | 138 | } |
| 91 | } | 139 | } |
| @@ -2,9 +2,141 @@ | @@ -2,9 +2,141 @@ | ||
| 2 | 2 | ||
| 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\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | +use App\Models\Blog\Blog; | ||
| 8 | +use App\Models\Blog\BlogCategory as BlogCategoryModel; | ||
| 9 | +use App\Models\RouteMap; | ||
| 10 | +use Illuminate\Support\Facades\DB; | ||
| 6 | 11 | ||
| 7 | class BlogLogic extends BaseLogic | 12 | class BlogLogic extends BaseLogic |
| 8 | { | 13 | { |
| 14 | + public function __construct() | ||
| 15 | + { | ||
| 16 | + parent::__construct(); | ||
| 9 | 17 | ||
| 18 | + $this->model = new Blog(); | ||
| 19 | + $this->param = $this->requestAll; | ||
| 20 | + } | ||
| 21 | + /** | ||
| 22 | + * @name :获取分类列表 | ||
| 23 | + * @return array | ||
| 24 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 25 | + * @author :liyuhang | ||
| 26 | + * @method | ||
| 27 | + */ | ||
| 28 | + public function blog_get_category_list(){ | ||
| 29 | + $this->map['status'] = 0; | ||
| 30 | + $this->map['project_id'] = $this->user['project_id']; | ||
| 31 | + $blogCategoryModel = new BlogCategoryModel(); | ||
| 32 | + $cate_list = $blogCategoryModel->list($this->map,'sort'); | ||
| 33 | + if($cate_list === false){ | ||
| 34 | + $this->fail('error',Code::USER_ERROR); | ||
| 35 | + } | ||
| 36 | + $list = []; | ||
| 37 | + foreach ($cate_list as $v){ | ||
| 38 | + $v = (array)$v; | ||
| 39 | + if ($v['pid'] == 0) { | ||
| 40 | + $v['sub'] = _get_child($v['id'], $cate_list); | ||
| 41 | + $list[] = $v; | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + return $this->success($list); | ||
| 45 | + } | ||
| 46 | + /** | ||
| 47 | + * @name :添加博客 | ||
| 48 | + * @return void | ||
| 49 | + * @author :liyuhang | ||
| 50 | + * @method | ||
| 51 | + */ | ||
| 52 | + public function blog_add(){ | ||
| 53 | + $this->param['create_id'] = $this->uid; | ||
| 54 | + $this->param['operator_id'] = $this->uid; | ||
| 55 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 56 | + DB::beginTransaction(); | ||
| 57 | + try { | ||
| 58 | + $rs = $this->model->insertGetId($this->param); | ||
| 59 | + RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']); | ||
| 60 | + DB::commit(); | ||
| 61 | + }catch (\Exception $e){ | ||
| 62 | + DB::rollBack(); | ||
| 63 | + $this->fail('error',Code::USER_ERROR); | ||
| 64 | + } | ||
| 65 | + //TODO::写入日志 | ||
| 66 | + $this->success(); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * @name : 编辑用户 | ||
| 71 | + * @return void | ||
| 72 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 73 | + * @author :liyuhang | ||
| 74 | + * @method | ||
| 75 | + */ | ||
| 76 | + public function blog_edit(){ | ||
| 77 | + $this->param['operator_id'] = $this->uid; | ||
| 78 | + DB::beginTransaction(); | ||
| 79 | + try { | ||
| 80 | + $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 81 | + RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']); | ||
| 82 | + DB::commit(); | ||
| 83 | + }catch (\Exception $e){ | ||
| 84 | + DB::rollBack(); | ||
| 85 | + $this->fail('error',Code::USER_ERROR); | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + /** | ||
| 89 | + * @name :获取数据详情 | ||
| 90 | + * @return array | ||
| 91 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 92 | + * @author :liyuhang | ||
| 93 | + * @method | ||
| 94 | + */ | ||
| 95 | + public function blog_info(){ | ||
| 96 | + $info = $this->model->read($this->param); | ||
| 97 | + //获取分类名称 | ||
| 98 | + $info['category_id'] = explode(',',trim($info['category_id'],',')); | ||
| 99 | + $blogCategoryModel = new BlogCategoryModel(); | ||
| 100 | + $category_list = $blogCategoryModel->list(['id'=>['in',$info['category_id']]],'id',['name']); | ||
| 101 | + $str = ''; | ||
| 102 | + foreach ($category_list as $v){ | ||
| 103 | + $str .= $v['name'].','; | ||
| 104 | + } | ||
| 105 | + $info['category_id'] = trim($str,','); | ||
| 106 | + if($info === false){ | ||
| 107 | + $this->fail('error',Code::USER_ERROR); | ||
| 108 | + } | ||
| 109 | + return $this->success($info); | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + /** | ||
| 113 | + * @name :修改状态 | ||
| 114 | + * @return array | ||
| 115 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 116 | + * @author :liyuhang | ||
| 117 | + * @method | ||
| 118 | + */ | ||
| 119 | + public function blog_status(){ | ||
| 120 | + $this->param['operator_id'] = $this->user['id']; | ||
| 121 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 122 | + if($rs === false){ | ||
| 123 | + $this->fail('error',Code::USER_ERROR); | ||
| 124 | + } | ||
| 125 | + return $this->success(); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + /** | ||
| 129 | + * @name :逻辑删除 | ||
| 130 | + * @return void | ||
| 131 | + * @author :liyuhang | ||
| 132 | + * @method | ||
| 133 | + */ | ||
| 134 | + public function blog_del(){ | ||
| 135 | + $this->param['id'] = ['in',$this->param['id']]; | ||
| 136 | + $rs = $this->model->edit(['status'=>2],$this->param); | ||
| 137 | + if($rs === false){ | ||
| 138 | + $this->fail('error',Code::USER_ERROR); | ||
| 139 | + } | ||
| 140 | + return $this->success(); | ||
| 141 | + } | ||
| 10 | } | 142 | } |
| @@ -15,6 +15,22 @@ class NewsCategoryLogic extends BaseLogic | @@ -15,6 +15,22 @@ class NewsCategoryLogic extends BaseLogic | ||
| 15 | parent::__construct(); | 15 | parent::__construct(); |
| 16 | 16 | ||
| 17 | $this->model = new NewsCategoryModel(); | 17 | $this->model = new NewsCategoryModel(); |
| 18 | + $this->param = $this->requestAll; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * @name :详情 | ||
| 23 | + * @return array | ||
| 24 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 25 | + * @author :liyuhang | ||
| 26 | + * @method | ||
| 27 | + */ | ||
| 28 | + public function info_news_category(){ | ||
| 29 | + $info = $this->model->read($this->param); | ||
| 30 | + if($info === false){ | ||
| 31 | + $this->fail('error',Code::USER_ERROR); | ||
| 32 | + } | ||
| 33 | + return $this->success($info); | ||
| 18 | } | 34 | } |
| 19 | /** | 35 | /** |
| 20 | * @name :添加时验证上级分类是否有商品,有则替换带当前分类下 | 36 | * @name :添加时验证上级分类是否有商品,有则替换带当前分类下 |
| @@ -24,7 +40,7 @@ class NewsCategoryLogic extends BaseLogic | @@ -24,7 +40,7 @@ class NewsCategoryLogic extends BaseLogic | ||
| 24 | */ | 40 | */ |
| 25 | public function add_news_category(){ | 41 | public function add_news_category(){ |
| 26 | DB::beginTransaction(); | 42 | DB::beginTransaction(); |
| 27 | - $this->param = $this->requestAll; | 43 | + |
| 28 | $this->param['project_id'] = $this->user['project_id']; | 44 | $this->param['project_id'] = $this->user['project_id']; |
| 29 | $this->param['operator_id'] = $this->user['id']; | 45 | $this->param['operator_id'] = $this->user['id']; |
| 30 | $this->param['create_id'] = $this->user['id']; | 46 | $this->param['create_id'] = $this->user['id']; |
| @@ -61,6 +77,36 @@ class NewsCategoryLogic extends BaseLogic | @@ -61,6 +77,36 @@ class NewsCategoryLogic extends BaseLogic | ||
| 61 | } | 77 | } |
| 62 | 78 | ||
| 63 | /** | 79 | /** |
| 80 | + * @name :编辑分类 | ||
| 81 | + * @return void | ||
| 82 | + * @author :liyuhang | ||
| 83 | + * @method | ||
| 84 | + */ | ||
| 85 | + public function edit_news_category(){ | ||
| 86 | + $this->param['operator_id'] = $this->user['id']; | ||
| 87 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 88 | + if($rs === false){ | ||
| 89 | + $this->fail('error',Code::USER_ERROR); | ||
| 90 | + } | ||
| 91 | + return $this->success(); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * @name :修改状态 | ||
| 96 | + * @return array | ||
| 97 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 98 | + * @author :liyuhang | ||
| 99 | + * @method | ||
| 100 | + */ | ||
| 101 | + public function status_news_category(){ | ||
| 102 | + $this->param['operator_id'] = $this->user['id']; | ||
| 103 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 104 | + if($rs === false){ | ||
| 105 | + $this->fail('error',Code::USER_ERROR); | ||
| 106 | + } | ||
| 107 | + return $this->success(); | ||
| 108 | + } | ||
| 109 | + /** | ||
| 64 | * @name :删除新闻分类 | 110 | * @name :删除新闻分类 |
| 65 | * @return array | 111 | * @return array |
| 66 | * @throws \App\Exceptions\BsideGlobalException | 112 | * @throws \App\Exceptions\BsideGlobalException |
| @@ -2,9 +2,145 @@ | @@ -2,9 +2,145 @@ | ||
| 2 | 2 | ||
| 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\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | +use App\Models\News\News; | ||
| 8 | +use App\Models\News\NewsCategory as NewsCategoryModel; | ||
| 9 | +use App\Models\RouteMap; | ||
| 10 | +use Illuminate\Support\Facades\DB; | ||
| 6 | 11 | ||
| 7 | class NewsLogic extends BaseLogic | 12 | class NewsLogic extends BaseLogic |
| 8 | { | 13 | { |
| 14 | + public function __construct() | ||
| 15 | + { | ||
| 16 | + parent::__construct(); | ||
| 9 | 17 | ||
| 18 | + $this->model = new News(); | ||
| 19 | + $this->param = $this->requestAll; | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * @name :获取分类列表 | ||
| 24 | + * @return array | ||
| 25 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 26 | + * @author :liyuhang | ||
| 27 | + * @method | ||
| 28 | + */ | ||
| 29 | + public function news_get_category_list(){ | ||
| 30 | + $this->map['status'] = 0; | ||
| 31 | + $this->map['project_id'] = $this->user['project_id']; | ||
| 32 | + $newsCategoryModel = new NewsCategoryModel(); | ||
| 33 | + $cate_list = $newsCategoryModel->list($this->map,'sort'); | ||
| 34 | + if($cate_list === false){ | ||
| 35 | + $this->fail('error',Code::USER_ERROR); | ||
| 36 | + } | ||
| 37 | + $list = []; | ||
| 38 | + foreach ($cate_list as $v){ | ||
| 39 | + $v = (array)$v; | ||
| 40 | + if ($v['pid'] == 0) { | ||
| 41 | + $v['sub'] = _get_child($v['id'], $cate_list); | ||
| 42 | + $list[] = $v; | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + return $this->success($list); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * @name :添加博客 | ||
| 50 | + * @return void | ||
| 51 | + * @author :liyuhang | ||
| 52 | + * @method | ||
| 53 | + */ | ||
| 54 | + public function news_add(){ | ||
| 55 | + $this->param['create_id'] = $this->uid; | ||
| 56 | + $this->param['operator_id'] = $this->uid; | ||
| 57 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 58 | + DB::beginTransaction(); | ||
| 59 | + try { | ||
| 60 | + $rs = $this->model->insertGetId($this->param); | ||
| 61 | + RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); | ||
| 62 | + DB::commit(); | ||
| 63 | + }catch (\Exception $e){ | ||
| 64 | + DB::rollBack(); | ||
| 65 | + $this->fail('error',Code::USER_ERROR); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + //TODO::写入日志 | ||
| 69 | + $this->success(); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * @name :编辑 | ||
| 74 | + * @return void | ||
| 75 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 76 | + * @author :liyuhang | ||
| 77 | + * @method | ||
| 78 | + */ | ||
| 79 | + public function news_edit(){ | ||
| 80 | + $this->param['operator_id'] = $this->user['id']; | ||
| 81 | + //多个分类按逗号隔开 | ||
| 82 | + $this->param['category_id'] = ','.$this->param['category_id'].','; | ||
| 83 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 84 | + if($rs === false){ | ||
| 85 | + $this->fail('error',Code::USER_ERROR); | ||
| 86 | + } | ||
| 87 | + //TODO::写入日志 | ||
| 88 | + $this->success(); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * @name :修改状态 | ||
| 93 | + * @return void | ||
| 94 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 95 | + * @author :liyuhang | ||
| 96 | + * @method | ||
| 97 | + */ | ||
| 98 | + public function news_status(){ | ||
| 99 | + $this->param['operator_id'] = $this->user['id']; | ||
| 100 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 101 | + if($rs === false){ | ||
| 102 | + $this->fail('error',Code::USER_ERROR); | ||
| 103 | + } | ||
| 104 | + //TODO::写入日志 | ||
| 105 | + $this->success(); | ||
| 106 | + } | ||
| 107 | + /** | ||
| 108 | + * @name :获取详情 | ||
| 109 | + * @return array | ||
| 110 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 111 | + * @author :liyuhang | ||
| 112 | + * @method | ||
| 113 | + */ | ||
| 114 | + public function news_info(){ | ||
| 115 | + $this->param = $this->requestAll; | ||
| 116 | + $info = $this->model->read($this->param); | ||
| 117 | + //获取分类名称 | ||
| 118 | + $info['category_id'] = explode(',',trim($info['category_id'],',')); | ||
| 119 | + $newsCategoryModel = new NewsCategoryModel(); | ||
| 120 | + $category_list = $newsCategoryModel->list(['id'=>['in',$info['category_id']]],'id',['name']); | ||
| 121 | + $str = ''; | ||
| 122 | + foreach ($category_list as $v){ | ||
| 123 | + $str .= $v['name'].','; | ||
| 124 | + } | ||
| 125 | + $info['category_id'] = trim($str,','); | ||
| 126 | + if($info === false){ | ||
| 127 | + $this->fail('error',Code::USER_ERROR); | ||
| 128 | + } | ||
| 129 | + return $this->success($info); | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + /** | ||
| 133 | + * @name :逻辑删除 | ||
| 134 | + * @return void | ||
| 135 | + * @author :liyuhang | ||
| 136 | + * @method | ||
| 137 | + */ | ||
| 138 | + public function news_del(){ | ||
| 139 | + $this->param['id'] = ['in',$this->param['id']]; | ||
| 140 | + $rs = $this->model->edit(['status'=>2,'operator_id'=>$this->user['id']],$this->param); | ||
| 141 | + if($rs === false){ | ||
| 142 | + $this->fail('error',Code::USER_ERROR); | ||
| 143 | + } | ||
| 144 | + return $this->success(); | ||
| 145 | + } | ||
| 10 | } | 146 | } |
| @@ -32,7 +32,13 @@ class UserLogic extends BaseLogic | @@ -32,7 +32,13 @@ class UserLogic extends BaseLogic | ||
| 32 | //密码加密 | 32 | //密码加密 |
| 33 | $param['password'] = base64_encode(md5($this->param['password'])); | 33 | $param['password'] = base64_encode(md5($this->param['password'])); |
| 34 | //上传头像 | 34 | //上传头像 |
| 35 | +<<<<<<< HEAD | ||
| 35 | $rs = $this->model->add($param); | 36 | $rs = $this->model->add($param); |
| 37 | +======= | ||
| 38 | + $data = $this->upload(); | ||
| 39 | + $this->param['image'] = $data['path']; | ||
| 40 | + $rs = $this->model->add($this->param); | ||
| 41 | +>>>>>>> 035a3ec52f37cac95246eaab50090ce3f6c67bb2 | ||
| 36 | if($rs === false){ | 42 | if($rs === false){ |
| 37 | $this->fail('error',Code::USER_ERROR); | 43 | $this->fail('error',Code::USER_ERROR); |
| 38 | } | 44 | } |
| @@ -96,8 +96,7 @@ class Base extends Model | @@ -96,8 +96,7 @@ class Base extends Model | ||
| 96 | public function edit($data,$condition){ | 96 | public function edit($data,$condition){ |
| 97 | $query = $this->formatQuery($condition); | 97 | $query = $this->formatQuery($condition); |
| 98 | $data['updated_at'] = date('Y-m-d H:i:s'); | 98 | $data['updated_at'] = date('Y-m-d H:i:s'); |
| 99 | - $rs = $query->update($data); | ||
| 100 | - return $rs; | 99 | + return $query->update($data); |
| 101 | } | 100 | } |
| 102 | /** | 101 | /** |
| 103 | * @name : 删除数据 | 102 | * @name : 删除数据 |
| @@ -22,7 +22,9 @@ class RouteMap extends Model | @@ -22,7 +22,9 @@ class RouteMap extends Model | ||
| 22 | const SOURCE_PRODUCT_CATE = 'product_category'; | 22 | const SOURCE_PRODUCT_CATE = 'product_category'; |
| 23 | const SOURCE_PRODUCT_KEYWORD = 'product_keyword'; | 23 | const SOURCE_PRODUCT_KEYWORD = 'product_keyword'; |
| 24 | 24 | ||
| 25 | - | 25 | + //路由类型 |
| 26 | + const SOURCE_BLOG = 'blog'; | ||
| 27 | + const SOURCE_NEWS = 'news'; | ||
| 26 | /** | 28 | /** |
| 27 | * 生成路由标识 | 29 | * 生成路由标识 |
| 28 | * @param $title | 30 | * @param $title |
| @@ -93,21 +93,6 @@ class User extends Base | @@ -93,21 +93,6 @@ class User extends Base | ||
| 93 | return $info; | 93 | return $info; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | - //新增用户 | ||
| 97 | - public function adds($param){ | ||
| 98 | - //验证当前用户是否存在 | ||
| 99 | - $info = $this->read(['mobile'=>$param['mobile']]); | ||
| 100 | - if($info !== false){ | ||
| 101 | - return false; | ||
| 102 | - } | ||
| 103 | - //密码加密 | ||
| 104 | - $param['password'] = base64_encode(md5($param['password'])); | ||
| 105 | - $rs = $this->add($param); | ||
| 106 | - if($rs === false){ | ||
| 107 | - return false; | ||
| 108 | - } | ||
| 109 | - return true; | ||
| 110 | - } | ||
| 111 | 96 | ||
| 112 | /** | 97 | /** |
| 113 | * @param $param | 98 | * @param $param |
| @@ -28,7 +28,8 @@ | @@ -28,7 +28,8 @@ | ||
| 28 | "Database\\Seeders\\": "database/seeders/" | 28 | "Database\\Seeders\\": "database/seeders/" |
| 29 | }, | 29 | }, |
| 30 | "files": [ | 30 | "files": [ |
| 31 | - "app/Helper/helper.php" | 31 | + "app/Helper/helper.php", |
| 32 | + "app/Helper/common.php" | ||
| 32 | ] | 33 | ] |
| 33 | }, | 34 | }, |
| 34 | "autoload-dev": { | 35 | "autoload-dev": { |
| @@ -128,6 +128,4 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -128,6 +128,4 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 128 | //无需登录验证的路由组 | 128 | //无需登录验证的路由组 |
| 129 | Route::group([], function () { | 129 | Route::group([], function () { |
| 130 | Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login'); | 130 | Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login'); |
| 131 | - | ||
| 132 | - | ||
| 133 | }); | 131 | }); |
-
请 注册 或 登录 后发表评论