PublicRpcService.php 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824
  1. <?php
  2. namespace App\JsonRpc;
  3. use _PHPStan_62c6a0a8b\OndraM\CiDetector\Env;
  4. use App\Model\BlackWord;
  5. use App\Model\Department;
  6. use App\Model\District;
  7. use App\Model\LetterOfComplaint;
  8. use App\Model\LetterType;
  9. use App\Model\LevelUser;
  10. use App\Model\UserLevel;
  11. use App\Tools\Result;
  12. use Hyperf\DbConnection\Db;
  13. use Hyperf\Di\Annotation\Inject;
  14. use Hyperf\RpcServer\Annotation\RpcService;
  15. use App\Service\MinioService;
  16. use Hyperf\Redis\Redis;
  17. use Overtrue\ChineseCalendar\Calendar;
  18. use App\Model\TemplateClass;
  19. use App\Model\Template;
  20. use App\Model\WebsiteTemplate;
  21. use App\Model\WebsiteTemplateInfo;
  22. use App\Model\Sector;
  23. use App\Model\Component;
  24. use App\Model\Link;
  25. use App\Model\FooterCategory;
  26. use App\Model\Size;
  27. use function Hyperf\Support\retry;
  28. use Hyperf\Paginator\Paginator;
  29. use App\Model\User;
  30. use App\Model\Website;
  31. use App\Constants\ErrorCode;
  32. use GuzzleHttp\Client;
  33. use GuzzleHttp\Exception\GuzzleException;
  34. use App\Model\SectorPlace;
  35. #[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
  36. class PublicRpcService implements PublicRpcServiceInterface
  37. {
  38. #[Inject]
  39. protected Redis $redis;
  40. /**
  41. * @param array $data
  42. * @return array
  43. */
  44. public function getDistrictList(array $data): array
  45. {
  46. $where = [];
  47. if (isset($data['keyWord'])) {
  48. $where = [
  49. ['name', 'like', '%' . $data['keyWord'] . '%']
  50. ];
  51. }
  52. $result = [];
  53. if (isset($data['pageSize'])) {
  54. $rep = District::where($where)->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("code", "asc")->get();
  55. $count = District::where($where)->count();
  56. $result = [
  57. 'rows' => $rep,
  58. 'count' => $count
  59. ];
  60. } else {
  61. $result = District::where($data)->orderBy("code", "asc")->get();
  62. }
  63. return $result ? Result::success($result) : Result::error("没有查到数据");
  64. }
  65. /**
  66. * @param array $data
  67. * @return array
  68. */
  69. public function getUserLevelList(array $data): array
  70. {
  71. $where = [];
  72. if (isset($data['keyWord'])) {
  73. $where = [
  74. ['name', 'like', '%' . $data['keyWord'] . '%'],
  75. ];
  76. }
  77. $result = [];
  78. if (isset($data['pageSize'])) {
  79. $rep = UserLevel::where($where)->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("id", "asc")->get();
  80. $count = UserLevel::where($where)->count();
  81. $result = [
  82. 'rows' => $rep,
  83. 'count' => $count,
  84. ];
  85. } else {
  86. $result = UserLevel::orderBy("id", "asc")->get();
  87. }
  88. return $result ? Result::success($result) : Result::error("没有查到数据");
  89. }
  90. /**
  91. * 添加用户等级
  92. * @param array $data
  93. * @return array
  94. */
  95. public function addUserLevel(array $data): array
  96. {
  97. LevelUser::insertGetId($data);
  98. return Result::success([]);
  99. }
  100. /**
  101. * 更新等级
  102. * @param array $data
  103. * @return array
  104. */
  105. public function updateUserLevel(array $data): array
  106. {
  107. $result = LevelUser::where(['id' => $data['id']])->update($data);
  108. if ($result) {
  109. return Result::success($result);
  110. }
  111. return Result::error("更新失败");
  112. }
  113. /**
  114. * 删除等级
  115. * @param array $data
  116. * @return array
  117. */
  118. public function delUserLevel(array $data): array
  119. {
  120. $result = LevelUser::where(['id' => $data['id']])->delete();
  121. if ($result) {
  122. return Result::success($result);
  123. }
  124. return Result::error("删除失败");
  125. }
  126. /**
  127. * 查询投诉举报信息
  128. * @param array $data
  129. * @return array
  130. */
  131. public function getLetterOfComplaint(array $data = []): array
  132. {
  133. var_dump("====");
  134. $where = [];
  135. if (isset($data['user_id']) && !empty($data['user_id'])) {
  136. array_push($where, ['letter_of_complaint.user_id', '=', $data['user_id']]);
  137. }
  138. if (isset($data['nature']) && !empty($data['nature'])) {
  139. array_push($where, ['letter_of_complaint.nature', '=', $data['nature']]);
  140. }
  141. if (isset($data['nature_level0']) && !empty($data['nature_level0'])) {
  142. array_push($where, ['letter_of_complaint.nature_level0', '=', $data['nature_level0']]);
  143. }
  144. if (isset($data['status']) && !empty($data['status'])) {
  145. array_push($where, ['letter_of_complaint.status', '=', $data['status']]);
  146. }
  147. $result = [];
  148. if (isset($data['pageSize'])) {
  149. $rep = LetterOfComplaint::where($where)
  150. ->leftJoin("letter_type as type_a", "letter_of_complaint.nature", "type_a.id")
  151. ->leftJoin("letter_type as type_c", "letter_of_complaint.nature_level0", "type_c.id")
  152. ->leftJoin("letter_type as type_b", "letter_of_complaint.nature_level1", "type_b.id")
  153. ->leftJoin("letter_type as type_e", "letter_of_complaint.nature_level3", "type_e.id")
  154. ->leftJoin("letter_type as type_d", "letter_of_complaint.status", "type_d.id")
  155. ->select(
  156. "letter_of_complaint.*",
  157. "type_a.type_name as nature_name",
  158. "type_b.type_name as nature_name1",
  159. "type_c.type_name as nature_name0",
  160. "type_d.type_name as status_name",
  161. "type_e.type_name as nature_name3"
  162. )
  163. ->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("letter_of_complaint.id", "desc")->get();
  164. $count = LetterOfComplaint::where($where)->count();
  165. if ($rep) {
  166. foreach ($rep as $val) {
  167. if ($val['judgment']) {
  168. $val['judgment'] = json_decode($val['judgment']);
  169. }
  170. if ($val['audio_and_video']) {
  171. $val['audio_and_video'] = json_decode($val['audio_and_video']);
  172. }
  173. if ($val['contract']) {
  174. $val['contract'] = json_decode($val['contract']);
  175. }
  176. if ($val['qualifications']) {
  177. $val['qualifications'] = json_decode($val['qualifications']);
  178. }
  179. }
  180. }
  181. $result = [
  182. 'rows' => $rep,
  183. 'count' => $count,
  184. ];
  185. } else {
  186. $result = LetterOfComplaint::where($where)
  187. ->leftJoin("letter_type as type_a", "letter_of_complaint.nature", "type_a.id")
  188. ->leftJoin("letter_type as type_c", "letter_of_complaint.nature_level0", "type_c.id")
  189. ->leftJoin("letter_type as type_b", "letter_of_complaint.nature_level1", "type_b.id")
  190. ->leftJoin("letter_type as type_e", "letter_of_complaint.nature_level3", "type_e.id")
  191. ->leftJoin("letter_type as type_d", "letter_of_complaint.status", "type_d.id")
  192. ->select(
  193. "letter_of_complaint.*",
  194. "type_a.type_name as nature_name",
  195. "type_b.type_name as nature_name1",
  196. "type_c.type_name as nature_name0",
  197. "type_d.type_name as status_name",
  198. "type_e.type_name as nature_name3"
  199. )
  200. ->orderBy("letter_of_complaint.id", "desc")->get();
  201. }
  202. return $result ? Result::success($result) : Result::error("没有查到数据");
  203. }
  204. /**
  205. * 添加投诉举报信息
  206. * @param array $data
  207. * @return array
  208. */
  209. public function addLetterOfComplaint(array $data): array
  210. {
  211. $data['judgment'] = $data['judgment'] ? json_encode($data['judgment']) : '';
  212. $data['audio_and_video'] = $data['audio_and_video'] ? json_encode($data['audio_and_video']) : '';
  213. $data['contract'] = $data['contract'] ? json_encode($data['contract']) : '';
  214. $data['qualifications'] = $data['qualifications'] ? json_encode($data['qualifications']) : '';
  215. unset($data['id']);
  216. $result = LetterOfComplaint::insertGetId($data);
  217. if (empty($result)) {
  218. return Result::error("创建失败", 0);
  219. } else {
  220. return Result::success(["id" => $result]);
  221. }
  222. }
  223. /**
  224. * 用户端更新投诉举报
  225. * @param array $data
  226. * @return array
  227. */
  228. public function userUpLetterOfComplaint(array $data): array
  229. {
  230. $data['judgment'] = $data['judgment'] ? json_encode($data['judgment']) : '';
  231. $data['audio_and_video'] = $data['audio_and_video'] ? json_encode($data['audio_and_video']) : '';
  232. $data['contract'] = $data['contract'] ? json_encode($data['contract']) : '';
  233. $data['qualifications'] = $data['qualifications'] ? json_encode($data['qualifications']) : '';
  234. $result = LetterOfComplaint::where(['id' => $data['id']])->update($data);
  235. if (empty($result)) {
  236. return Result::error("创建失败", 0);
  237. } else {
  238. return Result::success(["id" => $result]);
  239. }
  240. }
  241. /**
  242. * 管理后台更新投诉举报信息
  243. * @param array $data
  244. * @return array
  245. */
  246. public function upLetterOfComplaint(array $data): array
  247. {
  248. var_dump("admin:", $data);
  249. $where = [
  250. 'id' => $data['id'],
  251. ];
  252. $filtered_array = array_filter($data, function ($value) {
  253. return $value !== "" && $value !== null && $value !== false && !is_array($value) || !empty($value);
  254. });
  255. $filtered_array['judgment'] = isset($filtered_array['judgment']) ? json_encode($filtered_array['judgment']) : '';
  256. $filtered_array['audio_and_video'] = isset($filtered_array['audio_and_video']) ? json_encode($filtered_array['audio_and_video']) : '';
  257. $filtered_array['contract'] = isset($filtered_array['contract']) ? json_encode($filtered_array['contract']) : '';
  258. $filtered_array['qualifications'] = isset($filtered_array['qualifications']) ? json_encode($filtered_array['qualifications']) : '';
  259. unset($filtered_array['nature_name']);
  260. unset($filtered_array['type_name']);
  261. unset($filtered_array['nature_level_name']);
  262. unset($filtered_array['status_name']);
  263. unset($filtered_array['is_admin']);
  264. unset($filtered_array['type_level_name']);
  265. $result = LetterOfComplaint::where($where)->update($filtered_array);
  266. if ($result) {
  267. return Result::success($result);
  268. }
  269. return Result::error("更新失败", 0);
  270. }
  271. /**
  272. * 查询投诉举报记录
  273. * @param array $data
  274. * @return array
  275. */
  276. public function getLetterOfComplaintInfo(array $data): array
  277. {
  278. $where = [
  279. 'letter_of_complaint.id' => $data['id'],
  280. ];
  281. if (isset($data['user_id']) && !empty($data['user_id'])) {
  282. array_push($where, ['letter_of_complaint.user_id', '=', $data['user_id']]);
  283. }
  284. $result = LetterOfComplaint::where($where)
  285. ->leftJoin("letter_type as type_a", "letter_of_complaint.nature", "type_a.id")
  286. ->leftJoin("letter_type as type_c", "letter_of_complaint.nature_level0", "type_c.id")
  287. ->leftJoin("letter_type as type_b", "letter_of_complaint.nature_level1", "type_b.id")
  288. ->leftJoin("letter_type as type_e", "letter_of_complaint.nature_level3", "type_e.id")
  289. ->leftJoin("letter_type as type_d", "letter_of_complaint.status", "type_d.id")
  290. ->select(
  291. "letter_of_complaint.*",
  292. "type_a.type_name as nature_name",
  293. "type_b.type_name as nature_name1",
  294. "type_c.type_name as nature_name0",
  295. "type_d.type_name as status_name",
  296. "type_e.type_name as nature_name3"
  297. )
  298. ->first();
  299. return Result::success($result);
  300. }
  301. /**
  302. * 删除投诉举报信息
  303. * @param array $data
  304. * @return array
  305. */
  306. public function delLetterOfComplaint(array $data): array
  307. {
  308. $result = LetterOfComplaint::when($data, function ($query) use ($data) {
  309. if (isset($data['id']) && !empty($data['id'])) {
  310. $query->where(['id' => $data['id']]);
  311. }
  312. if (isset($data['user_id']) && !empty($data['user_id'])) {
  313. $query->where(['user_id' => $data['user_id']]);
  314. }
  315. })->delete();
  316. if (empty($result)) {
  317. return Result::error("删除失败", 0);
  318. } else {
  319. return Result::success();
  320. }
  321. }
  322. /**
  323. * 获取举报信息类型
  324. * @param array $data
  325. * @return array
  326. */
  327. public function getLetterType(array $data): array
  328. {
  329. $where = [];
  330. if (isset($data['type'])) {
  331. array_push($where, ['type', '=', $data['type']]);
  332. }
  333. if (isset($data['pid']) && $data['pid'] > 0) {
  334. array_push($where, ['pid', '=', $data['pid']]);
  335. }
  336. $result = LetterType::where($where)->orderBy('sort', 'asc')->get();
  337. return $result ? Result::success($result) : Result::error("没有查到数据");
  338. }
  339. /**
  340. * 更新举报类型
  341. * @param array $data
  342. * @return array
  343. */
  344. public function upLetterType(array $data): array
  345. {
  346. return [];
  347. }
  348. /**
  349. * 添加举报类型
  350. * @param array $data
  351. * @return array
  352. */
  353. public function addLetterType(array $data): array
  354. {
  355. $result = LetterType::insertGetId($data);
  356. if (empty($result)) {
  357. return Result::error("创建失败", 0);
  358. } else {
  359. return Result::success(["id" => $result]);
  360. }
  361. }
  362. /**
  363. * 删除举报类型
  364. * @param array $data
  365. * @return array
  366. */
  367. public function delLetterType(array $data): array
  368. {
  369. $result = LetterType::where('id', $data['id'])->delete();
  370. if (empty($result)) {
  371. return Result::error("删除失败", 0);
  372. } else {
  373. return Result::success();
  374. }
  375. }
  376. /**
  377. * 检测是否已经被接案
  378. * @param array $data
  379. * @return array
  380. */
  381. public function checkMeasure(array $data): array
  382. {
  383. $where = [
  384. 'id' => $data['id'],
  385. ];
  386. $letterOfComplaintInfo = LetterOfComplaint::where($where)->first();
  387. var_dump("查询数据:", $letterOfComplaintInfo['admin_id'], $data['user_id']);
  388. //操作人和当前登陆用户id 相等说明是当前人接收的案件
  389. if (($letterOfComplaintInfo['admin_id'] == $data['user_id']) || empty($letterOfComplaintInfo['admin_id'])) {
  390. return Result::success();
  391. } else {
  392. return Result::error("您不能处理其他人已经接过的案件", 0);
  393. }
  394. }
  395. /**
  396. * 后台获取职能部门
  397. * @param array $data
  398. * @return array
  399. */
  400. public function getZhinengbumenList(array $data): array
  401. {
  402. // 获取分页参数,默认每页 10 条记录
  403. $page = isset($data['page']) ? (int) $data['page'] : 1;
  404. $perPage = isset($data['pagesize']) ? (int) $data['pagesize'] : 10;
  405. // 查询数据并分页
  406. $query = Department::query();
  407. // 可以在这里添加更多的查询条件
  408. if (isset($data['search'])) {
  409. $query->where('name', 'like', '%' . $data['search'] . '%');
  410. }
  411. // 执行分页查询
  412. $result = $query->paginate($perPage, ['*'], 'page', $page);
  413. // 返回分页结果
  414. return Result::success([
  415. 'count' => $result->total(),
  416. 'current_page' => $result->currentPage(),
  417. 'last_page' => $result->lastPage(),
  418. 'pagesize' => $result->perPage(),
  419. 'rows' => $result->items(),
  420. ]);
  421. }
  422. /**
  423. * 添加获取职能部门
  424. * @param array $data
  425. * @return array
  426. */
  427. public function addZhinengbumen(array $data): array
  428. {
  429. $result = Department::insertGetId($data);
  430. if (empty($result)) {
  431. return Result::error("创建失败", 0);
  432. } else {
  433. return Result::success(["id" => $result]);
  434. }
  435. }
  436. public function delZhinengbumen(array $data): array
  437. {
  438. $result = Department::where('id', $data['id'])->delete();
  439. if (empty($result)) {
  440. return Result::error("删除失败", 0);
  441. } else {
  442. return Result::success();
  443. }
  444. }
  445. public function getZhinengbumen(array $data): array
  446. {
  447. $result = Department::where('id', $data['id'])
  448. ->orderBy('department', 'desc')
  449. ->first();
  450. return Result::success($result);
  451. }
  452. public function getPidZhinengbumen(array $data): array
  453. {
  454. if (empty($data['pid'])) {
  455. $data['pid'] = 0;
  456. }
  457. $result = Department::where('pid', $data['pid'])->get();
  458. return Result::success($result);
  459. }
  460. public function modZhinengbumen(array $data): array
  461. {
  462. $result = Department::where('id', $data['id'])->update($data);
  463. if (empty($result)) {
  464. return Result::error("修改失败", 0);
  465. } else {
  466. return Result::success();
  467. }
  468. }
  469. /**
  470. * 查询职能列表
  471. * @param array $data
  472. * @return array
  473. */
  474. public function getDepartment(array $data): array
  475. {
  476. $where = [];
  477. if (isset($data['pid'])) {
  478. $where = [
  479. 'pid' => $data['pid'] ?? 0
  480. ];
  481. }
  482. $result = Department::when(!empty($where), function ($query) use ($where) {
  483. $query->where($where);
  484. })->orderBy("sort", "desc")->get();
  485. if (empty($result)) {
  486. return Result::error("查询失败", 0);
  487. } else {
  488. return Result::success($result);
  489. }
  490. }
  491. /**
  492. * 获取所有的buckets
  493. * @param array $data
  494. * @return array
  495. */
  496. public function getBuckets(array $data): array
  497. {
  498. $result = new MinioService();
  499. // 调用服务层的方法获取存储桶列表
  500. $bucketsResponse = $result->listBuckets();
  501. // 直接返回服务层生成的响应
  502. return Result::success($bucketsResponse['data']);
  503. }
  504. /**
  505. * 上传文件
  506. * @param array $data
  507. * @return array
  508. */
  509. public function uploadFile(array $data): array
  510. {
  511. $result = new MinioService();
  512. $rep = $result->uploadFile($data);
  513. if ($rep['code'] == 200) {
  514. return Result::success($rep['data']);
  515. } else {
  516. return Result::error("上传失败!");
  517. }
  518. }
  519. /**
  520. * 黑名单管理
  521. * @param array $data
  522. * @return array
  523. */
  524. public function getBlackWordList(array $data): array
  525. {
  526. $result = BlackWord::when($data, function ($query) use ($data) {
  527. if (isset($data['name']) && $data['name']) {
  528. $query->where('black_word.name', 'like', '%' . $data['name'] . '%');
  529. }
  530. })->orderBy('black_word.id', 'desc')
  531. ->paginate(
  532. intval($data['pageSize']),
  533. [
  534. 'black_word.*',
  535. ],
  536. 'page',
  537. intval($data['page'])
  538. );
  539. $count = $result->total();
  540. $returnData = [
  541. 'rows' => $result->items(),
  542. 'count' => $count
  543. ];
  544. return Result::success($returnData);
  545. }
  546. /**
  547. * 添加黑名单
  548. * @param array $data
  549. * @return array
  550. */
  551. public function addBlackWord(array $data): array
  552. {
  553. Db::beginTransaction();
  554. try {
  555. $info = BlackWord::where(['name' => $data['name']])->first();
  556. if ($info) {
  557. Db::rollBack();
  558. return Result::error("该黑名单已存在", 0);
  559. }
  560. $data['type'] = 10;
  561. $result = BlackWord::insertGetId($data);
  562. $redisKey = 'black_word';
  563. $this->redis->sAdd($redisKey, $data['name']);
  564. Db::commit();
  565. return Result::success(["id" => $result]);
  566. } catch (\Exception $e) {
  567. Db::rollBack();
  568. return Result::error("创建失败" . $e->getMessage(), 0);
  569. }
  570. }
  571. /**
  572. * 删除黑名单
  573. * @param array $data
  574. * @return array
  575. */
  576. public function delBlackWord(array $data): array
  577. {
  578. Db::beginTransaction();
  579. try {
  580. BlackWord::where(['name' => $data['name']])->delete();
  581. $redisKey = 'black_word';
  582. $this->redis->sRem($redisKey, $data['name']);
  583. Db::commit();
  584. return Result::success([]);
  585. } catch (\Exception $e) {
  586. Db::rollBack();
  587. return Result::error("删除失败" . $e->getMessage(), 0);
  588. }
  589. }
  590. /**
  591. * 修改违禁词
  592. * @param array $data
  593. * @return array
  594. */
  595. public function upBlackWord(array $data): array
  596. {
  597. Db::beginTransaction();
  598. try {
  599. $checkInfo = BlackWord::where(['name' => $data['name']])->first();
  600. if ($checkInfo) {
  601. Db::rollBack();
  602. return Result::error("该违禁词已经存在", 0);
  603. }
  604. $blackWordInfo = BlackWord::where(['id' => $data['id']])->first();
  605. if ($blackWordInfo) {
  606. //先删除redis
  607. $blackWordInfo = $blackWordInfo->toArray();
  608. $redisKey = 'black_word';
  609. $this->redis->sRem($redisKey, $blackWordInfo['name']);
  610. $this->redis->sAdd($redisKey, $data['name']);
  611. BlackWord::where(['id' => $data['id']])->update(['name' => $data['name']]);
  612. Db::commit();
  613. return Result::success([]);
  614. } else {
  615. Db::rollBack();
  616. return Result::error("系统错误", 0);
  617. }
  618. } catch (\Exception $e) {
  619. Db::rollBack();
  620. return Result::error("修改失败" . $e->getMessage(), 0);
  621. }
  622. }
  623. /**
  624. * 获取风格
  625. * @return void
  626. */
  627. public function getTemplateClassList(array $data): array
  628. {
  629. $where = [];
  630. if (isset($data['name']) && $data['name']) {
  631. array_push($where, ['template_class.name', 'like', '%' . $data['name'] . '%']);
  632. }
  633. if (isset($data['keyword']) && $data['keyword']) {
  634. array_push($where, ['template_class.keyword', 'like', '%' . $data['keyword'] . '%']);
  635. }
  636. $template = TemplateClass::when($where, function ($query) use ($where) {
  637. $query->where($where);
  638. });
  639. $count = $template->count();
  640. // $countQuery = clone $template;
  641. $row = $template
  642. ->leftJoin('template', function ($join) {
  643. $join->on('template_class.class_id', '=', 'template.template_class_id');
  644. })
  645. ->select('template_class.*', DB::raw('COUNT(template.template_class_id) as template_count'))
  646. ->groupBy('template_class.id')
  647. ->orderBy('template_class.id', 'desc')
  648. ->offset(($data['page'] - 1) * $data['pageSize'])
  649. ->limit($data['pageSize'])
  650. ->get();
  651. $result = [
  652. 'rows' => $row,
  653. 'count' => $count,
  654. ];
  655. if ($row->isEmpty()) {
  656. return Result::error("暂无风格", 0);
  657. } else {
  658. return Result::success($result);
  659. }
  660. }
  661. /**
  662. * 添加风格
  663. * @param
  664. * @return void
  665. */
  666. public function addTemplateClass(array $data): array
  667. {
  668. $data['keyword'] = json_encode($data['keyword']);
  669. $template_class = TemplateClass::where('name', $data['name'])
  670. ->orWhere('class_id', $data['class_id'])
  671. ->first();
  672. if ($template_class) {
  673. return Result::error("风格名称或者风格编号已存在,不可添加!", 0);
  674. }
  675. $result = TemplateClass::insertGetId($data);
  676. if (empty($result)) {
  677. return Result::error("创建风格失败", 0);
  678. } else {
  679. return Result::success(["id" => $result]);
  680. }
  681. }
  682. /**
  683. * 更新风格
  684. * @param array $data
  685. * @return array
  686. */
  687. public function upTemplateClass(array $data): array
  688. {
  689. $where = [
  690. 'id' => $data['id'],
  691. ];
  692. $template_class = TemplateClass::where($where)->first();
  693. if (empty($template_class)) {
  694. return Result::error("未查询到风格", 0);
  695. }
  696. if ($template_class->type == 1) {
  697. return Result::error("默认风格不能修改", 0);
  698. }
  699. $template = TemplateClass::where('id', '!=', $data['id'])
  700. // ->where(['name' => $data['name']])
  701. // ->orWhere(['class_id' => $data['class_id']])
  702. ->where(function ($query) use ($data) {
  703. $query->where('name', $data['name'])
  704. ->orWhere('class_id', $data['class_id']);
  705. })
  706. ->first();
  707. if ($template) {
  708. return Result::error("风格名称或者风格编号已存在,不可编辑!", 0);
  709. }
  710. $updateData = [
  711. 'name' => $data['name'],
  712. 'keyword' => json_encode($data['keyword']),
  713. 'class_id' => $data['class_id'],
  714. ];
  715. $result = TemplateClass::where($where)->update($updateData);
  716. if (empty($result)) {
  717. return Result::error("更新失败", 0);
  718. } else {
  719. return Result::success($result);
  720. }
  721. }
  722. /**
  723. * 删除风格
  724. * @param array $data
  725. * @return array
  726. */
  727. public function delTemplateClass(array $data): array
  728. {
  729. $where = [
  730. 'id' => $data['id'],
  731. ];
  732. $template_class = TemplateClass::where($where)->first();
  733. if (empty($template_class)) {
  734. return Result::error("未查询到风格", 0);
  735. }
  736. if ($template_class->type == 1) {
  737. return Result::error("默认风格不能删除", 0);
  738. }
  739. $template = Template::where('template_class_id', $template_class['class_id'])->get();
  740. if (!empty($template->all())) {
  741. try {
  742. // 默认风格 1
  743. Db::beginTransaction();
  744. $template = Template::where('template_class_id', $template['class_id'])->update(['template_class_id' => 1]);
  745. if (empty($template)) {
  746. Db::rollBack();
  747. return Result::error("删除失败", 0);
  748. }
  749. $result = TemplateClass::where($where)->delete();
  750. } catch (\Exception $e) {
  751. return Result::error("删除失败" . $e->getMessage(), 0);
  752. }
  753. } else {
  754. $result = TemplateClass::where('id', $data['id'])->delete();
  755. }
  756. if (empty($result)) {
  757. return Result::error("删除失败", 0);
  758. }
  759. return Result::success($result);
  760. }
  761. /**
  762. * 根据风格名称-获取获取所有风格
  763. * @param array $data
  764. * @return array
  765. */
  766. public function getTemplateClass(array $data): array
  767. {
  768. $where = [];
  769. if (!empty($data['template_name'])) {
  770. $where['name'] = $data['template_name'];
  771. }
  772. $result = TemplateClass::where($where)->get();
  773. if (empty($result)) {
  774. return Result::error("暂无风格", 0);
  775. }
  776. return Result::success($result);
  777. }
  778. /**
  779. * 获取皮肤列表
  780. * @param array $data
  781. * @return array
  782. */
  783. public function getTemplateList(array $data): array
  784. {
  785. $where = [];
  786. if (!empty($data['template_class_id'])) {
  787. $where['template_class_id'] = $data['template_class_id'];
  788. }
  789. if (!empty($data['template_name'])) {
  790. array_push($where, ['template_name', 'like', '%' . $data['template_name'] . '%']);
  791. }
  792. if (!empty($data['template_keyword'])) {
  793. array_push($where, ['template_keyword', 'like', '%' . $data['template_keyword'] . '%']);
  794. }
  795. $result = Template::where($where)
  796. ->leftJoin('template_class', 'template.template_class_id', 'template_class.class_id')
  797. ->select('template.*', 'template_class.name as template_class_name')
  798. ->orderBy('template.id', 'desc')
  799. ->paginate($data['page_size'], ['*'], 'mypage_name', $data['page']);
  800. if (empty($result)) {
  801. return Result::error("暂无皮肤", 0);
  802. }
  803. return Result::success($result);
  804. }
  805. public function getTemplateInfo(array $data): array
  806. {
  807. $result = Template::where('template.id', $data['id'])
  808. ->leftJoin('template_class', 'template.template_class_id', 'template_class.class_id')
  809. ->select('template.*', 'template_class.name as template_class_name')
  810. ->first();
  811. if (empty($result)) {
  812. return Result::error("暂无皮肤", 0);
  813. }
  814. return Result::success($result);
  815. }
  816. /**
  817. * 添加皮肤
  818. * @param array $data
  819. * @return array
  820. */
  821. public function addTemplate(array $data): array
  822. {
  823. var_dump($data);
  824. unset($data['user_id']);
  825. $template = Template::where('template_name', $data['template_name'])
  826. ->orWhere('template_id', $data['template_id'])
  827. ->first();
  828. if ($template) {
  829. return Result::error("皮肤名称或者皮肤编号已存在,不可添加!", 0);
  830. }
  831. $data['template_keyword'] = json_encode($data['template_keyword']) ?? '';
  832. $page_type = json_decode($data['page_type'], true);
  833. $data['page_type'] = json_encode(array_values(array_unique($page_type)));
  834. $result = Template::insertGetId($data);
  835. if (empty($result)) {
  836. return Result::error("创建失败", 0);
  837. } else {
  838. return Result::success($result);
  839. }
  840. }
  841. /**
  842. * 删除皮肤
  843. * @param array $data
  844. * @return array
  845. */
  846. public function delTemplate(array $data): array
  847. {
  848. $rector = Sector::where('template_id', $data['id'])->first();
  849. if (!empty($rector)) {
  850. return Result::error("此皮肤已被绑定通栏,不可删除", 0);
  851. }
  852. $template = WebsiteTemplateInfo::where('template_id', $data['id'])->first();
  853. if (empty($template)) {
  854. return Result::error("此皮肤已被绑定网站,不可删除", 0);
  855. }
  856. if ($template->type == 1) {
  857. return Result::error("默认皮肤不能删除", 0);
  858. }
  859. $result = Template::where('id', $data['id'])->delete();
  860. var_dump($result, '-------------------delete');
  861. if ($result) {
  862. return Result::success($result);
  863. } else {
  864. return Result::error("删除失败", 0);
  865. }
  866. }
  867. /**
  868. * 更新皮肤
  869. * @param array $data
  870. * @return array
  871. */
  872. public function updateTemplate(array $data): array
  873. {
  874. unset($data['user_id']);
  875. $template = Template::where('id', $data['id'])
  876. ->first();
  877. if (empty($template)) {
  878. return Result::error("此皮肤不存在!", 0);
  879. }
  880. $template = Template::where('id', '!=', $data['id'])
  881. ->where(function ($query) use ($data) {
  882. $query->where('template_name', $data['template_name'])
  883. ->orWhere('template_id', $data['template_id']);
  884. })
  885. ->first();
  886. if ($template) {
  887. return Result::error("皮肤名称或者皮肤编号已存在,不可编辑!", 0);
  888. }
  889. $data['template_keyword'] = json_encode($data['template_keyword']) ?? '';
  890. $page_type = json_decode($data['page_type'], true);
  891. $data['page_type'] = json_encode(array_values(array_unique($page_type)));
  892. $result = Template::where('id', $data['id'])->update($data);
  893. var_dump($result, '-------------------update');
  894. if (!$result) {
  895. return Result::error("更新失败", 0);
  896. } else {
  897. return Result::success('更新成功');
  898. }
  899. }
  900. /**
  901. * 获取所有尺寸
  902. * @param array $data
  903. * @return array
  904. */
  905. public function getAllSize(array $data): array
  906. {
  907. if(isset($data['id']) && !empty($data['id'])){
  908. $result = Size::where('id', $data['id'])->get()->all();
  909. }else{
  910. $result = Size::get()->all();
  911. }
  912. if(empty($result)){
  913. return Result::error("暂无尺寸", 0);
  914. }
  915. return Result::success($result);
  916. }
  917. /**
  918. * 根据皮肤名称-获取所有皮肤
  919. * @param array $data
  920. * @return array
  921. */
  922. public function getAllTemplate(array $data): array
  923. {
  924. $where = [];
  925. if (isset($data['template_class_id']) && !empty($data['template_class_id'])) {
  926. $where[] = ['template_class_id', $data['template_class_id']];
  927. }
  928. if (isset($data['template_name']) && !empty($data['template_name'])) {
  929. $where[] = ['template_name', 'like', '%' . $data['template_name'] . '%'];
  930. }
  931. $result = Template::where($where)->get()->all();
  932. if (empty($result)) {
  933. return Result::error("暂无皮肤", 0);
  934. }
  935. return Result::success($result);
  936. }
  937. /**
  938. * 获取通栏列表
  939. * @param array $data
  940. * @return array
  941. */
  942. public function getSectorList(array $data): array
  943. {
  944. $where = [];
  945. if (isset($data['template_class_id']) && !empty($data['template_class_id'])) {
  946. $where['template.template_class_id'] = $data['template_class_id'];
  947. }
  948. if (isset($data['template_id']) && !empty($data['template_id'])) {
  949. array_push($where, ['template.template_id', $data['template_id']]);
  950. }
  951. if (isset($data['sector_name']) && !empty($data['sector_name'])) {
  952. array_push($where, ['sector.sector_name', 'like', '%' . $data['sector_name'] . '%']);
  953. }
  954. if (isset($data['width']) && !empty($data['width']) && isset($data['height']) && !empty($data['height'])) {
  955. $size_id = Size::where('width', 'like', '%' . $data['width'] . '%')->where('height', 'like', '%' . $data['height'] . '%')->pluck('id');
  956. } else if (isset($data['width']) && !empty($data['width'])) {
  957. $size_id = Size::where('width', 'like', '%' . $data['width'] . '%')->pluck('id');
  958. } else if (isset($data['height']) && !empty($data['height'])) {
  959. $size_id = Size::where('height', 'like', '%' . $data['height'] . '%')->pluck('id');
  960. } else {
  961. $size_id = [];
  962. }
  963. $result = Sector::when(!empty($size_id), function ($query) use ($size_id) {
  964. $query->whereIn('size_id', $size_id);
  965. })
  966. ->leftJoin('size', 'size.id', '=', 'sector.size_id')
  967. ->leftJoin('template', 'template.template_id', '=', 'sector.template_id')
  968. ->leftJoin('template_class', 'template_class.class_id', '=', 'template.template_class_id')
  969. ->where($where)
  970. ->select('sector.*', 'size.width','size.height','template_class.name as class_name','template.template_name')
  971. ->orderBy('sector.id', 'desc')
  972. ->paginate($data['page_size'], ['*'], 'page', $data['page']);
  973. if(empty($result)){
  974. return Result::error('暂无通栏!');
  975. }
  976. return Result::success($result);
  977. }
  978. /**
  979. * 获取通栏详情
  980. * @param array $data
  981. * @return array
  982. */
  983. public function getSectorInfo(array $data): array
  984. {
  985. $where = [];
  986. $where[] = ['sector.id', '=', $data['id']];
  987. $result = Sector::where($where)
  988. ->leftJoin('size', 'size.id', '=', 'sector.size_id')
  989. ->select('sector.*', 'size.width', 'size.height')
  990. ->orderBy('sector.id', 'desc')
  991. ->first();
  992. if (empty($result)) {
  993. return Result::error('此通栏不存在!');
  994. }
  995. return Result::success($result);
  996. }
  997. /**
  998. * 获取经纬度信息
  999. * @return void
  1000. */
  1001. public function getIpInfo(array $data): array
  1002. {
  1003. if (empty($data['ip'])) {
  1004. // 在RPC服务中,依赖$_SERVER是不可靠的,强制要求调用方传入IP
  1005. return Result::error('IP地址不能为空!');
  1006. }
  1007. $client_ip = $data['ip'];
  1008. try {
  1009. // 直接从容器获取 Guzzle 客户端实例
  1010. /** @var \GuzzleHttp\Client $client */
  1011. $client = \Hyperf\Context\ApplicationContext::getContainer()->get(Client::class);
  1012. // 使用新的 GeoJS API 地址
  1013. $api_url = "https://get.geojs.io/v1/ip/geo/{$client_ip}.json";
  1014. // 将 timeout 作为请求选项传递
  1015. $response = $client->get($api_url, ['timeout' => 5]);
  1016. if ($response->getStatusCode() !== 200) {
  1017. return Result::error('IP查询接口请求失败,状态码:' . $response->getStatusCode());
  1018. }
  1019. $ip_info = json_decode($response->getBody()->getContents(), true);
  1020. // GeoJS 的成功响应不包含 'status' 字段,直接检查关键数据是否存在
  1021. if ($ip_info && isset($ip_info['latitude']) && isset($ip_info['longitude'])) {
  1022. // GeoJS 返回的经纬度是字符串,转换为浮点数
  1023. $ip_info['latitude'] = floatval($ip_info['latitude']);
  1024. $ip_info['longitude'] = floatval($ip_info['longitude']);
  1025. return Result::success($ip_info);
  1026. }
  1027. // 如果返回的数据不符合预期,提供一个通用错误
  1028. $errorMessage = $ip_info['message'] ?? '获取IP地理位置信息失败';
  1029. return Result::error($errorMessage);
  1030. } catch (GuzzleException $e) {
  1031. // 这个异常会给出详细的网络错误信息,如超时、无法解析域名等
  1032. return Result::error('请求IP查询接口异常: ' . $e->getMessage());
  1033. } catch (\Throwable $e) {
  1034. return Result::error('获取IP信息时发生未知错误: ' . $e->getMessage());
  1035. }
  1036. }
  1037. /**
  1038. * 获取天气
  1039. * @param array $data
  1040. * @return array
  1041. */
  1042. public function getWeatherInfo(array $data): array
  1043. {
  1044. $month = $data['month'] ?? date('m');
  1045. $day = $data['day'] ?? date('d');
  1046. // 使用缓存键
  1047. $cacheKey = "tsbb_data_weather_{$month}_{$day}";
  1048. // 尝试从缓存获取数据
  1049. $container = \Hyperf\Context\ApplicationContext::getContainer();
  1050. $cache = $container->get(\Psr\SimpleCache\CacheInterface::class);
  1051. if ($cachedData = $cache->get($cacheKey)) {
  1052. return Result::success(unserialize($cachedData));
  1053. }
  1054. $location = $data['latitude'] . ":" . $data['longitude'];
  1055. $api_url = "https://api.seniverse.com/v3/weather/now.json?key=" . \Hyperf\Support\env('WEATHER_KEY') . "&location=" . $location . "&language=zh-Hans&unit=c";
  1056. $ch = curl_init($api_url);
  1057. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1058. $response = curl_exec($ch);
  1059. curl_close($ch);
  1060. // 解析 JSON 响应
  1061. $WeatherInfo = json_decode($response, true);
  1062. // 缓存结果,设置1小时过期
  1063. $cache->set($cacheKey, serialize($WeatherInfo), 3600);
  1064. if ($WeatherInfo) {
  1065. return Result::success($WeatherInfo);
  1066. } else {
  1067. return Result::error("获取天气失败", 0);
  1068. }
  1069. }
  1070. /**
  1071. * 获取农历信息
  1072. * @return void
  1073. */
  1074. public function getCalendar(array $data): array
  1075. {
  1076. $calendar = new Calendar();
  1077. $result = $calendar->solar($data['year'], $data['month'], $data['day'], $data['hour']); // 阳历
  1078. return Result::success($result);
  1079. }
  1080. /**
  1081. * 添加通栏
  1082. * @param array $data
  1083. * @return array
  1084. */
  1085. public function addSector(array $data): array
  1086. {
  1087. unset($data['user_id']);
  1088. // 对传入的 page_type 数组进行去重、转换为整数并重新索引
  1089. $data['page_type'] = array_values(array_unique(array_map('intval', $data['page_type'])));
  1090. $data['page_type'] = json_encode($data['page_type']);
  1091. $template = Template::where('template_id', $data['template_id'])
  1092. ->first();
  1093. if (empty($template)) {
  1094. return Result::error('皮肤不存在!');
  1095. }
  1096. $sector_id = Sector::where('sector_id',$data['sector_id'])->first();
  1097. if(!empty($sector_id)){
  1098. return Result::error('通栏编号已存在!');
  1099. }
  1100. // 通栏分类:1:资讯类:2:通栏广告类;3:混合类;4:头条类;5:轮播图类;
  1101. if($data['sector_type'] == 2 || $data['sector_type'] == 3){
  1102. $sector_code = [
  1103. 'sectorName' => $data['sector_name'],
  1104. 'sectorId' => $data['sector_id'],
  1105. 'sectorType' => $data['sector_type'],
  1106. 'sectorPlace' => $data['place_type'],
  1107. 'ad' => [],
  1108. ];
  1109. }else{
  1110. $sector_code = [
  1111. 'sectorName' => $data['sector_name'],
  1112. 'sectorId' => $data['sector_id'],
  1113. 'sectorType' => $data['sector_type'],
  1114. 'sectorPlace' => $data['place_type'],
  1115. ];
  1116. }
  1117. // return Result::success($sector_code);
  1118. $data['sector_code'] = json_encode($sector_code);
  1119. $result = Sector::insertGetId($data);
  1120. if (empty($result)) {
  1121. return Result::error('添加失败');
  1122. }
  1123. return Result::success($result);
  1124. }
  1125. /**
  1126. * 删除通栏
  1127. * @param array $data
  1128. * @return array
  1129. */
  1130. public function delSector(array $data): array
  1131. {
  1132. $component_id = Component::where('sector_id', $data['id'])->pluck('id')->toArray();
  1133. if (!empty($component_id)) {
  1134. return Result::error('请先删除相关组件!');
  1135. }
  1136. $result = Sector::where('id', $data['id'])->delete();
  1137. if ($result == 1) {
  1138. return Result::success('删除成功');
  1139. } else {
  1140. return Result::error('删除失败');
  1141. }
  1142. }
  1143. /**
  1144. * 修改通栏
  1145. * @param array $data
  1146. * @return array
  1147. */
  1148. public function updateSector(array $data): array
  1149. {
  1150. unset($data['user_id']);
  1151. $sector = Sector::where('id', $data['id'])->first();
  1152. if (empty($sector)) {
  1153. return Result::error('通栏不存在!');
  1154. }
  1155. if($sector['sector_id'] != $data['sector_id']){
  1156. $sector_id = Sector::where('sector_id',$data['sector_id'])->first();
  1157. if(!empty($sector_id)){
  1158. return Result::error('通栏编号已存在!');
  1159. }
  1160. }
  1161. if($data['sector_type'] == 2 || $data['sector_type'] == 3){
  1162. $sector_code = [
  1163. 'sectorName' => strval($data['sector_name']),
  1164. 'sectorId' => intval($data['sector_id']),
  1165. 'sectorType' => intval($data['sector_type']),
  1166. 'sectorPlace' => intval($data['place_type']),
  1167. 'ad' => [],
  1168. ];
  1169. }else{
  1170. $sector_code = [
  1171. 'sectorName' => strval($data['sector_name']),
  1172. 'sectorId' => intval($data['sector_id']),
  1173. 'sectorType' => intval($data['sector_type']),
  1174. 'sectorPlace' => intval($data['place_type']),
  1175. ];
  1176. }
  1177. // return Result::success($sector_code);
  1178. $data['sector_code'] = json_encode($sector_code);
  1179. // 对传入的 page_type 数组进行去重、转换为整数并重新索引
  1180. $data['page_type'] = array_values(array_unique(array_map('intval', $data['page_type'])));
  1181. $data['page_type'] = json_encode($data['page_type']);
  1182. $template = Template::where('template_id', $data['template_id'])
  1183. ->whereRaw("JSON_CONTAINS(template.page_type, ?)", [$data['page_type']])
  1184. ->first();
  1185. if (empty($template)) {
  1186. return Result::error('皮肤不存在!');
  1187. }
  1188. $result = Sector::where('id', $data['id'])->update($data);
  1189. if ($result == 1) {
  1190. return Result::success('修改成功');
  1191. } else {
  1192. return Result::error('修改失败');
  1193. }
  1194. }
  1195. public function getComponentList(array $data): array
  1196. {
  1197. var_dump($data, '---------');
  1198. $where = [];
  1199. // $where[] = ['sector.id', '=', $data['id']];
  1200. if (!empty($data['template_class_id'])) {
  1201. $where['template_class.id'] = $data['template_class_id'];
  1202. }
  1203. if (!empty($data['component_name'])) {
  1204. $where['component.component_name'] = $data['component_name'];
  1205. }
  1206. if (!empty($data['sector_id'])) {
  1207. $where['sector.id'] = $data['sector_id'];
  1208. };
  1209. $result = Component::where($where)
  1210. ->leftJoin('template', 'template.id', '=', 'component.template_id')
  1211. ->leftJoin('template_class', 'template_class.id', '=', 'template.template_class_id') // 添加这一行
  1212. ->leftJoin('sector', 'sector.id', '=', 'component.sector_id')
  1213. ->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') // 修改这一行)
  1214. ->orderBy('sector.updated_at', 'desc')
  1215. ->orderBy('sector.created_at', 'desc')
  1216. ->paginate($data['page_size'], ['*'], 'mypage_name', $data['page']);
  1217. return Result::success($result);
  1218. }
  1219. public function getComponentInfo(array $data): array
  1220. {
  1221. $where = [];
  1222. $result = Component::where($where)
  1223. ->leftJoin('template', 'template.id', '=', 'component.template_id')
  1224. ->leftJoin('template_class', 'template_class.id', '=', 'template.template_class_id') // 添加这一行
  1225. ->leftJoin('sector', 'sector.id', '=', 'component.sector_id')
  1226. ->select('template_class.name as template_class_name', 'template.template_name as template_name', 'sector.sector_name as sector_name', 'component.*')
  1227. ->get();
  1228. return Result::success($result);
  1229. }
  1230. public function addComponent(array $data): array
  1231. {
  1232. unset($data['user_id']);
  1233. $result = Component::insertGetId($data);
  1234. if ($result) {
  1235. return Result::success($result);
  1236. } else {
  1237. return Result::error('添加失败');
  1238. }
  1239. }
  1240. public function delComponent(array $data): array
  1241. {
  1242. $result = Component::where('id', $data['id'])->delete();
  1243. return Result::success($result);
  1244. }
  1245. public function updateComponent(array $data): array
  1246. {
  1247. $result = Component::where('id', $data['id'])->update($data);
  1248. return Result::success($result);
  1249. }
  1250. public function getWebsiteTemplateInfo(array $data)
  1251. {
  1252. $where = [];
  1253. if (isset($data['id'])) {
  1254. $where[] = ['id', '=', $data['id']];
  1255. }
  1256. $result = WebsiteTemplateInfo::where($where)
  1257. ->leftJoin('website', 'website_template_info.website_id', '=', 'website.id')
  1258. ->leftJoin('website_template', 'website_template_info.template_id', '=', 'website_template.id')
  1259. ->select('website_template_info.*', 'website.website_name')
  1260. ->get();
  1261. if ($result) {
  1262. return Result::success($result);
  1263. } else {
  1264. return Result::error('暂无数据');
  1265. }
  1266. }
  1267. /**
  1268. * 自助建站----1.获取页面类型回显
  1269. * @param array $data
  1270. * @return array
  1271. */
  1272. public function getWebPageType(array $data): array
  1273. {
  1274. // 1:图片 2:文字 3:底部
  1275. $friend_link = Link::where('website_id', $data['website_id'])->where('type', 3)->get();
  1276. if (empty($friend_link->toArray())) {
  1277. return Result::error('暂无友情链接数据!');
  1278. }
  1279. $footer_category = FooterCategory::where('website_id', $data['website_id'])->get();
  1280. if (empty($footer_category->toArray())) {
  1281. return Result::error('暂无底部导航数据!');
  1282. }
  1283. $page_type = WebsiteTemplateInfo::where('website_id', $data['website_id'])->value('page_type');
  1284. if (empty($page_type)) {
  1285. $page_type = [];
  1286. } else {
  1287. $page_type = json_decode($page_type, true);
  1288. }
  1289. // '网站页面类型(存数组)1:首页 2:分类页 3:列表页 4:详情页 5:搜索页 6:特殊列表 7:特殊详情页
  1290. if (isset($page_type) && in_array(5, $page_type)) {
  1291. $page_type = 1;
  1292. } else {
  1293. $page_type = 0;
  1294. }
  1295. $result = [
  1296. 'friend_link' => $friend_link,
  1297. 'footer_category' => $footer_category,
  1298. 'page_type' => $page_type,
  1299. ];
  1300. return Result::success($result);
  1301. }
  1302. /**
  1303. * 自助建站----2.添加页面类型
  1304. * @param array $data
  1305. * @return array
  1306. */
  1307. public function addWebPageType(array $data): array
  1308. {
  1309. // return Result::success($data);
  1310. // 1:首页 2:频道页 3:列表页 4:详情页 5:搜索页 6:特殊列表 7:特殊详情页'
  1311. if ($data['is_search'] == 1) {
  1312. $page_type = json_encode([1, 2, 3, 4, 5, 6, 7]);
  1313. } else {
  1314. $page_type = json_encode([1, 2, 3, 4, 6, 7]);
  1315. }
  1316. // 0:未构建;1:已填写基础信息;2:已选择模板; action_id
  1317. $website_template_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
  1318. // return Result::success($website_template_info);
  1319. // return Result::success(empty($website_template_info));
  1320. if (empty($website_template_info)) {
  1321. $result = WebsiteTemplateInfo::insertGetId(['website_id' => $data['website_id'], 'page_type' => $page_type, 'user_id' => $data['user_id']]);
  1322. } else {
  1323. if ($website_template_info['status'] == 2) {
  1324. return Result::error('网站已应用,不可再次修改!');
  1325. }
  1326. $result = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['page_type' => $page_type], ['action_id' => 1, 'user_id' => $data['user_id']]);
  1327. }
  1328. if ($result) {
  1329. return Result::success($result);
  1330. } else {
  1331. return Result::error('添加失败');
  1332. }
  1333. }
  1334. /**
  1335. * 自助建站---流程---3.选择皮肤列表
  1336. * @param array $data
  1337. * @return array
  1338. */
  1339. public function getWebsiteTemplateList(array $data): array
  1340. {
  1341. $where = [];
  1342. if (isset($data['template_class_id']) && $data['template_class_id']) {
  1343. $where[] = ['template_class_id', '=', $data['template_class_id']];
  1344. }
  1345. // 0:未构建 1:未应用 2:已应用 status
  1346. $templste_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
  1347. if (empty($templste_info)) {
  1348. return Result::error('请先填写网站基础信息!');
  1349. }
  1350. if ($templste_info['status'] == 2) {
  1351. return Result::error('网站已应用,不可再次修改!');
  1352. }
  1353. if (isset($data['keyword']) && !empty($data['keyword'])) {
  1354. if (is_array($data['keyword'])) {
  1355. // 拼接多个模糊查询条件
  1356. $query = Template::query();
  1357. foreach ($data['keyword'] as $kw) {
  1358. $escapedKw = addcslashes($kw, '%_'); // 转义通配符
  1359. $query->WhereRaw("JSON_EXTRACT(template_keyword, '$[*]') LIKE ?", ["%$escapedKw%"]);
  1360. }
  1361. } else {
  1362. $escapedKeyword = addcslashes($data['keyword'], '%_'); // 转义通配符
  1363. $where[] = [DB::raw("JSON_EXTRACT(template_keyword, '$[*]') LIKE ?"), "%$escapedKeyword%"];
  1364. }
  1365. } else {
  1366. $query = Template::where($where);
  1367. }
  1368. $template_id = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first(['template_id', 'page_type']);
  1369. // return Result::success($template_id);
  1370. if (!empty($template_id['page_type']) && $templste_info['page_type'] != '[]' && is_string($templste_info['page_type'])) {
  1371. $template_page = is_string($templste_info['page_type']) ? json_decode($templste_info['page_type'], true) : [];
  1372. } else {
  1373. $template_page = [];
  1374. }
  1375. if (!empty($template_id['template_id'])) {
  1376. $result['template_id'] = $templste_info['template_id'];
  1377. }
  1378. // 确保 $template_page 为有效数据,避免 SQL 注入风险,这里使用参数绑定
  1379. $template_page_str = json_encode($template_page);
  1380. $result['template'] = $query->where($where)
  1381. ->whereRaw("JSON_CONTAINS(template.page_type, ?)", [$template_page_str])
  1382. ->orderBy('updated_at', 'desc')
  1383. ->paginate($data['page_size'], ['*'], 'page', $data['page']);
  1384. if (empty($result['template'])) {
  1385. $result['template'] = Template::orderBy('updated_at', 'desc')
  1386. ->paginate($data['page_size'], ['*'], 'page', $data['page']);
  1387. }
  1388. $template = WebsiteTemplateInfo::where('website_id', $data['website_id'])->value('template_id');
  1389. if ($template) {
  1390. $result['template_id'] = $template;
  1391. } else {
  1392. $result['template_id'] = 0;
  1393. }
  1394. return Result::success($result);
  1395. }
  1396. /**
  1397. * 自助建站---流程---4.选择皮肤
  1398. * @param array $data
  1399. * @return array
  1400. */
  1401. public function chooseWebsiteTemplate(array $data): array
  1402. {
  1403. $website_template_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
  1404. if (empty($website_template_info)) {
  1405. return Result::error('请先填写网站基础信息!');
  1406. }
  1407. // 0:未构建 1:未应用 2:已应用 status
  1408. if ($website_template_info['status'] == 2) {
  1409. return Result::error('网站已应用,不可再次修改!');
  1410. }
  1411. $template = Template::where('template_id', $data['template_id'])->first();
  1412. if (empty($template)) {
  1413. return Result::error('未查询到皮肤!');
  1414. }
  1415. // 0:未构建;1:已填写基础信息;2:已选择模板; action_id
  1416. $web_template = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['template_id' => $data['template_id'], 'action_id' => 2]);
  1417. if ($web_template) {
  1418. return Result::success($web_template);
  1419. } else {
  1420. return Result::error('选择皮肤失败!');
  1421. }
  1422. }
  1423. /**
  1424. * 自助建站---流程---5.保存模版
  1425. * @param array $data
  1426. * @return array
  1427. */
  1428. public function saveWebsiteTemplate(array $data): array
  1429. {
  1430. // return Result::success($data);
  1431. $website_template_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
  1432. if (empty($website_template_info) || empty($website_template_info->template_id) || empty($website_template_info->page_type)) {
  1433. return Result::error('请先填写网站基础信息!');
  1434. }
  1435. // 0:未构建 1:未应用 2:已应用 status
  1436. if ($website_template_info['status'] == 2) {
  1437. return Result::error('网站已应用,不可再次保存!');
  1438. }
  1439. if ($website_template_info['action_id'] != 2) {
  1440. return Result::error('请完成之前的步骤!');
  1441. }
  1442. $template_info = WebsiteTemplate::where('website_id', $data['website_id'])->first();
  1443. // var_dump($data['template_data']);
  1444. try {
  1445. Db::beginTransaction();
  1446. if (empty($template_info)) {
  1447. $template = WebsiteTemplate::insertGetId([
  1448. 'website_id' => $data['website_id'],
  1449. 'template_data' => $data['template_data'],
  1450. 'user_id' => $data['user_id'],
  1451. 'canvas_data' => $data['canvas_data'],
  1452. 'page_type' => $website_template_info['page_type'],
  1453. 'template_id' => $website_template_info['template_id'],
  1454. ]);
  1455. } else {
  1456. $template = WebsiteTemplate::where('website_id', $data['website_id'])->update(
  1457. [
  1458. 'template_data' => $data['template_data'],
  1459. 'user_id' => $data['user_id'],
  1460. 'canvas_data' => $data['canvas_data'],
  1461. 'page_type' => $website_template_info['page_type'],
  1462. 'template_id' => $website_template_info['template_id'],
  1463. ]
  1464. );
  1465. }
  1466. if (empty($template)) {
  1467. Db::rollback();
  1468. return Result::error('保存失败!');
  1469. } else {
  1470. $tempalte_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['status' => 1]);
  1471. if (empty($tempalte_info)) {
  1472. Db::rollback();
  1473. return Result::error('保存失败!');
  1474. }
  1475. Db::commit();
  1476. }
  1477. } catch (\Exception $e) {
  1478. return Result::error('模版数据格式错误!');
  1479. }
  1480. return Result::success($template);
  1481. }
  1482. /**
  1483. * 自助建站---流程---6.返显保存的模版
  1484. * @param array $data
  1485. * @return array
  1486. */
  1487. public function getWebsiteTemplate(array $data): array
  1488. {
  1489. $web = Website::where('id', $data['website_id'])->first();
  1490. if (empty($web)) {
  1491. return Result::error('未查询到网站信息!');
  1492. }
  1493. $template = WebsiteTemplate::where('website_id', $data['website_id'])
  1494. ->first(['website_id', 'template_id', 'page_type', 'template_data', 'canvas_data']);
  1495. if (empty($template)) {
  1496. return Result::error('未查询到模版!');
  1497. }
  1498. return Result::success($template);
  1499. }
  1500. /**
  1501. * 自助建站-通栏管理-获取通栏位置
  1502. */
  1503. public function getSectorPlace(array $data): array
  1504. {
  1505. if(isset($data['sector_num']) && !empty($data['sector_num'])){
  1506. $where['sector_place.component_num'] = $data['sector_num'];
  1507. $template = SectorPlace::where('sector_place.type_id',1)
  1508. ->where($where)
  1509. ->leftJoin('size','sector_place.size_id','=','size.id')
  1510. ->select('sector_place.*','size.width','size.height')
  1511. ->get();
  1512. }
  1513. if(empty($template)){
  1514. return Result::error('未查询到相关通栏版式!');
  1515. }
  1516. return Result::success($template);
  1517. }
  1518. /**
  1519. * 通栏版式管理-获取通栏版式列表
  1520. */
  1521. public function getSectorPlaceList(array $data): array
  1522. {
  1523. $where['sector_place.type_id'] = $data['type_id'];
  1524. if(isset($data['component_num']) && !empty($data['component_num'])){
  1525. $where['sector_place.component_num'] = $data['component_num'];
  1526. }
  1527. if(isset($data['sector_type']) && !empty($data['sector_type'])){
  1528. $where['sector_place.sector_type'] = $data['sector_type'];
  1529. }
  1530. // if(isset($data['component_type']) && !empty($data['component_type'])){
  1531. // $where['sector_place.component_type'] = $data['component_type'];
  1532. // }
  1533. if(isset($data['name']) && !empty($data['name'])){
  1534. array_push($where,['sector_place.name', 'like', '%'.$data['name'].'%']);
  1535. }
  1536. if (isset($data['width']) && !empty($data['width']) && isset($data['height']) && !empty($data['height'])){
  1537. $size_id = Size::where('width','like','%' .$data['width'].'%')->where('height','like','%' .$data['height'].'%')->pluck('id');
  1538. } else if( isset($data['width']) && !empty($data['width'])){
  1539. $size_id = Size::where('width','like','%' .$data['width'].'%')->pluck('id');
  1540. }else if( isset($data['height']) && !empty($data['height'])){
  1541. $size_id = Size::where('height','like','%' .$data['height'].'%')->pluck('id');
  1542. }else{
  1543. $size_id = [];
  1544. }
  1545. $sector_place = SectorPlace::where($where)
  1546. ->when(!empty($size_id), function ($query) use ($size_id) {
  1547. $query->whereIn('sector_place.size_id', $size_id);
  1548. })
  1549. ->leftJoin('size','sector_place.size_id','=','size.id')
  1550. ->select('sector_place.*','size.width','size.height');
  1551. $result['count'] = $sector_place->count();
  1552. $result['row'] =$sector_place->paginate($data['page_size'], ['*'], 'page', $data['page']);
  1553. if(empty($result['count'])){
  1554. return Result::error("暂无相关版式数据!");
  1555. }
  1556. return Result::success($result);
  1557. }
  1558. /**
  1559. * 通栏版式管理-添加通栏版式
  1560. */
  1561. public function addSectorPlace(array $data): array
  1562. {
  1563. // 1:通栏;2:组件;
  1564. if($data['type_id'] == 1){
  1565. $sector_place = SectorPlace::where('sector_type', $data['type'])->first();
  1566. if(!empty($sector_place)){
  1567. return Result::error('通栏版式类别编号已存在!');
  1568. }
  1569. $data = [
  1570. 'name' => $data['name'],
  1571. 'component_num' => $data['component_num'],
  1572. 'size_id' => $data['size_id'],
  1573. 'sort_id' => 0,
  1574. 'sector_img' => $data['sector_img'],
  1575. 'sector_type' => $data['type'],
  1576. 'type_id' => $data['type_id'],
  1577. ];
  1578. }else{
  1579. $sector_type = SectorPlace::where('sector_type', $data['sector_type'])->where('type_id',1)->first();
  1580. if(empty($sector_type)){
  1581. return Result::error('通栏版式类别不存在!');
  1582. }
  1583. $component = SectorPlace::where('component_type', $data['type'])
  1584. ->where('type_id',2)
  1585. ->first();
  1586. if(!empty($component)){
  1587. return Result::error('组件版式类别编号已存在!');
  1588. }
  1589. $data = [
  1590. 'name' => $data['name'],
  1591. 'component_num' => 0,
  1592. 'size_id' => $data['size_id'],
  1593. 'sort_id' => $data['sort_id'],
  1594. 'sector_img' => $data['sector_img'],
  1595. 'component_type' => $data['type'],
  1596. 'type_id' => $data['type_id'],
  1597. 'sector_type' => $data['sector_type'],
  1598. ];
  1599. }
  1600. $result = SectorPlace::insertGetId($data);
  1601. if(empty($result)){
  1602. return Result::error('添加失败!');
  1603. }
  1604. return Result::success('添加成功!',$result);
  1605. }
  1606. /**
  1607. * 通栏版式管理-修改通栏版式
  1608. */
  1609. public function upSectorPlace(array $data): array
  1610. {
  1611. $id = $data['id'];
  1612. // 1:通栏;2:组件;
  1613. if($data['type_id'] == 1){
  1614. $sector_place = SectorPlace::where('id','!=',$id)->where('sector_type', $data['type'])->where('type_id',1)->first();
  1615. if(!empty($sector_place)){
  1616. return Result::error('通栏版式类别编号已存在!');
  1617. }
  1618. $data = [
  1619. 'name' => $data['name'],
  1620. 'component_num' => $data['component_num'],
  1621. 'size_id' => $data['size_id'],
  1622. 'sort_id' => 0,
  1623. 'sector_img' => $data['sector_img'],
  1624. 'sector_type' => $data['type'],
  1625. 'type_id' => $data['type_id'],
  1626. ];
  1627. }else{
  1628. $sector_type = SectorPlace::where('sector_type', $data['sector_type'])->where('type_id',1)->first();
  1629. if(empty($sector_type)){
  1630. return Result::error('通栏版式类别不存在!');
  1631. }
  1632. $component = SectorPlace::where('id','!=',$id)
  1633. ->where('component_type', $data['type'])
  1634. ->where('type_id',2)
  1635. ->first();
  1636. if(!empty($component)){
  1637. return Result::error('组件版式类别编号已存在!');
  1638. }
  1639. $data = [
  1640. 'name' => $data['name'],
  1641. 'component_num' => 0,
  1642. 'size_id' => $data['size_id'],
  1643. 'sort_id' => $data['sort_id'],
  1644. 'sector_img' => $data['sector_img'],
  1645. 'component_type' => $data['type'],
  1646. 'type_id' => $data['type_id'],
  1647. 'sector_type' => $data['sector_type'],
  1648. ];
  1649. }
  1650. $result = SectorPlace::where('id',$id)->update($data);
  1651. if(empty($result)){
  1652. return Result::error('修改失败!');
  1653. }
  1654. return Result::success('修改成功!',$result);
  1655. }
  1656. /**
  1657. * 通栏版式管理-删除通栏版式
  1658. */
  1659. public function delSectorPlace(array $data): array
  1660. {
  1661. $sector_place = SectorPlace::where('id',$data['id'])->first();
  1662. if(empty($sector_place)){
  1663. return Result::error('通栏版式不存在!');
  1664. }
  1665. if($sector_place['type_id'] == 1){
  1666. $sector = Sector::where('place_type', $sector_place['sector_type'])->first();
  1667. $component = SectorPlace::where('sector_type', $sector_place['sector_type'])
  1668. ->where('type_id',2)
  1669. ->first();
  1670. if(!empty($sector) || !empty($component)){
  1671. return Result::error('通栏版式分类已应用,暂不可删除!');
  1672. }
  1673. }else{
  1674. $sector = Component::where('place_type', $sector_place['component_type'])->first();
  1675. if(!empty($sector)){
  1676. return Result::error('组件版式分类已应用,暂不可删除!');
  1677. }
  1678. }
  1679. $result = SectorPlace::where('id',$data['id'])->delete();
  1680. if(empty($result)){
  1681. return Result::error('删除失败!');
  1682. }
  1683. return Result::success('删除成功!');
  1684. }
  1685. /**
  1686. * 自助建站-通栏版式管理-获取通栏版式详情
  1687. */
  1688. public function getSectorPlaceInfo(array $data): array
  1689. {
  1690. $result = SectorPlace::where('sector_place.id',$data['id'])
  1691. ->leftJoin('size','sector_place.size_id','=','size.id')
  1692. ->select('sector_place.*','size.width','size.height')
  1693. ->first();
  1694. if(empty($result)){
  1695. return Result::error('通栏版式不存在!');
  1696. }
  1697. return Result::success($result);
  1698. }
  1699. /**
  1700. * 自助建站-通栏版式管理-获取通栏版式列表
  1701. */
  1702. public function getSectorPlaceSort(array $data): array
  1703. {
  1704. $sector = SectorPlace::where('sector_type',$data['sector_type'])->first();
  1705. if(empty($sector)){
  1706. return Result::error('通栏版式不存在!');
  1707. }
  1708. $component = SectorPlace::where('type_id',2)->where('sector_type',$sector['sector_type'])->pluck('sort_id')->toArray();
  1709. if(count($component) < $sector['component_num']){
  1710. // 根据 $sector['component_num'] 的值生成对应元素数量的数组
  1711. if (isset($sector['component_num']) && is_numeric($sector['component_num'])) {
  1712. $num = intval($sector['component_num']);
  1713. if ($num > 0 && $num <= 10) {
  1714. // 使用 range 函数生成一个从 1 到 $num 的连续整数数组,存储到 $sector_arr 中
  1715. $sector_arr = range(1, $num);
  1716. } else {
  1717. $sector_arr = [];
  1718. }
  1719. } else {
  1720. $sector_arr = [];
  1721. }
  1722. // 获取 $sector_arr 中不在 $component 里的元素
  1723. $sort = array_diff($sector_arr, $component);
  1724. // return Result::success($sort);
  1725. }
  1726. if(!empty($sort)){
  1727. $sort = array_values(array_map(function($value) {
  1728. return ['id' => $value];
  1729. }, $sort));
  1730. }else{
  1731. return Result::error("组件版式数量已达上限!");
  1732. }
  1733. return Result::success($sort);
  1734. }
  1735. /**
  1736. * 获取所有通栏版式
  1737. */
  1738. public function getAllSectorPlace(array $data): array
  1739. {
  1740. $where['type_id'] = $data['type_id'];
  1741. if(isset($data['sector_type']) && !empty($data['sector_type'])){
  1742. $where['sector_type'] = $data['sector_type'];
  1743. }
  1744. if(isset($data['component_num']) && !empty($data['component_num'])){
  1745. $where['component_num'] = $data['component_num'];
  1746. }
  1747. $sector_place = SectorPlace::where($where)
  1748. ->leftJoin('size','sector_place.size_id','=','size.id')
  1749. ->select('sector_place.*','size.width','size.height')
  1750. ->get()->all();
  1751. if(empty($sector_place)){
  1752. return Result::error('通栏版式不存在!');
  1753. }
  1754. return Result::success($sector_place);
  1755. }
  1756. }