remove_whatcapp_batch_msg_logic.go 977 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package batch_msg
  2. import (
  3. "context"
  4. "github.com/suyuan32/simple-admin-common/msg/errormsg"
  5. "wechat-api/ent/batchmsg"
  6. "wechat-api/internal/utils/dberrorhandler"
  7. "wechat-api/internal/svc"
  8. "wechat-api/internal/types"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type RemoveWhatcappBatchMsgLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewRemoveWhatcappBatchMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveWhatcappBatchMsgLogic {
  17. return &RemoveWhatcappBatchMsgLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx}
  21. }
  22. func (l *RemoveWhatcappBatchMsgLogic) RemoveWhatcappBatchMsg(req *types.IDsReq) (*types.BaseMsgResp, error) {
  23. _, err := l.svcCtx.DB.BatchMsg.Delete().Where(
  24. batchmsg.IDIn(req.Ids...),
  25. batchmsg.CtypeEQ(2),
  26. ).Exec(l.ctx)
  27. if err != nil {
  28. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  29. }
  30. return &types.BaseMsgResp{Msg: errormsg.DeleteSuccess}, nil
  31. }