NewsService.php 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267
  1. <?php
  2. namespace App\JsonRpc;
  3. use App\Model\Article;
  4. use App\Model\ArticleData;
  5. use App\Model\Category;
  6. use App\Model\WebsiteCategory;
  7. use App\Model\ArticleSurvey;
  8. use App\Model\jobHunting;
  9. use App\Model\JobEnum;
  10. use App\Model\JobIndustry;
  11. use App\Model\JobPosition;
  12. use App\Model\JobRecruiting;
  13. use App\Model\Good;
  14. use App\Model\JobNature;
  15. use App\Model\Website;
  16. use Hyperf\DbConnection\Db;
  17. use Hyperf\RpcServer\Annotation\RpcService;
  18. use App\Tools\Result;
  19. use Ramsey\Uuid\Uuid;
  20. use Hyperf\Utils\Random;
  21. #[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
  22. class NewsService implements NewsServiceInterface
  23. {
  24. /**
  25. * 获取导航池列表
  26. * @param array $data
  27. * @return array
  28. */
  29. public function getCategoryList(array $data): array
  30. {
  31. $where = [];
  32. if (isset($data['name']) && $data['name']) {
  33. array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
  34. }
  35. if (isset($data['department_id']) && $data['department_id']) {
  36. array_push($where, ['category.department_id', '=', $data['department_id']]);
  37. }
  38. $city_id = '';
  39. if (isset($data['city_id']) && $data['city_id']) {
  40. $city_id = intval($data['city_id']);
  41. }
  42. $rep = Category::where($where)
  43. ->when($city_id, function ($query) use ($city_id) {
  44. if (isset($city_id) && $city_id) {
  45. $query->whereJsonContains("category.city_arr_id", $city_id);
  46. }
  47. })
  48. ->leftJoin('district', 'category.city_id', 'district.id')
  49. ->leftJoin('department', 'category.department_id', 'department.id')
  50. ->leftJoin('category as c', 'category.pid', 'c.id')
  51. ->select("category.*", "district.name as city_name", "department.name as department_name","c.name as parent_name")
  52. ->limit($data['pageSize'])->orderByDesc('category.updated_at')->offset(($data['page'] - 1) * $data['pageSize'])->get();
  53. $count = Category::where($where)->when($city_id, function ($query) use ($city_id) {
  54. if (isset($city_id) && $city_id) {
  55. $query->whereJsonContains("category.city_arr_id", $city_id);
  56. }
  57. })->count();
  58. $data = [
  59. 'rows' => $rep->toArray(),
  60. 'count' => $count,
  61. ];
  62. if (empty($rep->toArray())) {
  63. return Result::error("没有导航池数据");
  64. }
  65. return Result::success($data);
  66. }
  67. public function myCategoryList(array $data): array
  68. {
  69. $sszq = $data['sszq'] ?? '';
  70. unset($data['sszq']);
  71. //1,2,3 根据这些webid,。从website_category表中取出对应的分类id,然后从category表中取出分类信息
  72. $catorytids = WebsiteCategory::whereIn('website_id', explode(',', $sszq))->get()->pluck('category_id')->toArray();
  73. $where[] = [
  74. 'pid', '=', $data['pid'],
  75. ];
  76. if (isset($data['name'])) {
  77. array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
  78. }
  79. var_dump($where);
  80. //根据分类id,从category表中取出分类信息
  81. $result = Category::where($where)
  82. ->whereIn('category.id', $catorytids)
  83. ->select('category.*', 'category.id as category_id')->get();
  84. if (empty($result)) {
  85. return Result::error("没有栏目数据");
  86. }
  87. return Result::success($result);
  88. }
  89. /**
  90. * @param array $data
  91. * @return array
  92. */
  93. public function categoryList(array $data): array
  94. {
  95. $where[] = [
  96. 'pid', '=', $data['pid'],
  97. ];
  98. if (isset($data['name'])) {
  99. array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
  100. }
  101. var_dump($where);
  102. $result = Category::where($where)->select('category.*', 'category.id as category_id')->get();
  103. if (empty($result)) {
  104. return Result::error("没有栏目数据");
  105. }
  106. return Result::success($result);
  107. }
  108. /**
  109. * @param array $data
  110. * @return array
  111. */
  112. public function addCategory(array $data): array
  113. {
  114. $id = Category::insertGetId($data);
  115. if (empty($id)) {
  116. return Result::error("添加失败");
  117. }
  118. return Result::success(['id' => $id]);
  119. }
  120. /**
  121. * @param array $data
  122. * @return array
  123. */
  124. public function delCategory(array $data): array
  125. {
  126. $categoryList = Category::where(['pid' => $data['id']])->get();
  127. var_dump("分类列表:", $data, $categoryList);
  128. if ($categoryList->toArray()) {
  129. return Result::error("分类下面有子分类不能删除");
  130. }
  131. $articleList = Article::where(['catid' => $data['id']])->get();
  132. var_dump("文章列表:", $articleList);
  133. if ($articleList->toArray()) {
  134. return Result::error("分类下面有资讯不能删除");
  135. }
  136. $result = Category::where($data)->delete();
  137. if (!$result) {
  138. return Result::error("删除失败");
  139. }
  140. return Result::success($result);
  141. }
  142. /**
  143. * @param array $data
  144. * @return array
  145. */
  146. public function updateCategory(array $data): array
  147. {
  148. $where = [
  149. 'id' => $data['id'],
  150. ];
  151. $result = Category::where($where)->update($data);
  152. if ($result) {
  153. return Result::success($result);
  154. } else {
  155. return Result::error("更新失败");
  156. }
  157. }
  158. /**
  159. * 获取导航池信息
  160. * @param array $data
  161. * @return array
  162. */
  163. public function getCategoryInfo(array $data): array
  164. {
  165. $where = [
  166. 'id' => $data['id'],
  167. ];
  168. $result = Category::where($where)->first();
  169. if ($result) {
  170. return Result::success($result);
  171. } else {
  172. return Result::error("更新失败");
  173. }
  174. }
  175. /**
  176. * @param array $data
  177. * @return array
  178. */
  179. public function getArticleList(array $data): array
  180. {
  181. //判断是否是管理员'1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)'
  182. $type_id = $data['type_id'];
  183. unset($data['type_id']);
  184. $user_id = $data['user_id'];
  185. unset($data['user_id']);
  186. $where = [];
  187. $status1 = [];
  188. if (isset($data['title']) && $data['title']) {
  189. array_push($where, ['article.title', 'like', '%' . $data['title'] . '%']);
  190. }
  191. if (isset($data['category_name']) && $data['category_name']) {
  192. array_push($where, ['category.name', 'like', '%' . $data['category_name'] . '%']);
  193. }
  194. if (isset($data['author']) && $data['author']) {
  195. array_push($where, ['article.author', '=', $data['author']]);
  196. }
  197. if (isset($data['islink']) && $data['islink'] !== "") {
  198. array_push($where, ['article.islink', '=', $data['islink']]);
  199. }
  200. if (isset($data['status']) && $data['status'] !== "") {
  201. array_push($where, ['article.status', '=', $data['status']]);
  202. }
  203. if (isset($data['status1'])) {
  204. $status1 = json_decode(($data['status1']));
  205. }
  206. //不是管理员展示个人数据;
  207. if ($type_id != 10000) {
  208. $where[] = ['article.admin_user_id', '=', $user_id];
  209. }
  210. $rep = Article::where($where)
  211. ->whereNotIn('article.status', [404])
  212. ->when($status1, function ($query) use ($status1) {
  213. if (isset($status1) && $status1) {
  214. $query->whereIn('article.status', $status1);
  215. }
  216. })
  217. ->leftJoin('category', 'article.catid', 'category.id')
  218. ->select("article.*", "category.name as category_name")
  219. ->orderBy("article.updated_at", "desc")
  220. ->limit($data['pageSize'])
  221. ->offset(($data['page'] - 1) * $data['pageSize'])->get();
  222. $count = Article::where($where)->whereNotIn('article.status', [404])
  223. ->when($status1, function ($query) use ($status1) {
  224. if (isset($status1) && $status1) {
  225. $query->whereIn('article.status', $status1);
  226. }
  227. })
  228. ->leftJoin('category', 'article.catid', 'category.id')->count();
  229. $data = [
  230. 'rows' => $rep->toArray(),
  231. 'count' => $count,
  232. ];
  233. if (empty($rep)) {
  234. return Result::error("没有信息数据");
  235. }
  236. return Result::success($data);
  237. }
  238. /**
  239. * @param array $data
  240. * @return array
  241. */
  242. public function addArticle(array $data): array
  243. {
  244. var_dump($data, '----------12-----------1');
  245. unset($data['user_type']);
  246. // unset($data['web_site_id']);
  247. unset($data['nav_add_pool_id']);
  248. // $data['cat_arr_id'] = is_string($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
  249. Db::beginTransaction();
  250. try {
  251. //处理投票
  252. $is_survey = isset($data['is_survey']) ? $data['is_survey'] : 0;
  253. $survey_name = isset($data['survey_name']) ? $data['survey_name'] : '';
  254. $suvey_array = isset($data['suvey_array']) ? $data['suvey_array'] : '';
  255. $website_id = isset($data['website_id']) ? $data['website_id'] : 2;
  256. unset($data['is_survey']);
  257. unset($data['survey_name']);
  258. unset($data['suvey_array']);
  259. unset($data['website_id']);
  260. $data['web_site_id'] = is_array($data['web_site_id']) ? json_encode($data['web_site_id']) : ($data['web_site_id']);
  261. if ($data['hits'] == '') {
  262. $data['hits'] = 0;
  263. }
  264. if ($data['is_original'] == '') {
  265. $data['is_original'] = 0;
  266. }
  267. if ($data['status'] == '') {
  268. $data['status'] = 0;
  269. }
  270. $articleData = $data;
  271. unset($articleData['content']);
  272. $id = Article::insertGetId($articleData);
  273. $articleDataContent = [
  274. 'article_id' => $id,
  275. 'content' => $data['content'],
  276. ];
  277. ArticleData::insertGetId($articleDataContent);
  278. //处理投票
  279. if ($is_survey == 1) {
  280. //生成年月日时分秒+8位随机数
  281. $uuid = date('YmdHis') . rand(10000000, 99999999);
  282. var_dump($suvey_array, 'suvey_array________');
  283. $suveys_array = is_array($suvey_array) ? $suvey_array : json_decode($suvey_array);
  284. var_dump($suveys_array, '---------------------1');
  285. var_dump($suvey_array, '---------------------2');
  286. $suvey_data = [];
  287. foreach ($suveys_array as $key => $value) {
  288. if ($value == '') {
  289. continue;
  290. }
  291. if (is_array($value)) {
  292. $suvey_data[] = [
  293. 'sur_id' => $uuid,
  294. 'art_id' => $id,
  295. 'website_id' => $website_id ?? 2,
  296. 'survey_name' => $survey_name,
  297. 'choice_name' => $value[1],
  298. 'is_other' => 1,
  299. 'other_id' => 0,
  300. 'results' => 0,
  301. ];
  302. } else {
  303. $suvey_data[] = [
  304. 'sur_id' => $uuid,
  305. 'art_id' => $id,
  306. 'website_id' => $website_id ?? 2,
  307. 'survey_name' => $survey_name,
  308. 'choice_name' => $value,
  309. 'is_other' => 0,
  310. 'other_id' => 0,
  311. 'results' => 0,
  312. ];
  313. }
  314. if (empty($suvey_data)) {
  315. throw new \Exception("投票数据为空");
  316. }
  317. }
  318. $result = ArticleSurvey::insert($suvey_data);
  319. if (!$result) {
  320. throw new \Exception("投票失败,ArticleSurvey插入失败");
  321. }
  322. $result = Article::where('id', $id)->update(['survey_id' => $uuid, 'survey_name' => $survey_name, 'is_survey' => $is_survey]);
  323. if (!$result) {
  324. throw new \Exception("投票失败,更新主表失败");
  325. }
  326. }
  327. Db::commit();
  328. return Result::success(['id' => $id]);
  329. } catch (\Throwable $ex) {
  330. Db::rollBack();
  331. var_dump($ex->getMessage());
  332. return Result::error("创建失败", 0);
  333. }
  334. }
  335. /**
  336. * @param array $data
  337. * @return array
  338. */
  339. public function delArticle(array $data): array
  340. {
  341. $result = Article::where($data)->delete();
  342. //survey投票删除
  343. articleSurvey::where(['art_id' => $data['id']])->delete();
  344. if (!$result) {
  345. return Result::error("删除失败");
  346. }
  347. return Result::success($result);
  348. }
  349. /**
  350. * @param array $data
  351. * @return array
  352. */
  353. public function updateArticle(array $data): array
  354. {
  355. var_dump($data, '----------12-----------1');
  356. Db::beginTransaction();
  357. unset($data['user_type']);
  358. // unset($data['web_site_id']);
  359. unset($data['nav_add_pool_id']);
  360. try {
  361. //处理投票
  362. $is_survey = isset($data['is_survey']) ? $data['is_survey'] : 0;
  363. $survey_name = isset($data['survey_name']) ? $data['survey_name'] : '';
  364. $suvey_array = isset($data['suvey_array']) ? $data['suvey_array'] : '';
  365. $website_id = isset($data['website_id']) ? $data['website_id'] : 2;
  366. unset($data['is_survey']);
  367. unset($data['survey_name']);
  368. unset($data['suvey_array']);
  369. unset($data['website_id']);
  370. $data['web_site_id'] = is_array($data['web_site_id']) ? json_encode($data['web_site_id']) : ($data['web_site_id']);
  371. if ($data['hits'] == '') {
  372. $data['hits'] = 0;
  373. }
  374. if ($data['is_original'] == '') {
  375. $data['is_original'] = 0;
  376. }
  377. if ($data['status'] == '') {
  378. $data['status'] = 0;
  379. }
  380. $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
  381. $data['tag'] = isset($data['tag']) ? json_encode($data['tag']) : '';
  382. $articleData = $data;
  383. unset($articleData['content']);
  384. unset($articleData['status_name']);
  385. unset($articleData['name']);
  386. unset($articleData['content']);
  387. unset($articleData['pid_arr']);
  388. unset($articleData['pid']);
  389. $id = Article::where(['id' => $data['id']])->update($articleData);
  390. $articleDataContent = [
  391. 'content' => $data['content'],
  392. ];
  393. ArticleData::where(['article_id' => $data['id']])->update($articleDataContent);
  394. //处理投票
  395. $id = $data['id'];
  396. $surveydata = ArticleSurvey::where(['art_id' => $data['id']])->delete();
  397. var_dump($suvey_array, 'suvey_array________delete');
  398. //处理投票
  399. if ($is_survey == 1) {
  400. //生成年月日时分秒+8位随机数
  401. $uuid = date('YmdHis') . rand(10000000, 99999999);
  402. $suveys_array = is_array($suvey_array) ? $suvey_array : json_decode($suvey_array);
  403. var_dump($suveys_array, '---------------------1');
  404. var_dump($suvey_array, '---------------------2');
  405. $suvey_data = [];
  406. if (is_array($suveys_array)) {
  407. foreach ($suveys_array as $key => $value) {
  408. if ($value == '') {
  409. continue;
  410. }
  411. if (is_array($value)) {
  412. $suvey_data[] = [
  413. 'sur_id' => $uuid,
  414. 'art_id' => $id,
  415. 'website_id' => $website_id ?? 2,
  416. 'survey_name' => $survey_name,
  417. 'choice_name' => $value[1],
  418. 'is_other' => 1,
  419. 'other_id' => 0,
  420. 'results' => 0,
  421. ];
  422. } else {
  423. $suvey_data[] = [
  424. 'sur_id' => $uuid,
  425. 'art_id' => $id,
  426. 'website_id' => $website_id ?? 2,
  427. 'survey_name' => $survey_name,
  428. 'choice_name' => $value,
  429. 'is_other' => 0,
  430. 'other_id' => 0,
  431. 'results' => 0,
  432. ];
  433. }
  434. if (empty($suvey_data)) {
  435. throw new \Exception("投票数据为空");
  436. }
  437. }
  438. }
  439. $result = ArticleSurvey::insert($suvey_data);
  440. if (!$result) {
  441. throw new \Exception("投票失败");
  442. }
  443. $result = Article::where('id', $id)->update(['survey_id' => $uuid, 'survey_name' => $survey_name, 'is_survey' => $is_survey]);
  444. if (!$result) {
  445. throw new \Exception("投票失败");
  446. }
  447. } else {
  448. $result = Article::where('id', $id)->update(['survey_id' => '', 'survey_name' => '', 'is_survey' => 0]);
  449. }
  450. Db::commit();
  451. return Result::success([]);
  452. } catch (\Throwable $ex) {
  453. Db::rollBack();
  454. var_dump($ex->getMessage());
  455. return Result::error("更新失败1" . $ex->getMessage(), 0);
  456. }
  457. }
  458. /**
  459. * 更新资讯状态
  460. * @param array $data
  461. * @return array
  462. */
  463. public function upArticleStatus(array $data): array
  464. {
  465. $result = Article::where(['id' => $data['id']])->update($data);
  466. if ($result) {
  467. return Result::success();
  468. } else {
  469. return Result::error("更新状态失败", 0);
  470. }
  471. }
  472. /**
  473. * @param array $data
  474. * @return array
  475. */
  476. public function getArticleInfo(array $data): array
  477. {
  478. $where = [
  479. 'article.id' => $data['id'],
  480. // 'article.status' => 1,
  481. ];
  482. $result = Article::where($where)->leftJoin("article_data", "article.id", "article_data.article_id")->first();
  483. $articleSurvey = ArticleSurvey::where(['art_id' => $data['id']])->get();
  484. $info = $result;
  485. // var_dump($info, 'info');
  486. $info['survey_array'] = $articleSurvey;
  487. if ($result) {
  488. return Result::success($info);
  489. } else {
  490. return Result::error("查询失败", 0);
  491. }
  492. }
  493. /**
  494. * 获取新闻
  495. * @param array $data
  496. * @return array
  497. */
  498. public function getWebsiteArticlett(array $data): array
  499. {
  500. $category = WebsiteCategory::where('website_id',$data['website_id'])->pluck('category_id');
  501. $result= [];
  502. if($category){
  503. $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
  504. $where = [
  505. 'status' => 1,
  506. 'level' => $data['level'],
  507. ];
  508. $result = Article::where($where)
  509. ->whereIn("catid", $category)
  510. ->where(function ($query) use ($data) {
  511. $query->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0")
  512. ->orWhereNull("ignore_ids");
  513. })
  514. ->orderBy("updated_at", "desc")
  515. ->offset($placeid)
  516. ->limit($data['pageSize'])
  517. ->get();
  518. if(empty($result)){
  519. return Result::error("暂无头条新闻",0);
  520. }
  521. return Result::success($result);
  522. }else{
  523. return Result::error("本网站下暂无相关栏目",0);
  524. }
  525. }
  526. /**
  527. * 获取模块新闻
  528. * @param array $data
  529. * @return array
  530. */
  531. public function getWebsiteModelArticles(array $data): array
  532. {
  533. $catid = $data['catid'];
  534. $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $catid)->select('category_id')->get();
  535. $category = $category->toArray();
  536. if (!empty($category)) {
  537. $where = [
  538. 'status' => 1,
  539. 'catid' => $catid,
  540. ];
  541. $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
  542. // 级别:0:未分类 1:头条 2:轮播图 3:推荐图 4:热点资讯 5:资讯推荐
  543. if ($data['level'] == 1) {
  544. $level = [
  545. 0 => '1',
  546. 1 => '4',
  547. 2 => '5',
  548. 3 => '0',
  549. ];
  550. $result = Article::where($where)
  551. ->whereIn('level',$level)
  552. ->where(function ($query) use ($data) {
  553. $query->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0")
  554. ->orWhereNull("ignore_ids");
  555. })
  556. ->orderBy("updated_at","desc")
  557. ->offset($placeid)
  558. ->limit($data['pagesize'])
  559. ->get();
  560. }elseif($data['level']==2){
  561. $level='2';
  562. $result = Article::where($where)
  563. ->where('level',$level)
  564. ->where(function ($query) use ($data) {
  565. $query->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0")
  566. ->orWhereNull("ignore_ids");
  567. })
  568. ->orderBy("updated_at","desc")
  569. ->offset($placeid)
  570. ->limit($data['pagesize'])
  571. ->get();
  572. }else{
  573. $level='3';
  574. $result = Article::where($where)
  575. ->where('level',$level)
  576. ->where(function ($query) use ($data) {
  577. $query->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0")
  578. ->orWhereNull("ignore_ids");
  579. })
  580. ->orderBy("updated_at","desc")
  581. ->offset($placeid)
  582. ->limit($data['pagesize'])
  583. ->get();
  584. }
  585. if (empty($result)) {
  586. return Result::error("此栏目暂无相关新闻", 0);
  587. }
  588. } else {
  589. return Result::error("此网站暂无此栏目", 0);
  590. }
  591. return Result::success($result);
  592. }
  593. /**
  594. *获取新闻列表
  595. * @param array $data
  596. * @return array
  597. */
  598. public function getWebsiteArticleList(array $data): array
  599. {
  600. $where[] = ['status', '=', 1];
  601. if (isset($data['keyword']) && !empty($data['keyword'])) {
  602. array_push($where, ['article.title', 'like', '%' . $data['keyword'] . '%']);
  603. }
  604. if (isset($data['catid']) && !empty($data['catid'])) {
  605. if (is_array($data['catid'])) {
  606. $category = WebsiteCategory::where('website_id', $data['website_id'])->whereIn('category_id', $data['catid'])->pluck('category_id');
  607. array_push($where, ['catid', 'in', $data['catid']]);
  608. } else {
  609. $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['catid'])->pluck('category_id');
  610. array_push($where, ['catid', '=', $data['catid']]);
  611. }
  612. if (empty($category)) {
  613. return Result::error("此网站暂无此栏目", 0);
  614. }
  615. }
  616. // return Result::success($where);
  617. $rep = Article::where(function ($query) use ($where) {
  618. foreach ($where as $condition) {
  619. if ($condition[1] === 'in') {
  620. $query->whereIn($condition[0], $condition[2]);
  621. } else {
  622. $query->where($condition[0], $condition[1], $condition[2]);
  623. }
  624. }
  625. })
  626. ->where(function ($query) use ($data) {
  627. $query->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0")
  628. ->orWhereNull("ignore_ids");
  629. })
  630. ->orderBy("updated_at", "desc")
  631. ->limit($data['pageSize'])
  632. ->offset(($data['page'] - 1) * $data['pageSize'])
  633. ->get();
  634. $count = Article::where(function ($query) use ($where) {
  635. foreach ($where as $condition) {
  636. if ($condition[1] === 'in') {
  637. $query->whereIn($condition[0], $condition[2]);
  638. } else {
  639. $query->where($condition[0], $condition[1], $condition[2]);
  640. }
  641. }
  642. })->count();
  643. $data = [
  644. 'rows' => $rep->toArray(),
  645. 'count' => $count,
  646. ];
  647. if (empty($rep)) {
  648. return Result::error("没有信息数据");
  649. }
  650. return Result::success($data);
  651. }
  652. /**
  653. * 前端-获取新闻详情
  654. * @param array $data
  655. * @return array
  656. */
  657. public function selectWebsiteArticleInfo(array $data): array
  658. {
  659. $where = [
  660. 'article.id' => $data['id'],
  661. 'article.status' => 1,
  662. ];
  663. $result = Article::where($where)->leftJoin("article_data","article.id","article_data.article_id")
  664. ->where(function ($query) use ($data) {
  665. $query->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0")
  666. ->orWhereNull("ignore_ids");
  667. })
  668. ->first();
  669. if(empty($result)){
  670. return Result::error("暂无此新闻!",0);
  671. }
  672. $category = WebsiteCategory::leftJoin('website', 'website.id', '=', 'website_category.website_id')
  673. ->select('website_category.*', 'website.website_name', 'website.suffix')
  674. ->where('website_category.website_id', $data['website_id'])
  675. ->where(['website_category.category_id' => $result['catid']])
  676. ->first();
  677. if (empty($category)) {
  678. return Result::error("查询失败", 0);
  679. }
  680. $result['category_id'] = $category['category_id'];
  681. $result['cat_name'] = $category['alias'];
  682. $result['website_name'] = $category['website_name']??"";
  683. $result['suffix'] = $category['suffix']??"";
  684. return Result::success($result);
  685. }
  686. /**
  687. * 前端-获取网站调查问卷
  688. * @param array $data
  689. * @return array
  690. */
  691. public function getWebsiteSurvey(array $data): array
  692. {
  693. if (isset($data['website_id']) && !empty($data['website_id'])) {
  694. $website = Website::where('id', $data['website_id'])->first();
  695. if (empty($website)) {
  696. return Result::error("暂无此网站", 0);
  697. }
  698. }
  699. if (isset($data['art_id']) && !empty($data['art_id'])) {
  700. $article = Article::where('id', $data['art_id'])->where('status', 1)->first();
  701. if (empty($article)) {
  702. return Result::error("暂无此文章", 0);
  703. }
  704. // return Result::error($data,0);
  705. $where['art_id'] = $data['art_id'];
  706. // $query = ArticleSurvey::where('art_id',$data['art_id']);
  707. } else {
  708. $survey = ArticleSurvey::where('website_id', $data['website_id'])->orderBy('created_at')->first();
  709. if (empty($survey)) {
  710. return Result::error("暂无调查问卷", 0);
  711. }
  712. $where['sur_id'] = $survey['sur_id'];
  713. // $query = ArticleSurvey::where('sur_id',$survey['sur_id']);
  714. }
  715. $result['survey'] = ArticleSurvey::where($where)->where('is_other', 0)
  716. ->leftJoin('article', 'article_survey.art_id', 'article.id')
  717. ->select('article_survey.*', 'article.survey_type')
  718. ->get()->all();
  719. $result['other'] = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', 0)->first();
  720. $result['others'] = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', '!=', 0)->orderByDesc('created_at')->first();
  721. if (empty($result)) {
  722. return Result::error("此文章暂无调查问卷", 0);
  723. }
  724. return Result::success($result);
  725. }
  726. /**
  727. * 前端-添加网站调查问卷选项
  728. * @param array $data
  729. * @return array
  730. */
  731. public function addWebsiteSurveyOption(array $data): array
  732. {
  733. if (isset($data['website_id']) && !empty($data['website_id'])) {
  734. $website = Website::where('id', $data['website_id'])->first();
  735. if (empty($website)) {
  736. return Result::error("暂无此网站", 0);
  737. }
  738. if (isset($data['sur_id']) && !empty($data['sur_id'])) {
  739. $survey = ArticleSurvey::where('sur_id', $data['sur_id'])->where('website_id', $data['website_id'])->where('is_other', 1)->where('other_id', 0)->first();
  740. if (empty($survey)) {
  741. return Result::error("此调查问卷不可添加选项", 0);
  742. }
  743. if (isset($data['choice_name']) && !empty($data['choice_name'])) {
  744. $choice = [
  745. 'art_id' => $survey['art_id'],
  746. 'website_id' => $data['website_id'],
  747. 'survey_name' => $survey['survey_name'],
  748. 'choice_name' => $data['choice_name'],
  749. 'sur_id' => $survey['sur_id'],
  750. 'is_other' => 1,
  751. 'other_id' => $survey['id'],
  752. ];
  753. $result = ArticleSurvey::insertGetId($choice);
  754. if (empty($result)) {
  755. return Result::error("添加失败", 0);
  756. }
  757. return Result::success($result);
  758. }
  759. }
  760. return Result::error("添加失败", 0);
  761. }
  762. return Result::error("添加失败", 0);
  763. }
  764. /**
  765. * 前端-调查问卷投票
  766. * @param array $data
  767. * @return array
  768. */
  769. public function addWebsiteSurveyVote(array $data): array
  770. {
  771. if (isset($data['website_id']) && !empty($data['website_id'])) {
  772. $website = Website::where('id', $data['website_id'])->first();
  773. if (empty($website)) {
  774. return Result::error("暂无此网站", 0);
  775. }
  776. if (isset($data['sur_id']) && !empty($data['sur_id'])) {
  777. $survey = ArticleSurvey::where('sur_id', $data['sur_id'])->where('website_id', $data['website_id'])->pluck('sur_id');
  778. if (empty($survey)) {
  779. return Result::error("此调查问卷不存在", 0);
  780. }
  781. // return Result::success($survey);
  782. // 调查问卷类型 0:单选 1:多选
  783. $type = Article::where('survey_id', $data['sur_id'])->pluck('survey_type');
  784. // return Result::success($type);
  785. if (empty($type) || ($type[0] != 1 && $type[0] != 0)) {
  786. return Result::error("此调查问卷不可投票", 0);
  787. }
  788. // return Result::success($type[0]);
  789. if (isset($data['choice_id']) && !empty($data['choice_id'])) {
  790. if ($type[0] == 0) {
  791. if (is_array($data['choice_id'])) {
  792. return Result::error("请选择一个选项!", 0);
  793. }
  794. $data['choice_id'] = [$data['choice_id']];
  795. } else {
  796. if (!is_array($data['choice_id'])) {
  797. return Result::error("请传递数组!", 0);
  798. }
  799. }
  800. // return Result::success($data['choice_id']);
  801. $other = ArticleSurvey::whereIn('id', $data['choice_id'])
  802. ->where('website_id', $data['website_id'])
  803. ->where('is_other', 1)
  804. ->where('other_id', 0)
  805. ->first();
  806. if (!empty($other)) {
  807. return Result::error("请选择已有的选项!", 0);
  808. }
  809. $choice['other'] = ArticleSurvey::whereIn('id', $data['choice_id'])
  810. ->where('website_id', $data['website_id'])
  811. ->where('is_other', 1)
  812. ->where('other_id', '!=', 0)
  813. ->first();
  814. // return Result::success($data);
  815. if (!empty($choice['other'])) {
  816. array_push($data['choice_id'], $choice['other']['other_id']);
  817. // return Result::success($data['choice_id']);
  818. }
  819. // return Result::success($data);
  820. $choice = ArticleSurvey::whereIn('id', $data['choice_id'])
  821. ->where('website_id', $data['website_id'])
  822. ->increment('results', 1);
  823. if (empty($choice)) {
  824. return Result::error("请选择已有的选项!", 0);
  825. }
  826. return Result::success($choice);
  827. }
  828. return Result::error("参数必填!");
  829. // if(isset($data['choice_id']) && !empty($data['choice_id'])){
  830. // $choice = ArticleSurvey::whereIn('id',$data['choice_id'])->where('website_id',$data['website_id'])->where('is_other',1)->where('other_id',0)->first();
  831. // }
  832. }
  833. return Result::error("此调查问卷不存在", 0);
  834. }
  835. return Result::error("参数必填!");
  836. }
  837. /**
  838. * 后端-获取网站调查问卷列表
  839. * @param array $data
  840. * @return array
  841. */
  842. public function getSurveyList(array $data): array
  843. {
  844. $where = [];
  845. if (isset($data['survey_name']) && !empty($data['survey_name'])) {
  846. array_push($where, ['survey_name', 'like', '%' . $data['survey_name'] . '%']);
  847. }
  848. if (isset($data['survey_type']) && $data['survey_type'] != null) {
  849. array_push($where, ['survey_type', '=', $data['survey_type']]);
  850. }
  851. if (isset($data['is_survey']) && $data['is_survey'] != null) {
  852. array_push($where, ['is_survey', '=', $data['is_survey']]);
  853. }
  854. // return Result::success($where);
  855. if (!empty($where)) {
  856. $query = Article::where($where)->where(function ($q) {
  857. $q->whereNotNull('survey_name')->where('survey_name', '!=', '');
  858. });
  859. } else {
  860. $query = Article::where(function ($q) {
  861. $q->whereNotNull('survey_name')->where('survey_name', '!=', '');
  862. });
  863. }
  864. $count = $query->count();
  865. $survey = $query->orderByDesc('id')
  866. ->limit($data['pageSize'])
  867. ->offset(($data['page'] - 1) * $data['pageSize'])
  868. ->get();
  869. if (empty($survey->toArray())) {
  870. return Result::error("暂无调查问卷!", 0);
  871. }
  872. $result = [
  873. 'rows' => $survey,
  874. 'count' => $count,
  875. ];
  876. return Result::success($result);
  877. }
  878. /**
  879. * 后端-获取网站调查问卷详情
  880. * @param array $data
  881. * @return array
  882. */
  883. public function getSurveyInfo(array $data): array
  884. {
  885. if (isset($data['sur_id']) && !empty($data['sur_id'])) {
  886. $where = ['sur_id' => $data['sur_id']];
  887. $choose = ArticleSurvey::where($where)->where('is_other', 0)
  888. ->leftJoin('article', 'article_survey.art_id', 'article.id')
  889. ->select('article_survey.*', 'article.survey_type')
  890. ->get()->all();
  891. if (empty($choose)) {
  892. return Result::error("此调查问卷不存在", 0);
  893. }
  894. $resultsArray = array_column($choose, 'results');
  895. $total = array_sum($resultsArray);
  896. $other = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', 0)->first();
  897. $others = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', '!=', 0)->orderByDesc('created_at')->get()->all();
  898. // $total = 0;
  899. if (!empty($other)) {
  900. $total = $total + $other['results'];
  901. $other['choice_name'] = $other['choice_name'] . '(其他)';
  902. if (!empty($others)) {
  903. $other['hasChildren'] = true;
  904. // array_push($other,['hasChildren','=',true]);
  905. $other['children'] = $others;
  906. $other_choices = [$other->toArray()];
  907. $mer_choice = array_merge($choose, $other_choices);
  908. $value_choice = array_values($mer_choice);
  909. } else {
  910. // return Result::error('1111');
  911. $other_choices = [$other->toArray()];
  912. $other_choices = array_merge($choose, $other_choices);
  913. $value_choice = array_values($other_choices);
  914. // return Result::success($result);
  915. }
  916. } else {
  917. $value_choice = $choose;
  918. }
  919. $result = [
  920. 'choose' => $value_choice,
  921. 'total' => $total,
  922. ];
  923. }
  924. return Result::success($result);
  925. }
  926. /**
  927. * 前端-搜索新闻列表
  928. * @param array $data
  929. * @return array
  930. */
  931. public function selectWebsiteArticle(array $data): array
  932. {
  933. $where = [];
  934. // 初始化查询构造器
  935. $category = WebsiteCategory::where('website_id',$data['website_id'])->pluck('category_id');
  936. $query = Article::where('status', 1)
  937. ->whereIn('catid', $category)
  938. ->where(function ($query) use ($data) {
  939. $query->where(function ($subQuery) use ($data) {
  940. $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0");
  941. })->orWhereNull("ignore_ids");
  942. });
  943. // return Result::success($all_articles);
  944. // 检查是否存在 cityid 参数
  945. if (isset($data['cityid']) && !empty($data['cityid'])) {
  946. $query->whereRaw("JSON_CONTAINS(city_arr_id, '".intval($data['cityid'])."')");
  947. }
  948. // 检查是否存在 department_id 参数
  949. if (isset($data['department_id']) && !empty($data['department_id'])) {
  950. $query->whereRaw("JSON_CONTAINS(department_arr_id, '".intval($data['department_id'])."')");
  951. }
  952. // 检查是否存在 keyword 参数
  953. if (isset($data['keyword']) && !empty($data['keyword'])) {
  954. $query->where('title', 'like', '%'.$data['keyword'].'%');
  955. }
  956. // 计算总数
  957. $count = $query->count();
  958. // 分页查询
  959. $articles = $query->orderBy("updated_at", "desc")
  960. ->limit($data['pageSize'])
  961. ->offset(($data['page'] - 1) * $data['pageSize'])
  962. ->get()->all();
  963. if (empty($articles)) {
  964. return Result::error("没有符合条件的资讯数据");
  965. }
  966. $data = [
  967. 'rows' => $articles,
  968. 'count' => $count
  969. ];
  970. return Result::success($data);
  971. }
  972. /**
  973. * 验证导航名称是否重复
  974. * @return void
  975. */
  976. public function checkCategoryName(array $data): array
  977. {
  978. $result = Category::when($data, function ($query) use ($data) {
  979. if (isset($data['name']) && $data['name']) {
  980. $query->where("name", $data['name']);
  981. }
  982. if (isset($data['id']) && $data['id']) {
  983. $query->where("id", "!=", $data['id']);
  984. }
  985. })->first();
  986. if ($result) {
  987. return Result::error("已存在");
  988. } else {
  989. return Result::success();
  990. }
  991. }
  992. //20250226 产品列表
  993. public function getGoodList(array $data): array
  994. {
  995. $type_id = isset($data['type_id']) ? $data['type_id'] : '';
  996. unset($data['type_id']);
  997. $user_id = isset($data['user_id']) ? $data['user_id'] : '';
  998. $where = [];
  999. if ($type_id != '10000') {
  1000. $where = [
  1001. 'good.user_id' => $user_id,
  1002. ];
  1003. }
  1004. //类型
  1005. if (isset($data['type_id']) && $data['type_id']) {
  1006. $where = [
  1007. 'type_id' => $data['type_id'],
  1008. ];
  1009. }
  1010. //名称
  1011. if (isset($data['name']) && $data['name']) {
  1012. $where = [
  1013. 'good.name' => $data['name'],
  1014. ];
  1015. }
  1016. $where1 = [];
  1017. //website_id
  1018. // if (isset($data['website_id']) && $data['website_id']) {
  1019. // $where1 = [
  1020. // 'good.website_id', 'like', '%' . $data['website_id'] . '%',
  1021. // ];
  1022. // }
  1023. // website_name
  1024. if (isset($data['website_name']) && $data['website_name']) {
  1025. $where1[] = ['website.website_name', 'like', '%' . $data['website_name'] . '%'];
  1026. }
  1027. // catid
  1028. if (isset($data['category_name']) && $data['category_name']) {
  1029. $where1[] = ['category.name', 'like', '%' . $data['category_name'] . '%'];
  1030. }
  1031. // $result = Good::where($where)
  1032. // ->orderBy("updated_at", "desc")->paginate($data['pige_size'], ['*'], 'page', $data['page']);
  1033. $result = Good::where($where)
  1034. ->when(!empty($where1), function ($query) use ($where1) {
  1035. return $query->where($where1);
  1036. })
  1037. ->leftJoin('district', 'good.city_id', '=', 'district.id')
  1038. ->leftJoin('website', 'good.website_id', '=', 'website.id')
  1039. ->leftJoin('category', 'good.catid', '=', 'category.id')
  1040. ->select('good.*', 'district.name as cityname', 'website.website_name as website_name', 'category.name as category_name')
  1041. ->orderBy("id", "desc")
  1042. ->limit($data['page_size'])
  1043. ->offset(($data['page'] - 1) * $data['page_size'])
  1044. ->get();
  1045. $count = Good::where($where)
  1046. ->leftJoin('district', 'good.city_id', '=', 'district.id')
  1047. ->leftJoin('website', 'good.website_id', '=', 'website.id')
  1048. ->leftJoin('category', 'good.catid', '=', 'category.id')
  1049. ->select('good.*', 'district.name as cityname', 'website.website_name as website_name', 'category.name as category_name')
  1050. ->orderBy("updated_at", "desc")->count();
  1051. $data = [
  1052. 'rows' => $result->toArray(),
  1053. 'count' => $count,
  1054. ];
  1055. if (empty($result)) {
  1056. return Result::error("此栏目暂无相关产品", 0);
  1057. }
  1058. return Result::success($data);
  1059. }
  1060. public function getGoodInfo(array $data): array
  1061. {
  1062. $result = Good::where('id', $data['id'])->first();
  1063. if (empty($result)) {
  1064. return Result::error("此产品不存在", 0);
  1065. }
  1066. return Result::success($result);
  1067. }
  1068. public function addGood(array $data): array
  1069. {
  1070. // unset($data['city_arr_id']);
  1071. // unset($data['cat_arr_id']);
  1072. $data['city_id'] = end($data['city_arr_id']);
  1073. $data['catid'] = end($data['cat_arr_id']);
  1074. $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode($data['city_arr_id']) : '';
  1075. $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
  1076. $data['imgurl'] = isset($data['imgurl']) ? json_encode($data['imgurl']) : '';
  1077. unset($data['imgUrl']);
  1078. $result = Good::insert($data);
  1079. if (empty($result)) {
  1080. return Result::error("添加失败", 0);
  1081. }
  1082. return Result::success($result);
  1083. }
  1084. public function updateGood(array $data): array
  1085. {
  1086. $data['city_id'] = end($data['city_arr_id']);
  1087. $data['catid'] = end($data['cat_arr_id']);
  1088. $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode($data['city_arr_id']) : '';
  1089. $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
  1090. $data['imgurl'] = isset($data['imgurl']) ? json_encode($data['imgurl']) : '';
  1091. //设置东八区
  1092. date_default_timezone_set('Asia/Shanghai');
  1093. $data['updated_at'] = date('Y-m-d H:i:s');
  1094. $result = Good::where('id', $data['id'])->update($data);
  1095. if (empty($result)) {
  1096. return Result::error("更新失败", 0);
  1097. }
  1098. return Result::success($result);
  1099. }
  1100. public function delGood(array $data): array
  1101. {
  1102. $result = Good::where('id', $data['id'])->delete();
  1103. if (empty($result)) {
  1104. return Result::error("删除失败", 0);
  1105. }
  1106. return Result::success($result);
  1107. }
  1108. //20250226 产品列表
  1109. //20250306 求职信息
  1110. public function getJobHuntingList(array $data): array
  1111. {
  1112. $where = [];
  1113. if (isset($data['username']) && !empty($data['username'])) {
  1114. $where[] = ['user.user_name', 'like', '%' . $data['username'] . '%'];
  1115. }
  1116. $type_id = isset($data['type_id']) ? $data['type_id'] : '';
  1117. $user_id = isset($data['user_id']) ? $data['user_id'] : '';
  1118. unset($data['type_id']);
  1119. if ($type_id != '10000') {
  1120. $where[] = ['job_hunting.user_id', '=', $user_id];
  1121. }
  1122. $result = JobHunting::where($where)
  1123. ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
  1124. ->leftJoin('website', 'website.id', '=', 'job_hunting.website_id')
  1125. ->select('job_hunting.*', 'user.nickname as nickname', 'user.user_name as username', 'website.website_name as website_name')
  1126. ->orderBy("id", "desc")
  1127. ->limit($data['page_size'])
  1128. ->offset(($data['page'] - 1) * $data['page_size'])
  1129. ->get();
  1130. if (empty($result)) {
  1131. return Result::error("查询失败", 0);
  1132. }
  1133. $count = JobHunting::where($where)
  1134. ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
  1135. ->leftJoin('website', 'website.id', '=', 'job_hunting.website_id')
  1136. ->count();
  1137. $data = [
  1138. 'rows' => $result->toArray(),
  1139. 'count' => $count,
  1140. ];
  1141. return Result::success($data);
  1142. }
  1143. public function addJobHunting(array $data): array
  1144. {
  1145. date_default_timezone_set('Asia/Shanghai');
  1146. unset($data['company_name']);
  1147. unset($data['job_industry']);
  1148. unset($data['job_name']);
  1149. unset($data['department']);
  1150. unset($data['job_timeList']);
  1151. unset($data['job_content']);
  1152. $data['created_at'] = date('Y-m-d H:i:s');
  1153. $data['updated_at'] = date('Y-m-d H:i:s');
  1154. var_dump($data, '-----------------test---------');
  1155. $result = JobHunting::create($data);
  1156. if (empty($result)) {
  1157. return Result::error("添加失败", 0);
  1158. }
  1159. return Result::success($result);
  1160. }
  1161. public function delJobHunting(array $data): array
  1162. {
  1163. $result = JobHunting::where('id', $data['id'])->delete();
  1164. if (empty($result)) {
  1165. return Result::error("删除失败", 0);
  1166. }
  1167. return Result::success($result);
  1168. }
  1169. public function updateJobHunting(array $data): array
  1170. {
  1171. //设置东八区
  1172. date_default_timezone_set('Asia/Shanghai');
  1173. unset($data['company_name']);
  1174. unset($data['job_industry']);
  1175. unset($data['job_name']);
  1176. unset($data['department']);
  1177. unset($data['job_timeList']);
  1178. unset($data['job_content']);
  1179. $data['created_at'] = date('Y-m-d H:i:s');
  1180. $data['updated_at'] = date('Y-m-d H:i:s');
  1181. $result = JobHunting::where('id', $data['id'])->update($data);
  1182. if (empty($result)) {
  1183. return Result::error("更新失败", 0);
  1184. }
  1185. return Result::success($result);
  1186. }
  1187. public function getJobHuntingInfo(array $data): array
  1188. {
  1189. $result = JobHunting::where('id', $data['id'])->first();
  1190. if (empty($result)) {
  1191. return Result::error("查询失败", 0);
  1192. }
  1193. return Result::success($result);
  1194. }
  1195. public function getJobHuntingData(array $data): array
  1196. {
  1197. $jobEnum = JobEnum::get();
  1198. $jobIndustry = JobIndustry::get();
  1199. $jobNature = JobNature::get();
  1200. $jobPosition = JobPosition::get();
  1201. $data = [
  1202. 'jobEnum' => $jobEnum,
  1203. 'jobIndustry' => $jobIndustry,
  1204. 'jobNature' => $jobNature,
  1205. 'jobPosition' => $jobPosition,
  1206. ];
  1207. return Result::success($data);
  1208. }
  1209. public function delJobHuntingInfo(array $data): array
  1210. {
  1211. $result = JobHunting::where('id', $data['id'])->delete();
  1212. return Result::success();
  1213. }
  1214. }