update_whatsapp_channel_logic.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package whatsapp_channel
  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/zeromicro/go-zero/core/logx"
  9. )
  10. type UpdateWhatsappChannelLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewUpdateWhatsappChannelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateWhatsappChannelLogic {
  16. return &UpdateWhatsappChannelLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. func (l *UpdateWhatsappChannelLogic) UpdateWhatsappChannel(req *types.WhatsappChannelInfo) (*types.BaseMsgResp, error) {
  23. err := l.svcCtx.DB.WhatsappChannel.UpdateOneID(*req.Id).
  24. //SetNotNilStatus(req.Status).
  25. SetNotNilAk(req.Ak).
  26. SetNotNilSk(req.Sk).
  27. SetNotNilWaID(req.WaId).
  28. SetNotNilWaName(req.WaName).
  29. SetNotNilWabaID(req.WabaId).
  30. SetNotNilBusinessID(req.BusinessId).
  31. SetNotNilOrganizationID(req.OrganizationId).
  32. SetNotNilVerifyAccount(req.VerifyAccount).
  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. }