Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
@@ -0,0 +1,44 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*/

package com.tinyengine.it.config.context;

import com.tinyengine.it.common.context.LoginUserContext;

/**
* 默认的登录用户Context实现
*/
public class DefaultLoginUserContext implements LoginUserContext {
@Override
public String getTenantId() {
return "1";
}

@Override
public String getLoginUserId() {
return "1";
}

@Override
public String getRenterId() {
return "1";
}

@Override
public int getAppId() {
return 1;
}

@Override
public int getPlatformId() {
return 1;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
* <p>
*
* Use of this source code is governed by an MIT-style license.
* <p>
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

package com.tinyengine.it.common.base;
Expand All @@ -23,6 +24,7 @@ public class PageQueryVo<T> {
* 最大分页数量
*/
public static final int PAGESIZE_MAX = 200;

/**
* 默认分页数量
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
* <p>
* Use of this source code is governed by an MIT-style license.
* <p>
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*/

package com.tinyengine.it.common.context;

/**
* 保存用户信息的上下文
* 由集成方自行实现接口
*/
public interface LoginUserContext {
/**
* 返回当前用户所诉的业务租户信息
* @return 租户ID
*/
public String getTenantId();

/**
* 返回当前用户信息
* @return 用户ID
*/
public String getLoginUserId();

/**
* 返回当前用户所属业务租户信息
* @return 业务租户ID
*/
public String getRenterId();

/**
* 返回当前应用信息
* @return 应用ID
*/
public int getAppId();

/**
* 返回当前设计器信息
* @return 设计器ID
*/
public int getPlatformId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
package com.tinyengine.it.common.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.tinyengine.it.common.context.LoginUserContext;

import lombok.extern.slf4j.Slf4j;

import org.apache.ibatis.reflection.MetaObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
Expand All @@ -29,15 +31,17 @@
@Component
@Slf4j
public class MyMetaObjectHandler implements MetaObjectHandler {
@Autowired
private LoginUserContext loginUserContext;

@Override
public void insertFill(MetaObject metaObject) {
this.setFieldValByName("createdTime", LocalDateTime.now(), metaObject);
this.setFieldValByName("lastUpdatedTime", LocalDateTime.now(), metaObject);
this.setFieldValByName("createdBy", "1", metaObject);
this.setFieldValByName("lastUpdatedBy", "1", metaObject);
this.setFieldValByName("tenantId", "1", metaObject);
this.setFieldValByName("renterId", "1", metaObject);
this.setFieldValByName("siteId", "1", metaObject);
this.setFieldValByName("createdBy", loginUserContext.getLoginUserId(), metaObject);
this.setFieldValByName("lastUpdatedBy", loginUserContext.getLoginUserId(), metaObject);
this.setFieldValByName("tenantId", loginUserContext.getTenantId(), metaObject);
this.setFieldValByName("renterId", loginUserContext.getRenterId(), metaObject);
}

@Override
Expand Down
35 changes: 35 additions & 0 deletions base/src/main/java/com/tinyengine/it/common/utils/TestUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
* <p>
* Use of this source code is governed by an MIT-style license.
* <p>
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*/

package com.tinyengine.it.common.utils;

import java.lang.reflect.Field;

/**
* 测试工工具类
*/
public class TestUtil {
/**
* 设置私有字段的属性值
*
* @param obj 对象
* @param field 字段名
* @param value 值
* @throws NoSuchFieldException 异常
* @throws IllegalAccessException 异常
*/
public static void setPrivateValue(Object obj, String field, Object value)
throws NoSuchFieldException, IllegalAccessException {
Field declaredField = obj.getClass().getDeclaredField(field);
declaredField.setAccessible(true);
declaredField.set(obj, value);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* <p>
* Use of this source code is governed by an MIT-style license.
*
* <p>
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

package com.tinyengine.it.controller;
Expand Down Expand Up @@ -71,8 +70,8 @@ public class PageController {
* @return allpage
*/
@Operation(summary = "获取页面列表", description = "获取页面列表", parameters = {
@Parameter(name = "aid", description = "appId")}, responses = {
@ApiResponse(responseCode = "200", description = "返回信息",
@Parameter(name = "aid", description = "appId")}, responses = {
@ApiResponse(responseCode = "200", description = "返回信息",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = Page.class))),
@ApiResponse(responseCode = "400", description = "请求失败")})
Expand Down Expand Up @@ -207,8 +206,8 @@ public Result<PreviewDto> previewData(@ModelAttribute PreviewParam previewParam)
@ApiResponse(responseCode = "400", description = "请求失败")})
@SystemControllerLog(description = "页面发布")
@PostMapping("/pages/deploy")
public Result<Integer> pageDeploy(@RequestBody PageHistory pageHistory) {
Integer result = pageHistoryService.createPageHistory(pageHistory);
return Result.success(result);
public Result<PageHistory> pageDeploy(@RequestBody PageHistory pageHistory) {
pageHistoryService.createPageHistory(pageHistory);
return Result.success(pageHistory);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
* <p>
*
* Use of this source code is governed by an MIT-style license.
* <p>
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

package com.tinyengine.it.mapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
* <p>
*
* Use of this source code is governed by an MIT-style license.
* <p>
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

package com.tinyengine.it.mapper;
Expand Down Expand Up @@ -85,10 +86,10 @@ public interface PageHistoryMapper extends BaseMapper<PageHistory> {
/**
* 查询发布的页面记录
*
* @param iPage the iPage
* @param iPage the iPage
* @param pageHistoryVo the pageQueryVo
* @return page history
*/
IPage<PublishedPageVo> findLatestPublishPage(IPage<PublishedPageVo> iPage,
@Param("pageHistory") PublishedPageVo pageHistoryVo);
@Param("pageHistory") PublishedPageVo pageHistoryVo);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
* <p>
*
* Use of this source code is governed by an MIT-style license.
* <p>
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

package com.tinyengine.it.model.dto;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
* <p>
*
* Use of this source code is governed by an MIT-style license.
* <p>
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

package com.tinyengine.it.model.dto;
Expand All @@ -25,6 +26,7 @@
@Getter
public class PublishedPageVo {
private Integer refId;

/**
* 名称
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
* <p>
*
* Use of this source code is governed by an MIT-style license.
* <p>
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

package com.tinyengine.it.service.app;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import com.tinyengine.it.service.app.I18nEntryService;

import cn.hutool.core.bean.BeanUtil;

import lombok.extern.slf4j.Slf4j;

import org.apache.ibatis.annotations.Param;
Expand Down Expand Up @@ -169,7 +168,8 @@ public List<I18nEntry> fillParam(OperateI18nEntries operateI18nEntries, Map<Stri

Map<String, String> contents = operateI18nEntries.getContents();

contents.keySet().forEach(item -> {
contents.keySet().forEach(item ->
{
int lang = langsDic.get(item);
if (lang != 0) {
I18nEntry i18nEntries = new I18nEntry();
Expand All @@ -180,7 +180,7 @@ public List<I18nEntry> fillParam(OperateI18nEntries operateI18nEntries, Map<Stri
i18nEntries.setContent(contents.get(item));
i18nEntriesList.add(i18nEntries);
}
});
});
return i18nEntriesList;
}

Expand Down Expand Up @@ -385,18 +385,20 @@ public Result<FileResult> readFilesAndbulkCreate(String lang, MultipartFile file
@SystemServiceLog(description = "bulkCreateOrUpdate 批量创建或修改")
public Result<FileResult> bulkCreateOrUpdate(List<EntriesItem> entriesArr, int host) {
List<I18nEntry> entries = new ArrayList<>();
entriesArr.forEach(entriesItem -> {
entriesArr.forEach(entriesItem ->
{
Map<String, Object> langEntries = entriesItem.getEntries();
langEntries.forEach((key, value) -> {
langEntries.forEach((key, value) ->
{
I18nEntry i18nEntry = new I18nEntry();
i18nEntry.setKey(key);
i18nEntry.setLang(entriesItem.getLang());
i18nEntry.setHost(host);
i18nEntry.setHostType("app");
i18nEntry.setContent(value.toString());
entries.add(i18nEntry);
});
});
});
// 超大量数据更新,如上传国际化文件,不返回插入或更新的词条
FileResult result = bulkInsertOrUpdate(entries);
return Result.success(result);
Expand Down
Loading
Loading