Merge remote-tracking branch 'origin/vben5-antd-schema' into vben5-antd-schema
This commit is contained in:
commit
15e2121078
|
@ -1,7 +1,6 @@
|
|||
package cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -46,9 +45,6 @@ public class CodegenTableRespVO {
|
|||
@Schema(description = "前端类型,参见 CodegenFrontTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
|
||||
private Integer frontType;
|
||||
|
||||
@Schema(description = "是否生成批量删除接口", example = "true")
|
||||
private Boolean deleteBatch;
|
||||
|
||||
@Schema(description = "父菜单编号", example = "1024")
|
||||
private Long parentMenuId;
|
||||
|
||||
|
|
|
@ -60,10 +60,6 @@ public class CodegenTableSaveReqVO {
|
|||
@NotNull(message = "前端类型不能为空")
|
||||
private Integer frontType;
|
||||
|
||||
@Schema(description = "是否生成批量删除接口", example = "true")
|
||||
@NotNull(message = "是否生成批量删除接口不能为空")
|
||||
private Boolean deleteBatch;
|
||||
|
||||
@Schema(description = "父菜单编号", example = "1024")
|
||||
private Long parentMenuId;
|
||||
|
||||
|
|
|
@ -108,12 +108,6 @@ public class CodegenTableDO extends BaseDO {
|
|||
* 枚举 {@link CodegenFrontTypeEnum}
|
||||
*/
|
||||
private Integer frontType;
|
||||
/**
|
||||
* 是否生成批量删除接口
|
||||
* -true 是
|
||||
* -false 否
|
||||
*/
|
||||
private Boolean deleteBatch;
|
||||
|
||||
// ========== 菜单相关字段 ==========
|
||||
|
||||
|
|
|
@ -49,4 +49,10 @@ public class CodegenProperties {
|
|||
@NotNull(message = "是否生成单元测试不能为空")
|
||||
private Boolean unitTestEnable;
|
||||
|
||||
/**
|
||||
* 是否生成批量删除接口
|
||||
*/
|
||||
@NotNull(message = "是否生成批量删除接口不能为空")
|
||||
private Boolean deleteBatchEnable;
|
||||
|
||||
}
|
||||
|
|
|
@ -382,7 +382,7 @@ public class CodegenEngine {
|
|||
bindingMap.put("columns", columns);
|
||||
bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段
|
||||
bindingMap.put("sceneEnum", CodegenSceneEnum.valueOf(table.getScene()));
|
||||
|
||||
bindingMap.put("deleteBatchEnable", codegenProperties.getDeleteBatchEnable());
|
||||
// className 相关
|
||||
// 去掉指定前缀,将 TestDictType 转换成 DictType. 因为在 create 等方法后,不需要带上 Test 前缀
|
||||
String className = table.getClassName();
|
||||
|
|
|
@ -74,7 +74,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
|||
return success(true);
|
||||
}
|
||||
|
||||
#if ( $table.templateType != 2 && $table.deleteBatch)
|
||||
#if ( $table.templateType != 2 && $deleteBatchEnable)
|
||||
@DeleteMapping("/delete-batch")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除${table.classComment}")
|
||||
|
@ -243,7 +243,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
|||
return success(true);
|
||||
}
|
||||
|
||||
#if ($table.deleteBatch)
|
||||
#if ($deleteBatchEnable)
|
||||
@DeleteMapping("/${subSimpleClassName_strikeCase}/delete-batch")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除${subTable.classComment}")
|
||||
|
|
|
@ -54,7 +54,7 @@ public interface ${subTable.className}Mapper extends BaseMapperX<${subTable.clas
|
|||
return delete(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField});
|
||||
}
|
||||
|
||||
#if ( $table.templateType != 2 && $table.deleteBatch)
|
||||
#if ( $table.templateType != 2 && $deleteBatchEnable)
|
||||
default int deleteBy${SubJoinColumnName}s(List<${subJoinColumn.javaType}> ${subJoinColumn.javaField}s) {
|
||||
return delete(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField}s);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public interface ${table.className}Service {
|
|||
*/
|
||||
void delete${simpleClassName}(${primaryColumn.javaType} id);
|
||||
|
||||
#if ( $table.templateType != 2 && $table.deleteBatch)
|
||||
#if ( $table.templateType != 2 && $deleteBatchEnable)
|
||||
/**
|
||||
* 批量删除${table.classComment}
|
||||
*
|
||||
|
@ -143,7 +143,7 @@ public interface ${table.className}Service {
|
|||
*/
|
||||
void delete${subSimpleClassName}(${subPrimaryColumn.javaType} id);
|
||||
|
||||
#if ($table.deleteBatch)
|
||||
#if ($deleteBatchEnable)
|
||||
/**
|
||||
* 批量删除${subTable.classComment}
|
||||
*
|
||||
|
|
|
@ -161,7 +161,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
|
|||
#end
|
||||
}
|
||||
|
||||
#if ( $table.templateType != 2 && $table.deleteBatch)
|
||||
#if ( $table.templateType != 2 && $deleteBatchEnable)
|
||||
@Override
|
||||
## 特殊:主子表专属逻辑
|
||||
#if ( $subTables && $subTables.size() > 0)
|
||||
|
@ -338,7 +338,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
|
|||
${subClassNameVars.get($index)}Mapper.deleteById(id);
|
||||
}
|
||||
|
||||
#if ($table.deleteBatch)
|
||||
#if ($deleteBatchEnable)
|
||||
@Override
|
||||
public void delete${subSimpleClassName}ByIds(List<${subPrimaryColumn.javaType}> ids) {
|
||||
// 校验存在
|
||||
|
@ -359,7 +359,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
|
|||
}
|
||||
}
|
||||
|
||||
#if ($table.deleteBatch)
|
||||
#if ($deleteBatchEnable)
|
||||
private void validate${subSimpleClassName}Exists(List<${subPrimaryColumn.javaType}> ids) {
|
||||
List<${subTable.className}DO> list = ${subClassNameVar}Mapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||
|
@ -406,7 +406,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
|
|||
${subClassNameVars.get($index)}Mapper.deleteBy${SubJoinColumnName}(${subJoinColumn.javaField});
|
||||
}
|
||||
|
||||
#if ( $table.templateType != 2 && $table.deleteBatch)
|
||||
#if ( $table.templateType != 2 && $deleteBatchEnable)
|
||||
private void delete${subSimpleClassName}By${SubJoinColumnName}s(List<${primaryColumn.javaType}> ${subJoinColumn.javaField}s) {
|
||||
${subClassNameVars.get($index)}Mapper.deleteBy${SubJoinColumnName}s(${subJoinColumn.javaField}s);
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ export function delete${simpleClassName}(id: number) {
|
|||
return requestClient.delete(`${baseURL}/delete?id=${id}`);
|
||||
}
|
||||
|
||||
#if ( $table.templateType != 2 && $table.deleteBatch)
|
||||
#if ( $table.templateType != 2 && $deleteBatchEnable)
|
||||
// 批量删除${table.classComment}
|
||||
export function delete${simpleClassName}ByIds(ids: number[]) {
|
||||
return requestClient.delete(`${baseURL}/delete-batch?ids=${ids.join(',')}`)
|
||||
|
@ -151,7 +151,7 @@ export function delete${subSimpleClassName}(id: number) {
|
|||
return requestClient.delete(`${baseURL}/${subSimpleClassName_strikeCase}/delete?id=${id}`);
|
||||
}
|
||||
|
||||
#if ($table.deleteBatch)
|
||||
#if ($deleteBatchEnable)
|
||||
// 批量删除${subTable.classComment}
|
||||
export function delete${subSimpleClassName}ByIds(ids: number[]) {
|
||||
return requestClient.delete(`${baseURL}/${subSimpleClassName_strikeCase}/delete-batch?ids=${ids.join(',')}`)
|
||||
|
|
|
@ -193,7 +193,7 @@ export function useGridColumns(
|
|||
onActionClick?: OnActionClickFn<${simpleClassName}Api.${simpleClassName}>,
|
||||
): VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>['columns'] {
|
||||
return [
|
||||
#if ($table.templateType != 2 && $table.deleteBatch)
|
||||
#if ($table.templateType != 2 && $deleteBatchEnable)
|
||||
{ type: 'checkbox', width: 40 },
|
||||
#end
|
||||
#if ($table.templateType == 12) ## 内嵌情况
|
||||
|
@ -431,7 +431,7 @@ export function use${subSimpleClassName}GridColumns(
|
|||
onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
|
||||
): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
|
||||
return [
|
||||
#if ($table.templateType != 2 && $table.deleteBatch)
|
||||
#if ($table.templateType != 2 && $deleteBatchEnable)
|
||||
{ type: 'checkbox', width: 40 },
|
||||
#end
|
||||
#foreach($column in $subColumns)
|
||||
|
|
|
@ -22,7 +22,7 @@ import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|||
#if (${table.templateType} == 2)## 树表接口
|
||||
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
#else## 标准表接口
|
||||
import { get${simpleClassName}Page, delete${simpleClassName},#if ($table.deleteBatch) delete${simpleClassName}ByIds,#end export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
import { get${simpleClassName}Page, delete${simpleClassName},#if ($deleteBatchEnable) delete${simpleClassName}ByIds,#end export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
#end
|
||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||
|
||||
|
@ -92,7 +92,7 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) {
|
|||
}
|
||||
}
|
||||
|
||||
#if ($table.templateType != 2 && $table.deleteBatch)
|
||||
#if ($table.templateType != 2 && $deleteBatchEnable)
|
||||
const deleteIds = ref<number[]>([]) // 待删除${table.classComment} ID
|
||||
const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value));
|
||||
function setDeleteIds({
|
||||
|
@ -204,14 +204,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>,
|
||||
#if (${table.templateType} == 11 || $table.deleteBatch)
|
||||
#if (${table.templateType} == 11 || $deleteBatchEnable)
|
||||
gridEvents:{
|
||||
#if(${table.templateType} == 11)
|
||||
cellClick: ({ row }: { row: ${simpleClassName}Api.${simpleClassName}}) => {
|
||||
select${simpleClassName}.value = row;
|
||||
},
|
||||
#end
|
||||
#if($table.deleteBatch)
|
||||
#if($deleteBatchEnable)
|
||||
checkboxAll: setDeleteIds,
|
||||
checkboxChange: setDeleteIds,
|
||||
#end
|
||||
|
@ -262,7 +262,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||
>
|
||||
{{ $t('ui.actionTitle.export') }}
|
||||
</Button>
|
||||
#if ($table.templateType != 2 && $table.deleteBatch)
|
||||
#if ($table.templateType != 2 && $deleteBatchEnable)
|
||||
<Button
|
||||
:icon="h(Trash2)"
|
||||
type="primary"
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
|
||||
#if ($table.templateType == 11) ## erp
|
||||
import { delete${subSimpleClassName},#if ($table.deleteBatch) delete${subSimpleClassName}ByIds,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}ByIds,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}';
|
||||
import { use${subSimpleClassName}GridFormSchema, use${subSimpleClassName}GridColumns } from '../data';
|
||||
import { isEmpty } from '@vben/utils';
|
||||
#else
|
||||
|
@ -73,7 +73,7 @@ async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
|
|||
}
|
||||
}
|
||||
|
||||
#if ($table.deleteBatch)
|
||||
#if ($deleteBatchEnable)
|
||||
const deleteIds = ref<number[]>([]) // 待删除${subTable.classComment} ID
|
||||
const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value));
|
||||
function setDeleteIds({
|
||||
|
@ -164,7 +164,7 @@ function onActionClick({
|
|||
isHover: true,
|
||||
},
|
||||
} as VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>,
|
||||
#if (${table.templateType} == 11 && $table.deleteBatch)
|
||||
#if (${table.templateType} == 11 && $deleteBatchEnable)
|
||||
gridEvents:{
|
||||
checkboxAll: setDeleteIds,
|
||||
checkboxChange: setDeleteIds,
|
||||
|
@ -207,7 +207,7 @@ const onRefresh = async ()=> {
|
|||
<Button :icon="h(Plus)" type="primary" @click="onCreate" v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:create']">
|
||||
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
||||
</Button>
|
||||
#if ($table.templateType == 11 && $table.deleteBatch)
|
||||
#if ($table.templateType == 11 && $deleteBatchEnable)
|
||||
<Button
|
||||
:icon="h(Trash2)"
|
||||
type="primary"
|
||||
|
|
|
@ -271,6 +271,7 @@ yudao:
|
|||
front-type: 20 # 前端模版的类型,参见 CodegenFrontTypeEnum 枚举类
|
||||
vo-type: 10 # VO 的类型,参见 CodegenVOTypeEnum 枚举类
|
||||
unit-test-enable: false # 是否生成单元测试
|
||||
delete-batch-enable: false # 是否生成批量删除接口
|
||||
tenant: # 多租户相关配置项
|
||||
enable: true
|
||||
ignore-urls:
|
||||
|
|
Loading…
Reference in New Issue