作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -11,6 +11,7 @@ use App\Models\Mail\Mail;
use App\Models\Project\DeployOptimize;
use App\Models\Project\ProjectUpdateTdk;
use App\Models\User\User;
use App\Models\WebSetting\WebLanguage;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
... ... @@ -40,6 +41,8 @@ class UpdateSeoTdk extends Command
*/
protected $description = '一键生成tdk';
protected $project;
/**
* Create a new command instance.
*
... ... @@ -143,7 +146,7 @@ class UpdateSeoTdk extends Command
echo date('Y-m-d H:i:s') . ' start project_id: ' . $project_id . PHP_EOL;
try {
ProjectServer::useProject($project_id);
$this->project = ProjectServer::useProject($project_id);
$this->seo_tdk($project_id, $task->id);
DB::disconnect('custom_mysql');
}catch (\Exception $e){
... ... @@ -280,7 +283,6 @@ class UpdateSeoTdk extends Command
}
public function getPrompt($project_id, $prompt, $table, $data){
$lang = '';
if(strpos($prompt, '{topic}') !== false){
$topic = $data[$this->topic_fields[$table]] ?? '';
if(!$topic){
... ... @@ -288,7 +290,6 @@ class UpdateSeoTdk extends Command
return false;
}
$prompt = str_replace('{topic}', $topic, $prompt);
$lang = $this->getLang($topic);
}
if(strpos($prompt, '{keyword}') !== false) {
$keyword = $this->mainKeywords($project_id, 1);
... ... @@ -297,7 +298,6 @@ class UpdateSeoTdk extends Command
return false;
}
$prompt = str_replace('{keyword}', $keyword, $prompt);
!$lang && $lang = $this->getLang($keyword);
}
if(strpos($prompt, '{company name}') !== false) {
$company_name = $this->companyName($project_id);
... ... @@ -307,8 +307,7 @@ class UpdateSeoTdk extends Command
}
$prompt = str_replace('{company name}', $company_name, $prompt);
}
$prompt .= '.Please answer in ' . ($lang ?: 'English');
$prompt .= '.Please answer in ' . $this->getLang();
return $prompt;
}
... ... @@ -365,14 +364,9 @@ class UpdateSeoTdk extends Command
return $str;
}
public function getLang($content){
$result = Translate::translateSl($content);
if (isset($result['texts']['sl']) && isset(Translate::$tls_list[$result['texts']['sl']])) {
$lang = Translate::$tls_list[$result['texts']['sl']]['lang_en'];
} else {
$lang = 'English';
}
return $lang;
public function getLang(){
$lang = WebLanguage::getLangById($this->project['main_lang_id']??1);
return $lang['english'] ?? 'English';
}
/**
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Http\Controllers\Bside\CustomModule;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic;
use App\Models\CustomModule\CustomModuleCategory;
... ...
... ... @@ -354,6 +354,7 @@ class FileController
'file'=>$path,
'file_link'=>getFileUrl($path,$this->upload_location),
'name'=>$name,
'file_download'=>url('a/download_files?path='.$path)
];
return $data;
}
... ...
... ... @@ -427,6 +427,7 @@ class ImageController extends Controller
'image'=>$path,
'image_link'=>getImageUrl($path),
'name'=>$name,
'image_download'=>url('a/download_images?path='.$path)
];
return $data;
}
... ...
... ... @@ -645,10 +645,11 @@ class ProjectLogic extends BaseLogic
/**
* @param $project
* @return bool
* @author zbj
* @date 2023/4/23
* @remark :创建数据库
* @name :initTable
* @author :lyh
* @method :post
* @time :2023/12/11 10:09
*/
public function initTable($project_id,$news_project_id)
{
... ...
... ... @@ -8,6 +8,7 @@ use App\Helper\Translate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Ai\AiCommand;
use App\Models\Project\DeployOptimize;
use App\Models\WebSetting\WebLanguage;
use Illuminate\Support\Facades\Cache;
class AiCommandLogic extends BaseLogic
... ... @@ -58,8 +59,8 @@ class AiCommandLogic extends BaseLogic
if(trim($ai_command->ai) == '{core keywords 8}'){
$ai_send = false;
}else{
$lang = $this->getLang($this->param['keywords']);
$prompt .= '.Please answer in ' . ($lang ?: 'English');
$lang = WebLanguage::getLangById($this->project['main_lang_id']??1)['english'] ?? 'English';
$prompt .= '.Please answer in ' . $lang;
$ai_send = true;
}
... ...
... ... @@ -82,7 +82,7 @@ class CustomModuleCategoryLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
$info['image_link'] = getImageUrl($info['image']);
$info['image'] = getImageUrl($info['image']);
return $this->success($info);
}
... ... @@ -131,10 +131,10 @@ class CustomModuleCategoryLogic extends BaseLogic
public function categoryAdd(){
try {
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE,
$id, $this->user['project_id']);
$this->handleAddSon($id);
$this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
$this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE,$route);
$this->curlDelRoute(['new_route'=>$route]);
$this->edit(['route' => $route], ['id' => $id]);
//处理上级分类商品
... ... @@ -153,7 +153,7 @@ class CustomModuleCategoryLogic extends BaseLogic
* @time :2023/12/5 10:55
*/
public function categoryEdit(){
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE,
$this->param['id'], $this->user['project_id']);
$this->editHandleCategory($this->param['id'],$this->param['pid']);
$this->editRoute($this->param['id'],$route);
... ... @@ -218,7 +218,7 @@ class CustomModuleCategoryLogic extends BaseLogic
//生成一条删除路由记录
$info = $this->model->read(['id' => $id], ['id', 'route']);
if ($info['route'] != $route) {
$this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
$this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE,$route);
$this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
}
return true;
... ... @@ -300,7 +300,7 @@ class CustomModuleCategoryLogic extends BaseLogic
public function delRoute($id)
{
$info = $this->model->read(['id' => $id], ['id', 'route','module_id']);
RouteMap::delRoute(RouteMap::SOURCE_MODULE_CATE.$info['module_id'], $id, $this->user['project_id']);
RouteMap::delRoute(RouteMap::SOURCE_MODULE_CATE, $id, $this->user['project_id']);
//通知
$this->curlDelRoute(['route'=>$info['route']]);
return $this->success();
... ...
... ... @@ -41,7 +41,7 @@ class CustomModuleContentLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
$info['image_link'] = getImageUrl($info['image']);
$info['image'] = getImageUrl($info['image']);
$info['extend'] = $this->getExtendInfo($info['module_id'],$info['id']);
return $this->success($info);
}
... ... @@ -152,9 +152,9 @@ class CustomModuleContentLogic extends BaseLogic
public function contentAdd(){
try {
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE.$this->param['module_id'],
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE,
$id, $this->user['project_id']);
$this->addUpdateNotify(RouteMap::SOURCE_MODULE.$this->param['module_id'],$route);
$this->addUpdateNotify(RouteMap::SOURCE_MODULE,$route);
$this->curlDelRoute(['new_route'=>$route]);
$this->edit(['route' => $route], ['id' => $id]);
}catch (\Exception $e){
... ... @@ -171,7 +171,7 @@ class CustomModuleContentLogic extends BaseLogic
* @time :2023/12/7 15:04
*/
public function contentEdit(){
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE.$this->param['module_id'],
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE,
$this->param['id'], $this->user['project_id']);
$this->editRoute($this->param['id'],$route);
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
... ... @@ -214,7 +214,7 @@ class CustomModuleContentLogic extends BaseLogic
//生成一条删除路由记录
$info = $this->model->read(['id' => $id], ['id', 'route']);
if ($info['route'] != $route) {
$this->addUpdateNotify(RouteMap::SOURCE_MODULE.$this->param['module_id'],$route);
$this->addUpdateNotify(RouteMap::SOURCE_MODULE,$route);
$this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
}
return true;
... ... @@ -320,7 +320,7 @@ class CustomModuleContentLogic extends BaseLogic
*/
public function delRoute($id)
{
RouteMap::delRoute(RouteMap::SOURCE_MODULE.$this->param['module_id'], $id, $this->user['project_id']);
RouteMap::delRoute(RouteMap::SOURCE_MODULE, $id, $this->user['project_id']);
//通知
$info = $this->model->read(['id' => $id], ['id', 'url']);
$this->curlDelRoute(['route'=>$info['url']]);
... ...
... ... @@ -11,6 +11,7 @@ namespace App\Http\Logic\Bside\CustomModule;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\CustomModule\CustomModuleExtend;
use App\Models\CustomModule\CustomModuleExtentContent;
class CustomModuleExtendLogic extends BaseLogic
{
... ... @@ -115,10 +116,14 @@ class CustomModuleExtendLogic extends BaseLogic
* @time :2023/12/4 15:47
*/
public function extendDel(){
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('系统错误,请联系管理员');
$info = $this->model->read(['id'=>$this->param['id']]);
//查看当前扩展字段是否设置了值
$extendInfoModel = new CustomModuleExtentContent();
$extendInfo = $extendInfoModel->read(['key'=>$info['key']]);
if($extendInfo !== false){
$this->fail('当前扩展字段已有产品在使用,不允许删除');
}
$this->model->del(['id'=>$this->param['id']]);
return $this->success();
}
}
... ...
... ... @@ -25,6 +25,7 @@ class ProjectCountryLogic extends BaseLogic
if (empty($lists)){
$lists = [];
}
$lists['country_lists'] = $this->countryListsFormat($lists['country_lists']);
return $this->success($lists);
}
... ... @@ -39,6 +40,8 @@ class ProjectCountryLogic extends BaseLogic
if(!isset($this->param['country_lists']) || empty($this->param['country_lists'])){
$this->param['country_lists'] = '';
}
$this->param['country_lists'] = $this->countryListsFormat($this->param['country_lists']);
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->param['project_id'] = $this->user['project_id'];
... ... @@ -51,4 +54,15 @@ class ProjectCountryLogic extends BaseLogic
}
return $this->success();
}
protected function countryListsFormat($country_lists)
{
//默认选中主语种
$country_lists = explode(',', $country_lists);
$main_lang_id = $this->project['main_lang_id'] ?? 1;
if (!in_array($main_lang_id, $country_lists)) {
$country_lists[] = $main_lang_id;
}
return implode(',', $country_lists);
}
}
... ...
... ... @@ -39,10 +39,10 @@ class RouteMap extends Base
const SOURCE_NAV = 'nav';
//自定义模块
const SOURCE_MODULE = 'module_';
const SOURCE_MODULE = 'module';
//自定义模块分类
const SOURCE_MODULE_CATE = 'module_cate_';
const SOURCE_MODULE_CATE = 'module_category';
/**
* 生成路由标识
* @param $title
... ...
... ... @@ -10,8 +10,26 @@
namespace App\Models\WebSetting;
use App\Models\Base;
use Illuminate\Support\Facades\Cache;
class WebLanguage extends Base
{
protected $table = 'gl_web_language';
/**
* @param $id
* @return mixed
* @author zbj
* @date 2023/12/11
*/
public static function getLangById($id){
$cache_key = 'lang_'.$id;
$lang = Cache::get($cache_key);
if(!$lang){
$lang = self::find($id);
Cache::put($cache_key, $lang, 7200);
}
return $lang;
}
}
... ...