|
@@ -35,7 +35,7 @@ use App\Model\Website;
|
|
|
use App\Constants\ErrorCode;
|
|
|
use GuzzleHttp\Client;
|
|
|
use GuzzleHttp\Exception\GuzzleException;
|
|
|
-
|
|
|
+use App\Model\SectorPlace;
|
|
|
#[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class PublicRpcService implements PublicRpcServiceInterface
|
|
|
{
|
|
@@ -945,6 +945,23 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
return Result::success('更新成功');
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 获取所有尺寸
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getAllSize(array $data): array
|
|
|
+ {
|
|
|
+ if(isset($data['id']) && !empty($data['id'])){
|
|
|
+ $result = Size::where('id', $data['id'])->get()->all();
|
|
|
+ }else{
|
|
|
+ $result = Size::get()->all();
|
|
|
+ }
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("暂无尺寸", 0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
/**
|
|
|
* 根据皮肤名称-获取所有皮肤
|
|
|
* @param array $data
|
|
@@ -974,7 +991,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
{
|
|
|
$where = [];
|
|
|
if (isset($data['template_class_id']) && !empty($data['template_class_id'])) {
|
|
|
- $where['template_class.class_id'] = $data['template_class_id'];
|
|
|
+ $where['template.template_class_id'] = $data['template_class_id'];
|
|
|
}
|
|
|
if (isset($data['template_id']) && !empty($data['template_id'])) {
|
|
|
array_push($where, ['template.template_id', $data['template_id']]);
|
|
@@ -991,17 +1008,20 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
} else {
|
|
|
$size_id = [];
|
|
|
}
|
|
|
- // $size_id = $size_id->toArray();
|
|
|
- $result = Sector::where($where)
|
|
|
- ->when(!empty($size_id), function ($query) use ($size_id) {
|
|
|
+ $result = Sector::when(!empty($size_id), function ($query) use ($size_id) {
|
|
|
$query->whereIn('size_id', $size_id);
|
|
|
})
|
|
|
->leftJoin('size', 'size.id', '=', 'sector.size_id')
|
|
|
- ->leftJoin('template_class', 'template_class.class_id', '=', 'sector.template_class_id')
|
|
|
->leftJoin('template', 'template.template_id', '=', 'sector.template_id')
|
|
|
- ->select('sector.*', 'size.width', 'size.height', 'template_class.name as class_name', 'template.template_name')
|
|
|
+ ->leftJoin('template_class', 'template_class.class_id', '=', 'template.template_class_id')
|
|
|
+ ->where($where)
|
|
|
+ ->select('sector.*', 'size.width','size.height','template_class.name as class_name','template.template_name')
|
|
|
+
|
|
|
->orderBy('sector.id', 'desc')
|
|
|
->paginate($data['page_size'], ['*'], 'page', $data['page']);
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error('暂无通栏!');
|
|
|
+ }
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
/**
|
|
@@ -1129,23 +1149,14 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$data['page_type'] = array_values(array_unique(array_map('intval', $data['page_type'])));
|
|
|
$data['page_type'] = json_encode($data['page_type']);
|
|
|
$template = Template::where('template_id', $data['template_id'])
|
|
|
- ->whereRaw("JSON_CONTAINS(template.page_type, ?)", [$data['page_type']])
|
|
|
->first();
|
|
|
if (empty($template)) {
|
|
|
return Result::error('皮肤不存在!');
|
|
|
}
|
|
|
- // 皮肤相关信息
|
|
|
- $data['template_name'] = $template['template_name'];
|
|
|
- $data['template_id'] = $template['template_id'];
|
|
|
- // 风格相关信息
|
|
|
- $template_class = TemplateClass::where('class_id', $template['template_class_id'])->first();
|
|
|
- if (empty($template_class)) {
|
|
|
- return Result::error('所属风格不存在!');
|
|
|
+ $sector_id = Sector::where('sector_id',$data['sector_id'])->first();
|
|
|
+ if(!empty($sector_id)){
|
|
|
+ return Result::error('通栏编号已存在!');
|
|
|
}
|
|
|
- // $data['sector_keyword'] = json_encode($data['sector_keyword']);
|
|
|
- $data['template_class_id'] = $template_class['class_id'];
|
|
|
- $data['template_class_name'] = $template_class['name'];
|
|
|
-
|
|
|
$result = Sector::insertGetId($data);
|
|
|
if (empty($result)) {
|
|
|
return Result::error('添加失败');
|
|
@@ -1182,6 +1193,12 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
if (empty($sector)) {
|
|
|
return Result::error('通栏不存在!');
|
|
|
}
|
|
|
+ if($sector['sector_id'] != $data['sector_id']){
|
|
|
+ $sector_id = Sector::where('sector_id',$data['sector_id'])->first();
|
|
|
+ if(!empty($sector_id)){
|
|
|
+ return Result::error('通栏编号已存在!');
|
|
|
+ }
|
|
|
+ }
|
|
|
// 对传入的 page_type 数组进行去重、转换为整数并重新索引
|
|
|
$data['page_type'] = array_values(array_unique(array_map('intval', $data['page_type'])));
|
|
|
$data['page_type'] = json_encode($data['page_type']);
|
|
@@ -1191,17 +1208,6 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
if (empty($template)) {
|
|
|
return Result::error('皮肤不存在!');
|
|
|
}
|
|
|
- // 皮肤相关信息
|
|
|
- $data['template_name'] = $template['template_name'];
|
|
|
- $data['template_id'] = $template['template_id'];
|
|
|
- // 风格相关信息
|
|
|
- $template_class = TemplateClass::where('class_id', $template['template_class_id'])->first();
|
|
|
- if (empty($template_class)) {
|
|
|
- return Result::error('所属风格不存在!');
|
|
|
- }
|
|
|
- // $data['sector_keyword'] = json_encode($data['sector_keyword']);
|
|
|
- $data['template_class_id'] = $template_class['class_id'];
|
|
|
- $data['template_class_name'] = $template_class['name'];
|
|
|
$result = Sector::where('id', $data['id'])->update($data);
|
|
|
if ($result == 1) {
|
|
|
return Result::success('修改成功');
|
|
@@ -1518,4 +1524,33 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
}
|
|
|
return Result::success($template);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 自助建站-通栏管理-获取通栏位置
|
|
|
+ */
|
|
|
+ public function getSectorPlace(array $data): array
|
|
|
+ {
|
|
|
+ if(isset($data['sector_num']) && !empty($data['sector_num'])){
|
|
|
+ $where['t.sector_num'] = $data['sector_num'];
|
|
|
+ $template = DB::table(DB::raw('(
|
|
|
+ SELECT
|
|
|
+ sp.*,
|
|
|
+ s.width,
|
|
|
+ s.height,
|
|
|
+ ROW_NUMBER() OVER (PARTITION BY sp.type ORDER BY sp.id DESC) as rn
|
|
|
+ FROM sector_place sp
|
|
|
+ LEFT JOIN size s ON sp.size_id = s.id
|
|
|
+ ) as t'))
|
|
|
+ ->where('rn', 1)
|
|
|
+ ->where($where)
|
|
|
+ ->select('t.*')
|
|
|
+ ->get();
|
|
|
+ }
|
|
|
+ if(isset($data['type']) && !empty($data['type'])){
|
|
|
+ $template = SectorPlace::where('type', $data['type'])->get()->all();
|
|
|
+ }
|
|
|
+ if(empty($template)){
|
|
|
+ return Result::error('未查询到通栏位置相关模版!');
|
|
|
+ }
|
|
|
+ return Result::success($template);
|
|
|
+ }
|
|
|
}
|