update_xunji_logic.go 999 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package xunji
  2. import (
  3. "context"
  4. "github.com/suyuan32/simple-admin-common/msg/errormsg"
  5. "wechat-api/internal/utils/dberrorhandler"
  6. "wechat-api/internal/svc"
  7. "wechat-api/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type UpdateXunjiLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewUpdateXunjiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateXunjiLogic {
  16. return &UpdateXunjiLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx}
  20. }
  21. func (l *UpdateXunjiLogic) UpdateXunji(req *types.XunjiInfo) (*types.BaseMsgResp, error) {
  22. err := l.svcCtx.DB.Xunji.UpdateOneID(*req.Id).
  23. SetNotNilStatus(req.Status).
  24. SetNotNilAppKey(req.AppKey).
  25. SetNotNilAppSecret(req.AppSecret).
  26. SetNotNilToken(req.Token).
  27. SetNotNilEncodingKey(req.EncodingKey).
  28. Exec(l.ctx)
  29. if err != nil {
  30. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  31. }
  32. return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
  33. }