作者 赵彬吉

update

@@ -177,7 +177,7 @@ class UpdateSeoTdk extends Command @@ -177,7 +177,7 @@ class UpdateSeoTdk extends Command
177 if(!Redis::setnx($cache_key, 1)){ 177 if(!Redis::setnx($cache_key, 1)){
178 continue; 178 continue;
179 } 179 }
180 - Redis::expire($cache_key, 300); 180 + Redis::expire($cache_key, 120);
181 181
182 echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL; 182 echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL;
183 $v = DB::connection('custom_mysql')->table($table)->where('id', $v['id'])->first(); 183 $v = DB::connection('custom_mysql')->table($table)->where('id', $v['id'])->first();
@@ -24,7 +24,7 @@ class BlogController extends BaseController @@ -24,7 +24,7 @@ class BlogController extends BaseController
24 * @time :2023/9/14 10:45 24 * @time :2023/9/14 10:45
25 */ 25 */
26 public function lists(BlogModel $blogModel){ 26 public function lists(BlogModel $blogModel){
27 - $filed = ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']; 27 + $filed = ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url','release_at'];
28 $this->order = 'sort'; 28 $this->order = 'sort';
29 $query = $blogModel->orderBy($this->order ,'desc')->orderBy('id','desc'); 29 $query = $blogModel->orderBy($this->order ,'desc')->orderBy('id','desc');
30 $query = $this->searchParam($query); 30 $query = $this->searchParam($query);
@@ -24,7 +24,7 @@ class NewsController extends BaseController @@ -24,7 +24,7 @@ class NewsController extends BaseController
24 * @method 24 * @method
25 */ 25 */
26 public function lists(NewsModel $news){ 26 public function lists(NewsModel $news){
27 - $filed = ['id','category_id','operator_id','status','created_at','image','updated_at','name','sort','url']; 27 + $filed = ['id','category_id','operator_id','status','created_at','image','updated_at','name','sort','url', 'release_at'];
28 $this->order = 'sort'; 28 $this->order = 'sort';
29 $query = $news->orderBy($this->order ,'desc')->orderBy('id','desc'); 29 $query = $news->orderBy($this->order ,'desc')->orderBy('id','desc');
30 $query = $this->searchParam($query); 30 $query = $this->searchParam($query);
@@ -54,15 +54,16 @@ class KeywordLogic extends BaseLogic @@ -54,15 +54,16 @@ class KeywordLogic extends BaseLogic
54 $this->param = $this->handleSaveParam($this->param); 54 $this->param = $this->handleSaveParam($this->param);
55 if(isset($this->param['id']) && !empty($this->param['id'])){ 55 if(isset($this->param['id']) && !empty($this->param['id'])){
56 $this->model->edit($this->param,['id'=>$this->param['id']]); 56 $this->model->edit($this->param,['id'=>$this->param['id']]);
  57 + $id = $this->param['id'];
57 }else{ 58 }else{
58 $this->param['project_id'] = $this->user['project_id']; 59 $this->param['project_id'] = $this->user['project_id'];
59 $this->param['created_at'] = date('Y-m-d H:i:s'); 60 $this->param['created_at'] = date('Y-m-d H:i:s');
60 $this->param['updated_at'] = $this->param['created_at']; 61 $this->param['updated_at'] = $this->param['created_at'];
61 $id = $this->model->insertGetId($this->param); 62 $id = $this->model->insertGetId($this->param);
62 - //路由映射  
63 - $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);  
64 - $this->model->edit(['route'=>$route],['id'=>$id]);  
65 } 63 }
  64 + //路由映射
  65 + $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
  66 + $this->model->edit(['route'=>$route],['id'=>$id]);
66 //清除缓存 67 //清除缓存
67 Common::del_user_cache('product_keyword',$this->user['project_id']); 68 Common::del_user_cache('product_keyword',$this->user['project_id']);
68 DB::commit(); 69 DB::commit();
@@ -92,6 +93,12 @@ class KeywordLogic extends BaseLogic @@ -92,6 +93,12 @@ class KeywordLogic extends BaseLogic
92 if(isset($param['keyword_video']) && !empty($param['keyword_video'])){ 93 if(isset($param['keyword_video']) && !empty($param['keyword_video'])){
93 $param['keyword_video'] = Arr::a2s($param['keyword_video']); 94 $param['keyword_video'] = Arr::a2s($param['keyword_video']);
94 } 95 }
  96 + if(!empty($param['related_news_ids'])){
  97 + $param['related_news_ids'] = Arr::arrToSet($param['related_news_ids']);
  98 + }
  99 + if(!empty($param['related_blog_ids'])){
  100 + $param['related_blog_ids'] = Arr::arrToSet($param['related_blog_ids']);
  101 + }
95 return $param; 102 return $param;
96 } 103 }
97 104
@@ -34,6 +34,8 @@ class KeywordRequest extends FormRequest @@ -34,6 +34,8 @@ class KeywordRequest extends FormRequest
34 'seo_title'=>'max:200', 34 'seo_title'=>'max:200',
35 'seo_keywords'=>'max:200', 35 'seo_keywords'=>'max:200',
36 'seo_description'=>'max:200', 36 'seo_description'=>'max:200',
  37 + 'related_news_ids'=>'array|max:2',
  38 + 'related_blog_ids'=>'array|max:2',
