Skip to content

Commit ab39d61

Browse files
committed
fix:fix page bug
1 parent 342bb06 commit ab39d61

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

base/src/main/java/com/tinyengine/it/model/entity/App.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ public class App extends BaseEntity {
8686

8787
@Schema(name = "config", description = "*设计预留字段*")
8888
@TableField(typeHandler = MapTypeHandler.class)
89-
private Map<String, Object> config = new HashMap<>();
89+
private Map<String, Object> config;
9090

9191
@Schema(name = "constants", description = "*设计预留字段*")
9292
private String constants;
9393

9494
@Schema(name = "dataHandler", description = "数据源的拦截器")
9595
@TableField(typeHandler = MapTypeHandler.class)
96-
private Map<String, Object> dataHandler = new HashMap<>();
96+
private Map<String, Object> dataHandler;
9797

9898
@Schema(name = "description", description = "描述")
9999
private String description;
@@ -134,14 +134,14 @@ public class App extends BaseEntity {
134134
@Schema(name = "globalState", description = "应用全局状态")
135135
@JsonProperty("global_state")
136136
@TableField(typeHandler = ListTypeHandler.class)
137-
private List<Map<String, Object>> globalState = new ArrayList<>();
137+
private List<Map<String, Object>> globalState;
138138

139139
@Schema(name = "defaultLang", description = "默认语言")
140140
private String defaultLang;
141141

142142
@Schema(name = "extendConfig", description = "应用扩展config")
143143
@TableField(typeHandler = MapTypeHandler.class)
144-
private Map<String, Object> extendConfig = new HashMap<>();
144+
private Map<String, Object> extendConfig;
145145

146146
@Schema(name = "dataHash", description = "应用内容哈希值")
147147
private String dataHash;
@@ -152,5 +152,5 @@ public class App extends BaseEntity {
152152
@Schema(name = "dataSourceGlobal", description = "数据源全局配置")
153153
@JsonProperty("data_source_global")
154154
@TableField(typeHandler = MapTypeHandler.class)
155-
private Map<String, Object> dataSourceGlobal = new HashMap<>();
155+
private Map<String, Object> dataSourceGlobal;
156156
}

base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,17 @@ public class PageServiceImpl implements PageService {
138138
@Override
139139
@SystemServiceLog(description = "通过appId查询page所有数据实现方法")
140140
public List<Page> queryAllPage(Integer aid) {
141-
return pageMapper.queryPageByApp(aid);
141+
List<Page> pageList = pageMapper.queryPageByApp(aid);
142+
if(pageList == null){
143+
return null;
144+
}
145+
// 遍历数据给页面的ishome字段赋值
146+
for (Page page:pageList) {
147+
if(page.getIsPage()){
148+
addIsHome(page);
149+
}
150+
}
151+
return pageList;
142152
}
143153

144154
/**
@@ -372,15 +382,11 @@ public Result<Page> update(Page page) {
372382
// getFolder 获取父类信息
373383
Page parentInfo = pageMapper.queryPageById(page.getId());
374384
// 当更新参数中没有depth 或 depth没有发生改变时
375-
if (page.getDepth().equals(parentInfo.getDepth())) {
376-
int result = pageMapper.updatePageById(page);
377-
if (result < 1) {
378-
return Result.failed(ExceptionEnum.CM001);
379-
}
380-
Page pagesResult = queryPageById(page.getId());
381-
return Result.success(pagesResult);
385+
if (shouldUpdateDepth(page, parentInfo)) {
386+
return performUpdate(page);
382387
}
383-
return Result.failed(ExceptionEnum.CM002);
388+
// 如果深度发生改变,执行更新
389+
return performUpdate(page);
384390
}
385391

386392
/**
@@ -419,6 +425,22 @@ public boolean setAppHomePage(int appId, int pageId) {
419425
return result >= 1;
420426
}
421427

428+
// 执行页面更新操作
429+
private Result<Page> performUpdate(Page page) {
430+
int result = pageMapper.updatePageById(page);
431+
if (result < 1) {
432+
return Result.failed(ExceptionEnum.CM001);
433+
}
434+
435+
Page updatedPage = queryPageById(page.getId());
436+
return Result.success(updatedPage);
437+
}
438+
439+
// 判断是否需要更新深度
440+
private boolean shouldUpdateDepth(Page page, Page parentInfo) {
441+
return page.getDepth() == 0 || page.getDepth().equals(parentInfo.getDepth());
442+
}
443+
422444
/**
423445
* 获取文件夹深度
424446
*

0 commit comments

Comments
 (0)