...
|
...
|
@@ -114,10 +114,10 @@ func DeleteObjectTable(ctx context.Context, svcCtx *svc.ServiceContext, conn tra |
|
|
return err
|
|
|
}
|
|
|
//是否远程已删除
|
|
|
objectTable, err := svcCtx.ObjectTableRepository.FindOne(ctx, conn, sourceId)
|
|
|
objectTable, err := svcCtx.ObjectTableRepository.FindOneByTableId(ctx, conn, sourceId)
|
|
|
if err == nil && objectTable.Id > 0 && objectTable.RemoteDeleted == 1 {
|
|
|
//删除表
|
|
|
_, err = svcCtx.ObjectTableRepository.Delete(ctx, conn, &domain.ObjectTable{Id: sourceId})
|
|
|
_, err = svcCtx.ObjectTableRepository.Delete(ctx, conn, &domain.ObjectTable{Id: sourceId, TableType: objectTable.TableType})
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
...
|
...
|
@@ -126,6 +126,48 @@ func DeleteObjectTable(ctx context.Context, svcCtx *svc.ServiceContext, conn tra |
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
//删除分组
|
|
|
err = DeleteObjectGroup(ctx, svcCtx, conn, objectTable.CompanyId, objectTable.ParentId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// DeleteObjectGroup 删除分组
|
|
|
func DeleteObjectGroup(ctx context.Context, svcCtx *svc.ServiceContext, conn transaction.Conn, companyId int64, parentId int) error {
|
|
|
//分组下是否有数据
|
|
|
_, list, err := svcCtx.ObjectTableRepository.Find(ctx, conn, domain.NewQueryOptions().WithKV("companyId", companyId).WithKV("parentId", parentId))
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
if len(list) > 0 {
|
|
|
return nil
|
|
|
}
|
|
|
_, items, err := svcCtx.ObjectTableRepository.Find(
|
|
|
ctx, conn,
|
|
|
domain.NewQueryOptions().
|
|
|
WithKV("companyId", companyId).
|
|
|
WithKV("id", parentId).
|
|
|
WithKV("flag", "Group"),
|
|
|
)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
if len(items) > 0 {
|
|
|
for _, item := range items {
|
|
|
//删除分组
|
|
|
_, err = svcCtx.ObjectTableRepository.Delete(ctx, conn, item)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
//递归删除上级分组
|
|
|
err = DeleteObjectGroup(ctx, svcCtx, conn, companyId, item.ParentId)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return nil
|
...
|
...
|
|