import BaseController from '../../base'; import { AdminRoute } from '../../../decorator/router_register'; import { PageGetDto } from '../../../dto/comm'; import { CreateGroupDto, DeleteGroupDto, SendGroupsMsgDto, SendMsgDto, UpdateGroupDto, } from '../../../dto/admin/tg/group'; export class TggroupController extends BaseController { /** * list */ @AdminRoute('/tg/group/list', 'get') async list() { this.res({ data: await this.service.admin.tg.tggroup.list(), }); } /** * page */ @AdminRoute('/tg/group/page', 'get') async page() { const dto = await this.ctx.validate(PageGetDto, this.getQuery()); this.res({ data: { list: await this.service.admin.tg.tggroup.page(dto.current - 1, dto.pageSize), pagination: { page: dto.current, size: dto.pageSize, total: await this.service.admin.tg.tggroup.count(), }, }, }); } /** * add */ @AdminRoute('/tg/group/add', 'post') async add() { const dto = await this.ctx.validate(CreateGroupDto); this.res({ data: await this.service.admin.tg.tggroup.add(dto), }); } /** * delete */ @AdminRoute('/tg/group/delete', 'post') async delete() { const dto = await this.ctx.validate(DeleteGroupDto); this.res({ data: await this.service.admin.tg.tggroup.delete(dto.ids), }); } /** * delete */ @AdminRoute('/tg/group/update', 'post') async update() { const dto = await this.ctx.validate(UpdateGroupDto); await this.service.admin.tg.tggroup.update(dto); this.res({}); } @AdminRoute('/tg/group/send_groups_msg', 'post') async send_groups_msg() { const dto = await this.ctx.validate(SendGroupsMsgDto); this.res({ data: await this.service.admin.tg.tggroup.send_groups_msg(dto.groupIds,dto.message), }); } @AdminRoute('/tg/group/send_msg', 'post') async send_msg() { const dto = await this.ctx.validate(SendMsgDto); this.res({ data: await this.service.admin.tg.tggroup.send_msg(dto.groupId, dto.botId, dto.message), }); } @AdminRoute('/tg/group/msg_groupIds', 'get') async msg_groupIds() { this.res({ data: await this.service.admin.tg.tggroup.msg_groupIds(), }); } @AdminRoute('/tg/group/all_botlist', 'get') async all_botlist() { this.res({ data: await this.service.admin.tg.tggroup.all_botlist(), }); } @AdminRoute('/tg/group/receive_page', 'get') async receive_page() { const dto = await this.ctx.validate(PageGetDto, this.getQuery()); this.res({ data: { list: await this.service.admin.tg.tglog.receive_page(dto.current - 1, dto.pageSize), pagination: { page: dto.current, size: dto.pageSize, total: await this.service.admin.tg.tglog.receive_count(), }, }, }); } @AdminRoute('/tg/group/send_page', 'get') async send_page() { const dto = await this.ctx.validate(PageGetDto, this.getQuery()); this.res({ data: { list: await this.service.admin.tg.tglog.send_page(dto.current - 1, dto.pageSize), pagination: { page: dto.current, size: dto.pageSize, total: await this.service.admin.tg.tglog.send_count(), }, }, }); } }