作者 赵彬吉

update

... ... @@ -177,7 +177,7 @@ class UpdateSeoTdk extends Command
if(!Redis::setnx($cache_key, 1)){
continue;
}
Redis::expire($cache_key, 300);
Redis::expire($cache_key, 120);
echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL;
$v = DB::connection('custom_mysql')->table($table)->where('id', $v['id'])->first();
... ...
... ... @@ -24,7 +24,7 @@ class BlogController extends BaseController
* @time :2023/9/14 10:45
*/
public function lists(BlogModel $blogModel){
$filed = ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url'];
$filed = ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url','release_at'];
$this->order = 'sort';
$query = $blogModel->orderBy($this->order ,'desc')->orderBy('id','desc');
$query = $this->searchParam($query);
... ...
... ... @@ -24,7 +24,7 @@ class NewsController extends BaseController
* @method
*/
public function lists(NewsModel $news){
$filed = ['id','category_id','operator_id','status','created_at','image','updated_at','name','sort','url'];
$filed = ['id','category_id','operator_id','status','created_at','image','updated_at','name','sort','url', 'release_at'];
$this->order = 'sort';
$query = $news->orderBy($this->order ,'desc')->orderBy('id','desc');
$query = $this->searchParam($query);
... ...
... ... @@ -54,15 +54,16 @@ class KeywordLogic extends BaseLogic
$this->param = $this->handleSaveParam($this->param);
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->model->edit($this->param,['id'=>$this->param['id']]);
$id = $this->param['id'];
}else{
$this->param['project_id'] = $this->user['project_id'];
$this->param['created_at'] = date('Y-m-d H:i:s');
$this->param['updated_at'] = $this->param['created_at'];
$id = $this->model->insertGetId($this->param);
//路由映射
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$id]);
}
//路由映射
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$id]);
//清除缓存
Common::del_user_cache('product_keyword',$this->user['project_id']);
DB::commit();
... ... @@ -92,6 +93,12 @@ class KeywordLogic extends BaseLogic
if(isset($param['keyword_video']) && !empty($param['keyword_video'])){
$param['keyword_video'] = Arr::a2s($param['keyword_video']);
}
if(!empty($param['related_news_ids'])){
$param['related_news_ids'] = Arr::arrToSet($param['related_news_ids']);
}
if(!empty($param['related_blog_ids'])){
$param['related_blog_ids'] = Arr::arrToSet($param['related_blog_ids']);
}
return $param;
}
... ...
... ... @@ -34,6 +34,8 @@ class KeywordRequest extends FormRequest
'seo_title'=>'max:200',
'seo_keywords'=>'max:200',
'seo_description'=>'max:200',
'related_news_ids'=>'array|max:2',
'related_blog_ids'=>'array|max:2',
];
}
... ... @@ -45,6 +47,8 @@ class KeywordRequest extends FormRequest
'seo_title.max' => 'SEO标题不能超过200个字符',
'seo_keywords.max' => 'SEO关键词不能超过200个字符',
'seo_description.max' => 'SEO描述不能超过200个字符',
'related_news_ids.max' => '关联新闻不能超过两条',
'related_blog_ids.max' => '关联博客不能超过两条',
];
}
... ...
... ... @@ -14,6 +14,14 @@ class Blog extends Base
public function user(){
return $this->hasMany(User::class,'operator_id','id');
}
public function getReleaseAtAttribute($value){
if(!$value){
return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at')));
}
return $value;
}
}
... ...
... ... @@ -15,4 +15,12 @@ class News extends Base
public static function getNumByProjectId($project_id){
return self::where('project_id', $project_id)->where('status', 1)->count();
}
public function getReleaseAtAttribute($value){
if(!$value){
return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at')));
}
return $value;
}
}
... ...
... ... @@ -56,4 +56,30 @@ class Keyword extends Base
}
return $value;
}
/**
* @param $value
* @return array|mixed
* @author zbj
* @date 2023/11/21
*/
public function getRelatedNewsIdsAttribute($value){
if(!empty($value)){
$value = Arr::setToArr($value);
}
return $value;
}
/**
* @param $value
* @return array|false|mixed|string[]
* @author zbj
* @date 2023/11/21
*/
public function getRelatedBlogIdsAttribute($value){
if(!empty($value)){
$value = Arr::setToArr($value);
}
return $value;
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Models\RouteMap;
use App\Helper\Translate;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Models\Base;
/**
... ... @@ -106,6 +107,14 @@ class RouteMap extends Base
}
try {
$route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first();
//上线项目 不能修改链接了
if($route_map){
$project = ProjectLogic::instance()->getInfo($project_id);
if($project['type'] !== Project::STATUS_ONE){
return $route_map->route;
// throw new \Exception('站点已上线,禁止修改链接');
}
}
if(!$route_map){
$route_map = new self();
$route_map->source = $source;
... ...