update_whatcapp_batch_msg_logic.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package batch_msg
  2. import (
  3. "context"
  4. "github.com/suyuan32/simple-admin-common/msg/errormsg"
  5. "github.com/suyuan32/simple-admin-common/utils/pointy"
  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 UpdateWhatcappBatchMsgLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewUpdateWhatcappBatchMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateWhatcappBatchMsgLogic {
  17. return &UpdateWhatcappBatchMsgLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx}
  21. }
  22. func (l *UpdateWhatcappBatchMsgLogic) UpdateWhatcappBatchMsg(req *types.BatchMsgInfo) (*types.BaseMsgResp, error) {
  23. err := l.svcCtx.DB.BatchMsg.UpdateOneID(*req.Id).
  24. SetNotNilBatchNo(req.BatchNo).
  25. SetNotNilFromwxid(req.Fromwxid).
  26. SetNotNilMsg(req.Msg).
  27. SetNotNilTag(req.Tag).
  28. SetNotNilTotal(req.Total).
  29. SetNotNilSuccess(req.Success).
  30. SetNotNilFail(req.Fail).
  31. SetNotNilStartTime(pointy.GetTimeMilliPointer(req.StartTime)).
  32. SetNotNilStopTime(pointy.GetTimeMilliPointer(req.StopTime)).
  33. Exec(l.ctx)
  34. if err != nil {
  35. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  36. }
  37. return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
  38. }