作者 Your Name

Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev

... ... @@ -28,7 +28,12 @@ class AiCommandController extends BaseController
]);
#TODO 通过key获取到ai指令对象
$data = Common::send_openai_msg($this->chat_url,$this->param);
$this->set_ai_log($data);
$param = [
'key'=>$this->param['key'],
'keywords'=>$this->param['keywords'],
'remark'=>json_encode($data)
];
$this->set_ai_log($param);
$this->response('success',Code::SUCCESS,$data);
}
... ... @@ -42,8 +47,9 @@ class AiCommandController extends BaseController
//写入日志
$param = [
'key'=> $this->param['key'],
'keywords'=>$this->param['key'],
'remark' =>$data
'keywords'=>$this->param['keywords'],
'remark' =>$data['remark'],
'operator_id'=>$this->uid
];
$aiLog = new AiLog();
return $aiLog->add($param);
... ...
... ... @@ -8,6 +8,7 @@ use App\Helper\Arr;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Product\ProductLogic;
use App\Http\Requests\Bside\Product\ProductRequest;
use App\Models\Product\CategoryRelated;
use App\Rules\Ids;
use Illuminate\Http\Request;
... ... @@ -26,11 +27,18 @@ class ProductController extends BaseController
if(!empty($this->param['search'])){
$map[] = ['title', 'like', "%{$this->param['search']}%"];
}
if(!empty($this->param['created_at'])){
if(!empty($this->param['created_at'][0]) && !empty($this->param['created_at'][1])){
$map[] = ['created_at', 'between', $this->param['created_at']];
}
if(!empty($this->param['category_id'])){
$ids = CategoryRelated::where('cate_id', $this->param['category_id'])->pluck('product_id')->toArray();
$map[] = ['id', 'in', $ids];
}
if(!empty($this->param['status'])){
$map[] = ['status', $this->param['status']];
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort, ['id', 'title', 'thumb', 'category_id', 'keywords', 'status', 'created_at', 'updated_at']);
$data = $logic->getList($map, $sort, ['id', 'title', 'thumb', 'category_id', 'keywords', 'status', 'created_uid', 'created_at', 'updated_at']);
return $this->success($data);
}
... ... @@ -42,7 +50,7 @@ class ProductController extends BaseController
]);
$data = $logic->getInfo($this->param['id']);
return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'gallery', 'attrs', 'category_id', 'keywords', 'intro', 'content',
'describe', 'seo_mate', 'related_product_id', 'status']));
'describe', 'seo_mate', 'related_product_id', 'status', 'category_id_text', 'status_text', 'created_uid', 'created_uid_text']));
}
public function save(ProductRequest $request, ProductLogic $logic)
... ...
... ... @@ -192,7 +192,7 @@ class ImageController
'data' => $data,
];
$this->header['Content-Type'] = $type;
$response = response($result,$result_code,$this->header);;
$response = response($result,$result_code,$this->header);
throw new HttpResponseException($response);
}
}
... ...
... ... @@ -34,7 +34,7 @@ class ProjectGroupLogic extends BaseLogic
*/
public function group_add(){
//查看当前用户组是否存在
$this->model->read(['name'=>$this->param['name'],'create_id'=>1]);
$this->model->read(['name'=>$this->param['name'],'create_id'=>$this->user['id']]);
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('error');
... ... @@ -50,7 +50,10 @@ class ProjectGroupLogic extends BaseLogic
*/
public function group_edit(){
//查看当前用户组是否存在
$this->model->read(['name'=>$this->param['name'],'create_id'=>1]);
$rs = $this->model->read(['name'=>$this->param['name'],'create_id'=>$this->user['id']]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
... ... @@ -61,6 +64,11 @@ class ProjectGroupLogic extends BaseLogic
* @method
*/
public function group_del(){
$this->param['id'] = ['in',$this->param['id']];
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
}
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\Product;
use App\Helper\Arr;
use App\Http\Logic\Bside\BaseLogic;
use App\Http\Logic\Bside\User\UserLogic;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Product;
use App\Models\RouteMap;
... ... @@ -24,6 +25,32 @@ class ProductLogic extends BaseLogic
$this->model = new Product();
}
public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20)
{
$data = parent::getList($map, $sort, $columns, $limit);
foreach ($data['list'] as &$v){
foreach ($v['category_id'] as $category_id){
$v['category_id_text'][] =(new CategoryLogic())->getCacheInfo($category_id)['title']??'';
}
$v['category_id_text'] = Arr::arrToSet($v['category_id_text'], 'trim');
$v['status_text'] = Product::statusMap()[$v['status']] ?? '';
$v['created_uid_text'] = (new UserLogic())->getCacheInfo($v['created_uid'])['name'] ?? '';
}
return $this->success($data);
}
public function getInfo($id)
{
$info = parent::getInfo($id);
foreach ($info['category_id'] as $category_id) {
$info['category_id_text'][] = (new CategoryLogic())->getCacheInfo($category_id)['title'] ?? '';
}
$info['category_id_text'] = Arr::arrToSet($info['category_id_text'], 'trim');
$info['status_text'] = Product::statusMap()[$info['status']] ?? '';
$info['created_uid_text'] = (new UserLogic())->getCacheInfo($info['created_uid'])['name'] ?? '';
return $this->success($info);
}
public function save($param){
//封面取第一个图片
$param['thumb'] = $param['gallery'][0] ?? '';
... ... @@ -31,6 +58,7 @@ class ProductLogic extends BaseLogic
try {
$data = $param;
unset($data['route']);
$data['created_uid'] = $this->user['id'];
$res = parent::save($data);
//关联分类
CategoryRelated::saveRelated($res['id'], $data['category_id']);
... ...
... ... @@ -16,14 +16,14 @@ class Product extends Base
const STATUS_DRAFT = 0;
const STATUS_ON = 1;
const STATUS_OFF = 2;
const STATUS_RECYCLE = 2;
public static function statusMap(){
return [
self::STATUS_DRAFT => '草稿',
self::STATUS_ON => '已上架',
self::STATUS_OFF => '未上架',
self::STATUS_ON => '已发布',
self::STATUS_RECYCLE => '回收站',
];
}
... ...
<?php
namespace App\Models\Project;
use App\Models\Base;
class Country extends Base
{
protected $table = 'gl_project_country';
}
... ...
<?php
namespace App\Models;
class ProjectGroup extends Base
{
//设置关联表名
protected $table = 'gl_project_group';
//自动维护create_at创建时间 updated_at修改时间
public $timestamps = true;
}
<?php
namespace App\Models\WebSetting;
use App\Models\Base;
class WebSetting extends Base
{
protected $table = 'gl_web_setting';
}
... ...
<?php
namespace App\Models\WebSetting;
use App\Models\Base;
class WebSettingCountry extends Base
{
protected $table = 'gl_web_setting_country';
}
... ...
<?php
namespace App\Models\WebSetting;
use App\Models\Base;
class WebSettingForm extends Base
{
protected $table = 'gl_web_setting_from';
}
... ...
<?php
namespace App\Models\WebSetting;
use App\Models\Base;
class WebSettingHtml extends Base
{
protected $table = 'gl_web_setting_html';
}
... ...
<?php
namespace App\Models\WebSetting;
use App\Models\Base;
class WebSettingService extends Base
{
protected $table = 'gl_web_setting_service';
}
... ...
... ... @@ -106,7 +106,11 @@ Route::middleware(['bloginauth'])->group(function () {
//公用ai自动生成
Route::any('/ai_http_post', [\App\Http\Controllers\Bside\Ai\AiCommandController::class, 'ai_http_post'])->name('ai_http_post');
});
//ai指令
Route::prefix('setting')->group(function () {
//公用ai自动生成
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'lists'])->name('web_setting_lists');
});
//产品
Route::prefix('product')->group(function () {
//产品
... ...