|
@@ -59,6 +59,7 @@ func (l *UpdateLabelRelationshipsLogic) UpdateLabelRelationships(req *types.Labe
|
|
// 如果 req.UpdateType 为空,或 req.UpdateType 的值为 “all” 时
|
|
// 如果 req.UpdateType 为空,或 req.UpdateType 的值为 “all” 时
|
|
if req.UpdateType == nil || *req.UpdateType == "all" {
|
|
if req.UpdateType == nil || *req.UpdateType == "all" {
|
|
// 删除需要移除的标签关系
|
|
// 删除需要移除的标签关系
|
|
|
|
+ l.Logger.Errorf("------------------------removeLabelIds--------------------------- %+v\n", removeLabelIds)
|
|
for _, id := range removeLabelIds {
|
|
for _, id := range removeLabelIds {
|
|
_, err := tx.LabelRelationship.
|
|
_, err := tx.LabelRelationship.
|
|
Delete().
|
|
Delete().
|
|
@@ -75,6 +76,7 @@ func (l *UpdateLabelRelationshipsLogic) UpdateLabelRelationships(req *types.Labe
|
|
}
|
|
}
|
|
|
|
|
|
// 创建需要新增的标签关系
|
|
// 创建需要新增的标签关系
|
|
|
|
+ l.Logger.Errorf("------------------------addLabelIds--------------------------- %+v\n", addLabelIds)
|
|
for _, id := range addLabelIds {
|
|
for _, id := range addLabelIds {
|
|
_, _ = tx.LabelRelationship.Create().
|
|
_, _ = tx.LabelRelationship.Create().
|
|
SetLabelID(id).
|
|
SetLabelID(id).
|
|
@@ -259,13 +261,14 @@ func (l *UpdateLabelRelationshipsLogic) AddLabelRelationships(sopStages map[uint
|
|
// 遍历 delLabelIds,找出在 currentLabelIds 中的元素
|
|
// 遍历 delLabelIds,找出在 currentLabelIds 中的元素
|
|
for _, id := range stage.ActionLabelDel {
|
|
for _, id := range stage.ActionLabelDel {
|
|
if _, exists := currentLabelIdSet[id]; exists {
|
|
if _, exists := currentLabelIdSet[id]; exists {
|
|
- remLabelIds = append(newLabelIds, id)
|
|
|
|
|
|
+ remLabelIds = append(remLabelIds, id)
|
|
delete(currentLabelIdSet, id)
|
|
delete(currentLabelIdSet, id)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ l.Logger.Errorf("------------------------stage.ActionLabelDel--------------------------- %+v\n", stage.ActionLabelDel)
|
|
|
|
+ l.Logger.Errorf("------------------------remLabelIds--------------------------- %+v\n", stage.ActionLabelDel)
|
|
if len(remLabelIds) > 0 {
|
|
if len(remLabelIds) > 0 {
|
|
- _, err = tx.LabelRelationship.Delete().Where(labelrelationship.IDIn(remLabelIds...), labelrelationship.ContactIDEQ(contact.ID), labelrelationship.OrganizationIDEQ(organizationId)).Exec(l.ctx)
|
|
|
|
|
|
+ _, err = tx.LabelRelationship.Delete().Where(labelrelationship.LabelIDIn(remLabelIds...), labelrelationship.ContactIDEQ(contact.ID), labelrelationship.OrganizationIDEQ(organizationId)).Exec(l.ctx)
|
|
if err != nil {
|
|
if err != nil {
|
|
//_ = tx.Rollback()
|
|
//_ = tx.Rollback()
|
|
return dberrorhandler.DefaultEntError(l.Logger, err, nil)
|
|
return dberrorhandler.DefaultEntError(l.Logger, err, nil)
|