123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007 |
- <?php
- namespace App\JsonRpc;
- use App\Model\Article;
- use App\Model\ArticleData;
- use App\Model\Category;
- use App\Model\WebsiteCategory;
- use App\Model\ArticleSurvey;
- use App\Model\jobHunting;
- use App\Model\JobEnum;
- use App\Model\JobIndustry;
- use App\Model\JobPosition;
- use App\Model\Notice;
- use App\Model\JobRecruiting;
- use App\Model\Good;
- use App\Model\JobNature;
- use App\Model\Website;
- use Hyperf\DbConnection\Db;
- use Hyperf\RpcServer\Annotation\RpcService;
- use App\Tools\Result;
- use Ramsey\Uuid\Uuid;
- use Hyperf\Utils\Random;
- use Fukuball\Jieba\Jieba;
- use Fukuball\Jieba\Finalseg;
- use App\Model\ChatRecords;
- use App\Model\User;
- use App\Model\UserInfo;
- use Hyperf\Utils\Collection;
- #[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
- class NewsService implements NewsServiceInterface
- {
- /**
- * 获取导航池列表
- * @param array $data
- * @return array
- */
- public function getCategoryList(array $data): array
- {
- $page = (int) $data['page'] ?? 1;
- $perPage = (int) $data['pageSize'] ?? 10;
- $search = $data['name'] ?? '';
- // 查找所有匹配的分类
- $matchedCategories = $this->findMatchedCategories($search);
- // 查找所有匹配分类的父级分类
- $allRequiredCategories = $this->findAllParents($matchedCategories);
- // 提取一级分类
- $topLevelCategories = [];
- foreach ($allRequiredCategories as $category) {
- if ($category->pid === 0) {
- $topLevelCategories[] = $category;
- }
- }
- // 分页处理
- $offset = ($page - 1) * $perPage;
- $paginatedTopLevelCategories = array_slice($topLevelCategories, $offset, $perPage);
- $categoryTree = [];
- foreach ($paginatedTopLevelCategories as $category) {
- $categoryTree[] = $this->buildCategoryTree($category, $allRequiredCategories);
- }
- $return = [
- 'rows' => $categoryTree,
- 'total' => count($topLevelCategories),
- ];
- return Result::success($return);
- }
- private function findMatchedCategories($search)
- {
- if ($search) {
- return Category::where('name', 'like', "%{$search}%")
- ->orderBy('updated_at', 'desc')
- ->get();
- }
- return Category::orderBy('updated_at', 'desc') // 按 updated_at 字段倒序排序
- ->get();
- }
- private function findAllParents($categories)
- {
- $allCategories = [];
- foreach ($categories as $category) {
- $parentId = $category->pid;
- while ($parentId > 0) {
- $parent = Category::find($parentId);
- if ($parent) {
- $allCategories[$parent->id] = $parent;
- $parentId = $parent->pid;
- } else {
- break;
- }
- }
- $allCategories[$category->id] = $category;
- }
- return array_values($allCategories);
- }
- private function buildCategoryTree($category, $allRequiredCategories)
- {
- $categoryData = $category->toArray();
- $children = [];
- foreach ($allRequiredCategories as $c) {
- if ($c->pid === $category->id) {
- $children[] = $this->buildCategoryTree($c, $allRequiredCategories);
- }
- }
- if (!empty($children)) {
- $categoryData['children'] = $children;
- }
- return $categoryData;
- }
- public function myCategoryList(array $data): array
- {
- $sszq = $data['sszq'] ?? '';
- unset($data['sszq']);
- //1,2,3 根据这些webid,。从website_category表中取出对应的分类id,然后从category表中取出分类信息
- $catorytids = WebsiteCategory::whereIn('website_id', explode(',', $sszq))->get()->pluck('category_id')->toArray();
- $where[] = [
- 'pid',
- '=',
- $data['pid'],
- ];
- if (isset($data['name'])) {
- array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
- }
- var_dump($where);
- //根据分类id,从category表中取出分类信息
- $result = Category::where($where)
- ->whereIn('category.id', $catorytids)
- ->select('category.*', 'category.id as category_id')->get();
- if (empty($result)) {
- return Result::error("没有栏目数据");
- }
- return Result::success($result);
- }
- /**
- * @param array $data
- * @return array
- */
- public function categoryList(array $data): array
- {
- $where[] = [
- 'pid',
- '=',
- $data['pid'],
- ];
- if (isset($data['name'])) {
- array_push($where, ['category.name', 'like', '%' . $data['name'] . '%']);
- }
- var_dump($where);
- $result = Category::where($where)->select('category.*', 'category.id as category_id')->get();
- if (empty($result)) {
- return Result::error("没有栏目数据");
- }
- return Result::success($result);
- }
- /**
- * @param array $data
- * @return array
- */
- public function addCategory(array $data): array
- {
- if (isset($data['id'])) {
- unset($data['id']);
- }
- $id = Category::insertGetId($data);
- if (empty($id)) {
- return Result::error("添加失败");
- }
- return Result::success(['id' => $id]);
- }
- /**
- * @param array $data
- * @return array
- */
- public function delCategory(array $data): array
- {
- Db::beginTransaction();
- try {
- $categoryList = Category::where(['pid' => $data['id']])->get();
- if ($categoryList->toArray()) {
- Db::rollBack();
- return Result::error("分类下面有子分类不能删除");
- }
- $articleList = Article::where(['catid' => $data['id']])->get();
- if ($articleList->toArray()) {
- Db::rollBack();
- return Result::error("分类下面有资讯不能删除");
- }
- $result = Category::where($data)->delete();
- WebsiteCategory::where(['category_id' => $data['id']])->delete();
- if (!$result) {
- return Result::error("删除失败");
- }
- return Result::success($result);
- Db::commit();
- } catch (\Exception $e) {
- Db::rollBack();
- return Result::error("删除失败");
- }
- }
- /**
- * @param array $data
- * @return array
- */
- public function updateCategory(array $data): array
- {
- $where = [
- 'id' => $data['id'],
- ];
- $result = Category::where($where)->update($data);
- if ($result) {
- return Result::success($result);
- } else {
- return Result::error("更新失败");
- }
- }
- /**
- * 获取导航池信息
- * @param array $data
- * @return array
- */
- public function getCategoryInfo(array $data): array
- {
- $where = [
- 'id' => $data['id'],
- ];
- $result = Category::where($where)->first();
- if ($result) {
- return Result::success($result);
- } else {
- return Result::error("更新失败");
- }
- }
- /**
- * @param array $data
- * @return array
- */
- public function getArticleList(array $data): array
- {
- //判断是否是管理员'1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)'
- $type_id = $data['type_id'];
- unset($data['type_id']);
- $user_id = $data['user_id'];
- unset($data['user_id']);
- $where = [];
- $status1 = [];
- if (isset($data['id']) && $data['id']) {
- array_push($where, ['article.id', '=', $data['id']]);
- }
- if (isset($data['title']) && $data['title']) {
- array_push($where, ['article.title', 'like', '%' . $data['title'] . '%']);
- }
- if (isset($data['category_name']) && $data['category_name']) {
- array_push($where, ['category.name', 'like', '%' . $data['category_name'] . '%']);
- }
- if (isset($data['author']) && $data['author']) {
- array_push($where, ['article.author', '=', $data['author']]);
- }
- if (isset($data['islink']) && $data['islink'] !== "") {
- array_push($where, ['article.islink', '=', $data['islink']]);
- }
- if (isset($data['status']) && $data['status'] !== "") {
- array_push($where, ['article.status', '=', $data['status']]);
- }
- if (isset($data['status1'])) {
- $status1 = json_decode(($data['status1']));
- }
- //不是管理员展示个人数据;
- if ($type_id != 10000) {
- $where[] = ['article.admin_user_id', '=', $user_id];
- }
- $rep = Article::where($where)
- ->whereNotIn('article.status', [404])
- ->when($status1, function ($query) use ($status1) {
- if (isset($status1) && $status1) {
- $query->whereIn('article.status', $status1);
- }
- })
- ->leftJoin('category', 'article.catid', 'category.id')
- ->select("article.*", "category.name as category_name")
- ->orderBy("article.updated_at", "desc")
- ->limit($data['pageSize'])
- ->offset(($data['page'] - 1) * $data['pageSize'])->get();
- $count = Article::where($where)->whereNotIn('article.status', [404])
- ->when($status1, function ($query) use ($status1) {
- if (isset($status1) && $status1) {
- $query->whereIn('article.status', $status1);
- }
- })
- ->leftJoin('category', 'article.catid', 'category.id')->count();
- $data = [
- 'rows' => $rep->toArray(),
- 'count' => $count,
- ];
- if (empty($rep)) {
- return Result::error("没有信息数据");
- }
- return Result::success($data);
- }
- /**
- * @param array $data
- * @return array
- */
- public function addArticle(array $data): array
- {
- var_dump($data, '----------12-----------1');
- unset($data['user_type']);
- unset($data['nav_add_pool_id']);
- // $data['cat_arr_id'] = is_string($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
- Db::beginTransaction();
- try {
- //处理投票
- $is_survey = isset($data['is_survey']) ? $data['is_survey'] : 0;
- $survey_name = isset($data['survey_name']) ? $data['survey_name'] : '';
- $suvey_array = isset($data['suvey_array']) ? $data['suvey_array'] : '';
- $website_id = isset($data['website_id']) ? $data['website_id'] : 2;
- unset($data['is_survey']);
- unset($data['survey_name']);
- unset($data['suvey_array']);
- // unset($data['website_id']);
- // unset($data['web_site_id']);
- // $data['web_site_id'] = is_array($data['web_site_id']) ? json_encode($data['web_site_id']) : ($data['web_site_id']);
- if ($data['hits'] == '') {
- $data['hits'] = 0;
- }
- if ($data['is_original'] == '') {
- $data['is_original'] = 0;
- }
- if ($data['status'] == '') {
- $data['status'] = 0;
- }
- $articleData = $data;
- unset($articleData['content']);
- //自动处理缩略图、关键字、描述
- if ($articleData['imgurl'] == '') {
- //如果没有图,设置level=0
- $levelArr = json_decode($articleData['level'], true);
- var_dump($levelArr, '----------levelArr-----------1');
- //content中提取图片第一个图,正则提取
- $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
- preg_match_all($reg, $data['content'], $matches);
- if (isset($matches[1][0])) {
- //截取varchar240
- $articleData['imgurl'] = substr($matches[1][0], 0, 240);
- //如果有图,设置level=3
- if (!in_array(3, $levelArr)) {
- $levelArr[] = 3;
- }
- $articleData['level'] = json_encode($levelArr);
- } else {
- if (!in_array(0, $levelArr)) {
- $levelArr[] = 0;
- }
- $articleData['level'] = json_encode($levelArr);
- }
- }
- var_dump($articleData['level'], '----------$articleData[level]----------1');
- if ($articleData['keyword'] == '') {
- //提取标题+内容中的关键词
- $articleData['keyword'] = $data['title'];
- // . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
- Jieba::init(); // 初始化 jieba-php
- Finalseg::init();
- $segList = Jieba::cut($articleData['keyword']);
- $segList1 = array_slice($segList, 0, 8);
- $articleData['keyword'] = implode(',', $segList1);
- }
- if ($articleData['introduce'] == '') {
- //提取内容中的描述
- $articleData['introduce'] = substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
- }
- $id = Article::insertGetId($articleData);
- $articleDataContent = [
- 'article_id' => $id,
- 'content' => $data['content'],
- ];
- ArticleData::insertGetId($articleDataContent);
- //处理投票
- if ($is_survey == 1) {
- //生成年月日时分秒+8位随机数
- $uuid = date('YmdHis') . rand(10000000, 99999999);
- var_dump($suvey_array, 'suvey_array________');
- $suveys_array = is_array($suvey_array) ? $suvey_array : json_decode($suvey_array);
- var_dump($suveys_array, '---------------------1');
- var_dump($suvey_array, '---------------------2');
- $suvey_data = [];
- foreach ($suveys_array as $key => $value) {
- if ($value == '') {
- continue;
- }
- if (is_array($value)) {
- $suvey_data[] = [
- 'sur_id' => $uuid,
- 'art_id' => $id,
- 'website_id' => $website_id ?? 2,
- 'survey_name' => $survey_name,
- 'choice_name' => $value[1],
- 'is_other' => 1,
- 'other_id' => 0,
- 'results' => 0,
- ];
- } else {
- $suvey_data[] = [
- 'sur_id' => $uuid,
- 'art_id' => $id,
- 'website_id' => $website_id ?? 2,
- 'survey_name' => $survey_name,
- 'choice_name' => $value,
- 'is_other' => 0,
- 'other_id' => 0,
- 'results' => 0,
- ];
- }
- if (empty($suvey_data)) {
- throw new \Exception("投票数据为空");
- }
- }
- $result = ArticleSurvey::insert($suvey_data);
- if (!$result) {
- throw new \Exception("投票失败,ArticleSurvey插入失败");
- }
- $result = Article::where('id', $id)->update(['survey_id' => $uuid, 'survey_name' => $survey_name, 'is_survey' => $is_survey]);
- if (!$result) {
- throw new \Exception("投票失败,更新主表失败");
- }
- }
- Db::commit();
- return Result::success(['id' => $id]);
- } catch (\Throwable $ex) {
- Db::rollBack();
- var_dump($ex->getMessage());
- return Result::error("创建失败", 0);
- }
- }
- /**
- * @param array $data
- * @return array
- */
- public function delArticle(array $data): array
- {
- $result = Article::where($data)->delete();
- //survey投票删除
- articleSurvey::where(['art_id' => $data['id']])->delete();
- if (!$result) {
- return Result::error("删除失败");
- }
- return Result::success($result);
- }
- /**
- * @param array $data
- * @return array
- */
- public function updateArticle(array $data): array
- {
- var_dump($data, '----------12-----------1');
- Db::beginTransaction();
- unset($data['user_type']);
- // unset($data['web_site_id']);
- unset($data['nav_add_pool_id']);
- try {
- //处理投票
- $is_survey = isset($data['is_survey']) ? $data['is_survey'] : 0;
- $survey_name = isset($data['survey_name']) ? $data['survey_name'] : '';
- $suvey_array = isset($data['suvey_array']) ? $data['suvey_array'] : '';
- $website_id = isset($data['website_id']) ? $data['website_id'] : 2;
- unset($data['is_survey']);
- unset($data['survey_name']);
- unset($data['suvey_array']);
- unset($data['website_id']);
- $data['web_site_id'] = is_array($data['web_site_id']) ? json_encode($data['web_site_id']) : ($data['web_site_id']);
- if ($data['hits'] == '') {
- $data['hits'] = 0;
- }
- if ($data['is_original'] == '') {
- $data['is_original'] = 0;
- }
- if ($data['status'] == '') {
- $data['status'] = 0;
- }
- $data['cat_arr_id'] = is_array($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : $data['cat_arr_id'];
- $data['tag'] = isset($data['tag']) ? json_encode($data['tag']) : '';
- $articleData = $data;
- unset($articleData['content']);
- unset($articleData['status_name']);
- unset($articleData['name']);
- unset($articleData['content']);
- unset($articleData['pid_arr']);
- unset($articleData['pid']);
- //自动处理缩略图、关键字、描述
- if ($articleData['imgurl'] == '') {
- //如果没有图,设置level=0
- $levelArr = json_decode($articleData['level'], true);
- var_dump($levelArr, '----------levelArr-----------1');
- //content中提取图片第一个图,正则提取
- $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
- preg_match_all($reg, $data['content'], $matches);
- if (isset($matches[1][0])) {
- //截取varchar240
- // 截取到第一个<
- $articleData['imgurl'] = $matches[1][0];
- var_dump($articleData['imgurl'], '----------imgurl-----------1');
- $pos = strpos($articleData['imgurl'], '"');
- if ($pos !== false) {
- $articleData['imgurl'] = substr($articleData['imgurl'], 0, $pos);
- }
- //$articleData['imgurl'] = substr($matches[1][0], 0, 240);
- //如果有图,设置level=3
- if (!in_array(3, $levelArr)) {
- $levelArr[] = 3;
- }
- $articleData['level'] = json_encode($levelArr);
- } else {
- if (!in_array(0, $levelArr)) {
- $levelArr[] = 0;
- }
- $articleData['level'] = json_encode($levelArr);
- }
- }
- var_dump($articleData['level'], '----------$articleData[level]----------1');
- if ($articleData['keyword'] == '') {
- //提取标题+内容中的关键词
- $articleData['keyword'] = $data['title'];
- // . substr(str_replace(' ', '', strip_tags($data['content'])), 0, 20);
- Jieba::init(); // 初始化 jieba-php
- Finalseg::init();
- $segList = Jieba::cut($articleData['keyword']);
- $segList1 = array_slice($segList, 0, 8);
- $articleData['keyword'] = implode(',', $segList1);
- }
- if ($articleData['introduce'] == '') {
- //提取内容中的描述
- $articleData['introduce'] = substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
- }
- $id = Article::where(['id' => $data['id']])->update($articleData);
- $articleDataContent = [
- 'content' => $data['content'],
- ];
- ArticleData::where(['article_id' => $data['id']])->update($articleDataContent);
- //处理投票
- $id = $data['id'];
- $surveydata = ArticleSurvey::where(['art_id' => $data['id']])->delete();
- var_dump($suvey_array, 'suvey_array________delete');
- //处理投票
- if ($is_survey == 1) {
- //生成年月日时分秒+8位随机数
- $uuid = date('YmdHis') . rand(10000000, 99999999);
- $suveys_array = is_array($suvey_array) ? $suvey_array : json_decode($suvey_array);
- var_dump($suveys_array, '---------------------1');
- $suvey_data = [];
- if (is_array($suveys_array)) {
- foreach ($suveys_array as $key => $value) {
- if ($value == '') {
- continue;
- }
- if (is_array($value)) {
- $suvey_data[] = [
- 'sur_id' => $uuid,
- 'art_id' => $id,
- 'website_id' => $website_id ?? 2,
- 'survey_name' => $survey_name,
- 'choice_name' => $value[1],
- 'is_other' => 1,
- 'other_id' => 0,
- 'results' => 0,
- ];
- } else {
- $suvey_data[] = [
- 'sur_id' => $uuid,
- 'art_id' => $id,
- 'website_id' => $website_id ?? 2,
- 'survey_name' => $survey_name,
- 'choice_name' => $value,
- 'is_other' => 0,
- 'other_id' => 0,
- 'results' => 0,
- ];
- }
- if (empty($suvey_data)) {
- throw new \Exception("投票数据为空");
- }
- }
- }
- $result = ArticleSurvey::insert($suvey_data);
- if (!$result) {
- throw new \Exception("投票失败");
- }
- $result = Article::where('id', $id)->update(['survey_id' => $uuid, 'survey_name' => $survey_name, 'is_survey' => $is_survey]);
- if (!$result) {
- throw new \Exception("投票失败");
- }
- } else {
- $result = Article::where('id', $id)->update(['survey_id' => '', 'survey_name' => '', 'is_survey' => 0]);
- }
- Db::commit();
- return Result::success([]);
- } catch (\Throwable $ex) {
- Db::rollBack();
- var_dump($ex->getMessage());
- return Result::error("更新失败" . $ex->getMessage(), 0);
- }
- }
- /**
- * 更新资讯状态
- * @param array $data
- * @return array
- */
- public function upArticleStatus(array $data): array
- {
- $result = Article::where(['id' => $data['id']])->update($data);
- if ($result) {
- return Result::success();
- } else {
- return Result::error("更新状态失败", 0);
- }
- }
- /**
- * @param array $data
- * @return array
- */
- public function getArticleInfo(array $data): array
- {
- $where = [
- 'article.id' => $data['id'],
- // 'article.status' => 1,
- ];
- $result = Article::where($where)->leftJoin("article_data", "article.id", "article_data.article_id")->first();
- $articleSurvey = ArticleSurvey::where(['art_id' => $data['id']])->get();
- $info = $result;
- // var_dump($info, 'info');
- $info['survey_array'] = $articleSurvey;
- if ($result) {
- return Result::success($info);
- } else {
- return Result::error("查询失败", 0);
- }
- }
- /**
- * 获取新闻
- * @param array $data
- * @return array
- */
- public function getWebsiteArticlett(array $data): array
- {
- $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
- $result = [];
- if ($category) {
- $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
- $where = [
- 'status' => 1,
- ];
- var_dump($data, 'data-----------------');
- // level=7 根据文章key来匹配文章
- if (isset($data['level']) && $data['level'] == 7) {
- // 根据文章id获取key
- // $data['id'] = 50142;
- if (isset($data['id']) && !empty($data['id'])) {
- $keyword = Article::where('id', $data['id'])->value('keyword');
- $keywordArray = explode(',', $keyword);
- $whereL7 = [];
- foreach ($keywordArray as $k => $v) {
- $whereL7[] = ['keyword', 'like', '%' . $v . '%'];
- }
- $result = Article::where($whereL7)
- ->offset($placeid)
- ->limit($data['pageSize'])
- ->orderBy('updated_at', 'desc')
- ->get();
- if (empty($result)) {
- return Result::success([]);
- }
- return Result::success($result);
- } else {
- return Result::error("参数错误level=7,id不能为空", 0);
- }
- }
- //如果是4:最新资讯(数据库已不存在) 5:资讯推荐(数据库已不存在);
- // 1:头条资讯;2:轮播图;6:热点资讯;(数据库)
- var_dump($where, 'where-----------------');
- $result = Article::where($where)
- ->whereIn("catid", $category)
- ->where(function ($query) use ($data) {
- $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
- ->orWhereNull("ignore_ids");
- })
- //$data['level'] == 4 || $data['level'] == 5 查询随机
- ->when($data['level'] == 5, function ($query) {
- $query->inRandomOrder()
- //updated_at最近三十天;
- ->where('updated_at', '>', date("Y-m-d H:i:s", strtotime("-30 day")));
- })
- ->when($data['level'] == 4, function ($query) {
- $query->orderBy("updated_at", "desc");
- })
- ->when(!empty($data['level']), function ($query) use ($data) {
- if ($data['level'] != 4 && $data['level'] != 5) {
- $query->whereRaw("JSON_CONTAINS(level, '" . intval($data['level']) . "') = 1")
- ->orderBy("updated_at", "desc");
- }
- })
- ->offset($placeid)
- ->limit($data['pageSize'])
- ->get();
- if (empty($result)) {
- return Result::error("暂无头条新闻", 0);
- }
- return Result::success($result);
- } else {
- return Result::error("本网站下暂无相关栏目", 0);
- }
- }
- /**
- * 获取模块新闻
- * @param array $data
- * @return array
- */
- public function getWebsiteModelArticles(array $data): array
- {
- $catid = $data['catid'];
- $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $catid)->select('category_id')->get();
- $category = $category->toArray();
- if (!empty($category)) {
- $where = [
- 'status' => 1,
- 'catid' => $catid,
- ];
- $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
- // 1:文字新闻;2:轮播图;3:图文;
- // 级别:0:未分类
- // 3:推荐图片
- if ($data['level'] == 1) {
- $data['level'] = 0;
- }
- $result = Article::where($where)
- ->where(function ($query) use ($data) {
- $query->whereRaw("JSON_CONTAINS(level, '" . intval($data['level']) . "') = 1")
- ->orWhereNull("level")
- ->orWhereRaw("level = '[]'");
- })
- ->where(function ($query) use ($data) {
- $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
- ->orWhereNull("ignore_ids");
- })
- ->orderBy("updated_at", "desc")
- ->offset($placeid)
- ->limit($data['pagesize'])
- ->get();
- if (empty($result)) {
- return Result::error("此栏目暂无相关新闻", 0);
- }
- } else {
- return Result::error("此网站暂无此栏目", 0);
- }
- return Result::success($result);
- }
- /**
- *获取新闻列表
- * @param array $data
- * @return array
- */
- public function getWebsiteArticleList(array $data): array
- {
- $where[] = ['status', '=', 1];
- if (isset($data['keyword']) && !empty($data['keyword'])) {
- array_push($where, ['article.title', 'like', '%' . $data['keyword'] . '%']);
- }
- if (isset($data['catid']) && !empty($data['catid'])) {
- if (is_array($data['catid'])) {
- $category = WebsiteCategory::where('website_id', $data['website_id'])->whereIn('category_id', $data['catid'])->pluck('category_id');
- array_push($where, ['catid', 'in', $data['catid']]);
- } else {
- $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['catid'])->pluck('category_id');
- array_push($where, ['catid', '=', $data['catid']]);
- }
- if (empty($category)) {
- return Result::error("此网站暂无此栏目", 0);
- }
- }
- // return Result::success($where);
- $rep = Article::where(function ($query) use ($where) {
- foreach ($where as $condition) {
- if ($condition[1] === 'in') {
- $query->whereIn($condition[0], $condition[2]);
- } else {
- $query->where($condition[0], $condition[1], $condition[2]);
- }
- }
- })
- ->where(function ($query) use ($data) {
- $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
- ->orWhereNull("ignore_ids");
- })
- ->orderBy("updated_at", "desc")
- ->limit($data['pageSize'])
- ->offset(($data['page'] - 1) * $data['pageSize'])
- ->get();
- $count = Article::where(function ($query) use ($where) {
- foreach ($where as $condition) {
- if ($condition[1] === 'in') {
- $query->whereIn($condition[0], $condition[2]);
- } else {
- $query->where($condition[0], $condition[1], $condition[2]);
- }
- }
- })->count();
- $data = [
- 'rows' => $rep->toArray(),
- 'count' => $count,
- ];
- if (empty($rep)) {
- return Result::error("没有信息数据");
- }
- return Result::success($data);
- }
- /**
- * 前端-获取新闻详情
- * @param array $data
- * @return array
- */
- public function selectWebsiteArticleInfo(array $data): array
- {
- $where = [
- 'article.id' => $data['id'],
- 'article.status' => 1,
- ];
- $result = Article::where($where)->leftJoin("article_data", "article.id", "article_data.article_id")
- ->where(function ($query) use ($data) {
- $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
- ->orWhereNull("ignore_ids");
- })
- ->first();
- if (empty($result)) {
- return Result::error("暂无此新闻!", 0);
- }
- $category = WebsiteCategory::leftJoin('website', 'website.id', '=', 'website_category.website_id')
- ->select('website_category.*', 'website.website_name', 'website.suffix')
- ->where('website_category.website_id', $data['website_id'])
- ->where(['website_category.category_id' => $result['catid']])
- ->first();
- if (empty($category)) {
- return Result::error("查询失败", 0);
- }
- //手动推荐文章
- $commend_ids = $result['commend_id'] ? json_decode($result['commend_id']) : [];
- $commendArticle = Article::whereIn('id', $commend_ids)
- ->where('status', 1)
- ->select('id', 'title', 'catid', 'imgurl', 'hits', 'created_at')
- ->orderBy('updated_at', 'desc')
- ->limit(5)
- ->get();
- $result['category_id'] = $category['category_id'];
- $result['cat_name'] = $category['alias'];
- $result['website_name'] = $category['website_name'] ?? "";
- $result['suffix'] = $category['suffix'] ?? "";
- $result['commendArticle'] = $commendArticle;
- return Result::success($result);
- }
- /**
- * 前端-获取网站调查问卷
- * @param array $data
- * @return array
- */
- public function getWebsiteSurvey(array $data): array
- {
- if (isset($data['website_id']) && !empty($data['website_id'])) {
- $website = Website::where('id', $data['website_id'])->first();
- if (empty($website)) {
- return Result::error("暂无此网站", 0);
- }
- }
- if (isset($data['art_id']) && !empty($data['art_id'])) {
- $article = Article::where('id', $data['art_id'])->where('status', 1)->first();
- if (empty($article)) {
- return Result::error("暂无此文章", 0);
- }
- // return Result::error($data,0);
- $where['art_id'] = $data['art_id'];
- // $query = ArticleSurvey::where('art_id',$data['art_id']);
- } else {
- $survey = Article::where(function ($query) {
- $query->whereRaw("JSON_CONTAINS(cat_arr_id, '28')")
- ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '\"28\"')");
- })
- ->where('status', 1)
- ->where('is_survey', 1)
- ->select('survey_id')
- ->orderBy('updated_at', 'desc')
- ->first();
- if (empty($survey)) {
- return Result::error("暂无调查问卷", 0);
- }
- $where['sur_id'] = $survey['survey_id'];
- // $query = ArticleSurvey::where('sur_id',$survey['sur_id']);
- }
- // return Result::success($where);
- $result = ArticleSurvey::where($where)
- ->where(function ($query) {
- $query->where('is_other', 0)
- ->orWhere(function ($subQuery) {
- $subQuery->where('is_other', 1)
- ->where('other_id', 0);
- });
- })
- ->leftJoin('article', 'article_survey.art_id', 'article.id')
- ->select('article_survey.*', 'article.survey_type')
- ->get()->all();
- if (empty($result)) {
- return Result::error("此文章暂无调查问卷", 0);
- }
- return Result::success($result);
- }
- /**
- * 前端-添加网站调查问卷选项
- * @param array $data
- * @return array
- */
- public function addWebsiteSurveyOption(array $data): array
- {
- if (isset($data['website_id']) && !empty($data['website_id'])) {
- $website = Website::where('id', $data['website_id'])->first();
- if (empty($website)) {
- return Result::error("暂无此网站", 0);
- }
- if (isset($data['sur_id']) && !empty($data['sur_id'])) {
- $survey = ArticleSurvey::where('sur_id', $data['sur_id'])->where('website_id', $data['website_id'])->where('is_other', 1)->where('other_id', 0)->first();
- if (empty($survey)) {
- return Result::error("此调查问卷不可添加选项", 0);
- }
- if (isset($data['choice_name']) && !empty($data['choice_name'])) {
- $choice = [
- 'art_id' => $survey['art_id'],
- 'website_id' => $data['website_id'],
- 'survey_name' => $survey['survey_name'],
- 'choice_name' => $data['choice_name'],
- 'sur_id' => $survey['sur_id'],
- 'is_other' => 1,
- 'other_id' => $survey['id'],
- ];
- $result = ArticleSurvey::insertGetId($choice);
- if (empty($result)) {
- return Result::error("添加失败", 0);
- }
- return Result::success($result);
- }
- }
- return Result::error("添加失败", 0);
- }
- return Result::error("添加失败", 0);
- }
- /**
- * 前端-调查问卷投票
- * @param array $data
- * @return array
- */
- public function addWebsiteSurveyVote(array $data): array
- {
- // return Result::success($data);
- if (isset($data['website_id']) && !empty($data['website_id'])) {
- $website = Website::where('id', $data['website_id'])->first();
- if (empty($website)) {
- return Result::error("暂无此网站", 0);
- }
- if (isset($data['sur_id']) && !empty($data['sur_id'])) {
- $is_survey = ArticleSurvey::where('sur_id', $data['sur_id'])->first();
- // return Result::success($survey);
- if (empty($is_survey)) {
- return Result::error("此调查问卷不存在", 0);
- }
- // return Result::success($survey);
- // 调查问卷类型
- if (isset($data['choice_id']) && !empty($data['choice_id'])) {
- //多选 若是json型则转化成数组类型
- if (strpos($data['choice_id'], '[') === 0) {
- $data['choice_id'] = json_decode($data['choice_id'], true);
- } else {
- // 单选 也转换成数组
- $data['choice_id'] = [$data['choice_id']];
- }
- $data['choice_id'] = array_map('intval', $data['choice_id']);
- $other = ArticleSurvey::whereIn('id', $data['choice_id'])
- ->where('website_id', $data['website_id'])
- ->where('is_other', 1)
- ->where('other_id', 0)
- ->first();
- if (!empty($other)) {
- return Result::error("请选择已有的选项!", 0);
- }
- $choice['other'] = ArticleSurvey::whereIn('id', $data['choice_id'])
- ->where('website_id', $data['website_id'])
- ->where('is_other', 1)
- ->where('other_id', '!=', 0)
- ->first();
- // return Result::success($choice['other']);
- $choice_id = $data['choice_id'];
- if (!empty($choice['other'])) {
- // array_push($data['choice_id'],$choice['other']['other_id']);
- if (!empty($choice_id)) {
- $key = array_search($choice['other']['id'], $choice_id);
- if ($key !== false) {
- unset($choice_id[$key]);
- $choice_id = array_values($choice_id);
- }
- array_push($choice_id, $choice['other']['other_id']);
- } else {
- $choice_id[0] = $choice['other']['other_id'];
- }
- array_push($data['choice_id'], $choice['other']['other_id']);
- }
- // return Result::success($data);
- $choice = ArticleSurvey::whereIn('id', $data['choice_id'])
- ->where('website_id', $data['website_id'])
- ->increment('results', 1);
- if (empty($choice)) {
- return Result::error("请选择已有的选项!", 0);
- }
- $survey['data'] = ArticleSurvey::where('sur_id', $data['sur_id'])
- ->where('website_id', $data['website_id'])
- ->where('other_id', 0)
- ->get();
- $survey['choice'] = $choice_id;
- return Result::success($survey);
- }
- return Result::error("参数必填!");
- }
- return Result::error("此调查问卷不存在", 0);
- }
- return Result::error("参数必填!");
- }
- /**
- * 后端-获取网站调查问卷列表
- * @param array $data
- * @return array
- */
- public function getSurveyList(array $data): array
- {
- $where = [];
- if (isset($data['survey_name']) && !empty($data['survey_name'])) {
- array_push($where, ['survey_name', 'like', '%' . $data['survey_name'] . '%']);
- }
- if (isset($data['survey_type']) && $data['survey_type'] != null) {
- array_push($where, ['survey_type', '=', $data['survey_type']]);
- }
- if (isset($data['is_survey']) && $data['is_survey'] != null) {
- array_push($where, ['is_survey', '=', $data['is_survey']]);
- }
- // return Result::success($where);
- if (!empty($where)) {
- $query = Article::where($where)->where(function ($q) {
- $q->whereNotNull('survey_name')->where('survey_name', '!=', '');
- });
- } else {
- $query = Article::where(function ($q) {
- $q->whereNotNull('survey_name')->where('survey_name', '!=', '');
- });
- }
- $count = $query->count();
- $survey = $query->orderByDesc('id')
- ->limit($data['pageSize'])
- ->offset(($data['page'] - 1) * $data['pageSize'])
- ->get();
- if (empty($survey->toArray())) {
- return Result::error("暂无调查问卷!", 0);
- }
- $result = [
- 'rows' => $survey,
- 'count' => $count,
- ];
- return Result::success($result);
- }
- /**
- * 后端-获取网站调查问卷详情
- * @param array $data
- * @return array
- */
- public function getSurveyInfo(array $data): array
- {
- if (isset($data['sur_id']) && !empty($data['sur_id'])) {
- $where = ['sur_id' => $data['sur_id']];
- $choose = ArticleSurvey::where($where)->where('is_other', 0)
- ->leftJoin('article', 'article_survey.art_id', 'article.id')
- ->select('article_survey.*', 'article.survey_type')
- ->get()->all();
- if (empty($choose)) {
- return Result::error("此调查问卷不存在", 0);
- }
- $resultsArray = array_column($choose, 'results');
- $total = array_sum($resultsArray);
- $other = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', 0)->first();
- $others = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', '!=', 0)->orderByDesc('created_at')->get()->all();
- // $total = 0;
- if (!empty($other)) {
- $total = $total + $other['results'];
- $other['choice_name'] = '(其他)';
- if (!empty($others)) {
- $other['hasChildren'] = true;
- // array_push($other,['hasChildren','=',true]);
- $other['children'] = $others;
- $other_choices = [$other->toArray()];
- $mer_choice = array_merge($choose, $other_choices);
- $value_choice = array_values($mer_choice);
- } else {
- // return Result::error('1111');
- $other_choices = [$other->toArray()];
- $other_choices = array_merge($choose, $other_choices);
- $value_choice = array_values($other_choices);
- // return Result::success($result);
- }
- } else {
- $value_choice = $choose;
- }
- $result = [
- 'choose' => $value_choice,
- 'total' => $total,
- ];
- }
- return Result::success($result);
- }
- /**
- * 前端-搜索新闻列表
- * @param array $data
- * @return array
- */
- public function selectWebsiteArticle(array $data): array
- {
- $where = [];
- // 初始化查询构造器
- $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
- $query = Article::where('status', 1)
- ->whereIn('catid', $category)
- ->where(function ($query) use ($data) {
- $query->where(function ($subQuery) use ($data) {
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0");
- })->orWhereNull("ignore_ids");
- });
- // return Result::success($all_articles);
- // 检查是否存在 cityid 参数
- if (isset($data['cityid']) && !empty($data['cityid'])) {
- $query->whereRaw("JSON_CONTAINS(city_arr_id, '" . intval($data['cityid']) . "')");
- }
- // 检查是否存在 department_id 参数
- if (isset($data['department_id']) && !empty($data['department_id'])) {
- $query->whereRaw("JSON_CONTAINS(department_arr_id, '" . intval($data['department_id']) . "')");
- }
- // 检查是否存在 keyword 参数
- if (isset($data['keyword']) && !empty($data['keyword'])) {
- $query->where('title', 'like', '%' . $data['keyword'] . '%');
- }
- // 计算总数
- $count = $query->count();
- // 分页查询
- $articles = $query->orderBy("updated_at", "desc")
- ->limit($data['pageSize'])
- ->offset(($data['page'] - 1) * $data['pageSize'])
- ->get()->all();
- if (empty($articles)) {
- return Result::error("没有符合条件的资讯数据");
- }
- $data = [
- 'rows' => $articles,
- 'count' => $count,
- ];
- return Result::success($data);
- }
- /**
- * 模块新闻加强版
- * @param array $data
- * @return array
- */
- public function getWebsiteCatidArticle(array $data): array
- {
- // return Result::success($data);
- $where = [
- // 'category.status' => 1,
- 'website_category.category_id' => $data['catid'],
- 'website_category.website_id' => $data['website_id'],
- // 'article.status' => 1,
- ];
- // $category = WebsiteCategory::where($where);
- if (isset($data['child_catnum']) && !empty($data['child_catnum'])) {
- $child_catnum = $data['child_catnum'] ?? 1;
- $category['child'] = WebsiteCategory::where('pid', $data['catid'])->where('website_id', $data['website_id'])->select('category_id', 'alias')->limit($child_catnum)->get()->toArray();
- $childCategoryIds = array_column($category['child'], 'category_id');
- if (empty($childCategoryIds)) {
- return Result::error("暂无子栏目", 0);
- }
- $imgArticles = [];
- $textArticles = [];
- // return Result::success($childCategoryIds);
- if (isset($data['child_imgnum']) && !empty($data['child_imgnum']) && $data['child_imgnum'] != 0) {
- // 初始化子分类图片新闻和文字新闻数组
- // 查询所有子级栏目的图文新闻
- $imgArticles = Article::where('catid', $childCategoryIds[0])
- ->where(function ($query) use ($data) {
- $query->where(function ($subQuery) use ($data) {
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0");
- })->orWhereNull("ignore_ids");
- })
- ->where('status', 1)
- ->where('imgurl', '!=', '')
- ->select('*')
- ->orderBy('updated_at', 'desc')
- ->limit($data['child_imgnum'])
- ->get();
- }
- if (isset($data['child_textnum']) && !empty($data['child_textnum']) && $data['child_textnum'] != 0) {
- // 查询所有子级栏目的文字新闻
- $textArticles = Article::where('catid', $childCategoryIds[0])
- ->where('status', 1)
- ->where(function ($query) use ($data) {
- $query->where(function ($subQuery) use ($data) {
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0");
- })->orWhereNull("ignore_ids");
- })
- // ->where(function ($query) {
- // $query->whereNull('imgurl')
- // ->orWhere('imgurl', '');
- // })
- ->select('*')
- ->orderBy('updated_at', 'desc')
- ->limit($data['child_textnum'])
- ->get();
- }
- // 遍历子分类,将图文新闻和文字新闻分别添加到子分类中
- $category['child'] = array_map(function ($child) use ($imgArticles, $textArticles) {
- $child['img'] = $imgArticles ? $imgArticles->where('catid', $child['category_id']) : [];
- $child['text'] = $textArticles ? $textArticles->where('catid', $child['category_id']) : [];
- return $child;
- }, $category['child']);
- }
- // }
- if (isset($data['img_num']) && !empty($data['img_num'])) {
- $category['img'] = WebsiteCategory::where($where)
- ->leftJoin('article', 'article.catid', 'website_category.category_id')
- ->where('article.status', 1)
- ->where('article.imgurl', '!=', '')
- ->select('article.*', 'website_category.category_id', 'website_category.alias')
- ->orderBy('article.updated_at', 'desc')
- ->limit($data['img_num'])
- ->get();
- }
- if (isset($data['text_num']) && !empty($data['text_num'])) {
- $category['text'] = WebsiteCategory::where($where)
- ->leftJoin('article', 'article.catid', 'website_category.category_id')
- ->where('article.status', 1)
- // ->where(function ($query) {
- // $query->whereNull('article.imgurl')
- // ->orWhere('article.imgurl', '');
- // })
- ->select('article.*', 'website_category.category_id', 'website_category.alias')
- ->orderBy('article.updated_at', 'desc')
- ->limit($data['text_num'])
- ->get();
- }
- // $category = $category->get();
- if (empty($category)) {
- return Result::error("查询失败", 0);
- }
- return Result::success($category);
- }
- /**
- * 模块新闻加强plus版
- * @param array $data
- * @return array
- */
- public function getWebsiteAllArticle(array $data): array
- {
- // 修正传入的字符串,将单引号替换为双引号
- $input['id'] = $data['id'];
- $input['website_id'] = $data['website_id'];
- // 将 JSON 字符串转换为 PHP 数组
- $data = json_decode($input['id'], true);
- // 使用 array_map 处理每个元素
- $result = array_map(function ($item) use ($input) {
- list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);
- $website = [
- 'website_id' => $input['website_id'],
- ];
- // 查询栏目名称
- $category = WebsiteCategory::where('category_id', $parentCatId)->where($website)->first(['alias', 'category_id', 'aLIas_pinyin']);
- if (empty($category)) {
- $imgArticles = [];
- $textArticles = [];
- // return Result::error("暂无此栏目",0);
- } else {
- // 查询图片新闻
- $imgArticles = Article::where('catid', $parentCatId)
- ->where('status', 1)
- ->where(function ($query) use ($website) {
- $query->where(function ($subQuery) use ($website) {
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0");
- })->orWhereNull("ignore_ids");
- })
- ->where('imgurl', '!=', '')
- ->orderBy('updated_at', 'desc')
- ->limit($parentImgNum)
- ->get()->all();
- // 查询文字新闻
- $textArticles = Article::where('catid', $parentCatId)
- ->where('status', 1)
- ->where(function ($query) use ($website) {
- $query->where(function ($subQuery) use ($website) {
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0");
- })->orWhereNull("ignore_ids");
- })
- ->orderBy('updated_at', 'desc')
- ->limit($parentTextNum)
- ->get()->all();
- }
- $resultItem = [
- 'alias' => $category ? $category->alias : null,
- 'category_id' => $parentCatId,
- 'pinyin' => $category->aLIas_pinyin ?? '',
- 'imgnum' => $imgArticles,
- 'textnum' => $textArticles,
- ];
- if (!empty($item['child']) && $item['child'] != "") {
- // 查询第一个pid等于parent中第一个参数的category来获取child的category_id
- $childCategory = WebsiteCategory::where('pid', $parentCatId)->where($website)->select('category_id', 'alias', 'aLIas_pinyin')->get()->all();
- if ($childCategory) {
- list($childCatId, $childImgNum, $childTextNum) = explode(',', $item['child']);
- // 查询子栏目名称
- $childCategoryInfo = WebsiteCategory::where('category_id', $childCatId)->where($website)->first(['alias', 'category_id', 'aLIas_pinyin']);
- // $childAllCartegory = WebsiteCategory::where('pid', $childCatId)->where($website)->first(['category_id']);
- if (empty($childCategoryInfo)) {
- $childImgArticles = [];
- $childTextArticles = [];
- } else {
- // 查询子栏目图片新闻
- $childImgArticles = Article::where('catid', $childCatId)
- ->where('status', 1)
- ->where(function ($query) use ($website) {
- $query->where(function ($subQuery) use ($website) {
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0");
- })->orWhereNull("ignore_ids");
- })
- ->where('imgurl', '!=', '')
- ->orderBy('updated_at', 'desc')
- ->limit($childImgNum)
- ->get()->all();
- // 查询子栏目文字新闻
- $childTextArticles = Article::where('catid', $childCatId)
- ->where('status', 1)
- ->where(function ($query) use ($website) {
- $query->where(function ($subQuery) use ($website) {
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0");
- })->orWhereNull("ignore_ids");
- })
- ->orderBy('updated_at', 'desc')
- ->limit($childTextNum)
- ->get()->all();
- }
- $resultItem['child'] = [
- 'alias' => $childCategoryInfo ? $childCategoryInfo->alias : null,
- 'category_id' => $childCatId,
- 'pinyin' => $childCategoryInfo->aLIas_pinyin ?? '',
- 'all_childcat' => $childCategory,
- 'imgnum' => $childImgArticles,
- 'textnum' => $childTextArticles,
- ];
- // $resultItem['pinyin'] = $childCategoryInfo->aLIas_pinyin ?? '';
- }
- }
- return $resultItem;
- }, $data);
- return Result::success($result);
- // return Result::success($data);
- }
- /**
- * 乡村网-获取特殊新闻模块
- * @param array $data
- * @return array
- */
- public function getWebsiteArticles(array $data): array
- {
- // 修正传入的字符串,将单引号替换为双引号
- $input['id'] = $data['id'];
- $input['website_id'] = $data['website_id'];
- // 将 JSON 字符串转换为 PHP 数组
- $data = json_decode($input['id'], true);
- // 使用 array_map 处理每个元素
- $result = array_map(function ($item) use ($input) {
- list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);
- $website = [
- 'website_id' => $input['website_id'],
- ];
- // 查询栏目名称
- $category = WebsiteCategory::where('category_id', $parentCatId)->where($website)->first(['alias', 'category_id', 'aLIas_pinyin']);
- if (empty($category)) {
- $imgArticles = [];
- $textArticles = [];
- // return Result::error("暂无此栏目",0);
- } else {
- // 查询图片新闻
- $imgArticles = Article::where('status', 1)
- ->where(function ($query) use ($website) {
- $query->where(function ($subQuery) use ($website) {
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0");
- })->orWhereNull("ignore_ids");
- })
- ->where('imgurl', '!=', '')
- ->whereRaw("JSON_CONTAINS(category_arr_id, '" . intval($parentCatId) . "')")
- ->leftJoin('website_category', 'website_category.category_id', 'article.catid')
- ->select('article.*', 'website_category.category_id', 'website_category.alias', 'website_category.aLIas_pinyin')
- ->orderBy('updated_at', 'desc')
- ->limit($parentImgNum)
- ->get()->all();
- // 查询文字新闻
- $textArticles = Article::where('status', 1)
- ->where(function ($query) use ($website) {
- $query->where(function ($subQuery) use ($website) {
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0");
- })->orWhereNull("ignore_ids");
- })
- ->whereRaw("JSON_CONTAINS(category_arr_id, '" . intval($parentCatId) . "')")
- ->leftJoin('website_category', 'website_category.category_id', 'article.catid')
- ->select('article.*', 'website_category.category_id', 'website_category.alias', 'website_category.aLIas_pinyin')
- ->orderBy('updated_at', 'desc')
- ->limit($parentTextNum)
- ->get()->all();
- }
- $resultItem = [
- 'alias' => $category ? $category->alias : null,
- 'category_id' => $parentCatId,
- 'pinyin' => $category->aLIas_pinyin ?? '',
- 'imgnum' => $imgArticles,
- 'textnum' => $textArticles,
- ];
- return $resultItem;
- }, $data);
- return Result::success($result);
- }
- /**
- * 验证导航名称是否重复
- * @return void
- */
- public function checkCategoryName(array $data): array
- {
- $result = Category::when($data, function ($query) use ($data) {
- if (isset($data['name']) && $data['name']) {
- $query->where("name", $data['name']);
- }
- if (isset($data['id']) && $data['id']) {
- $query->where("id", "!=", $data['id']);
- }
- })->first();
- if ($result) {
- return Result::error("已存在");
- } else {
- return Result::success();
- }
- }
- //20250226 产品列表
- public function getGoodList(array $data): array
- {
- $type_id = isset($data['type_id']) ? $data['type_id'] : '';
- unset($data['type_id']);
- $user_id = isset($data['user_id']) ? $data['user_id'] : '';
- $where = [];
- if ($type_id != '10000') {
- $where = [
- 'good.user_id' => $user_id,
- ];
- }
- //类型
- if (isset($data['type_id']) && $data['type_id']) {
- $where = [
- 'type_id' => $data['type_id'],
- ];
- }
- //名称
- if (isset($data['name']) && $data['name']) {
- $where = [
- 'good.name' => $data['name'],
- ];
- }
- $where1 = [];
- //website_id
- // if (isset($data['website_id']) && $data['website_id']) {
- // $where1 = [
- // 'good.website_id', 'like', '%' . $data['website_id'] . '%',
- // ];
- // }
- // website_name
- if (isset($data['website_name']) && $data['website_name']) {
- $where1[] = ['website.website_name', 'like', '%' . $data['website_name'] . '%'];
- }
- // catid
- if (isset($data['category_name']) && $data['category_name']) {
- $where1[] = ['category.name', 'like', '%' . $data['category_name'] . '%'];
- }
- // $result = Good::where($where)
- // ->orderBy("updated_at", "desc")->paginate($data['pige_size'], ['*'], 'page', $data['page']);
- $result = Good::where($where)
- ->when(!empty($where1), function ($query) use ($where1) {
- return $query->where($where1);
- })
- ->leftJoin('district', 'good.city_id', '=', 'district.id')
- ->leftJoin('website', 'good.website_id', '=', 'website.id')
- ->leftJoin('category', 'good.catid', '=', 'category.id')
- ->select('good.*', 'district.name as cityname', 'website.website_name as website_name', 'category.name as category_name')
- ->orderBy("id", "desc")
- ->limit($data['page_size'])
- ->offset(($data['page'] - 1) * $data['page_size'])
- ->get();
- $count = Good::where($where)
- ->leftJoin('district', 'good.city_id', '=', 'district.id')
- ->leftJoin('website', 'good.website_id', '=', 'website.id')
- ->leftJoin('category', 'good.catid', '=', 'category.id')
- ->select('good.*', 'district.name as cityname', 'website.website_name as website_name', 'category.name as category_name')
- ->orderBy("updated_at", "desc")->count();
- $data = [
- 'rows' => $result->toArray(),
- 'count' => $count,
- ];
- if (empty($result)) {
- return Result::error("此栏目暂无相关产品", 0);
- }
- return Result::success($data);
- }
- public function getGoodInfo(array $data): array
- {
- $result = Good::where('id', $data['id'])->first();
- if (empty($result)) {
- return Result::error("此产品不存在", 0);
- }
- return Result::success($result);
- }
- public function addGood(array $data): array
- {
- // unset($data['city_arr_id']);
- // unset($data['cat_arr_id']);
- $data['city_id'] = end($data['city_arr_id']);
- $data['catid'] = end($data['cat_arr_id']);
- $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode($data['city_arr_id']) : '';
- $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
- $data['imgurl'] = isset($data['imgurl']) ? json_encode($data['imgurl']) : '';
- unset($data['imgUrl']);
- $result = Good::insert($data);
- if (empty($result)) {
- return Result::error("添加失败", 0);
- }
- return Result::success($result);
- }
- public function updateGood(array $data): array
- {
- $data['city_id'] = end($data['city_arr_id']);
- $data['catid'] = end($data['cat_arr_id']);
- $data['city_arr_id'] = isset($data['city_arr_id']) ? json_encode($data['city_arr_id']) : '';
- $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
- $data['imgurl'] = isset($data['imgurl']) ? json_encode($data['imgurl']) : '';
- //设置东八区
- date_default_timezone_set('Asia/Shanghai');
- $data['updated_at'] = date('Y-m-d H:i:s');
- $result = Good::where('id', $data['id'])->update($data);
- if (empty($result)) {
- return Result::error("更新失败", 0);
- }
- return Result::success($result);
- }
- public function delGood(array $data): array
- {
- $result = Good::where('id', $data['id'])->delete();
- if (empty($result)) {
- return Result::error("删除失败", 0);
- }
- return Result::success($result);
- }
- //20250226 产品列表
- //20250306 求职信息
- public function getJobHuntingList(array $data): array
- {
- $where = [];
- if (isset($data['username']) && !empty($data['username'])) {
- $where[] = ['user.user_name', 'like', '%' . $data['username'] . '%'];
- }
- $type_id = isset($data['type_id']) ? $data['type_id'] : '';
- $user_id = isset($data['user_id']) ? $data['user_id'] : '';
- unset($data['type_id']);
- if ($type_id != '10000') {
- $where[] = ['job_hunting.user_id', '=', $user_id];
- }
- $result = JobHunting::where($where)
- ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
- ->leftJoin('website', 'website.id', '=', 'job_hunting.website_id')
- ->select('job_hunting.*', 'user.nickname as nickname', 'user.user_name as username', 'website.website_name as website_name')
- ->orderBy("id", "desc")
- ->limit($data['page_size'])
- ->offset(($data['page'] - 1) * $data['page_size'])
- ->get();
- if (empty($result)) {
- return Result::error("查询失败", 0);
- }
- $count = JobHunting::where($where)
- ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
- ->leftJoin('website', 'website.id', '=', 'job_hunting.website_id')
- ->count();
- $data = [
- 'rows' => $result->toArray(),
- 'count' => $count,
- ];
- return Result::success($data);
- }
- public function addJobHunting(array $data): array
- {
- date_default_timezone_set('Asia/Shanghai');
- unset($data['company_name']);
- unset($data['job_industry']);
- unset($data['job_name']);
- unset($data['department']);
- unset($data['job_timeList']);
- unset($data['job_content']);
- $data['created_at'] = date('Y-m-d H:i:s');
- $data['updated_at'] = date('Y-m-d H:i:s');
- var_dump($data, '-----------------test---------');
- $result = JobHunting::create($data);
- if (empty($result)) {
- return Result::error("添加失败", 0);
- }
- return Result::success($result);
- }
- public function delJobHunting(array $data): array
- {
- $result = JobHunting::where('id', $data['id'])->delete();
- if (empty($result)) {
- return Result::error("删除失败", 0);
- }
- return Result::success($result);
- }
- public function updateJobHunting(array $data): array
- {
- //设置东八区
- date_default_timezone_set('Asia/Shanghai');
- unset($data['company_name']);
- unset($data['job_industry']);
- unset($data['job_name']);
- unset($data['department']);
- unset($data['job_timeList']);
- unset($data['job_content']);
- $data['created_at'] = date('Y-m-d H:i:s');
- $data['updated_at'] = date('Y-m-d H:i:s');
- $result = JobHunting::where('id', $data['id'])->update($data);
- if (empty($result)) {
- return Result::error("更新失败", 0);
- }
- return Result::success($result);
- }
- public function getJobHuntingInfo(array $data): array
- {
- $result = JobHunting::where('id', $data['id'])->first();
- if (empty($result)) {
- return Result::error("查询失败", 0);
- }
- return Result::success($result);
- }
- public function getJobHuntingData(array $data): array
- {
- $jobEnum = JobEnum::get();
- $jobIndustry = JobIndustry::get();
- $jobNature = JobNature::get();
- $jobPosition = JobPosition::get();
- $data = [
- 'jobEnum' => $jobEnum,
- 'jobIndustry' => $jobIndustry,
- 'jobNature' => $jobNature,
- 'jobPosition' => $jobPosition,
- ];
- return Result::success($data);
- }
- public function delJobHuntingInfo(array $data): array
- {
- $result = JobHunting::where('id', $data['id'])->delete();
- return Result::success();
- }
- //20250324 通知,公告,消息
- public function delNotice(array $data): array
- {
- return Result::success();
- }
- public function getNoticeInfo(array $data): array
- {
- $result = Notice::where('id', $data['id'])->first();
- if (empty($result)) {
- return Result::error("查询失败", 0);
- }
- return Result::success($result);
- }
- public function addNotice(array $data): array
- {
- date_default_timezone_set('Asia/Shanghai');
- $data['created_at'] = date('Y-m-d H:i:s');
- $data['updated_at'] = date('Y-m-d H:i:s');
- $user_id = UserInfo::
- //city_id不是null
- whereNotNull('city_id')
- ->whereNotNull('department_id')
- ->where(function ($query) use ($data) {
- $query->where(function ($subQuery) use ($data) {
- $subQuery->whereRaw("JSON_VALID(city_arr_id) AND JSON_CONTAINS(city_arr_id, '" . intval($data['city_id']) . "') = 1");
- });
- })
- ->where(function ($query) use ($data) {
- $query->where(function ($subQuery) use ($data) {
- $subQuery->whereRaw("JSON_VALID(department_arr_id) AND JSON_CONTAINS(department_arr_id, '" . intval($data['department_id']) . "') = 1");
- });
- })
- ->pluck('user_id')->toArray();
- $user_id = array_unique($user_id);
- $user_id = json_encode($user_id);
- $data['re_user_ids'] = $user_id;
- $result = Notice::create($data);
- if (empty($result)) {
- return Result::error("添加失败", 0);
- }
- return Result::success($result);
- }
- public function updateNotice(array $data): array
- {
- date_default_timezone_set('Asia/Shanghai');
- //根据city_id 和department_id 查询出对应的user_id,放到 re_user_ids
- $user_id = UserInfo::
- //city_id不是null
- whereNotNull('city_id')
- ->whereNotNull('department_id')
- ->where(function ($query) use ($data) {
- $query->where(function ($subQuery) use ($data) {
- $subQuery->whereRaw("JSON_VALID(city_arr_id) AND JSON_CONTAINS(city_arr_id, '" . intval($data['city_id']) . "') = 1");
- });
- })
- ->where(function ($query) use ($data) {
- $query->where(function ($subQuery) use ($data) {
- $subQuery->whereRaw("JSON_VALID(department_arr_id) AND JSON_CONTAINS(department_arr_id, '" . intval($data['department_id']) . "') = 1");
- });
- })
- ->pluck('user_id')->toArray();
- $user_id = array_unique($user_id);
- $user_id = json_encode($user_id);
- $data['re_user_ids'] = $user_id;
- $data['updated_at'] = date('Y-m-d H:i:s');
- $result = Notice::where('id', $data['id'])->update($data);
- return Result::success($result);
- }
- public function getNoticeList(array $data): array
- {
- $where = [];
- //title
- if (isset($data['title']) && !empty($data['title'])) {
- $where[] = ['title', 'like', '%' . $data['title'] . '%'];
- }
- //level
- if (isset($data['level']) && !empty($data['level'])) {
- $where[] = ['level', '=', $data['level']];
- }
- var_dump($data['type_id'], '-----------------test---------');
- if ($data['type_id'] == 10000) {
- $result = Notice::where('status', 1)
- ->where($where)
- ->orderBy('updated_at', 'desc')
- ->limit($data['page_size'])
- ->offset(($data['page'] - 1) * $data['page_size'])
- ->get();
- } else {
- $result = Notice::where('status', 1)
- ->where($where)
- ->where('user_id', $data['user_id'])
- ->orWhere(function ($query) use ($data) {
- $query->where('re_user_ids', 'like', '%' . $data['user_id'] . '%');
- })
- ->orderBy('updated_at', 'desc')
- ->limit($data['page_size'])
- ->offset(($data['page'] - 1) * $data['page_size'])
- ->get();
- }
- if (empty($result)) {
- return Result::error("查询失败", 0);
- }
- $count = Notice::where('status', 1)->count();
- $data = [
- 'rows' => $result,
- 'count' => $count,
- ];
- return Result::success($data);
- }
- public function getNoticeDetail(array $data): array
- {
- $result = Notice::where('id', $data['id'])->first();
- if (empty($result)) {
- return Result::error("查询失败", 0);
- }
- return Result::success($result);
- }
- public function deleteNotice(array $data): array
- {
- $result = Notice::where('id', $data['id'])->delete();
- return Result::success($result);
- }
- public function getMSG(array $data): array
- {
- $type_id = isset($data['type_id']) ? $data['type_id'] : 1;
- // '1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)
- $user_id = isset($data['user_id']) ? $data['user_id'] : 0; //用户id
- $result = [];
- if ($type_id == 1) {
- //最近的5篇已审的文章
- $apply_articale = Article::where('status', 1)
- ->where('admin_user_id', $user_id)
- ->orderBy('updated_at', 'desc')
- ->limit(5)->get();
- //获取5条单聊未读聊天消息
- $chat = ChatRecords::where('is_read', 0)
- ->where('user_id', $user_id)
- ->where('talk_type', 1)
- ->orderBy('created_at', 'desc')
- ->limit(5)->get();
- //获取5条未读群聊信息
- $chat_group = ChatRecords::where('is_read', 0)
- ->where('user_id', $user_id)
- ->where('talk_type', 2)
- ->orderBy('created_at', 'desc')
- ->limit(5)->get();
- $count = count($chat) + count($chat_group) + count($apply_articale);
- $result = [
- 'apply_articale' => $apply_articale,
- 'chat' => $chat,
- 'chat_group' => $chat_group,
- 'count' => $count,
- ];
- } elseif ($type_id == 2) {
- //最近的5篇已审的文章
- $apply_articale = Article::where('status', 1)
- ->where('admin_user_id', $user_id)
- ->limit(5)->get();
- //获取5条单聊未读聊天消息
- $chat = ChatRecords::where('is_read', 0)
- ->where('user_id', $user_id)
- ->where('talk_type', 1)
- ->orderBy('created_at', 'desc')
- ->limit(5)->get();
- //获取5条未读群聊信息
- $chat_group = ChatRecords::where('is_read', 0)
- ->where('user_id', $user_id)
- ->where('talk_type', 2)
- ->orderBy('created_at', 'desc')
- ->limit(5)->get();
- $count = count($chat) + count($chat_group) + count($apply_articale);
- $result = [
- 'apply_articale' => $apply_articale,
- 'chat' => $chat,
- 'chat_group' => $chat_group,
- 'count' => $count,
- ];
- } elseif ($type_id == 3) {
- //最近的5篇已审的文章
- $apply_articale = Article::where('status', 1)
- ->where('admin_user_id', $user_id)
- ->limit(5)->get();
- //获取5条单聊未读聊天消息
- $chat = ChatRecords::where('is_read', 0)
- ->where('user_id', $user_id)
- ->where('talk_type', 1)
- ->orderBy('created_at', 'desc')
- ->limit(5)->get();
- //获取5条未读群聊信息
- $chat_group = ChatRecords::where('is_read', 0)
- ->where('user_id', $user_id)
- ->where('talk_type', 2)
- ->orderBy('created_at', 'desc')
- ->limit(5)->get();
- $count = count($chat) + count($chat_group) + count($apply_articale);
- $result = [
- 'apply_articale' => $apply_articale,
- 'chat' => $chat,
- 'chat_group' => $chat_group,
- 'count' => $count,
- ];
- } elseif ($type_id == 4) {
- //最近的5篇已审的文章
- $apply_articale = Article::where('status', 1)
- ->where('admin_user_id', $user_id)
- ->limit(5)->get();
- $count = count($apply_articale);
- $result = [
- 'apply_articale' => $apply_articale,
- 'count' => $count,
- ];
- } elseif ($type_id == 10000) {
- //获取未审核的5篇文章
- $apply_articale = Article::where('status', 0)
- ->orderBy('updated_at', 'desc')
- ->limit(5)->get();
- //获取5条单聊未读聊天消息
- $chat = ChatRecords::where('is_read', 0)
- ->where('user_id', $user_id)
- ->where('talk_type', 1)
- ->orderBy('created_at', 'desc')
- ->limit(5)->get();
- //获取5条未读群聊信息
- $chat_group = ChatRecords::where('is_read', 0)
- ->where('user_id', $user_id)
- ->where('talk_type', 2)
- ->orderBy('created_at', 'desc')
- ->limit(5)->get();
- $count = count($chat) + count($chat_group) + count($apply_articale);
- $result = [
- 'apply_articale' => $apply_articale,
- 'chat' => $chat,
- 'chat_group' => $chat_group,
- 'count' => $count,
- ];
- } elseif ($type_id == 20000) {
- }
- var_dump($type_id, '-----------------test---------');
- return Result::success($result);
- }
- public function getComplaintList(array $data): array
- {
- $result = Notice::where('status', 1)->get();
- return Result::success($result);
- }
- public function getComplaintInfo(array $data): array
- {
- $result = Notice::where('id', $data['id'])->first();
- if (empty($result)) {
- return Result::error("查询失败", 0);
- }
- return Result::success($result);
- }
- public function addComplaint(array $data): array
- {
- $result = Notice::create($data);
- return Result::success($result);
- }
- public function updateComplaint(array $data): array
- {
- $result = Notice::where('id', $data['id'])->update($data);
- return Result::success($result);
- }
- public function deleteComplaint(array $data): array
- {
- $result = Notice::where('id', $data['id'])->delete();
- return Result::success($result);
- }
- public function getComplainInfo(array $data): array
- {
- $result = Notice::where('id', $data['id'])->first();
- if (empty($result)) {
- return Result::error("查询失败", 0);
- }
- return Result::success($result);
- }
- //20250324 通知,公告,消息
- }
|