lrf 7 月之前
父节点
当前提交
2d2b92ba3e

+ 20 - 2
src/controller/system/message.controller.ts

@@ -96,7 +96,19 @@ export class RegionController implements BaseController {
   @ApiTags('未读查询')
   @ApiTags('未读查询')
   @ApiQuery({ name: 'query' })
   @ApiQuery({ name: 'query' })
   async checkNotRead() {
   async checkNotRead() {
-    const qobj = { 'to.is_read': '0' };
+    const qobj = { 'to.is_read': '0', 'to.user_type': MessageUserType.USER };
+    const user = get(this.ctx, 'user');
+    if (!user) return 0;
+    qobj['to.user'] = get(user, 'id');
+    const result = await this.service.query(qobj);
+    return get(result, 'total');
+  }
+
+  @Get('/adminCheckNotRead')
+  @ApiTags('管理员未读查询')
+  @ApiQuery({ name: 'query' })
+  async adminCheckNotRead() {
+    const qobj = { 'to.is_read': '0', 'to.user_type': MessageUserType.ADMIN };
     const user = get(this.ctx, 'user');
     const user = get(this.ctx, 'user');
     if (!user) return 0;
     if (!user) return 0;
     qobj['to.user'] = get(user, 'id');
     qobj['to.user'] = get(user, 'id');
@@ -107,7 +119,13 @@ export class RegionController implements BaseController {
   @Get('/read/:id')
   @Get('/read/:id')
   @ApiTags('全部已读')
   @ApiTags('全部已读')
   async read(@Param('id') id: number) {
   async read(@Param('id') id: number) {
-    const data = await this.service.read({ id });
+    const data = await this.service.read({ id, user_type: MessageUserType.USER });
+    return data;
+  }
+  @Get('/adminRead/:id')
+  @ApiTags('管理员全部已读')
+  async adminRead(@Param('id') id: number) {
+    const data = await this.service.read({ id, user_type: MessageUserType.ADMIN });
     return data;
     return data;
   }
   }
 }
 }

+ 2 - 1
src/entity/system/message.entity.ts

@@ -1,10 +1,11 @@
 import { Column, Entity } from 'typeorm';
 import { Column, Entity } from 'typeorm';
 import { BaseModel } from '../../frame/BaseModel';
 import { BaseModel } from '../../frame/BaseModel';
+import { MessageUserType } from '../../public/var';
 
 
 class toModel {
 class toModel {
   user: string; // 用户id
   user: string; // 用户id
   user_nick_name: string; //用户名称
   user_nick_name: string; //用户名称
-  user_type: string; //用户类型(管理员admin/站内用户user)
+  user_type: MessageUserType; //用户类型(管理员admin/站内用户user, MessageUserType)
   is_read: string; // 是否阅读: 0否;1是
   is_read: string; // 是否阅读: 0否;1是
 }
 }
 
 

+ 27 - 1
src/service/initData/initSystemData.service.ts

@@ -488,7 +488,7 @@ export class InitSystemDataService {
             route_name: 'information_platform',
             route_name: 'information_platform',
             children: [
             children: [
               {
               {
-                name: '供信息',
+                name: '供信息',
                 component: 'supply',
                 component: 'supply',
                 type: '2',
                 type: '2',
                 is_default: '0',
                 is_default: '0',
@@ -739,6 +739,32 @@ export class InitSystemDataService {
           },
           },
         ],
         ],
       },
       },
+      {
+        name: '申请审核',
+        path: '/exam/index',
+        type: '1',
+        is_default: '0',
+        is_use: '0',
+        route_name: 'exam',
+        children: [
+          {
+            name: '联系申请',
+            component: 'contact',
+            type: '2',
+            is_default: '0',
+            is_use: '0',
+            route_name: 'exam_contact_apply',
+          },
+          {
+            name: '企业认领',
+            component: 'company',
+            type: '2',
+            is_default: '0',
+            is_use: '0',
+            route_name: 'exam_company',
+          },
+        ],
+      },
       {
       {
         name: '数据看板',
         name: '数据看板',
         path: '/board/index',
         path: '/board/index',

+ 26 - 6
src/service/system/message.service.ts

@@ -14,14 +14,14 @@ export class MessageService extends BaseServiceV2 {
   @Config('modulesConfig.mq')
   @Config('modulesConfig.mq')
   mqServiceHttpPrefix: any;
   mqServiceHttpPrefix: any;
   getQueryColumnsOpera() {
   getQueryColumnsOpera() {
-    return { 'to.user': this.Opera.JsonArrayObject, 'to.is_read': this.Opera.JsonArrayObject };
+    return { 'to.user': this.Opera.JsonArrayObject, 'to.is_read': this.Opera.JsonArrayObject, 'to.user_type': this.Opera.JsonArrayObject };
   }
   }
 
 
   // 全部已读
   // 全部已读
-  async read({ id }) {
+  async read({ id, user_type }) {
     const list = await this.model
     const list = await this.model
       .createQueryBuilder()
       .createQueryBuilder()
-      .where('"to" @> :member', { member: JSON.stringify([{ user: parseInt(id) }]) })
+      .where('"to" @> :member', { member: JSON.stringify([{ user: parseInt(id), user_type }]) })
       .getMany();
       .getMany();
     for (const tag of list) {
     for (const tag of list) {
       const to = get(tag, 'to', []);
       const to = get(tag, 'to', []);
@@ -31,15 +31,35 @@ export class MessageService extends BaseServiceV2 {
       await this.model.update({ id: tag.id }, { to: to });
       await this.model.update({ id: tag.id }, { to: to });
     }
     }
   }
   }
+  /**
+   * 发送消息
+   * @param id 消息数据id
+   */
+  async toSendMsg(id) {
+    const data = await this.model.createQueryBuilder().where(`id =:id`, { id }).getOne();
+    if (!data) return;
+    const data_content = get(data, 'content');
+    const to = get(data, 'to', []);
+    for (const i of to) {
+      const target = get(i, 'user');
+      const userType = get(i, 'user_type');
+      const content = {
+        data_id: id,
+        content: data_content,
+      };
+      this.toSendMq(target, userType, content);
+    }
+  }
+
   /**
   /**
    * 发送mq消息
    * 发送mq消息
    * @param target mq接收人
    * @param target mq接收人
    * @param userType 用户类型
    * @param userType 用户类型
-   * @param data_id 消息数据id
+   * @param content 消息对象
    */
    */
-  async toSendMq(target, userType: MessageUserType, data_id) {
+  async toSendMq(target, userType: MessageUserType, content) {
     const url = `${this.mqServiceHttpPrefix}/send`;
     const url = `${this.mqServiceHttpPrefix}/send`;
-    const body = { target, userType, data_id };
+    const body = { target, userType, content };
     try {
     try {
       await Axios.post(url, body, { responseType: 'json' });
       await Axios.post(url, body, { responseType: 'json' });
     } catch (error) {
     } catch (error) {