delete_whatsapp_logic.go 943 B

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