update_batch_msg_logic.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package batch_msg
  2. import (
  3. "context"
  4. "wechat-api/internal/svc"
  5. "wechat-api/internal/types"
  6. "wechat-api/internal/utils/dberrorhandler"
  7. "github.com/suyuan32/simple-admin-common/msg/errormsg"
  8. "github.com/suyuan32/simple-admin-common/utils/pointy"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type UpdateBatchMsgLogic struct {
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. logx.Logger
  15. }
  16. func NewUpdateBatchMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateBatchMsgLogic {
  17. return &UpdateBatchMsgLogic{
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. Logger: logx.WithContext(ctx),
  21. }
  22. }
  23. func (l *UpdateBatchMsgLogic) UpdateBatchMsg(req *types.BatchMsgInfo) (*types.BaseMsgResp, error) {
  24. err := l.svcCtx.DB.BatchMsg.UpdateOneID(*req.Id).
  25. SetNotNilStatus(req.Status).
  26. SetNotNilBatchNo(req.BatchNo).
  27. SetNotNilFromwxid(req.Fromwxid).
  28. SetNotNilMsg(req.Msg).
  29. SetNotNilTag(req.Tag).
  30. SetNotNilTotal(req.Total).
  31. SetNotNilSuccess(req.Success).
  32. SetNotNilFail(req.Fail).
  33. SetNotNilStartTime(pointy.GetTimeMilliPointer(req.StartTime)).
  34. SetNotNilStopTime(pointy.GetTimeMilliPointer(req.StopTime)).
  35. Exec(l.ctx)
  36. if err != nil {
  37. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  38. }
  39. return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
  40. }