|
@@ -21,6 +21,7 @@ use Ramsey\Uuid\Uuid;
|
|
|
use Hyperf\Utils\Random;
|
|
|
use Fukuball\Jieba\Jieba;
|
|
|
use Fukuball\Jieba\Finalseg;
|
|
|
+use App\Model\ChatRecords;
|
|
|
|
|
|
#[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class NewsService implements NewsServiceInterface
|
|
@@ -265,7 +266,8 @@ class NewsService implements NewsServiceInterface
|
|
|
$reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
|
|
|
preg_match_all($reg, $data['content'], $matches);
|
|
|
if (isset($matches[1][0])) {
|
|
|
- $articleData['imgurl'] = $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);
|
|
@@ -426,7 +428,8 @@ class NewsService implements NewsServiceInterface
|
|
|
$reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
|
|
|
preg_match_all($reg, $data['content'], $matches);
|
|
|
if (isset($matches[1][0])) {
|
|
|
- $articleData['imgurl'] = $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);
|
|
@@ -521,7 +524,7 @@ class NewsService implements NewsServiceInterface
|
|
|
} catch (\Throwable $ex) {
|
|
|
Db::rollBack();
|
|
|
var_dump($ex->getMessage());
|
|
|
- return Result::error("更新失败1" . $ex->getMessage(), 0);
|
|
|
+ return Result::error("更新失败" . $ex->getMessage(), 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -941,7 +944,7 @@ class NewsService implements NewsServiceInterface
|
|
|
} else {
|
|
|
$choice_id[0] = $choice['other']['other_id'];
|
|
|
}
|
|
|
- array_push($data['choice_id'],$choice['other']['other_id']);
|
|
|
+ array_push($data['choice_id'], $choice['other']['other_id']);
|
|
|
}
|
|
|
// return Result::success($data);
|
|
|
$choice = ArticleSurvey::whereIn('id', $data['choice_id'])
|
|
@@ -1103,12 +1106,11 @@ class NewsService implements NewsServiceInterface
|
|
|
return Result::success($data);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * 模块新闻加强版
|
|
|
+ * 模块新闻加强版
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
- */
|
|
|
+ */
|
|
|
public function getWebsiteCatidArticle(array $data): array
|
|
|
{
|
|
|
$where = [
|
|
@@ -1123,7 +1125,7 @@ class NewsService implements NewsServiceInterface
|
|
|
->leftJoin('article', 'article.catid', 'website_category.category_id')
|
|
|
->where('article.status', 1)
|
|
|
->where('article.imgurl', '!=', '')
|
|
|
- ->select('article.*','website_category.category_id','website_category.alias')
|
|
|
+ ->select('article.*', 'website_category.category_id', 'website_category.alias')
|
|
|
->orderBy('article.updated_at', 'desc')
|
|
|
->limit($data['img_num'])
|
|
|
->get();
|
|
@@ -1135,17 +1137,17 @@ class NewsService implements NewsServiceInterface
|
|
|
->where('article.status', 1)
|
|
|
->where(function ($query) {
|
|
|
$query->whereNull('article.imgurl')
|
|
|
- ->orWhere('article.imgurl', '');
|
|
|
+ ->orWhere('article.imgurl', '');
|
|
|
})
|
|
|
- ->select('article.*','website_category.category_id','website_category.alias')
|
|
|
+ ->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)){
|
|
|
+
|
|
|
+ if (empty($category)) {
|
|
|
return Result::error("查询失败", 0);
|
|
|
}
|
|
|
return Result::success($category);
|
|
@@ -1400,4 +1402,184 @@ class NewsService implements NewsServiceInterface
|
|
|
$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
|
|
|
+ {
|
|
|
+ $result = Notice::create($data);
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ public function updateNotice(array $data): array
|
|
|
+ {
|
|
|
+ $result = Notice::where('id', $data['id'])->update($data);
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ public function getNoticeList(array $data): array
|
|
|
+ {
|
|
|
+ $result = Notice::where('status', 1)->get();
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ 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']) ? $data['type'] : 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)->limit(5)->get();
|
|
|
+ //获取5条单聊未读聊天消息
|
|
|
+ $chat = ChatRecords::where('is_read', 0)
|
|
|
+ ->where('user_id', $user_id)
|
|
|
+ ->where('talk_type', 1)
|
|
|
+ ->limit(5)->get();
|
|
|
+ //获取5条未读群聊信息
|
|
|
+ $chat_group = ChatRecords::where('is_read', 0)
|
|
|
+ ->where('user_id', $user_id)
|
|
|
+ ->where('talk_type', 2)
|
|
|
+ ->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)->limit(5)->get();
|
|
|
+ //获取5条单聊未读聊天消息
|
|
|
+ $chat = ChatRecords::where('is_read', 0)
|
|
|
+ ->where('user_id', $user_id)
|
|
|
+ ->where('talk_type', 1)
|
|
|
+ ->limit(5)->get();
|
|
|
+ //获取5条未读群聊信息
|
|
|
+ $chat_group = ChatRecords::where('is_read', 0)
|
|
|
+ ->where('user_id', $user_id)
|
|
|
+ ->where('talk_type', 2)
|
|
|
+ ->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)->limit(5)->get();
|
|
|
+ //获取5条单聊未读聊天消息
|
|
|
+ $chat = ChatRecords::where('is_read', 0)
|
|
|
+ ->where('user_id', $user_id)
|
|
|
+ ->where('talk_type', 1)
|
|
|
+ ->limit(5)->get();
|
|
|
+ //获取5条未读群聊信息
|
|
|
+ $chat_group = ChatRecords::where('is_read', 0)
|
|
|
+ ->where('user_id', $user_id)
|
|
|
+ ->where('talk_type', 2)
|
|
|
+ ->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)->limit(5)->get();
|
|
|
+
|
|
|
+ $count = count($apply_articale);
|
|
|
+ $result = [
|
|
|
+ 'count' => $count,
|
|
|
+ ];
|
|
|
+ } elseif ($type_id == 10000) {
|
|
|
+ //获取未审核的5篇文章
|
|
|
+ $apply_articale = Article::where('status', 0)->limit(5)->get();
|
|
|
+ //获取5条单聊未读聊天消息
|
|
|
+ $chat = ChatRecords::where('is_read', 0)
|
|
|
+ ->where('user_id', $user_id)
|
|
|
+ ->where('talk_type', 1)
|
|
|
+ ->limit(5)->get();
|
|
|
+ //获取5条未读群聊信息
|
|
|
+ $chat_group = ChatRecords::where('is_read', 0)
|
|
|
+ ->where('user_id', $user_id)
|
|
|
+ ->where('talk_type', 2)
|
|
|
+ ->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) {
|
|
|
+ }
|
|
|
+ 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 通知,公告,消息
|
|
|
+
|
|
|
}
|