|
@@ -1,4 +1,5 @@
|
|
|
<?php
|
|
|
+
|
|
|
namespace App\JsonRpc;
|
|
|
|
|
|
use App\Model\BlackWord;
|
|
@@ -15,6 +16,13 @@ use Hyperf\RpcServer\Annotation\RpcService;
|
|
|
use App\Service\MinioService;
|
|
|
use Hyperf\Redis\Redis;
|
|
|
|
|
|
+use App\Model\TemplateClass;
|
|
|
+use App\Model\Template;
|
|
|
+use App\Model\WebsiteTemplate;
|
|
|
+use App\Model\WebsiteTemplateInfo;
|
|
|
+use App\Model\Sector;
|
|
|
+use App\Model\Component;
|
|
|
+
|
|
|
#[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class PublicRpcService implements PublicRpcServiceInterface
|
|
|
{
|
|
@@ -27,24 +35,24 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
public function getDistrictList(array $data): array
|
|
|
{
|
|
|
$where = [];
|
|
|
- if(isset($data['keyWord'])){
|
|
|
- $where = [
|
|
|
- ['name','like','%'.$data['keyWord'].'%']
|
|
|
- ];
|
|
|
+ if (isset($data['keyWord'])) {
|
|
|
+ $where = [
|
|
|
+ ['name', 'like', '%' . $data['keyWord'] . '%']
|
|
|
+ ];
|
|
|
}
|
|
|
$result = [];
|
|
|
- if(isset($data['pageSize'])){
|
|
|
- $rep = District::where($where)->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->orderBy("code","asc")->get();
|
|
|
+ if (isset($data['pageSize'])) {
|
|
|
+ $rep = District::where($where)->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("code", "asc")->get();
|
|
|
$count = District::where($where)->count();
|
|
|
$result = [
|
|
|
- 'rows'=>$rep,
|
|
|
- 'count'=>$count
|
|
|
+ 'rows' => $rep,
|
|
|
+ 'count' => $count
|
|
|
|
|
|
];
|
|
|
- }else{
|
|
|
- $result = District::where($data)->orderBy("code","asc")->get();
|
|
|
+ } else {
|
|
|
+ $result = District::where($data)->orderBy("code", "asc")->get();
|
|
|
}
|
|
|
- return $result?Result::success($result):Result::error("没有查到数据");
|
|
|
+ return $result ? Result::success($result) : Result::error("没有查到数据");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -146,12 +154,14 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
->leftJoin("letter_type as type_e", "letter_of_complaint.nature_level3", "type_e.id")
|
|
|
->leftJoin("letter_type as type_d", "letter_of_complaint.status", "type_d.id")
|
|
|
|
|
|
- ->select("letter_of_complaint.*",
|
|
|
+ ->select(
|
|
|
+ "letter_of_complaint.*",
|
|
|
"type_a.type_name as nature_name",
|
|
|
"type_b.type_name as nature_name1",
|
|
|
"type_c.type_name as nature_name0",
|
|
|
"type_d.type_name as status_name",
|
|
|
- "type_e.type_name as nature_name3")
|
|
|
+ "type_e.type_name as nature_name3"
|
|
|
+ )
|
|
|
->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("letter_of_complaint.id", "desc")->get();
|
|
|
$count = LetterOfComplaint::where($where)->count();
|
|
|
if ($rep) {
|
|
@@ -182,12 +192,14 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
->leftJoin("letter_type as type_e", "letter_of_complaint.nature_level3", "type_e.id")
|
|
|
->leftJoin("letter_type as type_d", "letter_of_complaint.status", "type_d.id")
|
|
|
|
|
|
- ->select("letter_of_complaint.*",
|
|
|
+ ->select(
|
|
|
+ "letter_of_complaint.*",
|
|
|
"type_a.type_name as nature_name",
|
|
|
"type_b.type_name as nature_name1",
|
|
|
"type_c.type_name as nature_name0",
|
|
|
"type_d.type_name as status_name",
|
|
|
- "type_e.type_name as nature_name3")
|
|
|
+ "type_e.type_name as nature_name3"
|
|
|
+ )
|
|
|
->orderBy("letter_of_complaint.id", "desc")->get();
|
|
|
}
|
|
|
return $result ? Result::success($result) : Result::error("没有查到数据");
|
|
@@ -283,12 +295,14 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
->leftJoin("letter_type as type_e", "letter_of_complaint.nature_level3", "type_e.id")
|
|
|
->leftJoin("letter_type as type_d", "letter_of_complaint.status", "type_d.id")
|
|
|
|
|
|
- ->select("letter_of_complaint.*",
|
|
|
+ ->select(
|
|
|
+ "letter_of_complaint.*",
|
|
|
"type_a.type_name as nature_name",
|
|
|
"type_b.type_name as nature_name1",
|
|
|
"type_c.type_name as nature_name0",
|
|
|
"type_d.type_name as status_name",
|
|
|
- "type_e.type_name as nature_name3")
|
|
|
+ "type_e.type_name as nature_name3"
|
|
|
+ )
|
|
|
->first();
|
|
|
return Result::success($result);
|
|
|
}
|
|
@@ -300,12 +314,12 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
*/
|
|
|
public function delLetterOfComplaint(array $data): array
|
|
|
{
|
|
|
- $result = LetterOfComplaint::when($data,function ($query) use ($data){
|
|
|
- if(isset($data['id']) && !empty($data['id'])){
|
|
|
- $query->where(['id'=>$data['id']]);
|
|
|
+ $result = LetterOfComplaint::when($data, function ($query) use ($data) {
|
|
|
+ if (isset($data['id']) && !empty($data['id'])) {
|
|
|
+ $query->where(['id' => $data['id']]);
|
|
|
}
|
|
|
- if(isset($data['user_id']) && !empty($data['user_id'])){
|
|
|
- $query->where(['user_id'=>$data['user_id']]);
|
|
|
+ if (isset($data['user_id']) && !empty($data['user_id'])) {
|
|
|
+ $query->where(['user_id' => $data['user_id']]);
|
|
|
}
|
|
|
})->delete();
|
|
|
if (empty($result)) {
|
|
@@ -325,10 +339,10 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
if (isset($data['type'])) {
|
|
|
array_push($where, ['type', '=', $data['type']]);
|
|
|
}
|
|
|
- if (isset($data['pid']) && $data['pid']>0) {
|
|
|
+ if (isset($data['pid']) && $data['pid'] > 0) {
|
|
|
array_push($where, ['pid', '=', $data['pid']]);
|
|
|
}
|
|
|
- $result = LetterType::where($where)->orderBy('sort','asc')->get();
|
|
|
+ $result = LetterType::where($where)->orderBy('sort', 'asc')->get();
|
|
|
return $result ? Result::success($result) : Result::error("没有查到数据");
|
|
|
}
|
|
|
/**
|
|
@@ -389,7 +403,6 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
} else {
|
|
|
return Result::error("您不能处理其他人已经接过的案件", 0);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -478,20 +491,20 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function getDepartment(array $data) :array
|
|
|
+ public function getDepartment(array $data): array
|
|
|
{
|
|
|
$where = [];
|
|
|
- if(isset($data['pid'])){
|
|
|
+ if (isset($data['pid'])) {
|
|
|
$where = [
|
|
|
- 'pid'=>$data['pid']??0
|
|
|
+ 'pid' => $data['pid'] ?? 0
|
|
|
];
|
|
|
}
|
|
|
- $result = Department::when(!empty($where),function ($query) use ($where){
|
|
|
+ $result = Department::when(!empty($where), function ($query) use ($where) {
|
|
|
$query->where($where);
|
|
|
- })->orderBy("sort","desc")->get();
|
|
|
+ })->orderBy("sort", "desc")->get();
|
|
|
if (empty($result)) {
|
|
|
return Result::error("查询失败", 0);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
}
|
|
@@ -501,11 +514,11 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function getBuckets(array $data) :array
|
|
|
+ public function getBuckets(array $data): array
|
|
|
{
|
|
|
$result = new MinioService();
|
|
|
// 调用服务层的方法获取存储桶列表
|
|
|
- $bucketsResponse =$result->listBuckets();
|
|
|
+ $bucketsResponse = $result->listBuckets();
|
|
|
// 直接返回服务层生成的响应
|
|
|
return Result::success($bucketsResponse['data']);
|
|
|
}
|
|
@@ -515,16 +528,15 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function uploadFile(array $data) :array
|
|
|
+ public function uploadFile(array $data): array
|
|
|
{
|
|
|
$result = new MinioService();
|
|
|
$rep = $result->uploadFile($data);
|
|
|
- if($rep['code']==200){
|
|
|
+ if ($rep['code'] == 200) {
|
|
|
return Result::success($rep['data']);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return Result::error("上传失败!");
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -532,22 +544,25 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function getBlackWordList(array $data) :array
|
|
|
+ public function getBlackWordList(array $data): array
|
|
|
{
|
|
|
$result = BlackWord::when($data, function ($query) use ($data) {
|
|
|
- if (isset($data['name']) && $data['name']){
|
|
|
- $query->where('black_word.name', 'like', '%'.$data['name'].'%');
|
|
|
+ if (isset($data['name']) && $data['name']) {
|
|
|
+ $query->where('black_word.name', 'like', '%' . $data['name'] . '%');
|
|
|
}
|
|
|
- })->orderBy('black_word.id','desc')
|
|
|
- ->paginate(intval($data['pageSize']),
|
|
|
+ })->orderBy('black_word.id', 'desc')
|
|
|
+ ->paginate(
|
|
|
+ intval($data['pageSize']),
|
|
|
[
|
|
|
'black_word.*',
|
|
|
],
|
|
|
- 'page', intval($data['page']));
|
|
|
+ 'page',
|
|
|
+ intval($data['page'])
|
|
|
+ );
|
|
|
$count = $result->total();
|
|
|
$returnData = [
|
|
|
- 'rows'=>$result->items(),
|
|
|
- 'count'=>$count
|
|
|
+ 'rows' => $result->items(),
|
|
|
+ 'count' => $count
|
|
|
];
|
|
|
return Result::success($returnData);
|
|
|
}
|
|
@@ -557,12 +572,12 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function addBlackWord(array $data) :array
|
|
|
+ public function addBlackWord(array $data): array
|
|
|
{
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
- $info = BlackWord::where(['name'=>$data['name']])->first();
|
|
|
- if($info){
|
|
|
+ $info = BlackWord::where(['name' => $data['name']])->first();
|
|
|
+ if ($info) {
|
|
|
Db::rollBack();
|
|
|
return Result::error("该黑名单已存在", 0);
|
|
|
}
|
|
@@ -572,29 +587,28 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$this->redis->sAdd($redisKey, $data['name']);
|
|
|
Db::commit();
|
|
|
return Result::success(["id" => $result]);
|
|
|
- }catch (\Exception $e){
|
|
|
+ } catch (\Exception $e) {
|
|
|
Db::rollBack();
|
|
|
- return Result::error("创建失败".$e->getMessage(), 0);
|
|
|
+ return Result::error("创建失败" . $e->getMessage(), 0);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
/**
|
|
|
* 删除黑名单
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function delBlackWord(array $data) :array
|
|
|
+ public function delBlackWord(array $data): array
|
|
|
{
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
- BlackWord::where(['name'=>$data['name']])->delete();
|
|
|
+ BlackWord::where(['name' => $data['name']])->delete();
|
|
|
$redisKey = 'black_word';
|
|
|
$this->redis->sRem($redisKey, $data['name']);
|
|
|
Db::commit();
|
|
|
return Result::success([]);
|
|
|
- }catch (\Exception $e){
|
|
|
+ } catch (\Exception $e) {
|
|
|
Db::rollBack();
|
|
|
- return Result::error("删除失败".$e->getMessage(), 0);
|
|
|
+ return Result::error("删除失败" . $e->getMessage(), 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -603,34 +617,256 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function upBlackWord(array $data) :array
|
|
|
+ public function upBlackWord(array $data): array
|
|
|
{
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
- $checkInfo = BlackWord::where(['name'=>$data['name']])->first();
|
|
|
- if($checkInfo){
|
|
|
+ $checkInfo = BlackWord::where(['name' => $data['name']])->first();
|
|
|
+ if ($checkInfo) {
|
|
|
Db::rollBack();
|
|
|
return Result::error("该违禁词已经存在", 0);
|
|
|
}
|
|
|
- $blackWordInfo = BlackWord::where(['id'=>$data['id']])->first();
|
|
|
- if($blackWordInfo){
|
|
|
+ $blackWordInfo = BlackWord::where(['id' => $data['id']])->first();
|
|
|
+ if ($blackWordInfo) {
|
|
|
//先删除redis
|
|
|
$blackWordInfo = $blackWordInfo->toArray();
|
|
|
$redisKey = 'black_word';
|
|
|
$this->redis->sRem($redisKey, $blackWordInfo['name']);
|
|
|
$this->redis->sAdd($redisKey, $data['name']);
|
|
|
- BlackWord::where(['id'=>$data['id']])->update(['name'=>$data['name']]);
|
|
|
+ BlackWord::where(['id' => $data['id']])->update(['name' => $data['name']]);
|
|
|
Db::commit();
|
|
|
return Result::success([]);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
Db::rollBack();
|
|
|
return Result::error("系统错误", 0);
|
|
|
}
|
|
|
- }catch (\Exception $e){
|
|
|
+ } catch (\Exception $e) {
|
|
|
Db::rollBack();
|
|
|
- return Result::error("修改失败".$e->getMessage(), 0);
|
|
|
+ return Result::error("修改失败" . $e->getMessage(), 0);
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 获取getTemplateClass
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getTemplateClass(array $data): array
|
|
|
+ {
|
|
|
+ $result = TemplateClass::get();
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ public function getTemplateList(array $data): array
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ if (!empty($data['template_class_id'])) {
|
|
|
+ $where['template_class_id'] = $data['template_class_id'];
|
|
|
+ }
|
|
|
+ if (!empty($data['template_name'])) {
|
|
|
+ $where['template_name'] = $data['template_name'];
|
|
|
+ }
|
|
|
+ $result = Template::where($where)
|
|
|
+ ->leftJoin('template_class', 'template.template_class_id', 'template_class.id')
|
|
|
+ ->select('template.*', 'template_class.name as template_class_name')
|
|
|
+ ->orderBy('template.id', 'desc')
|
|
|
+ ->paginate($data['page_size'], ['*'], 'mypage_name', $data['page']);
|
|
|
+ // 使用 items 方法获取分页数据
|
|
|
+ // $items = collect($result->items());
|
|
|
+ // $items->each(function ($item) {
|
|
|
+ // $item['template_content'] = json_decode($item['template_content'], true);
|
|
|
+ // });
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ public function getTemplateInfo(array $data): array
|
|
|
+ {
|
|
|
+ $result = Template::where('template.id', $data['id'])
|
|
|
+ ->leftJoin('template_class', 'template.template_class_id', 'template_class.id')
|
|
|
+ ->select('template.*', 'template_class.name as template_class_name')
|
|
|
+ ->first();
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ public function addTemplate(array $data): array
|
|
|
+ {
|
|
|
+ var_dump($data);
|
|
|
+ unset($data['user_id']);
|
|
|
+ $result = Template::insertGetId($data);
|
|
|
+ if ($result) {
|
|
|
+ $returData = Template::where('id', $result)->first();
|
|
|
+ return Result::success($returData);
|
|
|
+ } else {
|
|
|
+ return Result::error("添加失败", 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function delTemplate(array $data): array
|
|
|
+ {
|
|
|
+ $result = Template::where('id', $data['id'])->delete();
|
|
|
+ var_dump($result, '-------------------delete');
|
|
|
+ if ($result) {
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error("删除失败", 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function updateTemplate(array $data): array
|
|
|
+ {
|
|
|
+ unset($data['user_id']);
|
|
|
+ $result = Template::where('id', $data['id'])->update($data);
|
|
|
+ var_dump($result, '-------------------update');
|
|
|
+ if (!$result) {
|
|
|
+ return Result::error("更新失败", 0);
|
|
|
+ } else {
|
|
|
+ return Result::success('更新成功');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function getSectorList(array $data): array
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ if (!empty($data['template_class_id'])) {
|
|
|
+ $where['template_class.id'] = $data['template_class_id'];
|
|
|
+ }
|
|
|
+ if (!empty($data['template_class_name'])) {
|
|
|
+ $where[] = ['template_class.name', 'like', '%' . $data['template_class_name'] . '%'];
|
|
|
+ }
|
|
|
|
|
|
-}
|
|
|
+ if (!empty($data['sector_name'])) {
|
|
|
+ if (!empty($data['sector_name'])) {
|
|
|
+ // $where['sector_name'] = $data['sector_name'];
|
|
|
+ $where[] = ['sector.sector_name', 'like', '%' . $data['sector_name'] . '%'];
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ $result = Sector::where($where)
|
|
|
+ ->leftJoin('template', 'template.id', '=', 'sector.template_id')
|
|
|
+ ->leftJoin('template_class', 'template_class.id', '=', 'sector.template_id') // 添加这一行
|
|
|
+ ->select('sector.*', 'sector.sector_name', 'template.template_name', 'template_class.name as template_class_name', 'template_class.id as template_class_id') // 修改这一行
|
|
|
+ ->orderBy('sector.id', 'desc')
|
|
|
+ ->paginate($data['page_size'], ['*'], 'mypage_name', $data['page']);
|
|
|
+
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ public function getSectorInfo(array $data): array
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ $where[] = ['sector.id', '=', $data['id']];
|
|
|
+ $result = Sector::where($where)
|
|
|
+ ->leftJoin('template', 'template.id', '=', 'sector.template_id')
|
|
|
+ ->leftJoin('template_class', 'template_class.id', '=', 'template.template_class_id') // 添加这一行
|
|
|
+ ->select('sector.*', 'template.template_name', 'template_class.name as template_class_name', 'template_class.id as template_class_id') // 修改这一行
|
|
|
+ ->orderBy('sector.id', 'desc')
|
|
|
+ ->get();
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ public function addSector(array $data): array
|
|
|
+ {
|
|
|
+ unset($data['user_id']);
|
|
|
+ // $data['page_type'] = json_encode($data['page_type']);
|
|
|
+ $result = Sector::insertGetId($data);
|
|
|
+ return Result::success();
|
|
|
+ }
|
|
|
+ public function delSector(array $data): array
|
|
|
+ {
|
|
|
+ $result = Sector::where('id', $data['id'])->delete();
|
|
|
+ if ($result == 1) {
|
|
|
+ return Result::success('删除成功');
|
|
|
+ } else {
|
|
|
+ return Result::error('删除失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function updateSector(array $data): array
|
|
|
+ {
|
|
|
+ unset($data['user_id']);
|
|
|
+ $result = Sector::where('id', $data['id'])->update($data);
|
|
|
+ if ($result == 1) {
|
|
|
+ return Result::success('修改成功');
|
|
|
+ } else {
|
|
|
+ return Result::error('修改失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function getComponentList(array $data): array
|
|
|
+ {
|
|
|
+ var_dump($data, '---------');
|
|
|
+ $where = [];
|
|
|
+ // $where[] = ['sector.id', '=', $data['id']];
|
|
|
+ if (!empty($data['template_class_id'])) {
|
|
|
+ $where['template_class.id'] = $data['template_class_id'];
|
|
|
+ }
|
|
|
+ if (!empty($data['component_name'])) {
|
|
|
+ $where['component.component_name'] = $data['component_name'];
|
|
|
+ }
|
|
|
+ if (!empty($data['sector_id'])) {
|
|
|
+ $where['sector.id'] = $data['sector_id'];
|
|
|
+ };
|
|
|
+
|
|
|
+ $result = Component::where($where)
|
|
|
+ ->leftJoin('template', 'template.id', '=', 'component.template_id')
|
|
|
+ ->leftJoin('template_class', 'template_class.id', '=', 'template.template_class_id') // 添加这一行
|
|
|
+ ->leftJoin('sector', 'sector.id', '=', 'component.sector_id')
|
|
|
+ ->select('template_class.name as template_class_name', 'template.template_name as template_name', 'template_class.id as template_class_id', 'sector.sector_name as sector_name', 'component.*', 'sector.id as sector_id') // 修改这一行)
|
|
|
+ ->orderBy('sector.updated_at', 'desc')
|
|
|
+ ->orderBy('sector.created_at', 'desc')
|
|
|
+ ->paginate($data['page_size'], ['*'], 'mypage_name', $data['page']);
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ public function getComponentInfo(array $data): array
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ $result = Component::where($where)
|
|
|
+ ->leftJoin('template', 'template.id', '=', 'component.template_id')
|
|
|
+ ->leftJoin('template_class', 'template_class.id', '=', 'template.template_class_id') // 添加这一行
|
|
|
+ ->leftJoin('sector', 'sector.id', '=', 'component.sector_id')
|
|
|
+ ->select('template_class.name as template_class_name', 'template.template_name as template_name', 'sector.sector_name as sector_name', 'component.*')
|
|
|
+ ->get();
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ public function addComponent(array $data): array
|
|
|
+ {
|
|
|
+ unset($data['user_id']);
|
|
|
+ $result = Component::insertGetId($data);
|
|
|
+ if ($result) {
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error('添加失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function delComponent(array $data): array
|
|
|
+ {
|
|
|
+ $result = Component::where('id', $data['id'])->delete();
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ public function updateComponent(array $data): array
|
|
|
+ {
|
|
|
+ $result = Component::where('id', $data['id'])->update($data);
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ public function getWebsiteTemplateList(array $data): array
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+
|
|
|
+ $result = WebsiteTemplateInfo::where($where)
|
|
|
+ ->leftJoin('website', 'website_template_info.website_id', '=', 'website.id')
|
|
|
+ ->select('website_template_info.*', 'website.website_name')
|
|
|
+ ->orderBy('website_template_info.id', 'desc')
|
|
|
+ ->paginate($data['page_size'], ['*'], 'page', $data['page']);
|
|
|
+ if ($result) {
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error('暂无数据');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function getWebsiteTemplateInfo(array $data)
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ if (isset($data['id'])) {
|
|
|
+ $where[] = ['id', '=', $data['id']];
|
|
|
+ }
|
|
|
+ $result = WebsiteTemplateInfo::where($where)
|
|
|
+ ->leftJoin('website', 'website_template_info.website_id', '=', 'website.id')
|
|
|
+ ->leftJoin('website_template', 'website_template_info.template_id', '=', 'website_template.id')
|
|
|
+ ->select('website_template_info.*', 'website.website_name')
|
|
|
+ ->get();
|
|
|
+ if ($result) {
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error('暂无数据');
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|