作者 liyuhang

gx

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