37 ]; 39 ];
38 } 40 }
39 41
@@ -45,6 +47,8 @@ class KeywordRequest extends FormRequest @@ -45,6 +47,8 @@ class KeywordRequest extends FormRequest
45 'seo_title.max' => 'SEO标题不能超过200个字符', 47 'seo_title.max' => 'SEO标题不能超过200个字符',
46 'seo_keywords.max' => 'SEO关键词不能超过200个字符', 48 'seo_keywords.max' => 'SEO关键词不能超过200个字符',
47 'seo_description.max' => 'SEO描述不能超过200个字符', 49 'seo_description.max' => 'SEO描述不能超过200个字符',
  50 + 'related_news_ids.max' => '关联新闻不能超过两条',
  51 + 'related_blog_ids.max' => '关联博客不能超过两条',
48 ]; 52 ];
49 } 53 }
50 54
@@ -14,6 +14,14 @@ class Blog extends Base @@ -14,6 +14,14 @@ class Blog extends Base
14 public function user(){ 14 public function user(){
15 return $this->hasMany(User::class,'operator_id','id'); 15 return $this->hasMany(User::class,'operator_id','id');
16 } 16 }
  17 +
  18 + public function getReleaseAtAttribute($value){
  19 + if(!$value){
  20 + return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at')));
  21 + }
  22 +
  23 + return $value;
  24 + }
17 } 25 }
18 26
19 27
@@ -15,4 +15,12 @@ class News extends Base @@ -15,4 +15,12 @@ class News extends Base
15 public static function getNumByProjectId($project_id){ 15 public static function getNumByProjectId($project_id){
16 return self::where('project_id', $project_id)->where('status', 1)->count(); 16 return self::where('project_id', $project_id)->where('status', 1)->count();
17 } 17 }
  18 +
  19 + public function getReleaseAtAttribute($value){
  20 + if(!$value){
  21 + return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at')));
  22 + }
  23 +
  24 + return $value;
  25 + }
18 } 26 }
@@ -56,4 +56,30 @@ class Keyword extends Base @@ -56,4 +56,30 @@ class Keyword extends Base
56 } 56 }
57 return $value; 57 return $value;
58 } 58 }
  59 +
  60 + /**
  61 + * @param $value
  62 + * @return array|mixed
  63 + * @author zbj
  64 + * @date 2023/11/21
  65 + */
  66 + public function getRelatedNewsIdsAttribute($value){
  67 + if(!empty($value)){
  68 + $value = Arr::setToArr($value);
  69 + }
  70 + return $value;
  71 + }
  72 +
  73 + /**
  74 + * @param $value
  75 + * @return array|false|mixed|string[]
  76 + * @author zbj
  77 + * @date 2023/11/21
  78 + */
  79 + public function getRelatedBlogIdsAttribute($value){
  80 + if(!empty($value)){
  81 + $value = Arr::setToArr($value);
  82 + }
  83 + return $value;
  84 + }
59 } 85 }
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace App\Models\RouteMap; 3 namespace App\Models\RouteMap;
4 4
5 use App\Helper\Translate; 5 use App\Helper\Translate;
  6 +use App\Http\Logic\Aside\Project\ProjectLogic;
6 use App\Models\Base; 7 use App\Models\Base;
7 8
8 /** 9 /**
@@ -106,6 +107,14 @@ class RouteMap extends Base @@ -106,6 +107,14 @@ class RouteMap extends Base
106 } 107 }
107 try { 108 try {
108 $route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first(); 109 $route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first();
  110 + //上线项目 不能修改链接了
  111 + if($route_map){
  112 + $project = ProjectLogic::instance()->getInfo($project_id);
  113 + if($project['type'] !== Project::STATUS_ONE){
  114 + return $route_map->route;
  115 +// throw new \Exception('站点已上线,禁止修改链接');
  116 + }
  117 + }
109 if(!$route_map){ 118 if(!$route_map){
110 $route_map = new self(); 119 $route_map = new self();
111 $route_map->source = $source; 120 $route_map->source = $source;