Skip to content

Commit

Permalink
CrudBizModel增加对于missing状态的识别处理
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Jul 29, 2024
1 parent 305aba1 commit f1566f3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions nop-biz/src/main/java/io/nop/biz/crud/CrudBizModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ protected T doGetEntity(@Name("id") String id,

IEntityDao<T> dao = dao();
T entity = dao.getEntityById(id);
if (entity == null) {
if (entity == null || entity.orm_state().isMissing()) {
if (ignoreUnknown)
return null;
throw new UnknownEntityException(dao.getEntityName(), id);
Expand Down Expand Up @@ -1110,14 +1110,16 @@ public void tryDelete(@Name("id") String id, IServiceContext context) {
@Description("@i18n:biz.batchUpdate|批量修改")
@BizMutation
public void batchUpdate(@Name("ids") Set<String> ids, @Name("data") Map<String, Object> data,
@Optional @Name("ignoreUnknown") boolean ignoreUnknown,
IServiceContext context) {
if (CollectionHelper.isEmpty(ids) || CollectionHelper.isEmptyMap(data))
return;

dao().batchGetEntitiesByIds(ids);
for (String id : ids) {
List<T> entityList = ignoreUnknown ?
dao().tryBatchGetEntitiesByIds(ids) : dao().batchGetEntitiesByIds(ids);
for (T entity: entityList) {
Map<String, Object> copy = new LinkedHashMap<>(data);
copy.put(GraphQLConstants.PROP_ID, id);
copy.put(GraphQLConstants.PROP_ID, entity.orm_idString());
update(copy, context);
}
}
Expand Down

0 comments on commit f1566f3

Please sign in to comment.