update_contact_logic.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package Contact
  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 UpdateContactLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewUpdateContactLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateContactLogic {
  16. return &UpdateContactLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. func (l *UpdateContactLogic) UpdateContact(req *types.ContactInfo) (*types.BaseMsgResp, error) {
  23. err := l.svcCtx.DB.Contact.UpdateOneID(*req.Id).
  24. SetNotNilStatus(req.Status).
  25. SetNotNilWxWxid(req.WxWxid).
  26. SetNotNilType(req.Type).
  27. SetNotNilWxid(req.Wxid).
  28. SetNotNilAccount(req.Account).
  29. SetNotNilNickname(req.Nickname).
  30. SetNotNilMarkname(req.Markname).
  31. SetNotNilHeadimg(req.Headimg).
  32. SetNotNilSex(req.Sex).
  33. SetNotNilStarrole(req.Starrole).
  34. SetNotNilDontseeit(req.Dontseeit).
  35. SetNotNilDontseeme(req.Dontseeme).
  36. SetNotNilLag(req.Lag).
  37. SetNotNilGid(req.Gid).
  38. SetNotNilGname(req.Gname).
  39. SetNotNilV3(req.V3).
  40. Exec(l.ctx)
  41. if err != nil {
  42. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  43. }
  44. return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
  45. }