12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package contact
- import (
- "context"
- "wechat-api/ent/contact"
- "wechat-api/internal/svc"
- "wechat-api/internal/types"
- "wechat-api/internal/utils/dberrorhandler"
- "github.com/suyuan32/simple-admin-common/msg/errormsg"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type UpdateContactLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewUpdateContactLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateContactLogic {
- return &UpdateContactLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- func (l *UpdateContactLogic) UpdateContact(req *types.ContactInfo) (*types.BaseMsgResp, error) {
- organizationId := l.ctx.Value("organizationId").(uint64)
- err := l.svcCtx.DB.Contact.UpdateOneID(*req.Id).
- Where(contact.OrganizationID(organizationId)).
- SetNotNilStatus(req.Status).
- SetNotNilWxWxid(req.WxWxid).
- SetNotNilType(req.Type).
- SetNotNilWxid(req.Wxid).
- SetNotNilAccount(req.Account).
- SetNotNilNickname(req.Nickname).
- SetNotNilMarkname(req.Markname).
- SetNotNilHeadimg(req.Headimg).
- SetNotNilSex(req.Sex).
- SetNotNilStarrole(req.Starrole).
- SetNotNilDontseeit(req.Dontseeit).
- SetNotNilDontseeme(req.Dontseeme).
- SetNotNilLag(req.Lag).
- SetNotNilGid(req.Gid).
- SetNotNilGname(req.Gname).
- SetNotNilV3(req.V3).
- SetNotNilCname(req.Cname).
- SetNotNilCarea(req.Carea).
- SetNotNilCage(req.Cage).
- SetNotNilCbirthday(req.Cbirthday).
- SetNotNilCbirtharea(req.Cbirtharea).
- SetNotNilCc(req.Cc).
- SetNotNilPhone(req.Phone).
- SetNotNilCidcardNo(req.CidcardNo).
- SetNotNilCtitle(req.Ctitle).
- Exec(l.ctx)
- if err != nil {
- return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
- }
- return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
- }
|