chatRecord.interface.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { OmitDto, Rule, RuleType } from '@midwayjs/validate';
  2. import { ApiProperty } from '@midwayjs/swagger';
  3. import _ = require('lodash');
  4. import { SearchBase } from 'free-midway-component';
  5. export class FetchVO_chatRecord {
  6. constructor(data: object) {
  7. for (const key of Object.keys(this)) {
  8. this[key] = _.get(data, key);
  9. }
  10. }
  11. @ApiProperty({ description: '数据id' })
  12. _id: string = undefined;
  13. @ApiProperty({ description: '房间' })
  14. 'room': string = undefined;
  15. @ApiProperty({ description: '发言人' })
  16. 'speaker': string = undefined;
  17. @ApiProperty({ description: '内容' })
  18. 'content': string = undefined;
  19. @ApiProperty({ description: '时间' })
  20. 'time': string = undefined;
  21. @ApiProperty({ description: '消息类型' })
  22. 'msg_type': string = undefined;
  23. @ApiProperty({ description: '是否已读' })
  24. 'is_read': string = undefined;
  25. }
  26. export class QueryDTO_chatRecord extends SearchBase {
  27. constructor() {
  28. const like_prop = [];
  29. const props = ['room', 'speaker', 'time', 'is_read'];
  30. const mapping = [];
  31. super({ like_prop, props, mapping });
  32. }
  33. @ApiProperty({ description: '房间' })
  34. 'room': string = undefined;
  35. @ApiProperty({ description: '发言人' })
  36. 'speaker': string = undefined;
  37. @ApiProperty({ description: '时间' })
  38. 'time': string = undefined;
  39. @ApiProperty({ description: '是否已读' })
  40. 'is_read': string = undefined;
  41. }
  42. export class QueryVO_chatRecord extends FetchVO_chatRecord {}
  43. export class CreateDTO_chatRecord {
  44. @ApiProperty({ description: '房间' })
  45. @Rule(RuleType['string']().empty(''))
  46. 'room': string = undefined;
  47. @ApiProperty({ description: '发言人' })
  48. @Rule(RuleType['string']().empty(''))
  49. 'speaker': string = undefined;
  50. @ApiProperty({ description: '内容' })
  51. @Rule(RuleType['string']().empty(''))
  52. 'content': string = undefined;
  53. @ApiProperty({ description: '时间' })
  54. @Rule(RuleType['string']().empty(''))
  55. 'time': string = undefined;
  56. @ApiProperty({ description: '消息类型' })
  57. @Rule(RuleType['string']().empty(''))
  58. 'msg_type': string = undefined;
  59. // 如果没有房间id, 那么顾客id和店铺id就传1个就行,另一个位置为发言人
  60. @ApiProperty({ description: '顾客' })
  61. @Rule(RuleType['string']().empty(''))
  62. 'customer': string = undefined;
  63. @ApiProperty({ description: '店铺' })
  64. @Rule(RuleType['string']().empty(''))
  65. 'shop': string = undefined;
  66. }
  67. export class CreateVO_chatRecord extends FetchVO_chatRecord {}
  68. export class UpdateDTO_chatRecord extends OmitDto(CreateDTO_chatRecord, ['customer', 'shop']) {
  69. @ApiProperty({ description: '数据id' })
  70. @Rule(RuleType['string']().empty(''))
  71. _id: string = undefined;
  72. }
  73. export class UpdateVO_chatRecord extends FetchVO_chatRecord {}
  74. export class ReadDTO {
  75. @ApiProperty({ description: '阅读的数据id' })
  76. @Rule(RuleType.array().min(1))
  77. ids: Array<string> = undefined;
  78. }