This commit is contained in:
parent
fb24e6cd96
commit
2d0d5c889e
|
|
@ -1,92 +0,0 @@
|
|||
{
|
||||
"project": {
|
||||
"packageName": "net.maku",
|
||||
"version": "",
|
||||
"backendPath": "/Users/maku/makunet/maku-boot/maku-boot-new",
|
||||
"frontendPath": "/Users/maku/makunet/maku-admin",
|
||||
"tablePrefix": "tb_",
|
||||
"moduleName": "test",
|
||||
"author": "阿沐",
|
||||
"email": "babamu@126.com"
|
||||
},
|
||||
"templates": [
|
||||
{
|
||||
"templateName": "java/Controller.java.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java"
|
||||
},
|
||||
{
|
||||
"templateName": "java/Service.java.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/service/${ClassName}Service.java"
|
||||
},
|
||||
{
|
||||
"templateName": "java/ServiceImpl.java.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/service/impl/${ClassName}ServiceImpl.java"
|
||||
},
|
||||
{
|
||||
"templateName": "java/Query.java.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/query/${ClassName}Query.java"
|
||||
},
|
||||
{
|
||||
"templateName": "java/Entity.java.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ClassName}Entity.java"
|
||||
},
|
||||
{
|
||||
"templateName": "java/VO.java.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/vo/${ClassName}VO.java"
|
||||
},
|
||||
{
|
||||
"templateName": "java/Excel.java.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/vo/${ClassName}ExcelVO.java"
|
||||
},
|
||||
{
|
||||
"templateName": "java/Convert.java.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/convert/${ClassName}Convert.java"
|
||||
},
|
||||
{
|
||||
"templateName": "java/Dao.java.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/dao/${ClassName}Dao.java"
|
||||
},
|
||||
{
|
||||
"templateName": "xml/Dao.xml.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/resources/mapper/${moduleName}/${ClassName}Dao.xml"
|
||||
},
|
||||
{
|
||||
"templateName": "sql/menu.sql.ftl",
|
||||
"generatorPath": "${backendPath}/menu/${tableName}_menu.sql"
|
||||
},
|
||||
{
|
||||
"templateName": "vue/api.ts.ftl",
|
||||
"generatorPath": "${frontendPath}/src/api/${moduleName}/${functionName}.ts"
|
||||
},
|
||||
{
|
||||
"templateName": "vue/index.vue.ftl",
|
||||
"generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/index.vue"
|
||||
},
|
||||
{
|
||||
"templateName": "vue/add-or-update.vue.ftl",
|
||||
"generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/add-or-update.vue"
|
||||
}
|
||||
],
|
||||
"subTemplates": [
|
||||
{
|
||||
"templateName": "java/Entity.java.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ClassName}Entity.java"
|
||||
},
|
||||
{
|
||||
"templateName": "java/Dao.java.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/dao/${ClassName}Dao.java"
|
||||
},
|
||||
{
|
||||
"templateName": "java/VO.java.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/vo/${ClassName}VO.java"
|
||||
},
|
||||
{
|
||||
"templateName": "java/Convert.java.ftl",
|
||||
"generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/convert/${ClassName}Convert.java"
|
||||
},
|
||||
{
|
||||
"templateName": "vue/sub-add-or-update.vue.ftl",
|
||||
"generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/${className}.vue"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
package ${package}.${moduleName}.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import ${package}.framework.common.utils.PageResult;
|
||||
import ${package}.framework.common.utils.Result;
|
||||
import ${package}.framework.operatelog.annotations.OperateLog;
|
||||
import ${package}.framework.operatelog.enums.OperateTypeEnum;
|
||||
import ${package}.${moduleName}.service.${ClassName}Service;
|
||||
import ${package}.${moduleName}.query.${ClassName}Query;
|
||||
import ${package}.${moduleName}.vo.${ClassName}VO;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
<#if tableOperation?seq_contains('import')>
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
</#if>
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${tableComment!}
|
||||
*
|
||||
* @author ${author} ${email!}
|
||||
* <a href="https://maku.net">MAKU</a>
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("${requestUrl}")
|
||||
@Tag(name="${tableComment}")
|
||||
@AllArgsConstructor
|
||||
public class ${ClassName}Controller {
|
||||
private final ${ClassName}Service ${className}Service;
|
||||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
@PreAuthorize("hasAuthority('${authority}<#if authLevel==1>:page</#if>')")
|
||||
public Result<PageResult<${ClassName}VO>> page(@ParameterObject @Valid ${ClassName}Query query){
|
||||
PageResult<${ClassName}VO> page = ${className}Service.page(query);
|
||||
|
||||
return Result.ok(page);
|
||||
}
|
||||
|
||||
<#if hasTree>
|
||||
@GetMapping("list")
|
||||
@Operation(summary = "列表")
|
||||
@PreAuthorize("hasAuthority('${authority}<#if authLevel==1>:page</#if>')")
|
||||
public Result<List<${ClassName}VO>> list(Long ${treePid}) {
|
||||
List<${ClassName}VO> list = ${className}Service.list(${treePid});
|
||||
|
||||
return Result.ok(list);
|
||||
}
|
||||
</#if>
|
||||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
@PreAuthorize("hasAuthority('${authority}<#if authLevel==1>:info</#if>')")
|
||||
public Result<${ClassName}VO> get(@PathVariable("id") Long id){
|
||||
${ClassName}VO data = ${className}Service.get(id);
|
||||
|
||||
return Result.ok(data);
|
||||
}
|
||||
|
||||
<#if tableOperation?seq_contains('insert')>
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
@OperateLog(type = OperateTypeEnum.INSERT)
|
||||
@PreAuthorize("hasAuthority('${authority}<#if authLevel==1>:save</#if>')")
|
||||
public Result<String> save(@RequestBody ${ClassName}VO vo){
|
||||
${className}Service.save(vo);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if tableOperation?seq_contains('update')>
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
@OperateLog(type = OperateTypeEnum.UPDATE)
|
||||
@PreAuthorize("hasAuthority('${authority}<#if authLevel==1>:update</#if>')")
|
||||
public Result<String> update(@RequestBody @Valid ${ClassName}VO vo){
|
||||
${className}Service.update(vo);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if tableOperation?seq_contains('delete')>
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除")
|
||||
@OperateLog(type = OperateTypeEnum.DELETE)
|
||||
@PreAuthorize("hasAuthority('${authority}<#if authLevel==1>:delete</#if>')")
|
||||
public Result<String> delete(@RequestBody List<Long> idList){
|
||||
${className}Service.delete(idList);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if tableOperation?seq_contains('import')>
|
||||
@PostMapping("import")
|
||||
@Operation(summary = "导入")
|
||||
@OperateLog(type = OperateTypeEnum.IMPORT)
|
||||
@PreAuthorize("hasAuthority('${authority}<#if authLevel==1>:import</#if>')")
|
||||
public Result<String> importExcel(@RequestParam("file") MultipartFile file) {
|
||||
if (file.isEmpty()) {
|
||||
return Result.error("请选择需要上传的文件");
|
||||
}
|
||||
${className}Service.importByExcel(file);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if tableOperation?seq_contains('export')>
|
||||
@GetMapping("export")
|
||||
@Operation(summary = "导出")
|
||||
@OperateLog(type = OperateTypeEnum.EXPORT)
|
||||
@PreAuthorize("hasAuthority('${authority}<#if authLevel==1>:export</#if>')")
|
||||
public void export() {
|
||||
${className}Service.export();
|
||||
}
|
||||
</#if>
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
package ${package}.${moduleName}.convert;
|
||||
|
||||
import ${package}.${moduleName}.entity.${ClassName}Entity;
|
||||
import ${package}.${moduleName}.vo.${ClassName}VO;
|
||||
<#if !hasSub?? && (tableOperation?seq_contains('import') || tableOperation?seq_contains('export'))>
|
||||
import ${package}.${moduleName}.vo.${ClassName}ExcelVO;
|
||||
</#if>
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${tableComment}
|
||||
*
|
||||
* @author ${author} ${email!}
|
||||
* <a href="https://maku.net">MAKU</a>
|
||||
*/
|
||||
@Mapper
|
||||
public interface ${ClassName}Convert {
|
||||
${ClassName}Convert INSTANCE = Mappers.getMapper(${ClassName}Convert.class);
|
||||
|
||||
${ClassName}Entity convert(${ClassName}VO vo);
|
||||
|
||||
${ClassName}VO convert(${ClassName}Entity entity);
|
||||
|
||||
List<${ClassName}VO> convertList(List<${ClassName}Entity> list);
|
||||
|
||||
List<${ClassName}Entity> convertList2(List<${ClassName}VO> list);
|
||||
|
||||
<#if !hasSub?? && (tableOperation?seq_contains('import') || tableOperation?seq_contains('export'))>
|
||||
List<${ClassName}ExcelVO> convertExcelList(List<${ClassName}Entity> list);
|
||||
|
||||
List<${ClassName}Entity> convertExcelList2(List<${ClassName}ExcelVO> list);
|
||||
</#if>
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package ${package}.${moduleName}.dao;
|
||||
|
||||
import ${package}.framework.mybatis.dao.BaseDao;
|
||||
import ${package}.${moduleName}.entity.${ClassName}Entity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* ${tableComment}
|
||||
*
|
||||
* @author ${author} ${email!}
|
||||
* <a href="https://maku.net">MAKU</a>
|
||||
*/
|
||||
@Mapper
|
||||
public interface ${ClassName}Dao extends BaseDao<${ClassName}Entity> {
|
||||
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
package ${package}.${moduleName}.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
<#list importList as i>
|
||||
import ${i!};
|
||||
</#list>
|
||||
<#if baseClass??>
|
||||
import ${baseClass.packageName}.${baseClass.code};
|
||||
</#if>
|
||||
|
||||
/**
|
||||
* ${tableComment}
|
||||
*
|
||||
* @author ${author} ${email!}
|
||||
* <a href="https://maku.net">MAKU</a>
|
||||
*/
|
||||
<#if baseClass??>@EqualsAndHashCode(callSuper=false)</#if>
|
||||
@Data
|
||||
@TableName("${tableName}")
|
||||
public class ${ClassName}Entity<#if baseClass??> extends ${baseClass.code}</#if> {
|
||||
<#list fieldList as field>
|
||||
<#if !field.baseField>
|
||||
<#if field.fieldComment!?length gt 0>
|
||||
/**
|
||||
* ${field.fieldComment}
|
||||
*/
|
||||
</#if>
|
||||
<#if field.primaryPk>
|
||||
@TableId
|
||||
</#if>
|
||||
<#if field.fieldName == 'deleted'>
|
||||
@TableLogic
|
||||
</#if>
|
||||
<#if field.fieldName == 'version'>
|
||||
@Version
|
||||
</#if>
|
||||
<#if field.autoFill == "INSERT">
|
||||
@TableField(value = "${field.fieldName}", fill = FieldFill.INSERT)
|
||||
<#elseif field.autoFill == "INSERT_UPDATE">
|
||||
@TableField(value = "${field.fieldName}", fill = FieldFill.INSERT_UPDATE)
|
||||
<#elseif field.autoFill == "UPDATE">
|
||||
@TableField(value = "${field.fieldName}", fill = FieldFill.UPDATE)
|
||||
<#elseif hasTree && field.fieldName == treePid>
|
||||
@TableField(value = "${field.fieldName}", updateStrategy = FieldStrategy.ALWAYS)
|
||||
<#else>
|
||||
@TableField(value = "${field.fieldName}")
|
||||
</#if>
|
||||
private ${field.attrType} ${field.attrName};
|
||||
</#if>
|
||||
|
||||
</#list>
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
package ${package}.${moduleName}.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.fhs.core.trans.vo.TransPojo;
|
||||
import com.fhs.core.trans.anno.Trans;
|
||||
import com.fhs.core.trans.constant.TransType;
|
||||
import ${package}.framework.common.excel.LocalDateTimeConverter;
|
||||
<#list importList as i>
|
||||
import ${i!};
|
||||
</#list>
|
||||
|
||||
/**
|
||||
* ${tableComment}
|
||||
*
|
||||
* @author ${author} ${email!}
|
||||
* <a href="https://maku.net">MAKU</a>
|
||||
*/
|
||||
@Data
|
||||
public class ${ClassName}ExcelVO implements TransPojo {
|
||||
<#list gridList as field>
|
||||
<#if field.attrName == 'id'>
|
||||
<#assign isPrimaryKey = 'true'>
|
||||
</#if>
|
||||
</#list>
|
||||
<#if !isPrimaryKey??>
|
||||
@ExcelIgnore
|
||||
private ${primaryType} ${primaryName};
|
||||
|
||||
</#if>
|
||||
<#list gridList as field>
|
||||
<#if field.attrType == 'LocalDateTime'>
|
||||
@ExcelProperty(value = "${field.fieldComment!}", converter = LocalDateTimeConverter.class)
|
||||
<#elseif field.fieldComment!?length gt 0>
|
||||
@ExcelProperty("${field.fieldComment}")
|
||||
</#if>
|
||||
<#if field.formDict??>
|
||||
private String ${field.attrName}Label;
|
||||
|
||||
@ExcelIgnore
|
||||
@Trans(type = TransType.DICTIONARY, key = "${field.formDict}", ref = "${field.attrName}Label")
|
||||
private ${field.attrType} ${field.attrName};
|
||||
<#else>
|
||||
private ${field.attrType} ${field.attrName};
|
||||
</#if>
|
||||
|
||||
</#list>
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
package ${package}.${moduleName}.query;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.*;
|
||||
import ${package}.framework.common.query.Query;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
<#list importList as i>
|
||||
import ${i!};
|
||||
</#list>
|
||||
|
||||
/**
|
||||
* ${tableComment}查询
|
||||
*
|
||||
* @author ${author} ${email!}
|
||||
* <a href="https://maku.net">MAKU</a>
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "${tableComment}查询")
|
||||
public class ${ClassName}Query extends Query {
|
||||
<#list queryList as field>
|
||||
<#if field.fieldComment!?length gt 0>
|
||||
@Schema(description = "${field.fieldComment}")
|
||||
</#if>
|
||||
<#if field.queryFormType == 'date' || field.queryFormType == 'datetime'>
|
||||
private List<String> ${field.attrName};
|
||||
<#else>
|
||||
private ${field.attrType} ${field.attrName};
|
||||
</#if>
|
||||
|
||||
</#list>
|
||||
<#if hasLeftTree>
|
||||
private List<Long> ${leftRelationField};
|
||||
</#if>
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
package ${package}.${moduleName}.service;
|
||||
|
||||
import ${package}.framework.common.utils.PageResult;
|
||||
import ${package}.framework.mybatis.service.BaseService;
|
||||
import ${package}.${moduleName}.vo.${ClassName}VO;
|
||||
import ${package}.${moduleName}.query.${ClassName}Query;
|
||||
import ${package}.${moduleName}.entity.${ClassName}Entity;
|
||||
<#if tableOperation?seq_contains('import')>
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
</#if>
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${tableComment}
|
||||
*
|
||||
* @author ${author} ${email!}
|
||||
* <a href="https://maku.net">MAKU</a>
|
||||
*/
|
||||
public interface ${ClassName}Service extends BaseService<${ClassName}Entity> {
|
||||
|
||||
PageResult<${ClassName}VO> page(${ClassName}Query query);
|
||||
|
||||
${ClassName}VO get(Long id);
|
||||
|
||||
<#if hasTree>
|
||||
List<${ClassName}VO> list(Long ${treePid});
|
||||
</#if>
|
||||
|
||||
<#if tableOperation?seq_contains('insert')>
|
||||
void save(${ClassName}VO vo);
|
||||
</#if>
|
||||
|
||||
<#if tableOperation?seq_contains('update')>
|
||||
void update(${ClassName}VO vo);
|
||||
</#if>
|
||||
|
||||
<#if tableOperation?seq_contains('delete')>
|
||||
void delete(List<Long> idList);
|
||||
</#if>
|
||||
|
||||
<#if tableOperation?seq_contains('import')>
|
||||
void importByExcel(MultipartFile file);
|
||||
</#if>
|
||||
|
||||
<#if tableOperation?seq_contains('export')>
|
||||
void export();
|
||||
</#if>
|
||||
}
|
||||
|
|
@ -1,264 +0,0 @@
|
|||
package ${package}.${moduleName}.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import ${package}.framework.common.utils.PageResult;
|
||||
import ${package}.framework.mybatis.service.impl.BaseServiceImpl;
|
||||
import ${package}.${moduleName}.convert.${ClassName}Convert;
|
||||
import ${package}.${moduleName}.entity.${ClassName}Entity;
|
||||
import ${package}.${moduleName}.query.${ClassName}Query;
|
||||
import ${package}.${moduleName}.vo.${ClassName}VO;
|
||||
import ${package}.${moduleName}.dao.${ClassName}Dao;
|
||||
import ${package}.${moduleName}.service.${ClassName}Service;
|
||||
<#list subs as sub>
|
||||
import ${package}.${moduleName}.convert.${sub.ClassName}Convert;
|
||||
import ${package}.${moduleName}.entity.${sub.ClassName}Entity;
|
||||
import ${package}.${moduleName}.dao.${sub.ClassName}Dao;
|
||||
</#list>
|
||||
<#if tableOperation?seq_contains('import') || tableOperation?seq_contains('export')>
|
||||
import com.fhs.trans.service.impl.TransService;
|
||||
import ${package}.framework.common.utils.ExcelUtils;
|
||||
import ${package}.${moduleName}.vo.${ClassName}ExcelVO;
|
||||
import ${package}.framework.common.excel.ExcelFinishCallBack;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
</#if>
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${tableComment}
|
||||
*
|
||||
* @author ${author} ${email!}
|
||||
* <a href="https://maku.net">MAKU</a>
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class ${ClassName}ServiceImpl extends BaseServiceImpl<${ClassName}Dao, ${ClassName}Entity> implements ${ClassName}Service {
|
||||
<#if tableOperation?seq_contains('import') || tableOperation?seq_contains('export')>
|
||||
private final TransService transService;
|
||||
</#if>
|
||||
<#list subs as sub>
|
||||
private final ${sub.ClassName}Dao ${sub.className}Dao;
|
||||
</#list>
|
||||
|
||||
@Override
|
||||
public PageResult<${ClassName}VO> page(${ClassName}Query query) {
|
||||
IPage<${ClassName}Entity> page = baseMapper.selectPage(getPage(query), getWrapper(query));
|
||||
|
||||
<#if hasTree>
|
||||
return new PageResult<>(getHasChild(page.getRecords()), page.getTotal());
|
||||
<#else>
|
||||
return new PageResult<>(${ClassName}Convert.INSTANCE.convertList(page.getRecords()), page.getTotal());
|
||||
</#if>
|
||||
}
|
||||
|
||||
<#if hasTree>
|
||||
@Override
|
||||
public List<${ClassName}VO> list(Long ${treePid}) {
|
||||
LambdaQueryWrapper<${ClassName}Entity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(${treePid} != null, ${ClassName}Entity::get${treePid?cap_first}, ${treePid});
|
||||
|
||||
List<${ClassName}Entity> list = baseMapper.selectList(wrapper);
|
||||
|
||||
<#if hasTree>
|
||||
return getHasChild(list);
|
||||
<#else>
|
||||
return ${ClassName}Convert.INSTANCE.convertList(list);
|
||||
</#if>
|
||||
}
|
||||
</#if>
|
||||
|
||||
private LambdaQueryWrapper<${ClassName}Entity> getWrapper(${ClassName}Query query){
|
||||
LambdaQueryWrapper<${ClassName}Entity> wrapper = Wrappers.lambdaQuery();
|
||||
<#list queryList as field>
|
||||
<#if hasTree && field.attrName == treePid>
|
||||
<#assign hasTreePid = true>
|
||||
if (ObjectUtil.isNotEmpty(query.get${field.attrName?cap_first}())) {
|
||||
wrapper.eq(${ClassName}Entity::get${field.attrName?cap_first}, query.get${field.attrName?cap_first}());
|
||||
} else {
|
||||
wrapper.isNull(${ClassName}Entity::get${treePid?cap_first});
|
||||
}
|
||||
<#else>
|
||||
<#if field.queryFormType == 'date' || field.queryFormType == 'datetime'>
|
||||
if (ObjectUtil.isNotEmpty(query.get${field.attrName?cap_first}())) {
|
||||
wrapper.between(${ClassName}Entity::get${field.attrName?cap_first}, query.get${field.attrName?cap_first}().get(0), query.get${field.attrName?cap_first}().get(1));
|
||||
}
|
||||
<#elseif field.queryType == '='>
|
||||
wrapper.eq(ObjectUtil.isNotEmpty(query.get${field.attrName?cap_first}()), ${ClassName}Entity::get${field.attrName?cap_first}, query.get${field.attrName?cap_first}());
|
||||
<#elseif field.queryType == 'like'>
|
||||
wrapper.like(ObjectUtil.isNotEmpty(query.get${field.attrName?cap_first}()), ${ClassName}Entity::get${field.attrName?cap_first}, query.get${field.attrName?cap_first}());
|
||||
</#if>
|
||||
</#if>
|
||||
|
||||
</#list>
|
||||
<#if hasTree && !hasTreePid??>
|
||||
wrapper.isNull(${ClassName}Entity::get${treePid?cap_first});
|
||||
</#if>
|
||||
<#if hasLeftTree>
|
||||
|
||||
// 左侧树过滤
|
||||
wrapper.in(query.get${leftRelationField?cap_first}() != null, ${ClassName}Entity::get${leftRelationField?cap_first}, query.get${leftRelationField?cap_first}());
|
||||
</#if>
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
<#if hasTree>
|
||||
private List<${ClassName}VO> getHasChild(List<${ClassName}Entity> entityList) {
|
||||
List<${ClassName}VO> list = ${ClassName}Convert.INSTANCE.convertList(entityList);
|
||||
list.forEach(vo -> {
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<${ClassName}Entity>().eq(${ClassName}Entity::get${treePid?cap_first}, vo.get${treeId?cap_first}()));
|
||||
vo.setHasChild(count > 0);
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
</#if>
|
||||
|
||||
@Override
|
||||
public ${ClassName}VO get(Long id) {
|
||||
${ClassName}Entity entity = baseMapper.selectById(id);
|
||||
${ClassName}VO vo = ${ClassName}Convert.INSTANCE.convert(entity);
|
||||
|
||||
<#list subs as sub>
|
||||
<#if sub.mainRelation ==1>
|
||||
${sub.ClassName}Entity ${sub.className}Entity = ${sub.className}Dao.selectOne(Wrappers.lambdaQuery(${sub.ClassName}Entity.class).eq(${sub.ClassName}Entity::get${sub.ForeignKey}, id));
|
||||
vo.set${sub.ClassName}(${sub.ClassName}Convert.INSTANCE.convert(${sub.className}Entity));
|
||||
</#if>
|
||||
<#if sub.mainRelation ==2>
|
||||
List<${sub.ClassName}Entity> ${sub.className}List = ${sub.className}Dao.selectList(Wrappers.lambdaQuery(${sub.ClassName}Entity.class).eq(${sub.ClassName}Entity::get${sub.ForeignKey}, id));
|
||||
vo.set${sub.ClassName}(${sub.ClassName}Convert.INSTANCE.convertList(${sub.className}List));
|
||||
</#if>
|
||||
|
||||
</#list>
|
||||
return vo;
|
||||
}
|
||||
|
||||
<#if tableOperation?seq_contains('insert')>
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(${ClassName}VO vo) {
|
||||
${ClassName}Entity entity = ${ClassName}Convert.INSTANCE.convert(vo);
|
||||
|
||||
baseMapper.insert(entity);
|
||||
|
||||
<#list subs as sub>
|
||||
${sub.className}Dao.delete(Wrappers.lambdaQuery(${sub.ClassName}Entity.class).eq(${sub.ClassName}Entity::get${sub.ForeignKey}, entity.getId()));
|
||||
</#list>
|
||||
|
||||
<#list subs as sub>
|
||||
<#if sub.mainRelation ==1>
|
||||
${sub.ClassName}Entity ${sub.className}Entity = ${sub.ClassName}Convert.INSTANCE.convert(vo.get${sub.ClassName}());
|
||||
${sub.className}Entity.set${sub.ForeignKey}(entity.getId());
|
||||
${sub.className}Dao.insert(${sub.className}Entity);
|
||||
</#if>
|
||||
<#if sub.mainRelation ==2>
|
||||
List<${sub.ClassName}Entity> ${sub.className}List = ${sub.ClassName}Convert.INSTANCE.convertList2(vo.get${sub.ClassName}());
|
||||
${sub.className}List.forEach(${sub.className}Entity -> {
|
||||
${sub.className}Entity.set${sub.ForeignKey}(entity.getId());
|
||||
${sub.className}Dao.insert(${sub.className}Entity);
|
||||
});
|
||||
</#if>
|
||||
|
||||
</#list>
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if tableOperation?seq_contains('update')>
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(${ClassName}VO vo) {
|
||||
${ClassName}Entity entity = ${ClassName}Convert.INSTANCE.convert(vo);
|
||||
|
||||
updateById(entity);
|
||||
|
||||
<#list subs as sub>
|
||||
${sub.className}Dao.delete(Wrappers.lambdaQuery(${sub.ClassName}Entity.class).eq(${sub.ClassName}Entity::get${sub.ForeignKey}, entity.getId()));
|
||||
</#list>
|
||||
|
||||
<#list subs as sub>
|
||||
<#if sub.mainRelation ==1>
|
||||
${sub.ClassName}Entity ${sub.className}Entity = ${sub.ClassName}Convert.INSTANCE.convert(vo.get${sub.ClassName}());
|
||||
${sub.className}Entity.set${sub.ForeignKey}(entity.getId());
|
||||
${sub.className}Dao.insert(${sub.className}Entity);
|
||||
</#if>
|
||||
<#if sub.mainRelation ==2>
|
||||
List<${sub.ClassName}Entity> ${sub.className}List = ${sub.ClassName}Convert.INSTANCE.convertList2(vo.get${sub.ClassName}());
|
||||
${sub.className}List.forEach(${sub.className}Entity -> {
|
||||
${sub.className}Entity.set${sub.ForeignKey}(entity.getId());
|
||||
${sub.className}Dao.insert(${sub.className}Entity);
|
||||
});
|
||||
</#if>
|
||||
|
||||
</#list>
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if tableOperation?seq_contains('delete')>
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(List<Long> idList) {
|
||||
<#if hasTree>
|
||||
idList.forEach(this::deleteAllChildren);
|
||||
<#else>
|
||||
removeByIds(idList);
|
||||
</#if>
|
||||
|
||||
<#if subs?size gt 0>
|
||||
// 删除子表数据
|
||||
idList.forEach(id -> {
|
||||
<#list subs as sub>
|
||||
${sub.className}Dao.delete(Wrappers.lambdaQuery(${sub.ClassName}Entity.class).eq(${sub.ClassName}Entity::get${sub.ForeignKey}, id));
|
||||
</#list>
|
||||
});
|
||||
</#if>
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if hasTree>
|
||||
/**
|
||||
* 递归删除所有子节点
|
||||
*
|
||||
* @param id 节点ID
|
||||
*/
|
||||
private void deleteAllChildren(Long id) {
|
||||
// 查询当前节点的所有子节点
|
||||
List<${ClassName}Entity> childrenList = baseMapper.selectList(new LambdaQueryWrapper<${ClassName}Entity>().eq(${ClassName}Entity::get${treePid?cap_first}, id));
|
||||
// 递归删除每个子节点
|
||||
for (${ClassName}Entity children : childrenList) {
|
||||
deleteAllChildren(children.getId());
|
||||
}
|
||||
|
||||
// 删除当前节点
|
||||
baseMapper.deleteById(id);
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if tableOperation?seq_contains('import')>
|
||||
@Override
|
||||
public void importByExcel(MultipartFile file) {
|
||||
ExcelUtils.readAnalysis(file, ${ClassName}ExcelVO.class, new ExcelFinishCallBack<>() {
|
||||
@Override
|
||||
public void doSaveBatch(List<${ClassName}ExcelVO> resultList) {
|
||||
ExcelUtils.parseDict(resultList);
|
||||
saveBatch(${ClassName}Convert.INSTANCE.convertExcelList2(resultList));
|
||||
}
|
||||
});
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if tableOperation?seq_contains('export')>
|
||||
@Override
|
||||
public void export() {
|
||||
List<${ClassName}ExcelVO> excelList = ${ClassName}Convert.INSTANCE.convertExcelList(list());
|
||||
transService.transBatch(excelList);
|
||||
ExcelUtils.excelExport(${ClassName}ExcelVO.class, "${tableComment}", null, excelList);
|
||||
}
|
||||
</#if>
|
||||
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
package ${package}.${moduleName}.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import ${package}.framework.common.utils.DateUtils;
|
||||
<#list importList as i>
|
||||
import ${i!};
|
||||
</#list>
|
||||
|
||||
/**
|
||||
* ${tableComment}
|
||||
*
|
||||
* @author ${author} ${email!}
|
||||
* <a href="https://maku.net">MAKU</a>
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "${tableComment}")
|
||||
public class ${ClassName}VO {
|
||||
<#list fieldList as field>
|
||||
<#if field.fieldComment!?length gt 0>
|
||||
@Schema(description = "${field.fieldComment}")
|
||||
</#if>
|
||||
<#if field.attrType == 'LocalDateTime'>
|
||||
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
||||
</#if>
|
||||
private ${field.attrType} ${field.attrName};
|
||||
|
||||
</#list>
|
||||
<#list subs as sub>
|
||||
@Schema(description = "${sub.tableTitle}")
|
||||
<#if sub.mainRelation ==1>
|
||||
private ${sub.ClassName}VO ${sub.className};
|
||||
<#else>
|
||||
private List<${sub.ClassName}VO> ${sub.className};
|
||||
</#if>
|
||||
|
||||
</#list>
|
||||
<#if hasTree>
|
||||
@Schema(description = "是否有子节点")
|
||||
private Boolean hasChild;
|
||||
</#if>
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
<#assign dbTime = "now()">
|
||||
<#if dbType=="SQLServer">
|
||||
<#assign dbTime = "getDate()">
|
||||
</#if>
|
||||
|
||||
-- 初始化菜单
|
||||
INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (1, '${tableComment!}', '${moduleName}/${functionName}/index', <#if authLevel==0>'${authority}'<#else>NULL</#if>, 0, 0, 'icon-menu', 0, 0, 0, 10000, ${dbTime}, 10000, ${dbTime});
|
||||
|
||||
<#if authLevel==1>
|
||||
|
||||
<#assign pid = "(SELECT max(id) from sys_menu where name = '${tableComment!}')">
|
||||
<#if dbType=="MySQL">
|
||||
set @menuId = @@identity;
|
||||
<#assign pid = "(SELECT @menuId)">
|
||||
</#if>
|
||||
|
||||
INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (${pid}, '查看', '', '${authority}:page', 1, 0, '', 0, 0, 0, 10000, ${dbTime}, 10000, ${dbTime});
|
||||
<#if tableOperation?seq_contains('insert')>
|
||||
INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (${pid}, '新增', '', '${authority}:save', 1, 0, '', 1, 0, 0, 10000, ${dbTime}, 10000, ${dbTime});
|
||||
</#if>
|
||||
<#if tableOperation?seq_contains('update')>
|
||||
INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (${pid}, '修改', '', '${authority}:update,${authority}:info', 1, 0, '', 2, 0, 0, 10000, ${dbTime}, 10000, ${dbTime});
|
||||
</#if>
|
||||
<#if tableOperation?seq_contains('delete')>
|
||||
INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (${pid}, '删除', '', '${authority}:delete', 1, 0, '', 3, 0, 0, 10000, ${dbTime}, 10000, ${dbTime});
|
||||
</#if>
|
||||
<#if tableOperation?seq_contains('import')>
|
||||
INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (${pid}, '导入', '', '${authority}:import', 1, 0, '', 3, 0, 0, 10000, ${dbTime}, 10000, ${dbTime});
|
||||
</#if>
|
||||
<#if tableOperation?seq_contains('export')>
|
||||
INSERT INTO sys_menu (pid, name, url, authority, type, open_style, icon, sort, version, deleted, creator, create_time, updater, update_time) VALUES (${pid}, '导出', '', '${authority}:export', 1, 0, '', 3, 0, 0, 10000, ${dbTime}, 10000, ${dbTime});
|
||||
</#if>
|
||||
</#if>
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
<#import "/vue/form.vue.ftl" as form>
|
||||
<template>
|
||||
<#if openType==0>
|
||||
<el-dialog v-model="visible" :title="!dataForm.id ? '新增' : '修改'" :close-on-click-modal="false" draggable>
|
||||
<#else>
|
||||
<el-drawer v-model="visible" :title="!dataForm.id ? '新增' : '修改'" :size="1000">
|
||||
</#if>
|
||||
<@form.maForm></@form.maForm>
|
||||
<#if subs?size gt 0>
|
||||
<el-tabs v-model="activeName">
|
||||
<#list subs as sub>
|
||||
<el-tab-pane label="${sub.tableTitle}" name="${sub.className}">
|
||||
<${sub.ClassName} ref="${sub.className}Ref" :value="dataForm.${sub.className}"/>
|
||||
</el-tab-pane>
|
||||
</#list>
|
||||
</el-tabs>
|
||||
</#if>
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submitHandle()">确定</el-button>
|
||||
</template>
|
||||
<#if openType==0>
|
||||
</el-dialog>
|
||||
<#else>
|
||||
</el-drawer>
|
||||
</#if>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus/es'
|
||||
import { use${FunctionName}Api, use${FunctionName}SubmitApi } from '@/api/${moduleName}/${functionName}'
|
||||
<#list subs as sub>
|
||||
import ${sub.ClassName} from './${sub.className}.vue'
|
||||
</#list>
|
||||
|
||||
const emit = defineEmits(['refreshDataList'])
|
||||
|
||||
const visible = defineModel<boolean>('visible')
|
||||
const dataFormRef = ref()
|
||||
<#if subs?size gt 0>
|
||||
const activeName = ref('${subs[0].className}')
|
||||
</#if>
|
||||
<#list subs as sub>
|
||||
const ${sub.className}Ref = ref()
|
||||
</#list>
|
||||
|
||||
const dataForm = reactive({
|
||||
<#list subs as sub>
|
||||
<#if sub.mainRelation == 1>
|
||||
${sub.className}: {},
|
||||
<#else>
|
||||
${sub.className}: [],
|
||||
</#if>
|
||||
</#list>
|
||||
<#list fieldList as field>
|
||||
${field.attrName}: ''<#sep>,
|
||||
</#list>
|
||||
})
|
||||
|
||||
const init = (id?: number) => {
|
||||
if (id) {
|
||||
get${FunctionName}(id)
|
||||
}
|
||||
}
|
||||
|
||||
const get${FunctionName} = (id: number) => {
|
||||
use${FunctionName}Api(id).then(res => {
|
||||
Object.assign(dataForm, res.data)
|
||||
})
|
||||
}
|
||||
|
||||
const dataRules = ref({
|
||||
<#list formList as field>
|
||||
<#if field.formRequired>
|
||||
${field.attrName}: [{ required: true, message: '必填项不能为空', trigger: 'blur' }]<#sep>,
|
||||
</#if>
|
||||
</#list>
|
||||
})
|
||||
|
||||
// 表单提交
|
||||
const submitHandle = () => {
|
||||
dataFormRef.value.validate(async (valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false
|
||||
}
|
||||
|
||||
<#list subs as sub>
|
||||
dataForm.${sub.className} = await ${sub.className}Ref.value.getData()
|
||||
</#list>
|
||||
|
||||
use${FunctionName}SubmitApi(dataForm).then(() => {
|
||||
ElMessage.success({
|
||||
message: '操作成功',
|
||||
duration: 500,
|
||||
onClose: () => {
|
||||
visible.value = false
|
||||
emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
init
|
||||
})
|
||||
</script>
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
import service from '@/utils/request'
|
||||
|
||||
export const use${FunctionName}Api = (id: number) => {
|
||||
return service.get('${requestUrl}/' + id)
|
||||
}
|
||||
|
||||
<#if hasTree>
|
||||
export const use${FunctionName}TreeLoadApi = (${treePid}: number) => {
|
||||
return service.get('${requestUrl}/list?${treePid}=' + ${treePid})
|
||||
}
|
||||
|
||||
</#if>
|
||||
export const use${FunctionName}SubmitApi = (dataForm: any) => {
|
||||
if (dataForm.id) {
|
||||
return service.put('${requestUrl}', dataForm)
|
||||
} else {
|
||||
return service.post('${requestUrl}', dataForm)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
<#macro maFormItem model field>
|
||||
<el-form-item label="${field.fieldComment!}" prop="${field.attrName}">
|
||||
<#if hasTree && field.attrName == treePid>
|
||||
<ma-data-tree-select
|
||||
v-model="${model}.${field.attrName}"
|
||||
url="${requestUrl}/list"
|
||||
:props="{ label: '${treeLabel}', value: '${treeId}', pid: '${treePid}' }"
|
||||
placeholder="${field.fieldComment!}" />
|
||||
<#elseif hasLeftTree?? && field.attrName == leftRelationField>
|
||||
<ma-data-tree-select
|
||||
v-model="${model}.${field.attrName}"
|
||||
<#if hasLeftFormDs??>
|
||||
:props="{ label: '${leftTreeLabel}', value: '${leftTreeId}' }"
|
||||
url="${leftRequestUrl}/list"
|
||||
<#else>
|
||||
url="${leftRequestUrl}"
|
||||
</#if>
|
||||
/>
|
||||
<#elseif field.formType == 'input'>
|
||||
<el-input v-model="${model}.${field.attrName}" placeholder="${field.fieldComment!}"></el-input>
|
||||
<#elseif field.formType == 'number'>
|
||||
<el-input-number v-model="${model}.${field.attrName}" placeholder="${field.fieldComment!}"></el-input-number>
|
||||
<#elseif field.formType == 'textarea'>
|
||||
<el-input type="textarea" v-model="${model}.${field.attrName}" placeholder="${field.fieldComment!}"></el-input>
|
||||
<#elseif field.formType == 'editor'>
|
||||
<ma-editor v-model="${model}.${field.attrName}" placeholder="${field.fieldComment!}"></ma-editor>
|
||||
<#elseif field.formType == 'select'>
|
||||
<#if field.formDict??>
|
||||
<ma-dict-select v-model="${model}.${field.attrName}" dict-type="${field.formDict}" placeholder="${field.fieldComment!}"></ma-dict-select>
|
||||
<#else>
|
||||
<el-select v-model="${model}.${field.attrName}" placeholder="${field.fieldComment!}">
|
||||
<el-option label="请选择" :value="0"></el-option>
|
||||
</el-select>
|
||||
</#if>
|
||||
<#elseif field.formType == 'radio'>
|
||||
<#if field.formDict??>
|
||||
<ma-dict-radio v-model="${model}.${field.attrName}" dict-type="${field.formDict}"></ma-dict-radio>
|
||||
<#else>
|
||||
<el-radio-group v-model="${model}.${field.attrName}">
|
||||
<el-radio :value="0">启用</el-radio>
|
||||
<el-radio :value="1">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</#if>
|
||||
<#elseif field.formType == 'checkbox'>
|
||||
<#if field.formDict??>
|
||||
<ma-dict-checkbox v-model="${model}.${field.attrName}" dict-type="${field.formDict}"></ma-dict-checkbox>
|
||||
<#else>
|
||||
<el-checkbox-group v-model="${model}.${field.attrName}">
|
||||
<el-checkbox :value="1">启用</el-checkbox>
|
||||
<el-checkbox :value="0">禁用</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</#if>
|
||||
<#elseif field.formType == 'address'>
|
||||
<ma-address v-model="${model}.${field.attrName}" placeholder="${field.fieldComment!}"></ma-address>
|
||||
<#elseif field.formType == 'date'>
|
||||
<el-date-picker type="date" value-format="YYYY-MM-DD" placeholder="${field.fieldComment!}" v-model="${model}.${field.attrName}"></el-date-picker>
|
||||
<#elseif field.formType == 'datetime'>
|
||||
<el-date-picker type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="${field.fieldComment!}" v-model="${model}.${field.attrName}"></el-date-picker>
|
||||
<#elseif field.formType == 'treeselect'>
|
||||
<ma-data-tree-select v-model="${model}.${field.attrName}" url="${field.formDict!}" :props="{ label: 'name', value: 'id' }" placeholder="${field.fieldComment!}" />
|
||||
<#elseif field.formType == 'user'>
|
||||
<ma-user-input v-model="${model}.${field.attrName}" placeholder="${field.fieldComment!}"></ma-user-input>
|
||||
<#elseif field.formType == 'org'>
|
||||
<ma-org-select v-model="${model}.${field.attrName}" placeholder="${field.fieldComment!}"></ma-org-select>
|
||||
<#elseif field.formType == 'post'>
|
||||
<ma-post-input v-model="${model}.${field.attrName}" placeholder="${field.fieldComment!}"></ma-post-input>
|
||||
<#elseif field.formType == 'file'>
|
||||
<ma-upload-file v-model="${model}.${field.attrName}"></ma-upload-file>
|
||||
<#elseif field.formType == 'image'>
|
||||
<ma-upload-images v-model="${model}.${field.attrName}"></ma-upload-images>
|
||||
<#else>
|
||||
<el-input v-model="${model}.${field.attrName}" placeholder="${field.fieldComment!}"></el-input>
|
||||
</#if>
|
||||
</el-form-item>
|
||||
</#macro>
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
<#import "/vue/form-item.vue.ftl" as formItem>
|
||||
|
||||
<#macro maForm>
|
||||
<el-form ref="dataFormRef" :model="dataForm" :rules="dataRules" :label-width="100">
|
||||
<#list formList as field>
|
||||
<#if (formLayout > 1)>
|
||||
<#if field_index % 2 == 0>
|
||||
<el-row>
|
||||
</#if>
|
||||
<el-col :span="12">
|
||||
<@formItem.maFormItem model='dataForm' field=field></@formItem.maFormItem>
|
||||
</el-col><#nt>
|
||||
<#if field_index % 2 != 0 || formList?size == field_index + 1>
|
||||
</el-row>
|
||||
</#if>
|
||||
<#else>
|
||||
<@formItem.maFormItem model='dataForm' field=field ></@formItem.maFormItem>
|
||||
</#if>
|
||||
</#list>
|
||||
<#nested>
|
||||
</el-form>
|
||||
</#macro>
|
||||
|
|
@ -1,211 +0,0 @@
|
|||
<template>
|
||||
<#if hasLeftTree>
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="5">
|
||||
<#if hasLeftFormDs??>
|
||||
<ma-data-tree-left url="${leftRequestUrl}/list" title="${leftTitle}" manage @click="handleClick" @manage="treeVisible = true" />
|
||||
<#else>
|
||||
<ma-data-tree-left url="${leftRequestUrl}" title="${leftTitle}" @click="handleClick" />
|
||||
</#if>
|
||||
</el-col>
|
||||
<el-col :span="19">
|
||||
</#if>
|
||||
<#if tableOperation?seq_contains('query')>
|
||||
<el-card class="layout-query">
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList()">
|
||||
<#list queryList as field>
|
||||
<el-form-item prop="${field.attrName}">
|
||||
<#if hasTree && field.attrName == treePid>
|
||||
<ma-data-tree-select
|
||||
v-model="state.queryForm.${field.attrName}"
|
||||
url="${requestUrl}/list"
|
||||
:props="{ label: '${treeLabel}', value: '${treeId}', pid: '${treePid}' }"
|
||||
placeholder="${field.fieldComment!}" />
|
||||
<#elseif field.queryFormType == 'input'>
|
||||
<el-input v-model="state.queryForm.${field.attrName}" placeholder="${field.fieldComment!}"></el-input>
|
||||
<#elseif field.queryFormType == 'select'>
|
||||
<#if field.formDict??>
|
||||
<ma-dict-select v-model="state.queryForm.${field.attrName}" dict-type="${field.formDict}" placeholder="${field.fieldComment!}" clearable></ma-dict-select>
|
||||
<#else>
|
||||
<el-select v-model="state.queryForm.${field.attrName}" placeholder="${field.fieldComment!}">
|
||||
<el-option label="选择" value="0"></el-option>
|
||||
</el-select>
|
||||
</#if>
|
||||
<#elseif field.queryFormType == 'radio'>
|
||||
<#if field.formDict??>
|
||||
<ma-dict-radio v-model="state.queryForm.${field.attrName}" dict-type="${field.formDict}" placeholder="${field.fieldComment!}"></ma-dict-radio>
|
||||
<#else>
|
||||
<el-radio-group v-model="state.queryForm.${field.attrName}" placeholder="${field.fieldComment!}">
|
||||
<el-radio :label="0">单选</el-radio>
|
||||
</el-radio-group>
|
||||
</#if>
|
||||
<#elseif field.queryFormType == 'date'>
|
||||
<el-date-picker v-model="state.queryForm.${field.attrName}" value-format="YYYY-MM-DD" type="daterange" start-placeholder="${field.fieldComment!}" end-placeholder="结束日期" clearable />
|
||||
<#elseif field.queryFormType == 'datetime'>
|
||||
<el-date-picker v-model="state.queryForm.${field.attrName}" value-format="YYYY-MM-DD HH:mm:ss" type="datetimerange" start-placeholder="${field.fieldComment!}" end-placeholder="结束日期" clearable />
|
||||
<#elseif field.queryFormType == 'user'>
|
||||
<ma-user-input v-model="state.queryForm.${field.attrName}" placeholder="${field.fieldComment!}"></ma-user-input>
|
||||
<#elseif field.queryFormType == 'org'>
|
||||
<ma-org-input v-model="state.queryForm.${field.attrName}" placeholder="${field.fieldComment!}"></ma-org-input>
|
||||
<#elseif field.queryFormType == 'post'>
|
||||
<ma-post-input v-model="state.queryForm.${field.attrName}" placeholder="${field.fieldComment!}"></ma-post-input>
|
||||
<#else>
|
||||
<el-input v-model="state.queryForm.${field.attrName}" placeholder="${field.fieldComment!}"></el-input>
|
||||
</#if>
|
||||
</el-form-item>
|
||||
</#list>
|
||||
<el-form-item>
|
||||
<el-button icon="Search" type="primary" @click="getDataList()">查询</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="RefreshRight" @click="reset(queryRef)">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</#if>
|
||||
|
||||
<el-card>
|
||||
<#if tableOperation?seq_contains('insert') || tableOperation?seq_contains('import') || tableOperation?seq_contains('export') || tableOperation?seq_contains('delete')>
|
||||
<el-space>
|
||||
<#if tableOperation?seq_contains('insert')>
|
||||
<el-space>
|
||||
<el-button <#if authLevel==1>v-auth="'${authority}:save'" </#if>icon="Plus" type="primary" @click="addOrUpdateHandle()">新增</el-button>
|
||||
</el-space>
|
||||
</#if>
|
||||
<#if tableOperation?seq_contains('import')>
|
||||
<el-space <#if authLevel==1>v-auth="'${authority}:import'"</#if>>
|
||||
<ma-upload-excel action="${requestUrl}/import">
|
||||
<el-button plain icon="Upload">导入</el-button>
|
||||
</ma-upload-excel>
|
||||
</el-space>
|
||||
</#if>
|
||||
<#if tableOperation?seq_contains('export')>
|
||||
<el-space>
|
||||
<el-button <#if authLevel==1>v-auth="'${authority}:export'" </#if>plain icon="Download" @click="downloadHandle('${requestUrl}/export')">导出</el-button>
|
||||
</el-space>
|
||||
</#if>
|
||||
<#if tableOperation?seq_contains('delete')>
|
||||
<el-space>
|
||||
<el-button <#if authLevel==1>v-auth="'${authority}:delete'" </#if>icon="Delete" plain type="danger" @click="deleteBatchHandle()">批量删除</el-button>
|
||||
</el-space>
|
||||
</#if>
|
||||
</el-space>
|
||||
</#if>
|
||||
<el-table v-loading="state.dataListLoading" :data="state.dataList" border class="layout-table" show-overflow-tooltip @selection-change="selectionChangeHandle" <#if hasTree>row-key="id" lazy :load="load" :tree-props="{ hasChildren: 'hasChild' }"</#if>>
|
||||
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
|
||||
<#list gridList as field>
|
||||
<#if field.formDict??>
|
||||
<ma-dict-column prop="${field.attrName}" label="${field.fieldComment!}" dict-type="${field.formDict}"></ma-dict-column>
|
||||
<#elseif field.formType=='image'>
|
||||
<ma-image-column prop="${field.attrName}" label="${field.fieldComment!}" header-align="center" align="center"></ma-image-column>
|
||||
<#else>
|
||||
<el-table-column prop="${field.attrName}" label="${field.fieldComment!}" header-align="center" align="center"></el-table-column>
|
||||
</#if>
|
||||
</#list>
|
||||
<#if tableOperation?seq_contains('update') || tableOperation?seq_contains('delete')>
|
||||
<el-table-column label="操作" fixed="right" header-align="center" align="center" width="150">
|
||||
<template #default="scope">
|
||||
<#if tableOperation?seq_contains('update')>
|
||||
<el-button <#if authLevel==1>v-auth="'${authority}:update'" </#if>type="primary" link @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
|
||||
</#if>
|
||||
<#if tableOperation?seq_contains('delete')>
|
||||
<el-button <#if authLevel==1>v-auth="'${authority}:delete'" </#if>type="primary" link @click="deleteBatchHandle(scope.row.id)">删除</el-button>
|
||||
</#if>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</#if>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
:current-page="state.page"
|
||||
:page-sizes="state.pageSizes"
|
||||
:page-size="state.limit"
|
||||
:total="state.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
>
|
||||
</el-pagination>
|
||||
|
||||
<#if tableOperation?seq_contains('insert') || tableOperation?seq_contains('update')>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdateRef" v-model:visible="addOrUpdateVisible" @refreshDataList="getDataList"></add-or-update>
|
||||
</#if>
|
||||
<#if hasLeftTree && hasLeftFormDs??>
|
||||
<el-drawer v-if="treeVisible" v-model="treeVisible" title="${leftTitle}" :size="800" :before-close="handleClose">
|
||||
<Left${FunctionNameLeft}></Left${FunctionNameLeft}>
|
||||
</el-drawer>
|
||||
</#if>
|
||||
</el-card>
|
||||
<#if hasLeftTree>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</#if>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="${ModuleName}${FunctionName}Index">
|
||||
import {useCrud} from '@/hooks'
|
||||
import {reactive, nextTick, ref} from 'vue'
|
||||
import {IHooksOptions} from '@/hooks/interface'
|
||||
<#if tableOperation?seq_contains('insert') || tableOperation?seq_contains('update')>
|
||||
import AddOrUpdate from './add-or-update.vue'
|
||||
</#if>
|
||||
<#if hasTree>import { use${FunctionName}TreeLoadApi } from '@/api/${moduleName}/${functionName}'</#if>
|
||||
<#if hasLeftTree>
|
||||
<#if hasLeftFormDs??>
|
||||
import Left${FunctionNameLeft} from '../${functionNameLeft}/index.vue'
|
||||
import emit, { MittEvent } from '@/utils/emits'
|
||||
|
||||
const treeVisible = ref(false)
|
||||
const handleClose = () => {
|
||||
treeVisible.value = false
|
||||
emit.emit(MittEvent.LeftTree)
|
||||
}
|
||||
</#if>
|
||||
const handleClick = (idList: any[]) => {
|
||||
state.queryForm.${leftRelationField} = idList
|
||||
getDataList()
|
||||
}
|
||||
|
||||
</#if>
|
||||
const state: IHooksOptions = reactive({
|
||||
dataListUrl: '${requestUrl}/page',
|
||||
<#if tableOperation?seq_contains('query')>
|
||||
deleteUrl: '${requestUrl}',
|
||||
</#if>
|
||||
queryForm: {
|
||||
<#if hasLeftTree>${leftRelationField}: [],</#if>
|
||||
<#list queryList as field>
|
||||
<#if field.formType == 'date'>
|
||||
startDate: '',
|
||||
endDate: ''<#sep>, </#sep>
|
||||
<#elseif field.formType == 'datetime'>
|
||||
startDateTime: '',
|
||||
endDateTime: ''<#sep>, </#sep>
|
||||
<#else>
|
||||
${field.attrName}: ''<#sep>, </#sep>
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
})
|
||||
|
||||
const queryRef = ref()
|
||||
<#if tableOperation?seq_contains('insert') || tableOperation?seq_contains('update')>
|
||||
const addOrUpdateVisible = ref(false)
|
||||
const addOrUpdateRef = ref()
|
||||
const addOrUpdateHandle = (id?: number) => {
|
||||
addOrUpdateVisible.value = true
|
||||
nextTick(() => addOrUpdateRef.value.init(id))
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if hasTree>
|
||||
// 树数据加载
|
||||
const load = (tree: any, treeNode: unknown, resolve: (data: any[]) => void) => {
|
||||
use${FunctionName}TreeLoadApi(tree.${treeId}).then((res: any) => {
|
||||
resolve(res.data)
|
||||
})
|
||||
}
|
||||
</#if>
|
||||
|
||||
const { getDataList, selectionChangeHandle, sizeChangeHandle, currentChangeHandle, deleteBatchHandle, downloadHandle, reset } = useCrud(state)
|
||||
</script>
|
||||
|
|
@ -1,183 +0,0 @@
|
|||
<#import "/vue/form.vue.ftl" as form>
|
||||
<template>
|
||||
<#if mainRelation == 1>
|
||||
<@form.maForm></@form.maForm>
|
||||
</#if>
|
||||
<#if mainRelation == 2>
|
||||
<el-button type="primary" plain icon="Plus" @click="openDialog">新增</el-button>
|
||||
<el-button type="danger" plain icon="Delete" @click="removeBatchEvent">删除</el-button>
|
||||
<vxe-table ref="xTable" max-height="500" style="margin-top: 10px" :data="value">
|
||||
<vxe-column type="checkbox" width="60"></vxe-column>
|
||||
<#list formList as field>
|
||||
<vxe-column field="${field.attrName}" title="${field.fieldComment!}"></vxe-column>
|
||||
</#list>
|
||||
<vxe-column title="操作" width="100" show-overflow>
|
||||
<template #default="{ row }">
|
||||
<vxe-button type="text" icon="vxe-icon-edit" @click="editEvent(row)"></vxe-button>
|
||||
<vxe-button type="text" icon="vxe-icon-delete" @click="removeEvent(row)"></vxe-button>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
<el-dialog v-model="visible" :title="!selectRow ? '新增' : '修改'" draggable @close="closeDialog">
|
||||
<@form.maForm></@form.maForm>
|
||||
<template #footer>
|
||||
<el-button @click="closeDialog">取消</el-button>
|
||||
<el-button type="primary" @click="submitEvent">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</#if>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
<#if mainRelation == 1>
|
||||
import { computed, PropType, ref } from 'vue'
|
||||
<#else>
|
||||
import { nextTick, reactive, ref } from 'vue'
|
||||
import VXETable from 'vxe-table'
|
||||
</#if>
|
||||
import { ElMessage } from 'element-plus/es'
|
||||
|
||||
<#if mainRelation == 1>
|
||||
const props = defineProps({
|
||||
value: {
|
||||
type: Object as PropType<any>,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
|
||||
const dataFormRef = ref()
|
||||
const dataForm = computed(() => props.value)
|
||||
|
||||
const dataRules = ref({
|
||||
<#list formList as field>
|
||||
<#if field.formRequired>
|
||||
${field.attrName}: [{ required: true, message: '必填项不能为空', trigger: 'blur' }]<#sep>,
|
||||
</#if>
|
||||
</#list>
|
||||
})
|
||||
|
||||
const getData = async () => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
dataFormRef.value
|
||||
.validate()
|
||||
.then((validate: boolean) => {
|
||||
if (validate) {
|
||||
resolve(dataForm)
|
||||
} else {
|
||||
ElMessage.error("表单效验失败")
|
||||
}
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
getData
|
||||
})
|
||||
<#else>
|
||||
const props = defineProps({
|
||||
value: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
})
|
||||
|
||||
const dataFormRef = ref()
|
||||
const visible = ref(false)
|
||||
const xTable = ref()
|
||||
const selectRow = ref()
|
||||
|
||||
const dataForm = reactive({
|
||||
<#list fieldList as field>
|
||||
${field.attrName}: ''<#sep>,
|
||||
</#list>
|
||||
})
|
||||
|
||||
const dataRules = ref({
|
||||
<#list formList as field>
|
||||
<#if field.formRequired>
|
||||
${field.attrName}: [{ required: true, message: '必填项不能为空', trigger: 'blur' }]<#sep>,
|
||||
</#if>
|
||||
</#list>
|
||||
})
|
||||
|
||||
const openDialog = () => {
|
||||
dataForm.id = ''
|
||||
visible.value = true
|
||||
selectRow.value = null
|
||||
|
||||
dataFormRef.value?.resetFields()
|
||||
}
|
||||
|
||||
const closeDialog = () => {
|
||||
visible.value = false
|
||||
dataFormRef.value?.resetFields()
|
||||
}
|
||||
|
||||
const editEvent = (row: any) => {
|
||||
visible.value = true
|
||||
|
||||
dataFormRef.value?.resetFields()
|
||||
|
||||
selectRow.value = row
|
||||
nextTick(() => {
|
||||
Object.assign(dataForm, { ...row })
|
||||
})
|
||||
}
|
||||
|
||||
const removeEvent = async (row: any) => {
|
||||
const type = await VXETable.modal.confirm("您确定要删除该数据?")
|
||||
if (type === "confirm") {
|
||||
const $table = xTable.value
|
||||
if ($table) {
|
||||
$table.remove(row)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const removeBatchEvent = () => {
|
||||
const selectRecords = xTable.value.getCheckboxRecords()
|
||||
if (selectRecords.length) {
|
||||
xTable.value.removeCheckboxRow()
|
||||
} else {
|
||||
ElMessage.error("请至少选择一条数据")
|
||||
}
|
||||
}
|
||||
|
||||
const submitEvent = () => {
|
||||
dataFormRef.value.validate(async (valid: boolean) => {
|
||||
if (!valid) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (selectRow.value) {
|
||||
Object.assign(selectRow.value, dataForm)
|
||||
} else {
|
||||
await xTable.value.insertAt({ ...dataForm }, -1)
|
||||
}
|
||||
|
||||
// 关闭对话框
|
||||
closeDialog()
|
||||
})
|
||||
}
|
||||
|
||||
const getData = async () => {
|
||||
const data = xTable.value.getTableData().tableData
|
||||
|
||||
// 删除自带的属性
|
||||
data.map((e: any) => {
|
||||
delete e._X_ROW_KEY
|
||||
})
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
getData
|
||||
})
|
||||
</#if>
|
||||
|
||||
|
||||
</script>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="${package}.${moduleName}.dao.${ClassName}Dao">
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user