Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ public enum ExceptionEnum implements IBaseError {
/**
* Cm 324 exception enum.
*/
CM324("CM324","文件名或路径无效"),
CM324("CM324", "文件名或路径无效"),

/**
* Cm 325 exception enum.
*/
CM325("CM325","文件校验失败");
CM325("CM325", "文件校验失败");

/**
* 错误码
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class SecurityFileCheckUtil {
public static boolean checkPathHasCrossDir(String dirOrFileName) {
if (!dirOrFileName.contains("../") && !dirOrFileName.contains("/..")) {
if (!dirOrFileName.contains("..\\") && !dirOrFileName.contains("\\..")) {
return dirOrFileName.contains("./") || dirOrFileName.contains(".\\.\\")
return dirOrFileName.contains("./") || dirOrFileName.contains(".\\.\\")
|| dirOrFileName.contains("%00");
} else {
return true;
Expand Down
2 changes: 2 additions & 0 deletions base/src/main/java/com/tinyengine/it/common/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ public static Result<JsonFile> parseJsonFileStream(MultipartFile file) {
log.info("Successfully parsed JSON file: {}", fileName);
return Result.success(jsonFile);
}

/**
* 去除文件BOM字符
*
Expand All @@ -412,6 +413,7 @@ public static String removeBOM(String input) {
}
return input;
}

/**
* 校验文件流合法性
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static Map<String, AiChatConfigData> getAiChatConfig(String model, String
String ernieBotAccessToken = Enums.FoundationModel.ERNIBOT_TURBO.getValue().equals(model) ? token : null;
config.put(Enums.FoundationModel.ERNIBOT_TURBO.getValue(), new AiChatConfigData(
"https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro?access_token="
+ ernieBotAccessToken, createCommonRequestOption(), ernieBotHeaders, "baidu"));
+ ernieBotAccessToken, createCommonRequestOption(), ernieBotHeaders, "baidu"));
return config;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public Result<BlockGroup> createBlockGroups(@Valid @RequestBody BlockGroup block
}, responses = {
@ApiResponse(responseCode = "200", description = "返回信息",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = BlockGroup.class))),
@ApiResponse(responseCode = "400", description = "请求失败")
@ApiResponse(responseCode = "400", description = "请求失败")
})
@SystemControllerLog(description = "修改区块分组")
@PostMapping("/block-groups/update/{id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public class CanvasController {
* @return CanvasDto
*/
@Operation(summary = "区块及页面锁", description = "区块及页面锁", parameters = {
@Parameter(name = "id", description = "页面id"),
@Parameter(name = "state", description = "状态"),
@Parameter(name = "type", description = "区分是页面还是区块")
@Parameter(name = "id", description = "页面id"),
@Parameter(name = "state", description = "状态"),
@Parameter(name = "type", description = "区分是页面还是区块")
}, responses = {
@ApiResponse(responseCode = "200", description = "返回信息",
content = @Content(mediaType = "application/json", schema = @Schema())),
@ApiResponse(responseCode = "400", description = "请求失败")}
@ApiResponse(responseCode = "200", description = "返回信息",
content = @Content(mediaType = "application/json", schema = @Schema())),
@ApiResponse(responseCode = "400", description = "请求失败")}
)
@SystemControllerLog(description = "区块及页面锁")
@GetMapping("apps/canvas/lock")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

import java.util.List;


/**
* <p>
* 前端控制器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class I18nEntryController {
})
@SystemControllerLog(description = "通过app获取国际化词条列表")
@GetMapping("/i18n/entries")
public Result<I18nEntryListResult> getI18nEntriesByApp( @RequestParam(value = "host", required = false) Integer host,
public Result<I18nEntryListResult> getI18nEntriesByApp(@RequestParam(value = "host", required = false) Integer host,
@RequestParam(value = "host_type", required = false) String hostType) {
I18nEntryListResult i18nEntriesList = i18nEntryService.findI18nEntryByApp(host, hostType);
return Result.success(i18nEntriesList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public Result<IPage<PublishedPageVo>> getLatestPublishPage(@RequestBody PageQuer
@Parameter(name = "id", description = "页面历史主键id")
}, responses = {
@ApiResponse(responseCode = "200", description = "返回信息",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = PageHistory.class))),
content = @Content(mediaType = "application/json", schema = @Schema(implementation = PageHistory.class))),
@ApiResponse(responseCode = "400", description = "请求失败")
})
@SystemControllerLog(description = "获取页面历史记录明细")
Expand Down Expand Up @@ -182,9 +182,8 @@ public Result<PageHistory> deletePageHistory(@PathVariable Integer historyId) {
@Parameter(name = "app", description = "appId")
}, responses = {
@ApiResponse(responseCode = "200", description = "返回信息",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = PageHistory.class))),
@ApiResponse(responseCode = "400", description = "请求失败")
content = @Content(mediaType = "application/json", schema = @Schema(implementation = PageHistory.class))),
@ApiResponse(responseCode = "400", description = "请求失败")
})
@SystemControllerLog(description = "根据名称查询页面历史记录")
@GetMapping("/pages/histories/find")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tinyengine.it.common.base.BaseEntity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,13 @@ public interface PageHistoryService {
* @return page history
*/
IPage<PublishedPageVo> findLatestPublishPage(PageQueryVo<PublishedPageVo> pageQueryVo);

