mirror of
https://github.com/getrebuild/rebuild.git
synced 2024-09-20 23:45:55 +08:00
fix: delete approval entity
This commit is contained in:
parent
797e59253c
commit
0d5ee7472a
|
@ -192,10 +192,11 @@ public class Entity2Schema extends Field2Schema {
|
|||
throw new MetadataModificationException(Language.L("BuiltInNotDelete"));
|
||||
}
|
||||
|
||||
// 强制删除先删除主实体
|
||||
// 强制删除先删除明细实体
|
||||
|
||||
if (entity.getDetailEntity() != null) {
|
||||
if (force) {
|
||||
LOG.warn("Force drop detail entity : " + entity.getDetailEntity().getName());
|
||||
LOG.warn("Force drop detail entity first : " + entity.getDetailEntity().getName());
|
||||
boolean dropDetail = this.dropEntity(entity.getDetailEntity(), true);
|
||||
if (dropDetail) {
|
||||
entity = MetadataHelper.getEntity(entity.getEntityCode());
|
||||
|
@ -224,13 +225,7 @@ public class Entity2Schema extends Field2Schema {
|
|||
}
|
||||
}
|
||||
|
||||
String ddl = String.format("drop table if exists `%s`", entity.getPhysicalName());
|
||||
try {
|
||||
Application.getSqlExecutor().execute(ddl, 10 * 60);
|
||||
} catch (Throwable ex) {
|
||||
LOG.error("DDL ERROR : \n" + ddl, ex);
|
||||
return false;
|
||||
}
|
||||
// 先删配置
|
||||
|
||||
final ID sessionUser = UserContextHolder.getUser(true);
|
||||
if (sessionUser == null) UserContextHolder.setUser(user);
|
||||
|
@ -241,6 +236,16 @@ public class Entity2Schema extends Field2Schema {
|
|||
if (sessionUser == null) UserContextHolder.clear();
|
||||
}
|
||||
|
||||
// 最后删表
|
||||
|
||||
String ddl = String.format("drop table if exists `%s`", entity.getPhysicalName());
|
||||
try {
|
||||
Application.getSqlExecutor().execute(ddl, 10 * 60);
|
||||
} catch (Throwable ex) {
|
||||
LOG.error("DDL ERROR : \n" + ddl, ex);
|
||||
return false;
|
||||
}
|
||||
|
||||
MetadataHelper.getMetadataFactory().refresh(false);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@ See LICENSE and COMMERCIAL in the project root for license information.
|
|||
|
||||
package com.rebuild.core.service.approval;
|
||||
|
||||
import cn.devezhao.commons.ThrowableUtils;
|
||||
import cn.devezhao.persist4j.Entity;
|
||||
import cn.devezhao.persist4j.PersistManagerFactory;
|
||||
import cn.devezhao.persist4j.Record;
|
||||
import cn.devezhao.persist4j.engine.ID;
|
||||
import cn.devezhao.persist4j.exception.jdbc.SqlSyntaxException;
|
||||
import com.rebuild.core.Application;
|
||||
import com.rebuild.core.UserContextHolder;
|
||||
import com.rebuild.core.configuration.BaseConfigurationService;
|
||||
|
@ -60,7 +62,16 @@ public class RobotApprovalConfigService extends BaseConfigurationService impleme
|
|||
|
||||
@Override
|
||||
public int delete(ID recordId) {
|
||||
int inUsed = ApprovalHelper.checkInUsed(recordId);
|
||||
int inUsed = 0;
|
||||
try {
|
||||
inUsed = ApprovalHelper.checkInUsed(recordId);
|
||||
} catch (SqlSyntaxException sqlex) {
|
||||
// fix: 表已不存在
|
||||
if (!ThrowableUtils.getRootCause(sqlex).getLocalizedMessage().contains("doesn't exist")) {
|
||||
throw sqlex;
|
||||
}
|
||||
}
|
||||
|
||||
if (inUsed > 0) {
|
||||
throw new DataSpecificationException(Language.LF("DeleteApprovalInUsedOnX", inUsed));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue