Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev
正在显示
6 个修改的文件
包含
87 行增加
和
34 行删除
| @@ -117,7 +117,7 @@ class BaseController extends Controller | @@ -117,7 +117,7 @@ class BaseController extends Controller | ||
| 117 | $result = [ | 117 | $result = [ |
| 118 | 'msg' => $msg == ' ' ? $code->description : $msg, | 118 | 'msg' => $msg == ' ' ? $code->description : $msg, |
| 119 | 'code' => $code->value, | 119 | 'code' => $code->value, |
| 120 | - 'data' => $data, | 120 | + 'data' => $this->_extents($data), |
| 121 | ]; | 121 | ]; |
| 122 | $this->header['Content-Type'] = $type; | 122 | $this->header['Content-Type'] = $type; |
| 123 | $this->header['token'] = $this->token; | 123 | $this->header['token'] = $this->token; |
| @@ -144,5 +144,26 @@ class BaseController extends Controller | @@ -144,5 +144,26 @@ class BaseController extends Controller | ||
| 144 | return $new_arr ? $new_arr : false; | 144 | return $new_arr ? $new_arr : false; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | + protected function _extents($data) { | ||
| 147 | 148 | ||
| 149 | + if (empty($data) || !is_array($data)) { | ||
| 150 | + return empty($data) ? is_array($data) ? [] : '' : $data; | ||
| 151 | + } | ||
| 152 | + foreach ($data as $k => $v) { | ||
| 153 | + if (is_array($v)) { | ||
| 154 | + $data[$k] = $this->_extents($v); | ||
| 155 | + } else { | ||
| 156 | + if (is_null($v)) { | ||
| 157 | + $data[$k] = ''; | ||
| 158 | + continue; | ||
| 159 | + } | ||
| 160 | + switch ((string) $k) { | ||
| 161 | + case 'image': | ||
| 162 | + $v['image_link'] = file_get_contents($v); | ||
| 163 | + break; | ||
| 164 | + } | ||
| 165 | + } | ||
| 166 | + } | ||
| 167 | + return $data; | ||
| 168 | + } | ||
| 148 | } | 169 | } |
| @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Bside\Blog; | @@ -4,6 +4,7 @@ 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\BlogLabelLogic; | ||
| 7 | use App\Http\Requests\Bside\Blog\BlogLabelRequest; | 8 | use App\Http\Requests\Bside\Blog\BlogLabelRequest; |
| 8 | use App\Models\Blog\BlogLabel as BlogLabelModel; | 9 | use App\Models\Blog\BlogLabel as BlogLabelModel; |
| 9 | use Illuminate\Http\Request; | 10 | use Illuminate\Http\Request; |
| @@ -27,15 +28,9 @@ class BlogLabelController extends BaseController | @@ -27,15 +28,9 @@ class BlogLabelController extends BaseController | ||
| 27 | * @author :liyuhang | 28 | * @author :liyuhang |
| 28 | * @method | 29 | * @method |
| 29 | */ | 30 | */ |
| 30 | - public function add(BlogLabelRequest $request,BlogLabelModel $blogLabelModel){ | 31 | + public function add(BlogLabelRequest $request,BlogLabelLogic $blogLabelLogic){ |
| 31 | $request->validated(); | 32 | $request->validated(); |
| 32 | - $this->param['create_id'] = $this->uid; | ||
| 33 | - $this->param['Operator_id'] = $this->uid; | ||
| 34 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 35 | - $rs = $blogLabelModel->add($this->param); | ||
| 36 | - if($rs === false){ | ||
| 37 | - $this->response('error',Code::USER_ERROR); | ||
| 38 | - } | 33 | + $blogLabelLogic->add_blog_label(); |
| 39 | //TODO::写入日志 | 34 | //TODO::写入日志 |
| 40 | $this->response('success'); | 35 | $this->response('success'); |
| 41 | } | 36 | } |
| @@ -46,18 +41,13 @@ class BlogLabelController extends BaseController | @@ -46,18 +41,13 @@ class BlogLabelController extends BaseController | ||
| 46 | * @author :liyuhang | 41 | * @author :liyuhang |
| 47 | * @method | 42 | * @method |
| 48 | */ | 43 | */ |
| 49 | - public function edit(BlogLabelRequest $request,BlogLabelModel $blogLabelModel){ | 44 | + public function edit(BlogLabelRequest $request,BlogLabelLogic $blogLabelLogic){ |
| 50 | $request->validate([ | 45 | $request->validate([ |
| 51 | 'id'=>['required'] | 46 | 'id'=>['required'] |
| 52 | ],[ | 47 | ],[ |
| 53 | 'id.required' => 'ID不能为空' | 48 | 'id.required' => 'ID不能为空' |
| 54 | ]); | 49 | ]); |
| 55 | - $this->param['operator_id'] = $this->uid; | ||
| 56 | - $rs = $blogLabelModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 57 | - //TODO::路由映射 | ||
| 58 | - if($rs === false){ | ||
| 59 | - $this->response('error',Code::USER_ERROR); | ||
| 60 | - } | 50 | + $blogLabelLogic->edit_blog_label(); |
| 61 | //TODO::写入日志 | 51 | //TODO::写入日志 |
| 62 | $this->response('success'); | 52 | $this->response('success'); |
| 63 | } | 53 | } |
| @@ -68,17 +58,13 @@ class BlogLabelController extends BaseController | @@ -68,17 +58,13 @@ class BlogLabelController extends BaseController | ||
| 68 | * @author :liyuhang | 58 | * @author :liyuhang |
| 69 | * @method | 59 | * @method |
| 70 | */ | 60 | */ |
| 71 | - public function status(Request $request,BlogLabelModel $blogLabelModel){ | 61 | + public function status(Request $request,BlogLabelLogic $blogLabelLogic){ |
| 72 | $request->validate([ | 62 | $request->validate([ |
| 73 | 'id'=>['required'], | 63 | 'id'=>['required'], |
| 74 | ],[ | 64 | ],[ |
| 75 | 'id.required' => 'ID不能为空', | 65 | 'id.required' => 'ID不能为空', |
| 76 | ]); | 66 | ]); |
| 77 | - $this->param['Operator_id'] = $this->uid; | ||
| 78 | - $rs = $blogLabelModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 79 | - if($rs === false){ | ||
| 80 | - $this->response('error',Code::USER_ERROR); | ||
| 81 | - } | 67 | + $blogLabelLogic->edit_blog_label(); |
| 82 | //TODO::写入日志 | 68 | //TODO::写入日志 |
| 83 | $this->response('success'); | 69 | $this->response('success'); |
| 84 | } | 70 | } |
| @@ -89,17 +75,13 @@ class BlogLabelController extends BaseController | @@ -89,17 +75,13 @@ class BlogLabelController extends BaseController | ||
| 89 | * @author :liyuhang | 75 | * @author :liyuhang |
| 90 | * @method | 76 | * @method |
| 91 | */ | 77 | */ |
| 92 | - public function del(Request $request,BlogLabelModel $blogLabelModel){ | 78 | + public function del(Request $request,BlogLabelLogic $blogLabelLogic){ |
| 93 | $request->validate([ | 79 | $request->validate([ |
| 94 | 'id'=>['required'], | 80 | 'id'=>['required'], |
| 95 | ],[ | 81 | ],[ |
| 96 | 'id.required' => 'ID不能为空', | 82 | 'id.required' => 'ID不能为空', |
| 97 | ]); | 83 | ]); |
| 98 | - $this->param['id'] = ['in',$this->param['id']]; | ||
| 99 | - $rs = $blogLabelModel->del($this->param); | ||
| 100 | - if($rs === false){ | ||
| 101 | - $this->response('error',Code::USER_ERROR); | ||
| 102 | - } | 84 | + $blogLabelLogic->del_blog_label(); |
| 103 | $this->response('success'); | 85 | $this->response('success'); |
| 104 | } | 86 | } |
| 105 | } | 87 | } |
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 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; |
| 6 | use App\Models\Blog\BlogLabel as BlogLabelModel; | 7 | use App\Models\Blog\BlogLabel as BlogLabelModel; |
| 7 | 8 | ||
| @@ -14,4 +15,52 @@ class BlogLabelLogic extends BaseLogic | @@ -14,4 +15,52 @@ class BlogLabelLogic extends BaseLogic | ||
| 14 | $this->model = new BlogLabelModel(); | 15 | $this->model = new BlogLabelModel(); |
| 15 | $this->param = $this->requestAll; | 16 | $this->param = $this->requestAll; |
| 16 | } | 17 | } |
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * @name :新增标签 | ||
| 21 | + * @return void | ||
| 22 | + * @author :liyuhang | ||
| 23 | + * @method | ||
| 24 | + */ | ||
| 25 | + public function add_blog_label(){ | ||
| 26 | + $this->param['create_id'] = $this->user['id']; | ||
| 27 | + $this->param['Operator_id'] = $this->user['id']; | ||
| 28 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 29 | + $rs = $this->model->add($this->param); | ||
| 30 | + if($rs === false){ | ||
| 31 | + $this->fail('error',Code::USER_ERROR); | ||
| 32 | + } | ||
| 33 | + return $this->success(); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * @name :编辑标签 | ||
| 38 | + * @return void | ||
| 39 | + * @author :liyuhang | ||
| 40 | + * @method | ||
| 41 | + */ | ||
| 42 | + public function edit_blog_label(){ | ||
| 43 | + $this->param['operator_id'] = $this->user['id']; | ||
| 44 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 45 | + //TODO::路由映射 | ||
| 46 | + if($rs === false){ | ||
| 47 | + $this->fail('error',Code::USER_ERROR); | ||
| 48 | + } | ||
| 49 | + return $this->success(); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * @name :删除标签 | ||
| 54 | + * @return array | ||
| 55 | + * @author :liyuhang | ||
| 56 | + * @method | ||
| 57 | + */ | ||
| 58 | + public function del_blog_label(){ | ||
| 59 | + $this->param['id'] = ['in',$this->param['id']]; | ||
| 60 | + $rs = $this->model->del($this->param); | ||
| 61 | + if($rs === false){ | ||
| 62 | + $this->fail('error',Code::USER_ERROR); | ||
| 63 | + } | ||
| 64 | + return $this->success(); | ||
| 65 | + } | ||
| 17 | } | 66 | } |
| @@ -93,7 +93,7 @@ class RoleLogic extends BaseLogic | @@ -93,7 +93,7 @@ class RoleLogic extends BaseLogic | ||
| 93 | } | 93 | } |
| 94 | } | 94 | } |
| 95 | $this->param['id'] = ['in',$this->param['id']]; | 95 | $this->param['id'] = ['in',$this->param['id']]; |
| 96 | - $rs = $this->model->del(['id'=>$this->param['id']]); | 96 | + $rs = $this->model->del($this->param); |
| 97 | if($rs === false){ | 97 | if($rs === false){ |
| 98 | $this->fail('error',Code::USER_ERROR); | 98 | $this->fail('error',Code::USER_ERROR); |
| 99 | } | 99 | } |
| @@ -131,7 +131,7 @@ class RoleLogic extends BaseLogic | @@ -131,7 +131,7 @@ class RoleLogic extends BaseLogic | ||
| 131 | foreach ($lists as $k => $v){ | 131 | foreach ($lists as $k => $v){ |
| 132 | $v = (array)$v; | 132 | $v = (array)$v; |
| 133 | if ($v['pid'] == 0) { | 133 | if ($v['pid'] == 0) { |
| 134 | - $v['sub'] = $this->_get_child($v['id'], $lists); | 134 | + $v['sub'] = _get_child($v['id'], $lists); |
| 135 | $menu[] = $v; | 135 | $menu[] = $v; |
| 136 | } | 136 | } |
| 137 | } | 137 | } |
| @@ -85,11 +85,11 @@ class UserLogic extends BaseLogic | @@ -85,11 +85,11 @@ class UserLogic extends BaseLogic | ||
| 85 | * @method | 85 | * @method |
| 86 | */ | 86 | */ |
| 87 | public function user_info(){ | 87 | public function user_info(){ |
| 88 | - $rs = $this->model->read($this->param); | ||
| 89 | - if($rs === false){ | 88 | + $info = $this->model->read($this->param); |
| 89 | + if($info === false){ | ||
| 90 | $this->fail('error',Code::USER_ERROR); | 90 | $this->fail('error',Code::USER_ERROR); |
| 91 | } | 91 | } |
| 92 | - return $this->success(); | 92 | + return $this->success($info); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | /** | 95 | /** |
| @@ -100,7 +100,7 @@ class UserLogic extends BaseLogic | @@ -100,7 +100,7 @@ class UserLogic extends BaseLogic | ||
| 100 | */ | 100 | */ |
| 101 | public function user_del(){ | 101 | public function user_del(){ |
| 102 | $this->param['operator_id'] = $this->user['id']; | 102 | $this->param['operator_id'] = $this->user['id']; |
| 103 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 103 | + $rs = $this->model->edit($this->param,['id'=>['in',$this->param['id']]]); |
| 104 | if($rs === false){ | 104 | if($rs === false){ |
| 105 | $this->fail('error',Code::USER_ERROR); | 105 | $this->fail('error',Code::USER_ERROR); |
| 106 | } | 106 | } |
-
请 注册 或 登录 后发表评论