Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b97583e
fix: update page history bug
lu-yg Dec 26, 2024
d30877c
fix: format code and fix style issue
lu-yg Jan 7, 2025
33316bf
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 7, 2025
7fc6507
fix: modify page histiry entity
lu-yg Jan 7, 2025
64be7b4
Merge branch 'opentiny:develop' into develop
lu-yg Jan 9, 2025
24474b8
feat: add code submission rules
lu-yg Jan 9, 2025
9745b66
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 9, 2025
239c624
Merge branch 'opentiny:develop' into develop
lu-yg Jan 9, 2025
b77f2f4
fix: modify app schema for test
lu-yg Jan 9, 2025
feeb8f7
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 9, 2025
7d52937
fix: modify block group
lu-yg Jan 22, 2025
6559bec
fix: modify t_i18n_entry u_idx_i18n_entity
lu-yg Jan 22, 2025
2a7fc44
Merge branch 'opentiny:develop' into develop
lu-yg Jan 22, 2025
656a4a1
fix: modify t_i18n_entry u_idx_i18n_entity
lu-yg Jan 22, 2025
9de10c5
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 22, 2025
e9aa592
fix: modify block update api
lu-yg Jan 23, 2025
aff95bb
Merge branch 'opentiny:develop' into develop
lu-yg Jan 23, 2025
02607e4
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 23, 2025
ed7483d
fix: Modify code format
lu-yg Jan 23, 2025
48267d6
fix: Modify code format
lu-yg Jan 23, 2025
cabb309
fix: Modify code format
lu-yg Jan 23, 2025
83cb48a
fix: Modify code format
lu-yg Jan 24, 2025
486944b
fix: Modify code format
lu-yg Jan 24, 2025
751f331
Merge branch 'opentiny:develop' into develop
lu-yg Jan 26, 2025
48645e1
fix: modify block group api
lu-yg Jan 26, 2025
d2f2406
fix: modify block group mapper
lu-yg Jan 26, 2025
e24d0ec
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 26, 2025
ee8219f
fix: modify workflows
lu-yg Jan 26, 2025
efad29b
fix: Update checkstyle.yml
lu-yg Jan 26, 2025
6868add
fix: modify workflows
lu-yg Jan 26, 2025
2e131ff
fix: Modify block create and update api
lu-yg Jan 27, 2025
9c1225a
Merge branch 'opentiny:develop' into develop
lu-yg Jan 27, 2025
8cc8ca5
fix: Modify code format
lu-yg Jan 27, 2025
4ba0818
fix: Modify code format
lu-yg Jan 27, 2025
6d978f1
fix: Modify block group
lu-yg Feb 6, 2025
b3f35a0
fix: Modify block group
lu-yg Feb 6, 2025
9717200
fix: Modify block group
lu-yg Feb 6, 2025
e757b29
fix: Modify block group
lu-yg Feb 6, 2025
7d90c86
fix: Modify block group api
lu-yg Feb 13, 2025
d6856ba
Merge branch 'opentiny:develop' into develop
lu-yg Feb 13, 2025
8a89475
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Feb 13, 2025
baa4eeb
fix: Modify block group api
lu-yg Feb 13, 2025
654da8b
fix: Modify block group api
lu-yg Feb 13, 2025
a230c24
feat: add code check
lu-yg Feb 27, 2025
6966946
Merge branch 'opentiny:develop' into develop
lu-yg Feb 27, 2025
d503c96
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Feb 27, 2025
7f9b378
feat: add code check
lu-yg Feb 27, 2025
2bdf54c
feat: add code check
lu-yg Feb 27, 2025
bef4adc
Merge branch 'opentiny:develop' into develop
lu-yg Feb 28, 2025
88dec60
feat: add code check
lu-yg Feb 28, 2025
63efa3c
Merge branch 'opentiny:develop' into develop
lu-yg Feb 28, 2025
f05a3ef
fix: Fix code check
lu-yg Feb 28, 2025
dbc910c
Merge branch 'opentiny:develop' into develop
lu-yg Mar 6, 2025
8a4041c
fix: Cross domain configuration
lu-yg Mar 6, 2025
57fd35a
fix: Cross domain configuration
lu-yg Mar 6, 2025
bff62cc
fix: i18n file upload
lu-yg Mar 7, 2025
ededae7
fix: i18n file upload
lu-yg Mar 7, 2025
1fa284b
Merge branch 'opentiny:develop' into develop
lu-yg Mar 20, 2025
7f17fb7
fix: page update api
lu-yg Mar 20, 2025
934130f
fix: page update api
lu-yg Mar 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public enum ExceptionEnum implements IBaseError {
/**
* Cm 301 exception enum.
*/
CM301("CM301", "默认页面不能删除和修改"),
CM301("CM301", "默认页面修改失败"),
/**
* Cm 302 exception enum.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package com.tinyengine.it.service.app.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.tinyengine.it.common.base.Result;
import com.tinyengine.it.common.enums.Enums;
import com.tinyengine.it.common.exception.ExceptionEnum;
Expand Down Expand Up @@ -190,9 +191,6 @@ public Result<Page> delPage(Integer id) {
// 如果是文件夹,调folder service的处理逻辑
return del(id);
}
// 保护默认页面
protectDefaultPage(pages, id);

// 删除
Page pageResult = pageMapper.queryPageById(id);
int result = pageMapper.deletePageById(id);
Expand Down Expand Up @@ -317,9 +315,11 @@ public Result<Page> updatePage(Page page) {
return Result.failed("isHome parameter error");
}
int appId = pageTemp.getApp();
// 保护默认页面
protectDefaultPage(pageTemp, appId);

// 默认页面
boolean isUpdate = protectDefaultPage(pageTemp);
if (!isUpdate) {
return Result.failed(ExceptionEnum.CM301);
}
// 针对参数中isHome的传值进行isHome字段的判定
if (page.getIsHome()) {
setAppHomePage(appId, id);
Expand Down Expand Up @@ -531,18 +531,74 @@ public boolean iCanDoIt(User occupier, User user) {

/**
* 保护默认页面
*
* @param pages the pages
* @param id the id
*/
public void protectDefaultPage(Page pages, Integer id) {
if (pages.getIsDefault()) {
// 查询是否是模板应用,不是的话不能删除或修改
App app = appMapper.queryAppById(id);
if (app.getTemplateType() == null) {
Result.failed(ExceptionEnum.CM310.getResultCode());
* @param page the pages
* @return boolean
*/
public boolean protectDefaultPage(Page page) {
String id = page.getParentId();
if("0".equals(id)){
return true;
}
String parentId = this.getParentPage(id);
int subPageId = this.getSubPage(parentId);
if (subPageId == 0) {
return true;
}

UpdateWrapper<Page> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", subPageId)
.set("is_default", false);
int result = pageMapper.update(null, updateWrapper);

if (result < 1) {
return false;
}
return true;
}

/**
* 查询父页面
* @param parentId the parentId
* @return parentId the parentId
*/
private String getParentPage(String parentId) {

Page page = pageMapper.queryPageById(Integer.parseInt(parentId));
if (page.getIsPage() || "0".equals(page.getParentId())) {
return parentId;
}
return this.getParentPage(page.getParentId());
}

/**
* 查询默认子页面
* @param parentId the parentId
* @return subPageId the subPageId
*/
private int getSubPage(String parentId) {
// 基础的检查
if ("0".equals(parentId)) {
return 0; // 0 表示没有父页面
}
// 查找子页面列表
Page pageParam = new Page();
pageParam.setParentId(parentId);
List<Page> pageList = pageMapper.queryPageByCondition(pageParam);

// 遍历页面列表,查找默认的子页面
for (Page page : pageList) {
if (page.getIsPage() && page.getIsDefault()) {
return page.getId(); // 找到默认子页面,返回其ID
} else if (!page.getIsPage()) {
// 如果不是页面,递归查找子页面
int subPageId = getSubPage(String.valueOf(page.getId()));
if (subPageId > 0) {
return subPageId; // 如果找到了子页面ID,返回
}
}
}

return 0; // 如果没有找到符合条件的子页面,返回null
}

/**
Expand Down
3 changes: 1 addition & 2 deletions base/src/main/resources/mappers/BlockGroupMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@
<set>
<include refid="BlockGroupSetColumns"/>
</set>
WHERE
id=#{id}
WHERE id = #{id}
</update>

<!-- 新增表t_block_group数据 -->
Expand Down
85 changes: 42 additions & 43 deletions base/src/main/resources/mappers/PageMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -305,55 +305,54 @@
<set>
<include refid="PageSetColumns"/>
</set>
WHERE
id=#{id}
WHERE id = #{id}
</update>

<!-- 新增表t_page数据 -->
<insert id="createPage" useGeneratedKeys="true" keyProperty="id"
parameterType="com.tinyengine.it.model.entity.Page">
INSERT INTO t_page ( id
, name
, app_id
, route
, page_content
, is_body
, parent_id
, `group`
, `depth`
, is_page
, occupier_by
, is_default
, content_blocks
, latest_version
, latest_history_id
, created_by
, last_updated_by
, created_time
, last_updated_time
, tenant_id, renter_id
, site_id)
, name
, app_id
, route
, page_content
, is_body
, parent_id
, `group`
, `depth`
, is_page
, occupier_by
, is_default
, content_blocks
, latest_version
, latest_history_id
, created_by
, last_updated_by
, created_time
, last_updated_time
, tenant_id, renter_id
, site_id)
VALUES ( #{id}
, #{name}
, #{app}
, #{route}
, #{pageContent}
, #{isBody}
, #{parentId}
, #{group}
, #{depth}
, #{isPage}
, #{occupierBy}
, #{isDefault}
, #{contentBlocks}
, #{latestVersion}
, #{latestHistoryId}
, #{createdBy}
, #{lastUpdatedBy}
, #{createdTime}
, #{lastUpdatedTime}
, #{tenantId}
, #{renterId}
, #{siteId})
, #{name}
, #{app}
, #{route}
, #{pageContent}
, #{isBody}
, #{parentId}
, #{group}
, #{depth}
, #{isPage}
, #{occupierBy}
, #{isDefault}
, #{contentBlocks}
, #{latestVersion}
, #{latestHistoryId}
, #{createdBy}
, #{lastUpdatedBy}
, #{createdTime}
, #{lastUpdatedTime}
, #{tenantId}
, #{renterId}
, #{siteId})
</insert>
</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,5 @@ void testExecuteChatRequest() {
Map<String, Object> returnData = aiChatClient.executeChatRequest(param);
Assertions.assertNull(returnData.get("data"));
}

@Test
void testInvalidTokenExecuteChatRequest() {
HashMap<String, String> foundationModel = new HashMap<>();
foundationModel.put("model", "gpt-3.5-turbo");
foundationModel.put("token","你好");
ArrayList<AiMessages> messages = new ArrayList<>();
AiMessages aiMessages = new AiMessages();
aiMessages.setContent("dddd编码时遵从以下几条要求aaa");
messages.add(aiMessages);
AiParam param = new AiParam(foundationModel,Arrays.asList(aiMessages));
Map<String, Object> returnData = aiChatClient.executeChatRequest(param);
Assertions.assertEquals("Invalid token format",returnData.get("error_message"));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ void testUpdatePage() {
int pageId = 123;
param.setId(pageId);
param.setIsHome(false);
param.setParentId("1");
param.setParentId("0");
param.setOccupierBy("555");

Page queryPage = new Page();
queryPage.setApp(222);
queryPage.setIsPage(false);
queryPage.setIsHome(false);
queryPage.setParentId("1");
queryPage.setParentId("0");
queryPage.setIsDefault(false);
when(pageMapper.queryPageById(pageId)).thenReturn(queryPage);

Expand Down
Loading