作者 liyuhang

gx

@@ -6,6 +6,7 @@ use App\Enums\Common\Code; @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
6 use App\Helper\Common; 6 use App\Helper\Common;
7 use App\Http\Controllers\Bside\BaseController; 7 use App\Http\Controllers\Bside\BaseController;
8 use App\Http\Logic\Bside\Blog\BlogCategoryLogic; 8 use App\Http\Logic\Bside\Blog\BlogCategoryLogic;
  9 +use App\Http\Logic\Bside\Blog\BlogLabelLogic;
9 use App\Http\Logic\Bside\Blog\BlogLogic; 10 use App\Http\Logic\Bside\Blog\BlogLogic;
10 use App\Http\Requests\Bside\Blog\BlogRequest; 11 use App\Http\Requests\Bside\Blog\BlogRequest;
11 use App\Models\Blog\Blog as BlogModel; 12 use App\Models\Blog\Blog as BlogModel;
@@ -19,7 +20,7 @@ class BlogController extends BaseController @@ -19,7 +20,7 @@ class BlogController extends BaseController
19 * @author :liyuhang 20 * @author :liyuhang
20 * @method 21 * @method
21 */ 22 */
22 - public function lists(BlogModel $blogModel,BlogCategoryLogic $blogCategoryLogic){ 23 + public function lists(BlogModel $blogModel,BlogCategoryLogic $blogCategoryLogic,BlogLabelLogic $blogLabelLogic){
23 //搜索条件 24 //搜索条件
24 $this->map['project_id'] = $this->user['project_id']; 25 $this->map['project_id'] = $this->user['project_id'];
25 $lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order); 26 $lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order);
@@ -27,6 +28,8 @@ class BlogController extends BaseController @@ -27,6 +28,8 @@ class BlogController extends BaseController
27 foreach ($lists['list'] as $k => $v){ 28 foreach ($lists['list'] as $k => $v){
28 //获取分类名称 29 //获取分类名称
29 $v = $blogCategoryLogic->get_category_name($v); 30 $v = $blogCategoryLogic->get_category_name($v);
  31 + //获取标签名称
  32 + $v = $blogLabelLogic->get_label_name($v);
30 $lists['list'][$k] = $v; 33 $lists['list'][$k] = $v;
31 } 34 }
32 } 35 }
@@ -16,7 +16,23 @@ class BlogLabelLogic extends BaseLogic @@ -16,7 +16,23 @@ class BlogLabelLogic extends BaseLogic
16 $this->model = new BlogLabelModel(); 16 $this->model = new BlogLabelModel();
17 $this->param = $this->requestAll; 17 $this->param = $this->requestAll;
18 } 18 }
19 - 19 + /**
  20 + * @param $v
  21 + * @name :获取分类名称
  22 + * @return void
  23 + * @author :liyuhang
  24 + * @method
  25 + */
  26 + public function get_label_name($v){
  27 + //获取用户已读还是未读
  28 + $label_info = $this->model->list(['id'=>['in',explode(',',trim($v['category_id'],','))]],'id',['name']);
  29 + $str = '';
  30 + foreach ($label_info as $v1){
  31 + $str .= $v1['name'].',';
  32 + }
  33 + $v['category_name'] = trim($str,',');
  34 + return $this->success($v);
  35 + }
20 /** 36 /**
21 * @name :新增标签 37 * @name :新增标签
22 * @return void 38 * @return void
@@ -68,7 +68,6 @@ class BlogLogic extends BaseLogic @@ -68,7 +68,6 @@ class BlogLogic extends BaseLogic
68 $this->param['project_id'] = $this->user['project_id']; 68 $this->param['project_id'] = $this->user['project_id'];
69 $this->param['created_at'] = date('Y-m-d H:i:s',time()); 69 $this->param['created_at'] = date('Y-m-d H:i:s',time());
70 $this->param['updated_at'] = date('Y-m-d H:i:s',time()); 70 $this->param['updated_at'] = date('Y-m-d H:i:s',time());
71 - $this->param['category_id'] = ','.$this->param['category_id'].',';  
72 DB::beginTransaction(); 71 DB::beginTransaction();
73 try { 72 try {
74 if(isset($this->param['image'])){ 73 if(isset($this->param['image'])){
@@ -59,7 +59,6 @@ class NewsLogic extends BaseLogic @@ -59,7 +59,6 @@ class NewsLogic extends BaseLogic
59 $this->param['project_id'] = $this->user['project_id']; 59 $this->param['project_id'] = $this->user['project_id'];
60 $this->param['created_at'] = date('Y-m-d H:i:s',time()); 60 $this->param['created_at'] = date('Y-m-d H:i:s',time());
61 $this->param['updated_at'] = date('Y-m-d H:i:s',time()); 61 $this->param['updated_at'] = date('Y-m-d H:i:s',time());
62 - $this->param['category_id'] = ','.$this->param['category_id'].',';  
63 DB::beginTransaction(); 62 DB::beginTransaction();
64 try { 63 try {
65 if(isset($this->param['image'])){ 64 if(isset($this->param['image'])){