作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !3345
... ... @@ -38,14 +38,15 @@ class GeoWritingTaskController extends BaseController
* @method :post
* @time :2025/10/25 15:12
*/
public function lists(){
public function lists()
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => 'project_id不能为空',
]);
$data = $this->logic->listWritingTask($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$data);
$data = $this->logic->listWritingTask($this->map, $this->page, $this->row, $this->order);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -55,10 +56,11 @@ class GeoWritingTaskController extends BaseController
* @method :post
* @time :2025/10/25 10:41
*/
public function saveWritingTask(GeoWritingsTaskRequest $request){
public function saveWritingTask(GeoWritingsTaskRequest $request)
{
$request->validated();
$data = $this->logic->saveWritingTask();
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -68,15 +70,16 @@ class GeoWritingTaskController extends BaseController
* @method :post
* @time :2025/10/25 15:03
*/
public function delWritingTask(){
public function delWritingTask()
{
$this->request->validate([
'id'=>'required|array',
],[
'id' => 'required|array',
], [
'id.required' => 'ID不能为空',
'id.array' => 'ID为数组',
]);
$data = $this->logic->delWritingTask();
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -86,25 +89,36 @@ class GeoWritingTaskController extends BaseController
* @method :post
* @time :2025/10/27 11:10
*/
public function sendAiTitle(){
public function sendAiTitle()
{
$this->request->validate([
'brand' => 'required',
'keyword' => 'required',
], [
'brand.required' => '品牌词不能为空',
'keyword.required' => '关键词不能为空',
]);
$data = $this->logic->sendAiTitle();
$this->response('success', Code::SUCCESS, $data);
}
/**
* 组装AI生成文章语句
* @author Akun
* @date 2025/11/24 15:58
*/
public function getAiCommand()
{
$this->request->validate([
'company'=>'required',
'number'=>'required',
'prefix'=>'required',
'keyword'=>'required',
'suffix'=>'required',
'event_title'=>'required',
],[
'company.required' => '公司简称不能为空',
'number.required' => '生成数量不能为空',
'prefix.required' => '关键词前缀为数组',
'keyword' => 'required',
'title' => 'required|max:120'
], [
'keyword.required' => '关键词不能为空',
'suffix.requiredrequired' => '关键词后缀不能为空',
'event_title.required' => '事件标题不能为空',
'title.required' => 'GEO文标题不能为空',
'title.max' => 'GEO文标题最多120个字符'
]);
$aiCommand = "请根据公司简称{$this->param['company']}和这个公司产品的关键词:{$this->param['prefix']}{$this->param['keyword']}{$this->param['suffix']},以及{$this->param['event_title']},帮我写{$this->param['number']}个有吸引力的英文新闻标题;确保这个标题在Google上面唯一存在的,只需要回复我标题,不需要别的内容(比如序号、你的提示、寒暄、解释、注释之类的) 标题不能超过 100 字符数!,一行一个";
$gptHelper = new Gpt();
$data = $gptHelper->openai_chat_qqs($aiCommand);
$this->response('success',Code::SUCCESS,$data);
$data = $this->logic->getAiCommand();
$this->response('success', Code::SUCCESS, $data);
}
}
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Http\Logic\Aside\Geo;
use App\Helper\Gpt;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Geo\GeoWritings;
use App\Models\Geo\GeoWritingsTask;
... ... @@ -29,37 +30,39 @@ class GeoWritingsTaskLogic extends BaseLogic
* @method :post
* @time :2025/10/25 15:13
*/
public function listWritingTask($map,$page,$row,$order){
$data = $this->model->lists($map,$page,$row,$order);
public function listWritingTask($map, $page, $row, $order)
{
$data = $this->model->lists($map, $page, $row, $order);
return $this->success($data);
}
/**
* @remark :保存AI文章数据
* @name :saveWritingTask
* @param :project_id->项目ID;company->公司名称;brand->品牌词;keyword->关键词;prefix->前缀;suffix->后缀;event_title->事件标题;
* event_content->事件内容;title->标题;description->描述;footer->结尾引用;img->图片;ai_model->ai_model
* @author :lyh
* @method :post
* @time :2025/10/25 14:41
* @param :project_id->项目ID;company->公司名称;brand->品牌词;keyword->关键词;prefix->前缀;suffix->后缀;event_title->事件标题;
* event_content->事件内容;title->标题;description->描述;footer->结尾引用;img->图片;ai_model->ai_model
*/
public function saveWritingTask(){
public function saveWritingTask()
{
try {
if(isset($this->param['id']) &&!empty($this->param['id'])){
if (isset($this->param['id']) && !empty($this->param['id'])) {
$id = $this->param['id'];
$this->model->edit($this->param,['id'=>$id]);
}else{
$this->model->edit($this->param, ['id' => $id]);
} else {
//自动保存一条数据
$writingModel = new GeoWritings();
$this->param['writings_id'] = $writingModel->addReturnId(['project_id'=>$this->param['project_id'],
'type'=>$writingModel::TYPE_AI_CREATE,'status'=>$writingModel::STATUS_AI_WAIT,
'uniqid'=>md5(uniqid().rand(1, 99999).$this->param['project_id'])]);
$this->param['writings_id'] = $writingModel->addReturnId(['project_id' => $this->param['project_id'],
'type' => $writingModel::TYPE_AI_CREATE, 'status' => $writingModel::STATUS_AI_WAIT,
'uniqid' => md5(uniqid() . rand(1, 99999) . $this->param['project_id'])]);
$id = $this->model->addReturnId($this->param);
}
}catch (\Exception $e){
$this->fail('保存数据失败,请联系管理员'.$e->getMessage());
} catch (\Exception $e) {
$this->fail('保存数据失败,请联系管理员' . $e->getMessage());
}
return $this->success(['id'=>$id]);
return $this->success(['id' => $id]);
}
/**
... ... @@ -71,10 +74,102 @@ class GeoWritingsTaskLogic extends BaseLogic
*/
public function delWritingTask()
{
$res = $this->model->del(['id'=>['in',$this->param['id']]]);
if($res === false){
$res = $this->model->del(['id' => ['in', $this->param['id']]]);
if ($res === false) {
$this->fail('删除失败,请联系管理员');
}
return $this->success();
}
/**
* Ai请求标题
* @return mixed|string
* @author Akun
* @date 2025/11/24 16:24
*/
public function sendAiTitle()
{
$brand = isset($this->param['brand']) && $this->param['brand'] ? $this->param['brand'] : '';
$prefix = isset($this->param['prefix']) && $this->param['prefix'] ? $this->param['prefix'] : '';
$keyword = isset($this->param['keyword']) && $this->param['keyword'] ? $this->param['keyword'] : '';
$suffix = isset($this->param['suffix']) && $this->param['suffix'] ? $this->param['suffix'] : '';
$event_content = isset($this->param['event_content']) && $this->param['event_content'] ? $this->param['event_content'] : '';
$desc = '帮我写1个有吸引力的英文新闻标题,并确保这个标题在Google上面唯一存在的,只需要回复我标题,不需要别的内容(比如序号、你的提示、寒暄、解释、注释之类的),标题不要超过100字符数。';
$config_title = [
"brand" => "请根据公司品牌词:{$brand}",
"keyword" => "和这个公司产品的关键词:{$prefix}{$keyword}{$suffix}",
"event_content" => "以及公司参与的事件内容:{$event_content}",
"desc" => $desc
];
foreach ($config_title as $k => $v) {
if (empty($$k)) {
unset($config_title[$k]);
}
}
$aiCommand = implode(',', $config_title);
$gptHelper = new Gpt();
return $gptHelper->openai_chat_qqs($aiCommand);
}
/**
* 组装AI生成文章语句
* @author Akun
* @date 2025/11/25 10:48
*/
public function getAiCommand()
{
$title = isset($this->param['title']) && $this->param['title'] ? $this->param['title'] : '';
$description = isset($this->param['description']) && $this->param['description'] ? $this->param['description'] : '';
$event_content = isset($this->param['event_content']) && $this->param['event_content'] ? $this->param['event_content'] : '';
$keyword = isset($this->param['keyword']) && $this->param['keyword'] ? $this->param['keyword'] : '';
$prefix = isset($this->param['prefix']) && $this->param['prefix'] ? $this->param['prefix'] : '';
$suffix = isset($this->param['suffix']) && $this->param['suffix'] ? $this->param['suffix'] : '';
$footer = isset($this->param['footer']) && $this->param['footer'] ? $this->param['footer'] : '';
//引言配置
$introduction = '给我写一个Press Release引言内容';
$industry = $keyword;
$character = '只需要1个段落,大约150-200字';
$desc = '所有内容一定要用英文,只需要回复我新闻稿引言内容,不需要别的内容(比如序号、你的提示、寒暄、解释、注释之类的)。';
$config_introduction = [
"title" => "请根据这个文章标题:{$title}",
"description" => "并同时参考公司的介绍:{$description}",
"event_content" => "以及公司参与的事件内容:{$event_content}",
"introduction" => $introduction,
"industry" => "引言内容请参考并引用'{$industry}'行业的一些专业数据报告",
"character" => $character,
"keyword" => "请一定要出现这个关键词'{$prefix}{$keyword}{$suffix}'",
'desc' => $desc
];
foreach ($config_introduction as $ki => $vi) {
if (empty($$ki)) {
unset($config_introduction[$ki]);
}
}
$aiCommandIntroduction = implode(',', $config_introduction);
//正文配置
$content = '给我写一篇Press Release正文内容(已经有引言内容了)';
$character = '需要 5-6 个大纲,每个大纲需要标题和 1-2 段内容,最后1-2个大纲主要介绍企业的核心优势、主营产品应用场景、主要客户案例,字数大约1000字';
$desc = '所有内容一定要用英文,只需要回复我新闻稿正文内容,不需要别的内容(比如序号、你的提示、寒暄、解释、注释之类的)。';
$config_content = [
"title" => "请根据这个文章标题:{$title}",
"description" => "并同时参考公司的介绍:{$description}",
"event_content" => "以及公司参与的事件内容:{$event_content}",
"content" => $content,
"keyword" => "正文内容请参考并引用'{$prefix}{$keyword}{$suffix}'行业的一些专业数据报告",
"character" => $character,
"footer" => "并最后附带内容:{$footer}",
"desc" => $desc
];
foreach ($config_content as $kc => $vc) {
if (empty($$kc)) {
unset($config_content[$kc]);
}
}
$aiCommandMain = implode(',', $config_content);
return ['command_introduction' => $aiCommandIntroduction, 'command_main' => $aiCommandMain];
}
}
... ...
... ... @@ -32,15 +32,22 @@ class GeoWritingsTaskRequest extends FormRequest
{
return [
'project_id' => 'required',
'company' => 'required|string',
'brand' => 'required|string',
'keyword' => 'required|string',
// 'prefix' => 'required|string',
// 'suffix' => 'required|string',
'event_title' => 'required|string',
// 'event_content' => 'required|string',
'title' => 'required|string|max:120',
'description' => 'required|string',
'keyword' => 'required',
'title' => 'required|max:120',
'command_introduction' => 'required',
'command_main' => 'required'
];
}
public function messages()
{
return [
'project_id.required' => '项目ID未知',
'keyword.required' => '关键词不能为空',
'title.required' => 'GEO文标题不能为空',
'title.max' => 'GEO文标题最多120个字符',
'command_introduction.required' => '生成引言内容命令不能为空',
'command_main.required' => '生成正文内容命令不能为空'
];
}
}
... ...
... ... @@ -610,6 +610,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/saveWritingTask', [Aside\Geo\GeoWritingTaskController::class, 'saveWritingTask'])->name('admin.geo_writing_task_saveWritingTask');
Route::any('/delWritingTask', [Aside\Geo\GeoWritingTaskController::class, 'delWritingTask'])->name('admin.geo_writing_task_delWritingTask');
Route::any('/sendAiTitle', [Aside\Geo\GeoWritingTaskController::class, 'sendAiTitle'])->name('admin.geo_writing_task_sendAiTitle');
Route::any('/getAiCommand', [Aside\Geo\GeoWritingTaskController::class, 'getAiCommand'])->name('admin.getAiCommand');
});
//geo文章管理
Route::prefix('writing')->group(function () {
... ...