Skip to content

Commit 5d244ba

Browse files
committed
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java into develop
2 parents b1e0f83 + 9735983 commit 5d244ba

File tree

11 files changed

+53
-28
lines changed

11 files changed

+53
-28
lines changed

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

Lines changed: 5 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() {
@@ -41,4 +43,7 @@ public int getAppId() {
4143
public int getPlatformId() {
4244
return 1;
4345
}
46+
47+
@Override
48+
public String getSiteId() { return "1"; }
4449
}

base/src/main/java/com/tinyengine/it/common/context/LoginUserContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ public interface LoginUserContext {
4545
* @return 设计器ID
4646
*/
4747
public int getPlatformId();
48+
49+
public String getSiteId();
4850
}

base/src/main/java/com/tinyengine/it/common/handler/MyMetaObjectHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public void insertFill(MetaObject metaObject) {
4242
this.setFieldValByName("lastUpdatedBy", loginUserContext.getLoginUserId(), metaObject);
4343
this.setFieldValByName("tenantId", loginUserContext.getTenantId(), metaObject);
4444
this.setFieldValByName("renterId", loginUserContext.getRenterId(), metaObject);
45+
this.setFieldValByName("siteId", loginUserContext.getSiteId(), metaObject);
46+
this.setFieldValByName("platformId", loginUserContext.getPlatformId(), metaObject);
4547
}
4648

4749
@Override

base/src/main/java/com/tinyengine/it/controller/BlockGroupController.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package com.tinyengine.it.controller;
1414

1515
import com.tinyengine.it.common.base.Result;
16+
import com.tinyengine.it.common.context.LoginUserContext;
1617
import com.tinyengine.it.common.exception.ExceptionEnum;
1718
import com.tinyengine.it.common.exception.ServiceException;
1819
import com.tinyengine.it.common.log.SystemControllerLog;
@@ -59,6 +60,8 @@ public class BlockGroupController {
5960
private BlockGroupService blockGroupService;
6061
@Autowired
6162
private BlockGroupMapper blockGroupMapper;
63+
@Autowired
64+
private LoginUserContext loginUserContext;
6265

6366
/**
6467
* 获取区块分组
@@ -111,8 +114,7 @@ public Result<List<BlockGroup>> getAllBlockGroups(
111114
)
112115
@SystemControllerLog(description = "创建区块分组")
113116
@PostMapping("/block-groups/create")
114-
public Result<List<BlockGroup>> createBlockGroups(@Valid @RequestBody BlockGroup blockGroup) {
115-
blockGroup.setPlatformId(1);
117+
public Result<BlockGroup> createBlockGroups(@Valid @RequestBody BlockGroup blockGroup) {
116118
return blockGroupService.createBlockGroup(blockGroup);
117119
}
118120

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
@@ -139,7 +139,17 @@ public class PageServiceImpl implements PageService {
139139
@Override
140140
@SystemServiceLog(description = "通过appId查询page所有数据实现方法")
141141
public List<Page> queryAllPage(Integer aid) {
142-
return pageMapper.queryPageByApp(aid);
142+
List<Page> pageList = pageMapper.queryPageByApp(aid);
143+
if(pageList == null){
144+
return null;
145+
}
146+
// 遍历数据给页面的ishome字段赋值
147+
for (Page page:pageList) {
148+
if(page.getIsPage()){
149+
addIsHome(page);
150+
}
151+
}
152+
return pageList;
143153
}
144154

145155
/**
@@ -370,18 +380,8 @@ public Result<Page> update(Page page) {
370380
}
371381
page.setDepth(depthInfo.getData() + 1);
372382
}
373-
// getFolder 获取父类信息
374-
Page parentInfo = pageMapper.queryPageById(page.getId());
375-
// 当更新参数中没有depth 或 depth没有发生改变时
376-
if (page.getDepth().equals(parentInfo.getDepth())) {
377-
int result = pageMapper.updatePageById(page);
378-
if (result < 1) {
379-
return Result.failed(ExceptionEnum.CM001);
380-
}
381-
Page pagesResult = queryPageById(page.getId());
382-
return Result.success(pagesResult);
383-
}
384-
return Result.failed(ExceptionEnum.CM002);
383+
// 如果深度发生改变,执行更新
384+
return performUpdate(page);
385385
}
386386

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

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

base/src/main/java/com/tinyengine/it/service/material/BlockGroupService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public interface BlockGroupService {
7171
* @param blockGroup the block group
7272
* @return the result
7373
*/
74-
Result<List<BlockGroup>> createBlockGroup(BlockGroup blockGroup);
74+
Result<BlockGroup> createBlockGroup(BlockGroup blockGroup);
7575

7676
/**
7777
* 根据ids或者appId获取区块信息

base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public Integer updateBlockGroupById(BlockGroup blockGroup) {
164164
* @return insert number
165165
*/
166166
@Override
167-
public Result<List<BlockGroup>> createBlockGroup(BlockGroup blockGroup) {
167+
public Result<BlockGroup> createBlockGroup(BlockGroup blockGroup) {
168168
List<BlockGroupDto> blockGroupsList = blockGroupMapper.queryBlockGroupByCondition(blockGroup);
169169
if (blockGroupsList.isEmpty()) {
170170
blockGroupMapper.createBlockGroup(blockGroup);
@@ -173,7 +173,7 @@ public Result<List<BlockGroup>> createBlockGroup(BlockGroup blockGroup) {
173173
}
174174
// 页面返回数据显示
175175
BlockGroup blockGroupResult = findBlockGroupById(blockGroup.getId());
176-
return Result.success(Collections.singletonList(blockGroupResult));
176+
return Result.success(blockGroupResult);
177177
}
178178

179179
/**
@@ -213,7 +213,7 @@ public List<BlockGroup> getBlockGroupByIdsOrAppId(List<Integer> ids, Integer app
213213
for (Block block : blockGroupTemp.getBlocks()) {
214214
BlockCarriersRelation queryParam = new BlockCarriersRelation();
215215
queryParam.setBlockId(block.getId());
216-
queryParam.setHostId(blockGroup.getId());
216+
queryParam.setHostId(blockGroupTemp.getId());
217217
queryParam.setHostType(Enums.BlockGroup.BLOCK_GROUP.getValue());
218218
List<BlockCarriersRelation> blockCarriersRelations = blockCarriersRelationMapper.queryBlockCarriersRelationByCondition(queryParam);
219219
if (blockCarriersRelations.isEmpty()) {

base/src/test/java/com/tinyengine/it/common/handler/MockUserContext.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ public int getAppId() {
4141
public int getPlatformId() {
4242
return 1;
4343
}
44+
45+
@Override
46+
public String getSiteId() { return "1"; }
4447
}

base/src/test/java/com/tinyengine/it/controller/BlockGroupControllerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ void testGetAllBlockGroups() {
6363

6464
@Test
6565
void testCreateBlockGroups() {
66-
when(blockGroupService.createBlockGroup(any(BlockGroup.class))).thenReturn(new Result<List<BlockGroup>>());
66+
when(blockGroupService.createBlockGroup(any(BlockGroup.class))).thenReturn(new Result<BlockGroup>());
6767

68-
Result<List<BlockGroup>> result = blockGroupController.createBlockGroups(new BlockGroup());
69-
Assertions.assertEquals(new Result<List<BlockGroup>>(), result);
68+
Result<BlockGroup> result = blockGroupController.createBlockGroups(new BlockGroup());
69+
Assertions.assertEquals(new Result<BlockGroup>(), result);
7070
}
7171

7272
@Test

0 commit comments

Comments
 (0)