1
0

tggroup.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import BaseController from '../../base';
  2. import { AdminRoute } from '../../../decorator/router_register';
  3. import { PageGetDto } from '../../../dto/comm';
  4. import {
  5. CreateGroupDto,
  6. DeleteGroupDto,
  7. SendGroupsMsgDto,
  8. SendMsgDto,
  9. UpdateGroupDto,
  10. } from '../../../dto/admin/tg/group';
  11. export class TggroupController extends BaseController {
  12. /**
  13. * list
  14. */
  15. @AdminRoute('/tg/group/list', 'get')
  16. async list() {
  17. this.res({
  18. data: await this.service.admin.tg.tggroup.list(),
  19. });
  20. }
  21. /**
  22. * page
  23. */
  24. @AdminRoute('/tg/group/page', 'get')
  25. async page() {
  26. const dto = await this.ctx.validate<PageGetDto>(PageGetDto, this.getQuery());
  27. this.res({
  28. data: {
  29. list: await this.service.admin.tg.tggroup.page(dto.current - 1, dto.pageSize),
  30. pagination: {
  31. page: dto.current,
  32. size: dto.pageSize,
  33. total: await this.service.admin.tg.tggroup.count(),
  34. },
  35. },
  36. });
  37. }
  38. /**
  39. * add
  40. */
  41. @AdminRoute('/tg/group/add', 'post')
  42. async add() {
  43. const dto = await this.ctx.validate<CreateGroupDto>(CreateGroupDto);
  44. this.res({
  45. data: await this.service.admin.tg.tggroup.add(dto),
  46. });
  47. }
  48. /**
  49. * delete
  50. */
  51. @AdminRoute('/tg/group/delete', 'post')
  52. async delete() {
  53. const dto = await this.ctx.validate<DeleteGroupDto>(DeleteGroupDto);
  54. this.res({
  55. data: await this.service.admin.tg.tggroup.delete(dto.ids),
  56. });
  57. }
  58. /**
  59. * delete
  60. */
  61. @AdminRoute('/tg/group/update', 'post')
  62. async update() {
  63. const dto = await this.ctx.validate<UpdateGroupDto>(UpdateGroupDto);
  64. await this.service.admin.tg.tggroup.update(dto);
  65. this.res({});
  66. }
  67. @AdminRoute('/tg/group/send_groups_msg', 'post')
  68. async send_groups_msg() {
  69. const dto = await this.ctx.validate<SendGroupsMsgDto>(SendGroupsMsgDto);
  70. this.res({
  71. data: await this.service.admin.tg.tggroup.send_groups_msg(dto.groupIds,dto.message),
  72. });
  73. }
  74. @AdminRoute('/tg/group/send_msg', 'post')
  75. async send_msg() {
  76. const dto = await this.ctx.validate<SendMsgDto>(SendMsgDto);
  77. this.res({
  78. data: await this.service.admin.tg.tggroup.send_msg(dto.groupId, dto.botId, dto.message),
  79. });
  80. }
  81. @AdminRoute('/tg/group/msg_groupIds', 'get')
  82. async msg_groupIds() {
  83. this.res({
  84. data: await this.service.admin.tg.tggroup.msg_groupIds(),
  85. });
  86. }
  87. @AdminRoute('/tg/group/all_botlist', 'get')
  88. async all_botlist() {
  89. this.res({
  90. data: await this.service.admin.tg.tggroup.all_botlist(),
  91. });
  92. }
  93. @AdminRoute('/tg/group/receive_page', 'get')
  94. async receive_page() {
  95. const dto = await this.ctx.validate<PageGetDto>(PageGetDto, this.getQuery());
  96. this.res({
  97. data: {
  98. list: await this.service.admin.tg.tglog.receive_page(dto.current - 1, dto.pageSize),
  99. pagination: {
  100. page: dto.current,
  101. size: dto.pageSize,
  102. total: await this.service.admin.tg.tglog.receive_count(),
  103. },
  104. },
  105. });
  106. }
  107. @AdminRoute('/tg/group/send_page', 'get')
  108. async send_page() {
  109. const dto = await this.ctx.validate<PageGetDto>(PageGetDto, this.getQuery());
  110. this.res({
  111. data: {
  112. list: await this.service.admin.tg.tglog.send_page(dto.current - 1, dto.pageSize),
  113. pagination: {
  114. page: dto.current,
  115. size: dto.pageSize,
  116. total: await this.service.admin.tg.tglog.send_count(),
  117. },
  118. },
  119. });
  120. }
  121. }