zs vor 1 Jahr
Ursprung
Commit
71c072ea7f

+ 4 - 1
src/controller/chat.controller.ts

@@ -5,6 +5,7 @@ import { CDTO_chat, CVO_chat, FVO_chat, QDTO_chat, QVO_chat, UDTO_chat, UVAO_cha
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
 import { Validate } from '@midwayjs/validate';
 import { verifyToken } from '../decorator/verifyToken.decorator';
 import { verifyToken } from '../decorator/verifyToken.decorator';
+import { get } from 'lodash';
 @ApiTags(['聊天记录'])
 @ApiTags(['聊天记录'])
 @Controller('/chat')
 @Controller('/chat')
 export class ChatController extends BaseController {
 export class ChatController extends BaseController {
@@ -15,7 +16,9 @@ export class ChatController extends BaseController {
   @verifyToken()
   @verifyToken()
   async getLastChatRecordList(@Query('doctor') doctor: string, @Query('name') name: string, @Query('skip') skip: number, @Query('limit') limit: number) {
   async getLastChatRecordList(@Query('doctor') doctor: string, @Query('name') name: string, @Query('skip') skip: number, @Query('limit') limit: number) {
     const result = await this.service.getLastChatRecordList(doctor, skip, limit, name);
     const result = await this.service.getLastChatRecordList(doctor, skip, limit, name);
-    return result;
+    const data = get(result, 'data') || [];
+    const total = get(result, 'total') || 0;
+    return { data, total };
   }
   }
 
 
   @Post('/')
   @Post('/')

+ 0 - 1
src/controller/config.controller.ts

@@ -21,7 +21,6 @@ export class ConfigController extends BaseController {
     return result;
     return result;
   }
   }
   @Get('/')
   @Get('/')
-  @verifyToken()
   @ApiQuery({ name: 'query' })
   @ApiQuery({ name: 'query' })
   @ApiResponse({ type: QVO_config })
   @ApiResponse({ type: QVO_config })
   async query() {
   async query() {

+ 7 - 1
src/entity/chat.entity.ts

@@ -4,7 +4,7 @@ import { BaseModel } from 'free-midway-component';
   schemaOptions: { collection: 'chat' },
   schemaOptions: { collection: 'chat' },
 })
 })
 export class Chat extends BaseModel {
 export class Chat extends BaseModel {
-  @prop({ required: false, index: true, zh: '发送人', ref: 'speaker_type', remark: 'refPath' })
+  @prop({ required: false, index: true, zh: '发送人', refPath: 'speaker_type', remark: 'refPath' })
   speaker: string;
   speaker: string;
   @prop({ required: false, index: false, zh: '回答人类型', remark: 'Doctor;Nurse' })
   @prop({ required: false, index: false, zh: '回答人类型', remark: 'Doctor;Nurse' })
   speaker_type: string;
   speaker_type: string;
@@ -14,8 +14,14 @@ export class Chat extends BaseModel {
   group: string;
   group: string;
   @prop({ required: false, index: true, zh: '医生', ref: 'Doctor' })
   @prop({ required: false, index: true, zh: '医生', ref: 'Doctor' })
   doctor: string;
   doctor: string;
+  @prop({ required: false, index: true, zh: '内容类型' })
+  type: string;
   @prop({ required: false, index: false, zh: '内容' })
   @prop({ required: false, index: false, zh: '内容' })
   content: string;
   content: string;
+  @prop({ required: false, index: false, zh: '音频' })
+  voice: number;
+  @prop({ required: false, index: false, zh: '发送时间' })
+  time: number;
   @prop({ required: false, index: false, zh: '是否未读', remark: '1:未读;0-已读', default: '1' })
   @prop({ required: false, index: false, zh: '是否未读', remark: '1:未读;0-已读', default: '1' })
   not_read: number;
   not_read: number;
 }
 }

+ 20 - 1
src/interface/chat.interface.ts

@@ -24,8 +24,14 @@ export class FVO_chat {
   'group': string = undefined;
   'group': string = undefined;
   @ApiProperty({ description: '医生' })
   @ApiProperty({ description: '医生' })
   'doctor': string = undefined;
   'doctor': string = undefined;
+  @ApiProperty({ description: '内容类型' })
+  'type': string = undefined;
   @ApiProperty({ description: '内容' })
   @ApiProperty({ description: '内容' })
   'content': string = undefined;
   'content': string = undefined;
+  @ApiProperty({ description: '音频' })
+  'voice': number = undefined;
+  @ApiProperty({ description: '时间' })
+  'time': number = undefined;
   @ApiProperty({ description: '是否未读' })
   @ApiProperty({ description: '是否未读' })
   'not_read': number = undefined;
   'not_read': number = undefined;
 }
 }
@@ -33,7 +39,7 @@ export class FVO_chat {
 export class QDTO_chat extends SearchBase {
 export class QDTO_chat extends SearchBase {
   constructor() {
   constructor() {
     const like_prop = [];
     const like_prop = [];
-    const props = ['speaker', 'patient', 'group', 'doctor'];
+    const props = ['speaker', 'patient', 'group', 'doctor', 'type', 'time'];
     const mapping = [];
     const mapping = [];
     super({ like_prop, props, mapping });
     super({ like_prop, props, mapping });
   }
   }
@@ -45,6 +51,10 @@ export class QDTO_chat extends SearchBase {
   'group': string = undefined;
   'group': string = undefined;
   @ApiProperty({ description: '医生' })
   @ApiProperty({ description: '医生' })
   'doctor': string = undefined;
   'doctor': string = undefined;
+  @ApiProperty({ description: '内容类型' })
+  'type': string = undefined;
+  @ApiProperty({ description: '时间' })
+  'time': number = undefined;
 }
 }
 
 
 export class QVO_chat extends FVO_chat {
 export class QVO_chat extends FVO_chat {
@@ -70,9 +80,18 @@ export class CDTO_chat {
   @ApiProperty({ description: '医生' })
   @ApiProperty({ description: '医生' })
   @Rule(RuleType['string']().empty(''))
   @Rule(RuleType['string']().empty(''))
   'doctor': string = undefined;
   'doctor': string = undefined;
+  @ApiProperty({ description: '内容类型' })
+  @Rule(RuleType['string']().empty(''))
+  'type': string = undefined;
+  @ApiProperty({ description: '音频内容' })
+  @Rule(RuleType['number']().empty(''))
+  'voice': number = undefined;
   @ApiProperty({ description: '内容' })
   @ApiProperty({ description: '内容' })
   @Rule(RuleType['string']().empty(''))
   @Rule(RuleType['string']().empty(''))
   'content': string = undefined;
   'content': string = undefined;
+  @ApiProperty({ description: '时间' })
+  @Rule(RuleType['number']().empty(''))
+  'time': number = undefined;
   @ApiProperty({ description: '是否未读' })
   @ApiProperty({ description: '是否未读' })
   @Rule(RuleType['number']().empty(''))
   @Rule(RuleType['number']().empty(''))
   'not_read': number = undefined;
   'not_read': number = undefined;

+ 2 - 1
src/service/chat.service.ts

@@ -22,7 +22,8 @@ export class ChatService extends BaseService<modelType> {
     patient: 1,
     patient: 1,
     patientName: '$pInfo.name',
     patientName: '$pInfo.name',
     patientIcon: '$pInfo.icon',
     patientIcon: '$pInfo.icon',
-    speakTime: '$meta.createdAt',
+    type: 1,
+    time: 1,
     content: 1,
     content: 1,
     notRead: 1,
     notRead: 1,
   };
   };