正在显示
11 个修改的文件
包含
58 行增加
和
120 行删除
| @@ -6,6 +6,7 @@ use App\Enums\Common\Code; | @@ -6,6 +6,7 @@ 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\BlogCategoryLogic; | 7 | use App\Http\Logic\Bside\Blog\BlogCategoryLogic; |
| 8 | use App\Http\Requests\Bside\Blog\BlogCategoryRequest; | 8 | use App\Http\Requests\Bside\Blog\BlogCategoryRequest; |
| 9 | +use App\Models\Blog\Blog as BlogModel; | ||
| 9 | use App\Models\Blog\BlogCategory as BlogCategoryModel; | 10 | use App\Models\Blog\BlogCategory as BlogCategoryModel; |
| 10 | 11 | ||
| 11 | class BlogCategoryController extends BaseController | 12 | class BlogCategoryController extends BaseController |
| @@ -21,6 +22,13 @@ class BlogCategoryController extends BaseController | @@ -21,6 +22,13 @@ class BlogCategoryController extends BaseController | ||
| 21 | $this->map['project_id'] = $this->user['project_id']; | 22 | $this->map['project_id'] = $this->user['project_id']; |
| 22 | $lists = $blogCategoryModel->lists($this->map,$this->page,$this->row,$this->order, | 23 | $lists = $blogCategoryModel->lists($this->map,$this->page,$this->row,$this->order, |
| 23 | ['id','pid','name','num','status','sort','remark','created_at','updated_at']); | 24 | ['id','pid','name','num','status','sort','remark','created_at','updated_at']); |
| 25 | + if(!empty($lists['list'])){ | ||
| 26 | + $blogModel = new BlogModel(); | ||
| 27 | + foreach ($lists['list'] as $k => $v){ | ||
| 28 | + $v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); | ||
| 29 | + $lists['list'][$k] = $v; | ||
| 30 | + } | ||
| 31 | + } | ||
| 24 | $this->response('success',Code::SUCCESS,$lists); | 32 | $this->response('success',Code::SUCCESS,$lists); |
| 25 | } | 33 | } |
| 26 | 34 |
| @@ -6,8 +6,8 @@ use App\Enums\Common\Code; | @@ -6,8 +6,8 @@ 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\NewsCategoryLogic; | 7 | use App\Http\Logic\Bside\News\NewsCategoryLogic; |
| 8 | use App\Http\Requests\Bside\News\NewsCategoryRequest; | 8 | use App\Http\Requests\Bside\News\NewsCategoryRequest; |
| 9 | +use App\Models\News\News as NewsModel; | ||
| 9 | use App\Models\News\NewsCategory as NewsCategoryModel; | 10 | use App\Models\News\NewsCategory as NewsCategoryModel; |
| 10 | -use Illuminate\Http\Request; | ||
| 11 | 11 | ||
| 12 | class NewsCategoryController extends BaseController | 12 | class NewsCategoryController extends BaseController |
| 13 | { | 13 | { |
| @@ -22,6 +22,13 @@ class NewsCategoryController extends BaseController | @@ -22,6 +22,13 @@ class NewsCategoryController extends BaseController | ||
| 22 | $this->map['project_id'] = $this->user['project_id']; | 22 | $this->map['project_id'] = $this->user['project_id']; |
| 23 | $lists = $newsCategory->lists($this->map,$this->page,$this->row,$this->order, | 23 | $lists = $newsCategory->lists($this->map,$this->page,$this->row,$this->order, |
| 24 | ['id','pid','name','num','status','sort','remark','created_at','updated_at']); | 24 | ['id','pid','name','num','status','sort','remark','created_at','updated_at']); |
| 25 | + if(!empty($lists['list'])){ | ||
| 26 | + $newsModel = new NewsModel(); | ||
| 27 | + foreach ($lists['list'] as $k => $v){ | ||
| 28 | + $v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); | ||
| 29 | + $lists['list'][$k] = $v; | ||
| 30 | + } | ||
| 31 | + } | ||
| 25 | $this->response('success',Code::SUCCESS,$lists); | 32 | $this->response('success',Code::SUCCESS,$lists); |
| 26 | } | 33 | } |
| 27 | 34 |
| @@ -14,13 +14,6 @@ use Intervention\Image\Facades\Image; | @@ -14,13 +14,6 @@ use Intervention\Image\Facades\Image; | ||
| 14 | class ImageController | 14 | class ImageController |
| 15 | { | 15 | { |
| 16 | public $upload_img = [ | 16 | public $upload_img = [ |
| 17 | - //验证 | ||
| 18 | - 'rule' => [ | ||
| 19 | - 'size' => 3 * 1024 * 1024, //大小限制 | ||
| 20 | - 'ext' => 'jpeg,jpg,png,gif', //文件类型限制 | ||
| 21 | - ], | ||
| 22 | - //生成文件规则 | ||
| 23 | - 'savename' => 'uniqid', | ||
| 24 | //设置静态缓存参数(304) | 17 | //设置静态缓存参数(304) |
| 25 | 'header' => [ | 18 | 'header' => [ |
| 26 | 'Cache-Control' => 'max-age=2592000', | 19 | 'Cache-Control' => 'max-age=2592000', |
| @@ -30,16 +23,17 @@ class ImageController | @@ -30,16 +23,17 @@ class ImageController | ||
| 30 | 'Last-Modified' => "%Last-Modified%", | 23 | 'Last-Modified' => "%Last-Modified%", |
| 31 | 'Content-Description' => 'File Transfer', | 24 | 'Content-Description' => 'File Transfer', |
| 32 | ], | 25 | ], |
| 33 | - //图片保存根路径 | ||
| 34 | - 'path' => './uploads/images/', | ||
| 35 | - //图片上传变量名 | ||
| 36 | - 'name' => 'image', | ||
| 37 | ]; | 26 | ]; |
| 27 | + public $path = ''; | ||
| 28 | + | ||
| 29 | + public $thr_path = ''; | ||
| 30 | + | ||
| 38 | public $request = ''; | 31 | public $request = ''; |
| 39 | 32 | ||
| 40 | public function __construct(Request $request) | 33 | public function __construct(Request $request) |
| 41 | { | 34 | { |
| 42 | $this->request = $request; | 35 | $this->request = $request; |
| 36 | + $this->path = config('filesystems.disks')['upload']['root'].config('upload'); | ||
| 43 | } | 37 | } |
| 44 | 38 | ||
| 45 | public function index($hash = '', $w = 0 ,$h = 0){ | 39 | public function index($hash = '', $w = 0 ,$h = 0){ |
| @@ -53,7 +47,7 @@ class ImageController | @@ -53,7 +47,7 @@ class ImageController | ||
| 53 | $this->response('指定图片不存在!', Code::USER_ERROR); | 47 | $this->response('指定图片不存在!', Code::USER_ERROR); |
| 54 | } | 48 | } |
| 55 | //查看缩略图是否存在 | 49 | //查看缩略图是否存在 |
| 56 | - $filename = './../uploads/images/cache_'. $info['hash'] . $w . '_' . $h; | 50 | + $filename = $this->path . $info['hash'] . $w . '_' . $h; |
| 57 | if(is_file($filename)){ | 51 | if(is_file($filename)){ |
| 58 | $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT"; | 52 | $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT"; |
| 59 | $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'], | 53 | $header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'], |
| @@ -111,7 +105,7 @@ class ImageController | @@ -111,7 +105,7 @@ class ImageController | ||
| 111 | */ | 105 | */ |
| 112 | public function single($files){ | 106 | public function single($files){ |
| 113 | $hash = hash_file('md5', $files->getPathname()); | 107 | $hash = hash_file('md5', $files->getPathname()); |
| 114 | - $url = './../uploads/images/'; | 108 | + $url = $this->path; |
| 115 | $filename = date('ymdHis').rand(10000,99999); | 109 | $filename = date('ymdHis').rand(10000,99999); |
| 116 | $res = $this->request->file('image')->move($url,$filename); | 110 | $res = $this->request->file('image')->move($url,$filename); |
| 117 | if ($res === false) { | 111 | if ($res === false) { |
| @@ -140,7 +134,7 @@ class ImageController | @@ -140,7 +134,7 @@ class ImageController | ||
| 140 | */ | 134 | */ |
| 141 | private function cacheImage($info, $w, $h) { | 135 | private function cacheImage($info, $w, $h) { |
| 142 | $path = $info['path']; | 136 | $path = $info['path']; |
| 143 | - $filename = './../uploads/images/cache_'. $info['hash'] . $w . '_' . $h; | 137 | + $filename = $this->path . $info['hash'] . $w . '_' . $h; |
| 144 | Image::make($path)->resize($w, $h)->save($filename); | 138 | Image::make($path)->resize($w, $h)->save($filename); |
| 145 | return $filename; | 139 | return $filename; |
| 146 | } | 140 | } |
| @@ -158,7 +152,7 @@ class ImageController | @@ -158,7 +152,7 @@ class ImageController | ||
| 158 | $data = []; | 152 | $data = []; |
| 159 | foreach ($files as $file) { | 153 | foreach ($files as $file) { |
| 160 | $hash = hash_file('md5', $file->getPathname()); | 154 | $hash = hash_file('md5', $file->getPathname()); |
| 161 | - $url = './../uploads/images/'; | 155 | + $url = $this->path; |
| 162 | $filename = date('ymdHis').rand(10000,99999); | 156 | $filename = date('ymdHis').rand(10000,99999); |
| 163 | $res = $file->move($url,$filename); | 157 | $res = $file->move($url,$filename); |
| 164 | if ($res === false) { | 158 | if ($res === false) { |
| @@ -67,9 +67,9 @@ class BlogCategoryLogic extends BaseLogic | @@ -67,9 +67,9 @@ class BlogCategoryLogic extends BaseLogic | ||
| 67 | if ($cate_info === false) { | 67 | if ($cate_info === false) { |
| 68 | //查看当前上一级分类下是否有新闻 | 68 | //查看当前上一级分类下是否有新闻 |
| 69 | $blogModel = new BlogModel(); | 69 | $blogModel = new BlogModel(); |
| 70 | - $blog_info = $blogModel->read(['category_id' => ['like', ',' . $this->param['pid'] . ',']]); | ||
| 71 | - if ($blog_info !== false) { | ||
| 72 | - $replacement = ',' . $cate_id . ','; | 70 | + $blog_count = $blogModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count(); |
| 71 | + if ($blog_count > 0) { | ||
| 72 | + $replacement = ','. $this->param['pid'] . ',' . $cate_id . ','; | ||
| 73 | $old = ',' . $this->param['pid'] . ','; | 73 | $old = ',' . $this->param['pid'] . ','; |
| 74 | //更新所有商品到当前分类 | 74 | //更新所有商品到当前分类 |
| 75 | DB::table('gl_Blog')->where('category_id', 'like', '%' . $old . '%') | 75 | DB::table('gl_Blog')->where('category_id', 'like', '%' . $old . '%') |
| @@ -75,9 +75,6 @@ class BlogLogic extends BaseLogic | @@ -75,9 +75,6 @@ class BlogLogic extends BaseLogic | ||
| 75 | $this->param['image'] = $data; | 75 | $this->param['image'] = $data; |
| 76 | } | 76 | } |
| 77 | $rs = $this->model->insertGetId($this->param); | 77 | $rs = $this->model->insertGetId($this->param); |
| 78 | - //分类计数 | ||
| 79 | - $category_data = explode(',',trim($this->param['category_id'],',')); | ||
| 80 | - $this->set_num(BlogCategoryModel::class,$category_data); | ||
| 81 | 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']); |
| 82 | DB::commit(); | 79 | DB::commit(); |
| 83 | }catch (\Exception $e){ | 80 | }catch (\Exception $e){ |
| @@ -106,11 +103,6 @@ class BlogLogic extends BaseLogic | @@ -106,11 +103,6 @@ class BlogLogic extends BaseLogic | ||
| 106 | $this->param['operator_id'] = $this->user['id']; | 103 | $this->param['operator_id'] = $this->user['id']; |
| 107 | DB::beginTransaction(); | 104 | DB::beginTransaction(); |
| 108 | try { | 105 | try { |
| 109 | - $info = $this->model->read(['id'=>$this->param['id']],['id','image','category_id']); | ||
| 110 | - //查看分类是否有更新 | ||
| 111 | - if($info['category_id'] !== $this->param['category_id']){ | ||
| 112 | - $this->update_category_num($info['category_id'],$this->param['category_id']); | ||
| 113 | - } | ||
| 114 | //是否有图片更新 | 106 | //是否有图片更新 |
| 115 | if(isset($this->param['image']) && is_file($this->param['image'])){ | 107 | if(isset($this->param['image']) && is_file($this->param['image'])){ |
| 116 | //查看当前用户是否已有头像 | 108 | //查看当前用户是否已有头像 |
| @@ -183,7 +175,7 @@ class BlogLogic extends BaseLogic | @@ -183,7 +175,7 @@ class BlogLogic extends BaseLogic | ||
| 183 | $this->param['operator_id'] = $this->user['id']; | 175 | $this->param['operator_id'] = $this->user['id']; |
| 184 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 176 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 185 | if($rs === false){ | 177 | if($rs === false){ |
| 186 | - $this->fail('error',Code::USER_ERROR); | 178 | + $this->fail('error'); |
| 187 | } | 179 | } |
| 188 | return $this->success(); | 180 | return $this->success(); |
| 189 | } | 181 | } |
| @@ -196,51 +188,15 @@ class BlogLogic extends BaseLogic | @@ -196,51 +188,15 @@ class BlogLogic extends BaseLogic | ||
| 196 | */ | 188 | */ |
| 197 | public function blog_del(){ | 189 | public function blog_del(){ |
| 198 | $ids = $this->param['id']; | 190 | $ids = $this->param['id']; |
| 199 | - //获取所有博客的分类id | ||
| 200 | - $str = $this->get_category_id($ids); | ||
| 201 | DB::beginTransaction(); | 191 | DB::beginTransaction(); |
| 202 | try { | 192 | try { |
| 203 | - $category_data = explode(',',$str); | ||
| 204 | - //分类计数减1 | ||
| 205 | - $this->set_num(BlogCategoryModel::class,$category_data,'del'); | ||
| 206 | $this->param['id'] = ['in',$this->param['id']]; | 193 | $this->param['id'] = ['in',$this->param['id']]; |
| 207 | $this->del($this->param,$ids); | 194 | $this->del($this->param,$ids); |
| 208 | DB::commit(); | 195 | DB::commit(); |
| 209 | }catch (Exception $e){ | 196 | }catch (Exception $e){ |
| 210 | DB::rollBack(); | 197 | DB::rollBack(); |
| 211 | - $this->fail('当前数据不存在'); | 198 | + $this->fail('error'); |
| 212 | } | 199 | } |
| 213 | return $this->success(); | 200 | return $this->success(); |
| 214 | } | 201 | } |
| 215 | - /** | ||
| 216 | - * @param $ids | ||
| 217 | - * @name :删除数据时获取所有数据的分类id | ||
| 218 | - * @return void | ||
| 219 | - * @author :liyuhang | ||
| 220 | - * @method | ||
| 221 | - */ | ||
| 222 | - public function get_category_id($ids = []){ | ||
| 223 | - $str = ''; | ||
| 224 | - $list = $this->model->list(['id'=>['in',$ids]],'id',['id','category_id']); | ||
| 225 | - foreach ($list as $v){ | ||
| 226 | - $str .= trim($v['category_id'],',').','; | ||
| 227 | - } | ||
| 228 | - return trim($str,','); | ||
| 229 | - } | ||
| 230 | - | ||
| 231 | - /** | ||
| 232 | - * @name :编辑分类时更新分类计数 | ||
| 233 | - * @return void | ||
| 234 | - * @author :liyuhang | ||
| 235 | - * @method | ||
| 236 | - */ | ||
| 237 | - public function update_category_num($category_del = '',$category_add = ''){ | ||
| 238 | - //分类计数(减) | ||
| 239 | - $category_del_data = explode(',',trim($category_del,',')); | ||
| 240 | - $this->set_num(BlogCategoryModel::class,$category_del_data); | ||
| 241 | - //分类计数(加) | ||
| 242 | - $category_add_data = explode(',',trim($category_add,',')); | ||
| 243 | - $this->set_num(BlogCategoryModel::class,$category_add_data,'del'); | ||
| 244 | - return true; | ||
| 245 | - } | ||
| 246 | } | 202 | } |
| @@ -77,15 +77,13 @@ class NewsCategoryLogic extends BaseLogic | @@ -77,15 +77,13 @@ class NewsCategoryLogic extends BaseLogic | ||
| 77 | if ($cate_info === false) { | 77 | if ($cate_info === false) { |
| 78 | //查看当前上一级分类下是否有新闻 | 78 | //查看当前上一级分类下是否有新闻 |
| 79 | $newsModel = new NewsModel(); | 79 | $newsModel = new NewsModel(); |
| 80 | - $news_count = $newsModel->formatQuery(['category_id' => ['like', ',' . $this->param['pid'] . ',']])->count(); | 80 | + $news_count = $newsModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count(); |
| 81 | if ($news_count > 0) { | 81 | if ($news_count > 0) { |
| 82 | $replacement = ','. $this->param['pid'] .','. $cate_id . ','; | 82 | $replacement = ','. $this->param['pid'] .','. $cate_id . ','; |
| 83 | $old = ',' . $this->param['pid'] . ','; | 83 | $old = ',' . $this->param['pid'] . ','; |
| 84 | //更新所有商品到当前分类 | 84 | //更新所有商品到当前分类 |
| 85 | DB::table('gl_news')->where('category_id', 'like', '%' . $old . '%') | 85 | DB::table('gl_news')->where('category_id', 'like', '%' . $old . '%') |
| 86 | ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]); | 86 | ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]); |
| 87 | - //更新计数 | ||
| 88 | - $this->set_num($this->model,$cate_id,'add',$news_count); | ||
| 89 | } | 87 | } |
| 90 | } | 88 | } |
| 91 | } | 89 | } |
| @@ -106,10 +104,10 @@ class NewsCategoryLogic extends BaseLogic | @@ -106,10 +104,10 @@ class NewsCategoryLogic extends BaseLogic | ||
| 106 | public function edit_news_category(){ | 104 | public function edit_news_category(){ |
| 107 | $condition = [ | 105 | $condition = [ |
| 108 | 'id'=>['!=',$this->param['id']], | 106 | 'id'=>['!=',$this->param['id']], |
| 109 | - 'name'=>$this->param['name'] | 107 | + 'name'=>$this->param['name'], |
| 110 | ]; | 108 | ]; |
| 111 | //查看当前分类名称是否存在 | 109 | //查看当前分类名称是否存在 |
| 112 | - $info = $this->model->read($condition); | 110 | + $info = $this->model->read($condition,['id']); |
| 113 | if($info !== false){ | 111 | if($info !== false){ |
| 114 | $this->fail('当前分类名称已存在'); | 112 | $this->fail('当前分类名称已存在'); |
| 115 | } | 113 | } |
| @@ -67,9 +67,6 @@ class NewsLogic extends BaseLogic | @@ -67,9 +67,6 @@ class NewsLogic extends BaseLogic | ||
| 67 | $this->param['image'] = $data; | 67 | $this->param['image'] = $data; |
| 68 | } | 68 | } |
| 69 | $rs = $this->model->insertGetId($this->param); | 69 | $rs = $this->model->insertGetId($this->param); |
| 70 | - //产品计数 | ||
| 71 | - $category_data = explode(',',trim($this->param['category_id'],',')); | ||
| 72 | - $this->set_num(NewsCategoryModel::class,$category_data); | ||
| 73 | 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']); |
| 74 | DB::commit(); | 71 | DB::commit(); |
| 75 | }catch (\Exception $e){ | 72 | }catch (\Exception $e){ |
| @@ -95,15 +92,8 @@ class NewsLogic extends BaseLogic | @@ -95,15 +92,8 @@ class NewsLogic extends BaseLogic | ||
| 95 | $this->fail('当前名称已存在'); | 92 | $this->fail('当前名称已存在'); |
| 96 | } | 93 | } |
| 97 | $this->param['operator_id'] = $this->user['id']; | 94 | $this->param['operator_id'] = $this->user['id']; |
| 98 | - //多个分类按逗号隔开 | ||
| 99 | - $this->param['category_id'] = $this->param['category_id']; | ||
| 100 | DB::beginTransaction(); | 95 | DB::beginTransaction(); |
| 101 | try { | 96 | try { |
| 102 | - $info = $this->model->read(['id'=>$this->param['id']],['id','image','category_id']); | ||
| 103 | - //查看分类是否有跟新 | ||
| 104 | - if($info['category_id'] !== $this->param['category_id']){ | ||
| 105 | - $this->update_category_num($info['category_id'],$this->param['category_id']); | ||
| 106 | - } | ||
| 107 | //上传图片 | 97 | //上传图片 |
| 108 | if(isset($this->param['image']) && is_file($this->param['image'])){ | 98 | if(isset($this->param['image']) && is_file($this->param['image'])){ |
| 109 | //查看当前用户是否已有头像 | 99 | //查看当前用户是否已有头像 |
| @@ -188,13 +178,8 @@ class NewsLogic extends BaseLogic | @@ -188,13 +178,8 @@ class NewsLogic extends BaseLogic | ||
| 188 | */ | 178 | */ |
| 189 | public function news_del(){ | 179 | public function news_del(){ |
| 190 | $ids = $this->param['id']; | 180 | $ids = $this->param['id']; |
| 191 | - //获取当前新闻下的所有新闻分类id | ||
| 192 | - $str = $this->get_category_id($ids); | ||
| 193 | DB::beginTransaction(); | 181 | DB::beginTransaction(); |
| 194 | try { | 182 | try { |
| 195 | - $category_data = explode(',',$str); | ||
| 196 | - //减计数 | ||
| 197 | - $this->set_num(NewsCategoryModel::class,$category_data,'del'); | ||
| 198 | $this->param['id'] = ['in',$this->param['id']]; | 183 | $this->param['id'] = ['in',$this->param['id']]; |
| 199 | $this->del($this->param,$ids); | 184 | $this->del($this->param,$ids); |
| 200 | DB::commit(); | 185 | DB::commit(); |
| @@ -205,35 +190,4 @@ class NewsLogic extends BaseLogic | @@ -205,35 +190,4 @@ class NewsLogic extends BaseLogic | ||
| 205 | return $this->success(); | 190 | return $this->success(); |
| 206 | } | 191 | } |
| 207 | 192 | ||
| 208 | - /** | ||
| 209 | - * @param $ids | ||
| 210 | - * @name :删除数据时获取所有数据的分类id | ||
| 211 | - * @return void | ||
| 212 | - * @author :liyuhang | ||
| 213 | - * @method | ||
| 214 | - */ | ||
| 215 | - public function get_category_id($ids){ | ||
| 216 | - $str = ''; | ||
| 217 | - $list = $this->model->list(['id'=>['in',$ids]],'id',['id','category_id']); | ||
| 218 | - foreach ($list as $v){ | ||
| 219 | - $str .= trim($v['category_id'],',').','; | ||
| 220 | - } | ||
| 221 | - return trim($str,','); | ||
| 222 | - } | ||
| 223 | - | ||
| 224 | - /** | ||
| 225 | - * @name :编辑分类时更新分类计数 | ||
| 226 | - * @return void | ||
| 227 | - * @author :liyuhang | ||
| 228 | - * @method | ||
| 229 | - */ | ||
| 230 | - public function update_category_num($category_del = '',$category_add = ''){ | ||
| 231 | - //分类计数(减) | ||
| 232 | - $category_del_data = explode(',',trim($category_del,',')); | ||
| 233 | - $this->set_num(NewsCategoryModel::class,$category_del_data); | ||
| 234 | - //分类计数(加) | ||
| 235 | - $category_add_data = explode(',',trim($category_add,',')); | ||
| 236 | - $this->set_num(NewsCategoryModel::class,$category_add_data,'del'); | ||
| 237 | - return true; | ||
| 238 | - } | ||
| 239 | } | 193 | } |
| @@ -369,10 +369,10 @@ class Logic | @@ -369,10 +369,10 @@ class Logic | ||
| 369 | * @author :liyuhang | 369 | * @author :liyuhang |
| 370 | * @method | 370 | * @method |
| 371 | */ | 371 | */ |
| 372 | - public function info($map){ | 372 | + public function info($map,$file = ['*']){ |
| 373 | $info = CommonHelper::get_user_cache($this->model->getTable(),$map['id']); | 373 | $info = CommonHelper::get_user_cache($this->model->getTable(),$map['id']); |
| 374 | if(empty($info)){ | 374 | if(empty($info)){ |
| 375 | - $info = $this->model->read($map); | 375 | + $info = $this->model->read($map,$file); |
| 376 | if($info === false){ | 376 | if($info === false){ |
| 377 | $this->fail('当前数据不存在'); | 377 | $this->fail('当前数据不存在'); |
| 378 | } | 378 | } |
| @@ -26,7 +26,7 @@ class BlogCategoryRequest extends FormRequest | @@ -26,7 +26,7 @@ class BlogCategoryRequest extends FormRequest | ||
| 26 | return [ | 26 | return [ |
| 27 | 'name'=>'required|max:100', | 27 | 'name'=>'required|max:100', |
| 28 | 'remark'=>'required|max:255', | 28 | 'remark'=>'required|max:255', |
| 29 | - 'alias'=>'required|max:10', | 29 | + 'alias'=>'required|max:10|unique:gl_blog_category,alias', |
| 30 | ]; | 30 | ]; |
| 31 | } | 31 | } |
| 32 | 32 |
| @@ -26,7 +26,7 @@ class NewsCategoryRequest extends FormRequest | @@ -26,7 +26,7 @@ class NewsCategoryRequest extends FormRequest | ||
| 26 | return [ | 26 | return [ |
| 27 | 'name'=>'required|max:100', | 27 | 'name'=>'required|max:100', |
| 28 | 'remark'=>'required|max:255', | 28 | 'remark'=>'required|max:255', |
| 29 | - 'alias'=>'required|max:10', | 29 | + 'alias'=>'required|max:10|unique:gl_news_category,alias', |
| 30 | ]; | 30 | ]; |
| 31 | } | 31 | } |
| 32 | 32 |
| @@ -14,4 +14,25 @@ return [ | @@ -14,4 +14,25 @@ return [ | ||
| 14 | ], | 14 | ], |
| 15 | 'path' => '/product' | 15 | 'path' => '/product' |
| 16 | ], | 16 | ], |
| 17 | + //用户头像 | ||
| 18 | + 'user' =>[ | ||
| 19 | + 'size' => [ | ||
| 20 | + 'max' => 1024*1024*2, // 2M | ||
| 21 | + ], | ||
| 22 | + 'path' => '/user' | ||
| 23 | + ], | ||
| 24 | + //博客图 | ||
| 25 | + 'blog' =>[ | ||
| 26 | + 'size' => [ | ||
| 27 | + 'max' => 1024*1024*2, // 2M | ||
| 28 | + ], | ||
| 29 | + 'path' => '/blog' | ||
| 30 | + ], | ||
| 31 | + //新闻图 | ||
| 32 | + 'news' =>[ | ||
| 33 | + 'size' => [ | ||
| 34 | + 'max' => 1024*1024*2, // 2M | ||
| 35 | + ], | ||
| 36 | + 'path' => '/news' | ||
| 37 | + ], | ||
| 17 | ]; | 38 | ]; |
-
请 注册 或 登录 后发表评论