34 lines
787 B
Go
34 lines
787 B
Go
|
|
package crm
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"apps/backend/internal/logic/crmmap"
|
||
|
|
"apps/backend/internal/svc"
|
||
|
|
"apps/backend/internal/types"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
type UnmergeContactLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewUnmergeContactLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UnmergeContactLogic {
|
||
|
|
return &UnmergeContactLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *UnmergeContactLogic) UnmergeContact(req *types.UnmergeContactReq) (*types.ContactPublic, error) {
|
||
|
|
uid, err := ownerUID(l.ctx)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
c, err := l.svcCtx.Crm.Unmerge(l.ctx, uid, req.Id, req.MergedContactId)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return crmmap.Contact(c), nil
|
||
|
|
}
|