/**
* 查询页面历史的最大版本号
*
* @param app the app
* @param name the name
* @return 页面历史的最大版本号
*/
String selectMaxVersionOfPageHistory(String name, Integer app);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Result<CanvasDto> lockCanvas(Integer id, String state, String type) {
String occupier;
// needTODO 先试用mock数据,后续添加登录及权限后从session获取,
User user = userMapper.queryUserById(loginUserContext.getLoginUserId());
if(user == null) {
if (user == null) {
user = new User();
user.setId(loginUserContext.getLoginUserId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

Expand All @@ -36,6 +37,8 @@
@Service
@Slf4j
public class PageHistoryServiceImpl implements PageHistoryService {
private static final String DEFAULT_PAGE_HISTORY_VERSION = "0";

@Autowired
private PageHistoryMapper pageHistoryMapper;

Expand Down Expand Up @@ -123,4 +126,21 @@ public IPage<PublishedPageVo> findLatestPublishPage(PageQueryVo<PublishedPageVo>
PublishedPageVo queryData = pageQueryVo.getData();
return pageHistoryMapper.findLatestPublishPage(pageQueryVo.getPage(), queryData);
}

/**
* 查询页面历史的最大版本号
*
* @param app the app
* @param name the name
* @return 页面历史的最大版本号
*/
@Override
public String selectMaxVersionOfPageHistory(String name, Integer app) {
List<PageHistory> pageHistories = pageHistoryMapper.queryPageHistoryByName(name, app);
if (CollectionUtils.isEmpty(pageHistories)) {
return DEFAULT_PAGE_HISTORY_VERSION;
}
PageHistory lastPageHistory = pageHistories.get(pageHistories.size() - 1);
return lastPageHistory.getVersion();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

Expand Down Expand Up @@ -285,7 +284,7 @@ public Result<Page> createPage(Page page) {
pageHistory.setId(null);
pageHistory.setMessage(page.getMessage());
pageHistory.setIsPublished(false);
pageHistory.setVersion("draft");
pageHistory.setVersion("0");
int resultPageHistory = pageHistoryService.createPageHistory(pageHistory);
if (resultPageHistory < 1) {
return Result.failed(ExceptionEnum.CM001);
Expand Down Expand Up @@ -379,7 +378,9 @@ public Result<Page> updatePage(Page page) {
pageHistory.setPage(pageTemp.getId());
pageHistory.setId(null);
pageHistory.setIsPublished(false);
pageHistory.setVersion("draft");
String maxVersion =
pageHistoryService.selectMaxVersionOfPageHistory(pageHistory.getName(), pageHistory.getApp());
pageHistory.setVersion(maxVersion);
int resultPageHistory = pageHistoryService.createPageHistory(pageHistory);
if (resultPageHistory < 1) {
return Result.failed(ExceptionEnum.CM001);
Expand Down Expand Up @@ -541,7 +542,7 @@ public Result<Page> checkDelete(Integer id) {
// needTODO 从缓存中获取的user信息
User user = userService.queryUserById(loginUserContext.getLoginUserId());
// 逻辑不对,如果没有同步用户数据,就用登录用户的
if(user == null) {
if (user == null) {
user = new User();
user.setId(loginUserContext.getLoginUserId());
user.setUsername(loginUserContext.getLoginUserId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import lombok.extern.slf4j.Slf4j;

import org.apache.ibatis.annotations.Param;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
Expand Down Expand Up @@ -221,7 +220,7 @@ public Result<BundleResultDto> parseBundle(BundleDto bundleDto) {
if (components == null || components.isEmpty()) {
return Result.failed(ExceptionEnum.CM009);
}
List<Component> componentList = buildComponentList(bundleDto,components,snippets);
List<Component> componentList = buildComponentList(bundleDto, components, snippets);
List<Map<String, Object>> packages = bundleDto.getMaterials().getPackages();

BundleResultDto bundleList = new BundleResultDto();
Expand Down Expand Up @@ -293,7 +292,7 @@ public Result<FileResult> bulkCreate(List<Component> componentList) {
List<Component> queryComponent = findComponentByCondition(componentParam);
// 查询组件库id
String packageName = null;
if (component.getNpm() != null &&component.getNpm().get("package") != null) {
if (component.getNpm() != null && component.getNpm().get("package") != null) {
packageName = String.valueOf(component.getNpm().get("package"));
}
if (packageName != null && !packageName.isEmpty()) {
Expand Down Expand Up @@ -355,7 +354,7 @@ private String toPascalCase(String input) {
return result.toString();
}

private List<Component> buildComponentList(BundleDto bundleDto, List<Map<String,Object>> components,
private List<Component> buildComponentList(BundleDto bundleDto, List<Map<String, Object>> components,
List<Child> snippets) {
List<Component> componentList = new ArrayList<>();
for (Map<String, Object> comp : components) {
Expand Down
1 change: 1 addition & 0 deletions base/src/main/resources/mappers/PageHistoryMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
WHERE name like concat('%',#{name},'%')
and app_id = #{app}
and is_published = 1
ORDER BY last_updated_time ASC
</select>

<!-- 根据主键id删除表t_page_history数据 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,6 @@ void testUpdateBlocks() {
Result<BlockDto> result = blockController.updateBlocks(blockParam, Integer.valueOf(0), Integer.valueOf(1));
Assertions.assertEquals(returnData, result.getData());
verify(blockService).updateBlockById(
argThat(param -> param.getName().equals("Updated Block") && param.getId().equals(0)), eq(1));
argThat(param -> param.getName().equals("Updated Block") && param.getId().equals(0)), eq(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void testGetAllBlockGroups() {
Arrays.asList(mockData));

Result<List<BlockGroup>> result = blockGroupController.getAllBlockGroups(
Arrays.<Integer>asList(Integer.valueOf(0)), Integer.valueOf(0), "block");
Arrays.<Integer>asList(Integer.valueOf(0)), Integer.valueOf(0), "block");
Assertions.assertEquals(mockData, result.getData().get(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.junit.jupiter.api.Test;
import org.mockito.Answers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.springframework.http.HttpMethod;
Expand Down