Skip to content

Commit bbf87be

Browse files
authored
fix:fix page bug (#199)
* fix:fix page bug * fix:modify issues
1 parent 342bb06 commit bbf87be

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

app/src/main/java/com/tinyengine/it/config/context/DefaultLoginUserContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
package com.tinyengine.it.config.context;
1313

1414
import com.tinyengine.it.common.context.LoginUserContext;
15+
import org.springframework.stereotype.Service;
1516

1617
/**
1718
* 默认的登录用户Context实现
1819
*/
20+
@Service
1921
public class DefaultLoginUserContext implements LoginUserContext {
2022
@Override
2123
public String getTenantId() {

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: 24 additions & 13 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
/**
@@ -369,18 +379,8 @@ public Result<Page> update(Page page) {
369379
}
370380
page.setDepth(depthInfo.getData() + 1);
371381
}
372-
// getFolder 获取父类信息
373-
Page parentInfo = pageMapper.queryPageById(page.getId());
374-
// 当更新参数中没有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);
382-
}
383-
return Result.failed(ExceptionEnum.CM002);
382+
// 如果深度发生改变,执行更新
383+
return performUpdate(page);
384384
}
385385

386386
/**
@@ -419,6 +419,17 @@ public boolean setAppHomePage(int appId, int pageId) {
419419
return result >= 1;
420420
}
421421

422+
// 执行页面更新操作
423+
private Result<Page> performUpdate(Page page) {
424+
int result = pageMapper.updatePageById(page);
425+
if (result < 1) {
426+
return Result.failed(ExceptionEnum.CM001);
427+
}
428+
429+
Page updatedPage = queryPageById(page.getId());
430+
return Result.success(updatedPage);
431+
}
432+
422433
/**
423434
* 获取文件夹深度
424435
*

0 commit comments

Comments
 (0)