Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/yudao-cloud
commit
1d1ee4698e
|
@ -7,6 +7,8 @@ package cn.iocoder.yudao.module.infra.enums;
|
||||||
*/
|
*/
|
||||||
public interface DictTypeConstants {
|
public interface DictTypeConstants {
|
||||||
|
|
||||||
|
String USER_TYPE = "user_type"; // 用户类型
|
||||||
|
|
||||||
String JOB_STATUS = "infra_job_status"; // 定时任务状态的枚举
|
String JOB_STATUS = "infra_job_status"; // 定时任务状态的枚举
|
||||||
String JOB_LOG_STATUS = "infra_job_log_status"; // 定时任务日志状态的枚举
|
String JOB_LOG_STATUS = "infra_job_log_status"; // 定时任务日志状态的枚举
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,6 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 依赖服务 -->
|
<!-- 依赖服务 -->
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.cloud</groupId>
|
|
||||||
<artifactId>yudao-module-system-api</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.iocoder.cloud</groupId>
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
<artifactId>yudao-module-infra-api</artifactId>
|
<artifactId>yudao-module-infra-api</artifactId>
|
||||||
|
|
|
@ -35,6 +35,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserNickname;
|
||||||
import static cn.iocoder.yudao.module.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
|
import static cn.iocoder.yudao.module.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 代码生成器")
|
@Tag(name = "管理后台 - 代码生成器")
|
||||||
|
@ -93,7 +94,7 @@ public class CodegenController {
|
||||||
@PostMapping("/create-list")
|
@PostMapping("/create-list")
|
||||||
@PreAuthorize("@ss.hasPermission('infra:codegen:create')")
|
@PreAuthorize("@ss.hasPermission('infra:codegen:create')")
|
||||||
public CommonResult<List<Long>> createCodegenList(@Valid @RequestBody CodegenCreateListReqVO reqVO) {
|
public CommonResult<List<Long>> createCodegenList(@Valid @RequestBody CodegenCreateListReqVO reqVO) {
|
||||||
return success(codegenService.createCodegenList(getLoginUserId(), reqVO));
|
return success(codegenService.createCodegenList(getLoginUserNickname(), reqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "更新数据库的表和字段定义")
|
@Operation(summary = "更新数据库的表和字段定义")
|
||||||
|
|
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class ApiErrorLogRespVO {
|
||||||
|
|
||||||
@Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||||
@DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_TYPE)
|
@DictFormat(DictTypeConstants.USER_TYPE)
|
||||||
private Integer userType;
|
private Integer userType;
|
||||||
|
|
||||||
@Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
|
@Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package cn.iocoder.yudao.module.infra.framework.rpc.config;
|
package cn.iocoder.yudao.module.infra.framework.rpc.config;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration(value = "infraRpcConfiguration", proxyBeanMethods = false)
|
@Configuration(value = "infraRpcConfiguration", proxyBeanMethods = false)
|
||||||
@EnableFeignClients(clients = AdminUserApi.class)
|
@EnableFeignClients()
|
||||||
public class RpcConfiguration {
|
public class RpcConfiguration {
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,11 @@ public interface CodegenService {
|
||||||
/**
|
/**
|
||||||
* 基于数据库的表结构,创建代码生成器的表定义
|
* 基于数据库的表结构,创建代码生成器的表定义
|
||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param author 作者
|
||||||
* @param reqVO 表信息
|
* @param reqVO 表信息
|
||||||
* @return 创建的表定义的编号数组
|
* @return 创建的表定义的编号数组
|
||||||
*/
|
*/
|
||||||
List<Long> createCodegenList(Long userId, CodegenCreateListReqVO reqVO);
|
List<Long> createCodegenList(String author, CodegenCreateListReqVO reqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新数据库的表和字段定义
|
* 更新数据库的表和字段定义
|
||||||
|
|
|
@ -18,7 +18,6 @@ import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties;
|
||||||
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder;
|
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder;
|
||||||
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine;
|
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine;
|
||||||
import cn.iocoder.yudao.module.infra.service.db.DatabaseTableService;
|
import cn.iocoder.yudao.module.infra.service.db.DatabaseTableService;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
||||||
import com.baomidou.mybatisplus.generator.config.po.TableField;
|
import com.baomidou.mybatisplus.generator.config.po.TableField;
|
||||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
@ -52,9 +51,6 @@ public class CodegenServiceImpl implements CodegenService {
|
||||||
@Resource
|
@Resource
|
||||||
private CodegenColumnMapper codegenColumnMapper;
|
private CodegenColumnMapper codegenColumnMapper;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private AdminUserApi userApi;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CodegenBuilder codegenBuilder;
|
private CodegenBuilder codegenBuilder;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -65,21 +61,21 @@ public class CodegenServiceImpl implements CodegenService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public List<Long> createCodegenList(Long userId, CodegenCreateListReqVO reqVO) {
|
public List<Long> createCodegenList(String author, CodegenCreateListReqVO reqVO) {
|
||||||
List<Long> ids = new ArrayList<>(reqVO.getTableNames().size());
|
List<Long> ids = new ArrayList<>(reqVO.getTableNames().size());
|
||||||
// 遍历添加。虽然效率会低一点,但是没必要做成完全批量,因为不会这么大量
|
// 遍历添加。虽然效率会低一点,但是没必要做成完全批量,因为不会这么大量
|
||||||
reqVO.getTableNames().forEach(tableName -> ids.add(createCodegen(userId, reqVO.getDataSourceConfigId(), tableName)));
|
reqVO.getTableNames().forEach(tableName -> ids.add(createCodegen(author, reqVO.getDataSourceConfigId(), tableName)));
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long createCodegen(Long userId, Long dataSourceConfigId, String tableName) {
|
private Long createCodegen(String author, Long dataSourceConfigId, String tableName) {
|
||||||
// 从数据库中,获得数据库表结构
|
// 从数据库中,获得数据库表结构
|
||||||
TableInfo tableInfo = databaseTableService.getTable(dataSourceConfigId, tableName);
|
TableInfo tableInfo = databaseTableService.getTable(dataSourceConfigId, tableName);
|
||||||
// 导入
|
// 导入
|
||||||
return createCodegen0(userId, dataSourceConfigId, tableInfo);
|
return createCodegen0(author, dataSourceConfigId, tableInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long createCodegen0(Long userId, Long dataSourceConfigId, TableInfo tableInfo) {
|
private Long createCodegen0(String author, Long dataSourceConfigId, TableInfo tableInfo) {
|
||||||
// 校验导入的表和字段非空
|
// 校验导入的表和字段非空
|
||||||
validateTableInfo(tableInfo);
|
validateTableInfo(tableInfo);
|
||||||
// 校验是否已经存在
|
// 校验是否已经存在
|
||||||
|
@ -93,7 +89,7 @@ public class CodegenServiceImpl implements CodegenService {
|
||||||
table.setDataSourceConfigId(dataSourceConfigId);
|
table.setDataSourceConfigId(dataSourceConfigId);
|
||||||
table.setScene(CodegenSceneEnum.ADMIN.getScene()); // 默认配置下,使用管理后台的模板
|
table.setScene(CodegenSceneEnum.ADMIN.getScene()); // 默认配置下,使用管理后台的模板
|
||||||
table.setFrontType(codegenProperties.getFrontType());
|
table.setFrontType(codegenProperties.getFrontType());
|
||||||
table.setAuthor(userApi.getUser(userId).getCheckedData().getNickname());
|
table.setAuthor(author);
|
||||||
codegenTableMapper.insert(table);
|
codegenTableMapper.insert(table);
|
||||||
|
|
||||||
// 构建 CodegenColumnDO 数组,插入到 DB 中
|
// 构建 CodegenColumnDO 数组,插入到 DB 中
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { ImageUpload, FileUpload } from "#/components/upload";
|
||||||
import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker, TreeSelect } from 'ant-design-vue';
|
import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker, TreeSelect } from 'ant-design-vue';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils';
|
import { DICT_TYPE, getDictOptions } from '#/utils';
|
||||||
#if($table.templateType == 2)## 树表需要导入这些
|
#if($table.templateType == 2)## 树表需要导入这些
|
||||||
import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${simpleClassName}List } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
import { handleTree } from '@vben/utils'
|
import { handleTree } from '@vben/utils'
|
||||||
#end
|
#end
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
|
@ -22,7 +22,7 @@ import { handleTree } from '@vben/utils'
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
const emit = defineEmits(['success']);
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
|
||||||
#if(${table.templateType} == 2)## 树表需要导入这些
|
#if(${table.templateType} == 2)## 树表需要导入这些
|
||||||
import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${simpleClassName}List } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
import { handleTree } from '@vben/utils';
|
import { handleTree } from '@vben/utils';
|
||||||
#end
|
#end
|
||||||
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
|
||||||
import { useAccess } from '@vben/access';
|
import { useAccess } from '@vben/access';
|
||||||
|
|
||||||
const { hasAccessByCodes } = useAccess();
|
const { hasAccessByCodes } = useAccess();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
import { message, Tabs, Checkbox, Input, Textarea, Select,RadioGroup,CheckboxGroup, DatePicker } from 'ant-design-vue';
|
import { message, Tabs, Checkbox, Input, Textarea, Select,RadioGroup,CheckboxGroup, DatePicker } from 'ant-design-vue';
|
||||||
|
@ -15,7 +15,7 @@ import { message, Tabs, Checkbox, Input, Textarea, Select,RadioGroup,CheckboxGro
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { useVbenForm } from '#/adapter/form';
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
import { useFormSchema } from '../data';
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
import { Page, useVbenModal } from '@vben/common-ui';
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { Button, message,Tabs } from 'ant-design-vue';
|
import { Button, message,Tabs } from 'ant-design-vue';
|
||||||
|
@ -20,9 +20,9 @@ import { ref, h } from 'vue';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
#if (${table.templateType} == 2)## 树表接口
|
#if (${table.templateType} == 2)## 树表接口
|
||||||
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
#else## 标准表接口
|
#else## 标准表接口
|
||||||
import { get${simpleClassName}Page, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${simpleClassName}Page, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
#end
|
#end
|
||||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
|
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
|
||||||
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
|
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { useVbenForm } from '#/adapter/form';
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
import { use${subSimpleClassName}FormSchema } from '../data';
|
import { use${subSimpleClassName}FormSchema } from '../data';
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#set ($subClassNameVar = $subClassNameVars.get($subIndex))
|
#set ($subClassNameVar = $subClassNameVars.get($subIndex))
|
||||||
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
import { computed, ref, h, onMounted,watch,nextTick } from 'vue';
|
import { computed, ref, h, onMounted,watch,nextTick } from 'vue';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
@ -17,11 +17,11 @@ import { ImageUpload, FileUpload } from "#/components/upload";
|
||||||
import type { OnActionClickParams } from '#/adapter/vxe-table';
|
import type { OnActionClickParams } from '#/adapter/vxe-table';
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { use${subSimpleClassName}GridEditColumns } from '../data';
|
import { use${subSimpleClassName}GridEditColumns } from '../data';
|
||||||
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
#else
|
#else
|
||||||
import { useVbenForm } from '#/adapter/form';
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { use${subSimpleClassName}FormSchema } from '../data';
|
import { use${subSimpleClassName}FormSchema } from '../data';
|
||||||
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
#end
|
#end
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
#if ($table.templateType == 11) ## erp
|
#if ($table.templateType == 11) ## erp
|
||||||
import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
|
import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
|
||||||
|
@ -21,13 +21,13 @@
|
||||||
|
|
||||||
|
|
||||||
#if ($table.templateType == 11) ## erp
|
#if ($table.templateType == 11) ## erp
|
||||||
import { delete${subSimpleClassName}, get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { delete${subSimpleClassName}, get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
import { use${subSimpleClassName}GridFormSchema, use${subSimpleClassName}GridColumns } from '../data';
|
import { use${subSimpleClassName}GridFormSchema, use${subSimpleClassName}GridColumns } from '../data';
|
||||||
#else
|
#else
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
#else
|
#else
|
||||||
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
#end
|
#end
|
||||||
import { use${subSimpleClassName}GridColumns } from '../data';
|
import { use${subSimpleClassName}GridColumns } from '../data';
|
||||||
#end
|
#end
|
||||||
|
|
|
@ -20,8 +20,6 @@ import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties;
|
||||||
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder;
|
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder;
|
||||||
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine;
|
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine;
|
||||||
import cn.iocoder.yudao.module.infra.service.db.DatabaseTableService;
|
import cn.iocoder.yudao.module.infra.service.db.DatabaseTableService;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
||||||
import com.baomidou.mybatisplus.generator.config.po.TableField;
|
import com.baomidou.mybatisplus.generator.config.po.TableField;
|
||||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -34,7 +32,6 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
|
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
|
||||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||||
|
@ -66,9 +63,6 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
||||||
@MockBean
|
@MockBean
|
||||||
private DatabaseTableService databaseTableService;
|
private DatabaseTableService databaseTableService;
|
||||||
|
|
||||||
@MockBean
|
|
||||||
private AdminUserApi userApi;
|
|
||||||
|
|
||||||
@MockBean
|
@MockBean
|
||||||
private CodegenBuilder codegenBuilder;
|
private CodegenBuilder codegenBuilder;
|
||||||
@MockBean
|
@MockBean
|
||||||
|
@ -80,7 +74,7 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCreateCodegenList() {
|
public void testCreateCodegenList() {
|
||||||
// 准备参数
|
// 准备参数
|
||||||
Long userId = randomLongId();
|
String author = randomString();
|
||||||
CodegenCreateListReqVO reqVO = randomPojo(CodegenCreateListReqVO.class,
|
CodegenCreateListReqVO reqVO = randomPojo(CodegenCreateListReqVO.class,
|
||||||
o -> o.setDataSourceConfigId(1L).setTableNames(Collections.singletonList("t_yunai")));
|
o -> o.setDataSourceConfigId(1L).setTableNames(Collections.singletonList("t_yunai")));
|
||||||
// mock 方法(TableInfo)
|
// mock 方法(TableInfo)
|
||||||
|
@ -98,9 +92,6 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
||||||
// mock 方法(CodegenTableDO)
|
// mock 方法(CodegenTableDO)
|
||||||
CodegenTableDO table = randomPojo(CodegenTableDO.class);
|
CodegenTableDO table = randomPojo(CodegenTableDO.class);
|
||||||
when(codegenBuilder.buildTable(same(tableInfo))).thenReturn(table);
|
when(codegenBuilder.buildTable(same(tableInfo))).thenReturn(table);
|
||||||
// mock 方法(AdminUserRespDTO)
|
|
||||||
AdminUserRespDTO user = randomPojo(AdminUserRespDTO.class, o -> o.setNickname("芋头"));
|
|
||||||
when(userApi.getUser(eq(userId))).thenReturn(success(user));
|
|
||||||
// mock 方法(CodegenColumnDO)
|
// mock 方法(CodegenColumnDO)
|
||||||
List<CodegenColumnDO> columns = randomPojoList(CodegenColumnDO.class);
|
List<CodegenColumnDO> columns = randomPojoList(CodegenColumnDO.class);
|
||||||
when(codegenBuilder.buildColumns(eq(table.getId()), same(fields)))
|
when(codegenBuilder.buildColumns(eq(table.getId()), same(fields)))
|
||||||
|
@ -109,7 +100,7 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
||||||
when(codegenProperties.getFrontType()).thenReturn(CodegenFrontTypeEnum.VUE3_ELEMENT_PLUS.getType());
|
when(codegenProperties.getFrontType()).thenReturn(CodegenFrontTypeEnum.VUE3_ELEMENT_PLUS.getType());
|
||||||
|
|
||||||
// 调用
|
// 调用
|
||||||
List<Long> result = codegenService.createCodegenList(userId, reqVO);
|
List<Long> result = codegenService.createCodegenList(author, reqVO);
|
||||||
// 断言
|
// 断言
|
||||||
assertEquals(1, result.size());
|
assertEquals(1, result.size());
|
||||||
// 断言(CodegenTableDO)
|
// 断言(CodegenTableDO)
|
||||||
|
@ -118,7 +109,7 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
||||||
assertEquals(1L, dbTable.getDataSourceConfigId());
|
assertEquals(1L, dbTable.getDataSourceConfigId());
|
||||||
assertEquals(CodegenSceneEnum.ADMIN.getScene(), dbTable.getScene());
|
assertEquals(CodegenSceneEnum.ADMIN.getScene(), dbTable.getScene());
|
||||||
assertEquals(CodegenFrontTypeEnum.VUE3_ELEMENT_PLUS.getType(), dbTable.getFrontType());
|
assertEquals(CodegenFrontTypeEnum.VUE3_ELEMENT_PLUS.getType(), dbTable.getFrontType());
|
||||||
assertEquals("芋头", dbTable.getAuthor());
|
assertEquals(author, dbTable.getAuthor());
|
||||||
// 断言(CodegenColumnDO)
|
// 断言(CodegenColumnDO)
|
||||||
List<CodegenColumnDO> dbColumns = codegenColumnMapper.selectList();
|
List<CodegenColumnDO> dbColumns = codegenColumnMapper.selectList();
|
||||||
assertEquals(columns.size(), dbColumns.size());
|
assertEquals(columns.size(), dbColumns.size());
|
||||||
|
|
Loading…
Reference in New Issue