| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- 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>(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>(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>(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>(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>(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>(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>(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>(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(),
- },
- },
- });
- }
- }
|