feat: 完成生成文本修改
This commit is contained in:
parent
51515d2d5f
commit
06f458bec2
|
@ -23,6 +23,9 @@ public class ColumnMetaData {
|
||||||
/* Java类型 */
|
/* Java类型 */
|
||||||
private String javaType;
|
private String javaType;
|
||||||
|
|
||||||
|
/* Javascript类型 */
|
||||||
|
private String javascriptType;
|
||||||
|
|
||||||
/* 是否为主键 */
|
/* 是否为主键 */
|
||||||
private Boolean isPrimaryKey;
|
private Boolean isPrimaryKey;
|
||||||
|
|
||||||
|
|
|
@ -30,30 +30,41 @@ public class VmsServiceImpl implements VmsService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GeneratorVo> generator(VmsArgumentDto dto) {
|
public List<GeneratorVo> generator(VmsArgumentDto dto) {
|
||||||
|
String tableName = dto.getTableName();
|
||||||
|
|
||||||
return dto.getPath().stream().map(path -> {
|
return dto.getPath().stream().map(path -> {
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
|
|
||||||
String vmsPath = "vms/" + path + ".vm";
|
// 表格属性名 和 列信息
|
||||||
String tableName = dto.getTableName();
|
|
||||||
|
|
||||||
TableInfoVo tableMetaData = tableService.getTableMetaData(tableName);
|
TableInfoVo tableMetaData = tableService.getTableMetaData(tableName);
|
||||||
List<ColumnMetaData> columnInfo = tableService.getColumnInfo(tableName);
|
List<ColumnMetaData> columnInfoList = tableService.getColumnInfo(tableName);
|
||||||
|
List<String> list = columnInfoList.stream().map(ColumnMetaData::getColumnName).toList();
|
||||||
|
|
||||||
|
// 添加要生成的属性
|
||||||
VelocityContext context = new VelocityContext();
|
VelocityContext context = new VelocityContext();
|
||||||
context.put("tableName", tableMetaData.getComment());
|
|
||||||
context.put("package", dto.getPackageName());
|
|
||||||
context.put("columnInfo", columnInfo);
|
|
||||||
|
|
||||||
// VmsUtil.commonVms(writer, context, "vms/server/controller.vm", dto);
|
// 当前的表名
|
||||||
VmsUtil.commonVms(writer, context, vmsPath, dto);
|
context.put("tableName", tableMetaData.getTableName());
|
||||||
String code = writer.toString();
|
|
||||||
|
// 表字段的注释内容
|
||||||
|
context.put("comment", tableMetaData.getComment());
|
||||||
|
|
||||||
|
// 设置包名称
|
||||||
|
context.put("package", dto.getPackageName());
|
||||||
|
|
||||||
|
// 当前表的列信息
|
||||||
|
context.put("columnInfoList", columnInfoList);
|
||||||
|
|
||||||
|
// 数据库sql列
|
||||||
|
context.put("baseColumnList", String.join(",", list));
|
||||||
|
|
||||||
|
VmsUtil.commonVms(writer, context, "vms/" + path + ".vm", dto);
|
||||||
|
|
||||||
return GeneratorVo.builder()
|
return GeneratorVo.builder()
|
||||||
.code(code)
|
.code(writer.toString())
|
||||||
.comment(tableMetaData.getComment())
|
.comment(tableMetaData.getComment())
|
||||||
.tableName(tableMetaData.getTableName())
|
.tableName(tableMetaData.getTableName())
|
||||||
.path(vmsPath)
|
.path(path)
|
||||||
.build();
|
.build();
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.bunny.utils;
|
||||||
|
|
||||||
import cn.bunny.dao.entity.ColumnMetaData;
|
import cn.bunny.dao.entity.ColumnMetaData;
|
||||||
import cn.bunny.dao.entity.TableMetaData;
|
import cn.bunny.dao.entity.TableMetaData;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ public class DbInfoUtil {
|
||||||
ResultSet pkResultSet = metaData.getPrimaryKeys(null, null, tableName);
|
ResultSet pkResultSet = metaData.getPrimaryKeys(null, null, tableName);
|
||||||
|
|
||||||
while (pkResultSet.next()) {
|
while (pkResultSet.next()) {
|
||||||
primaryKeys.add(pkResultSet.getString("COLUMN_NAME").toLowerCase());
|
primaryKeys.add(pkResultSet.getString("COLUMN_NAME" ).toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
return primaryKeys;
|
return primaryKeys;
|
||||||
|
@ -50,7 +51,7 @@ public class DbInfoUtil {
|
||||||
List<TableMetaData> list = new ArrayList<>();
|
List<TableMetaData> list = new ArrayList<>();
|
||||||
|
|
||||||
while (tables.next()) {
|
while (tables.next()) {
|
||||||
String tableName = tables.getString("TABLE_NAME");
|
String tableName = tables.getString("TABLE_NAME" );
|
||||||
TableMetaData tableMetaData = tableInfo(tableName);
|
TableMetaData tableMetaData = tableInfo(tableName);
|
||||||
list.add(tableMetaData);
|
list.add(tableMetaData);
|
||||||
}
|
}
|
||||||
|
@ -75,15 +76,15 @@ public class DbInfoUtil {
|
||||||
|
|
||||||
// 获取表的注释信息
|
// 获取表的注释信息
|
||||||
if (tables.next()) {
|
if (tables.next()) {
|
||||||
String remarks = tables.getString("REMARKS");
|
String remarks = tables.getString("REMARKS" );
|
||||||
String tableCat = tables.getString("TABLE_CAT");
|
String tableCat = tables.getString("TABLE_CAT" );
|
||||||
String tableSchem = tables.getString("TABLE_SCHEM");
|
String tableSchem = tables.getString("TABLE_SCHEM" );
|
||||||
String tableType = tables.getString("TABLE_TYPE");
|
String tableType = tables.getString("TABLE_TYPE" );
|
||||||
String typeCat = tables.getString("TYPE_CAT");
|
String typeCat = tables.getString("TYPE_CAT" );
|
||||||
String typeSchem = tables.getString("TYPE_SCHEM");
|
String typeSchem = tables.getString("TYPE_SCHEM" );
|
||||||
String typeName = tables.getString("TYPE_NAME");
|
String typeName = tables.getString("TYPE_NAME" );
|
||||||
String selfReferencingColName = tables.getString("SELF_REFERENCING_COL_NAME");
|
String selfReferencingColName = tables.getString("SELF_REFERENCING_COL_NAME" );
|
||||||
String refGeneration = tables.getString("REF_GENERATION");
|
String refGeneration = tables.getString("REF_GENERATION" );
|
||||||
|
|
||||||
tableMetaData = TableMetaData.builder()
|
tableMetaData = TableMetaData.builder()
|
||||||
.tableName(tableName)
|
.tableName(tableName)
|
||||||
|
@ -98,7 +99,7 @@ public class DbInfoUtil {
|
||||||
.refGeneration(refGeneration)
|
.refGeneration(refGeneration)
|
||||||
.build();
|
.build();
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("数据表不存在");
|
throw new RuntimeException("数据表不存在" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return tableMetaData;
|
return tableMetaData;
|
||||||
|
@ -122,13 +123,16 @@ public class DbInfoUtil {
|
||||||
try (ResultSet columnsRs = metaData.getColumns(null, null, tableName, null)) {
|
try (ResultSet columnsRs = metaData.getColumns(null, null, tableName, null)) {
|
||||||
while (columnsRs.next()) {
|
while (columnsRs.next()) {
|
||||||
ColumnMetaData column = new ColumnMetaData();
|
ColumnMetaData column = new ColumnMetaData();
|
||||||
String columnName = columnsRs.getString("COLUMN_NAME");
|
String columnName = columnsRs.getString("COLUMN_NAME" );
|
||||||
|
|
||||||
|
String javaType = ConvertUtil.convertToJavaType(column.getJdbcType());
|
||||||
|
|
||||||
column.setColumnName(columnName);
|
column.setColumnName(columnName);
|
||||||
column.setFieldName(ConvertUtil.convertToFieldName(column.getColumnName()));
|
column.setFieldName(ConvertUtil.convertToFieldName(column.getColumnName()));
|
||||||
column.setJdbcType(columnsRs.getString("TYPE_NAME"));
|
column.setJdbcType(columnsRs.getString("TYPE_NAME" ));
|
||||||
column.setJavaType(ConvertUtil.convertToJavaType(column.getJdbcType()));
|
column.setJavaType(javaType);
|
||||||
column.setComment(columnsRs.getString("REMARKS"));
|
column.setJavascriptType(StringUtils.uncapitalize(javaType));
|
||||||
|
column.setComment(columnsRs.getString("REMARKS" ));
|
||||||
|
|
||||||
// 确保 primaryKeyColumns 不为空
|
// 确保 primaryKeyColumns 不为空
|
||||||
if (!primaryKeyColumns.isEmpty()) {
|
if (!primaryKeyColumns.isEmpty()) {
|
||||||
|
|
|
@ -30,11 +30,12 @@ public class VmsUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
String date = new SimpleDateFormat(dto.getSimpleDateFormat()).format(new Date());
|
String date = new SimpleDateFormat(dto.getSimpleDateFormat()).format(new Date());
|
||||||
context.put("date" , date);
|
context.put("leftBrace", "{" );
|
||||||
context.put("author" , author);
|
context.put("date", date);
|
||||||
context.put("requestMapping" , requestMapping);
|
context.put("author", author);
|
||||||
context.put("classLowercaseName" , ConvertUtil.convertToCamelCase(replaceTableName.get()));
|
context.put("requestMapping", requestMapping);
|
||||||
context.put("classUppercaseName" , ConvertUtil.convertToCamelCase(replaceTableName.get(), true));
|
context.put("classLowercaseName", ConvertUtil.convertToCamelCase(replaceTableName.get()));
|
||||||
|
context.put("classUppercaseName", ConvertUtil.convertToCamelCase(replaceTableName.get(), true));
|
||||||
|
|
||||||
Template servicePathTemplate = Velocity.getTemplate(templateName, "UTF-8" );
|
Template servicePathTemplate = Velocity.getTemplate(templateName, "UTF-8" );
|
||||||
servicePathTemplate.merge(context, writer);
|
servicePathTemplate.merge(context, writer);
|
||||||
|
|
|
@ -15,13 +15,13 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* ${tableName}表 前端控制器
|
* ${comment}表 前端控制器
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @since ${date}
|
* @since ${date}
|
||||||
*/
|
*/
|
||||||
@Tag(name = "${tableName}" , description = "${tableName}相关接口" )
|
@Tag(name = "${comment}", description = "${comment}相关接口" )
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("${requestMapping}/${classLowercaseName}" )
|
@RequestMapping("${requestMapping}/${classLowercaseName}" )
|
||||||
public class ${classUppercaseName}Controller {
|
public class ${classUppercaseName}Controller {
|
||||||
|
@ -29,37 +29,37 @@ public class ${classUppercaseName}Controller {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ${classUppercaseName}Service ${classLowercaseName}Service;
|
private ${classUppercaseName}Service ${classLowercaseName}Service;
|
||||||
|
|
||||||
@Operation(summary = "分页查询${tableName}" , description = "分页查询${tableName}" )
|
@Operation(summary = "分页查询${comment}", description = "分页查询${comment}" )
|
||||||
@GetMapping("get${classUppercaseName}List/{page}/{limit}" )
|
@GetMapping("get${classUppercaseName}List/{page}/{limit}" )
|
||||||
public Result<PageResult<${classUppercaseName}Vo>> get${classUppercaseName}List(
|
public Result<PageResult<${classUppercaseName}Vo>> get${classUppercaseName}List(
|
||||||
@Parameter(name = "page" , description = "当前页" , required = true)
|
@Parameter(name = "page", description = "当前页", required = true)
|
||||||
@PathVariable("page" ) Integer page,
|
@PathVariable("page" ) Integer page,
|
||||||
@Parameter(name = "limit" , description = "每页记录数" , required = true)
|
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||||
@PathVariable("limit" ) Integer limit,
|
@PathVariable("limit" ) Integer limit,
|
||||||
${classUppercaseName}Dto dto) {
|
${classUppercaseName}Dto dto) {
|
||||||
Page<${classUppercaseName}> pageParams = new Page<>(page, limit);
|
Page<${classUppercaseName}> pageParams = new Page<>(page, limit);
|
||||||
PageResult<${classUppercaseName}Vo> pageResult = ${classLowercaseName}Service.get${classUppercaseName}List(pageParams, dto);
|
PageResult<${classUppercaseName}Vo> pageResult = ${classLowercaseName}Service.get${classUppercaseName}List(pageParams, dto);
|
||||||
return Mono.just(Result.success(pageResult));
|
return Result.success(pageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "添加${tableName}" , description = "添加${tableName}" )
|
@Operation(summary = "添加${comment}", description = "添加${comment}" )
|
||||||
@PostMapping("add${classUppercaseName}" )
|
@PostMapping("add${classUppercaseName}" )
|
||||||
public Result<String> add${classUppercaseName}(@Valid @RequestBody ${classUppercaseName}AddDto dto) {
|
public Result<String> add${classUppercaseName}(@Valid @RequestBody ${classUppercaseName}AddDto dto) {
|
||||||
${classLowercaseName}Service.add${classUppercaseName}(dto);
|
${classLowercaseName}Service.add${classUppercaseName}(dto);
|
||||||
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "更新${tableName}" , description = "更新${tableName}" )
|
@Operation(summary = "更新${comment}", description = "更新${comment}" )
|
||||||
@PutMapping("update${classUppercaseName}" )
|
@PutMapping("update${classUppercaseName}" )
|
||||||
public Result<String> update${classUppercaseName}(@Valid @RequestBody ${classUppercaseName}UpdateDto dto) {
|
public Result<String> update${classUppercaseName}(@Valid @RequestBody ${classUppercaseName}UpdateDto dto) {
|
||||||
${classLowercaseName}Service.update${classUppercaseName}(dto);
|
${classLowercaseName}Service.update${classUppercaseName}(dto);
|
||||||
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除${tableName}" , description = "删除${tableName}" )
|
@Operation(summary = "删除${comment}", description = "删除${comment}" )
|
||||||
@DeleteMapping("delete${classUppercaseName}" )
|
@DeleteMapping("delete${classUppercaseName}" )
|
||||||
public Result<String> delete${classUppercaseName}(@RequestBody List<Long> ids) {
|
public Result<String> delete${classUppercaseName}(@RequestBody List<Long> ids) {
|
||||||
${classLowercaseName}Service.delete${classUppercaseName}(ids);
|
${classLowercaseName}Service.delete${classUppercaseName}(ids);
|
||||||
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* ${tableName} Mapper 接口
|
* ${comment} Mapper 接口
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
|
@ -19,16 +19,16 @@ import java.util.List;
|
||||||
public interface ${classUppercaseName}Mapper extends BaseMapper<${classUppercaseName}> {
|
public interface ${classUppercaseName}Mapper extends BaseMapper<${classUppercaseName}> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 分页查询${tableName}内容
|
* * 分页查询${comment}内容
|
||||||
*
|
*
|
||||||
* @param pageParams ${tableName}分页参数
|
* @param pageParams ${comment}分页参数
|
||||||
* @param dto ${tableName}查询表单
|
* @param dto ${comment}查询表单
|
||||||
* @return ${tableName}分页结果
|
* @return ${comment}分页结果
|
||||||
*/
|
*/
|
||||||
IPage<${classUppercaseName}Vo> selectListByPage(@Param("page") Page<${classUppercaseName}> pageParams, @Param("dto") ${classUppercaseName}Dto dto);
|
IPage<${classUppercaseName}Vo> selectListByPage(@Param("page" ) Page<${classUppercaseName}> pageParams, @Param("dto" ) ${classUppercaseName}Dto dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物理删除${tableName}
|
* 物理删除${comment}
|
||||||
*
|
*
|
||||||
* @param ids 删除 id 列表
|
* @param ids 删除 id 列表
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="cn.bunny.services.mapper.${originalName}Mapper">
|
<mapper namespace="${package}.mapper.${classUppercaseName}Mapper">
|
||||||
|
|
||||||
<!-- 通用查询映射结果 -->
|
<!-- 通用查询映射结果 -->
|
||||||
<resultMap id="BaseResultMap" type="$type">
|
<resultMap id="BaseResultMap" type="${classUppercaseName}">
|
||||||
#foreach($field in $baseResultMaps)
|
#foreach($field in ${columnInfoList})
|
||||||
<id column="$field.column" property="$field.property"/>
|
<id column="${field.column}" property="${field.fieldName}"/>
|
||||||
#end
|
#end
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<!-- 通用查询结果列 -->
|
<!-- 通用查询结果列 -->
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
$baseColumnList
|
${baseColumnList}
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<!-- 分页查询${classTitle}内容 -->
|
<!-- 分页查询${comment}内容 -->
|
||||||
<select id="selectListByPage" resultType="${voClassType}">
|
<select id="selectListByPage" resultType="${voClassType}">
|
||||||
select
|
select
|
||||||
base.*,
|
base.*,
|
||||||
|
@ -25,18 +25,17 @@
|
||||||
left join sys_user update_user on update_user.id = base.update_user
|
left join sys_user update_user on update_user.id = base.update_user
|
||||||
<where>
|
<where>
|
||||||
base.is_deleted = 0
|
base.is_deleted = 0
|
||||||
#foreach($field in $pageQueryMap)
|
#foreach($field in $columnInfoList)
|
||||||
<if test="dto.${field.property} != null and dto.${field.property} != ''">
|
<if test="dto.${field.fieldName} != null and dto.${field.fieldName} != ''">
|
||||||
and base.$field.column like CONCAT('%',#{dto.${field.property}},'%')
|
and base.${field.columnName} like CONCAT('%',#{dto.${field.fieldName}},'%')
|
||||||
</if>
|
</if>
|
||||||
#end
|
#end
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 物理删除${classTitle} -->
|
<!-- 物理删除${comment} -->
|
||||||
<delete id="deleteBatchIdsWithPhysics">
|
<delete id="deleteBatchIdsWithPhysics">
|
||||||
delete
|
delete from ${tableName}
|
||||||
from $tableName
|
|
||||||
where id in
|
where id in
|
||||||
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||||
#{id}
|
#{id}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package cn.bunny.services.service;
|
package ${package}.service;
|
||||||
|
|
||||||
import cn.bunny.dao.entity.system.MenuIcon;
|
import cn.bunny.dao.entity.system.MenuIcon;
|
||||||
import cn.bunny.dao.pojo.result.PageResult;
|
import cn.bunny.dao.pojo.result.PageResult;
|
||||||
|
@ -11,39 +11,39 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* ${classTitle} 服务类
|
* ${comment} 服务类
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Bunny
|
* @author Bunny
|
||||||
* @since ${date}
|
* @since ${date}
|
||||||
*/
|
*/
|
||||||
public interface ${originalName}Service extends IService<${originalName}> {
|
public interface ${classUppercaseName}Service extends IService<${classUppercaseName}> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 获取${classTitle}列表
|
* * 获取${comment}列表
|
||||||
*
|
*
|
||||||
* @return ${classTitle}返回列表
|
* @return ${comment}返回列表
|
||||||
*/
|
*/
|
||||||
PageResult<${originalName}Vo> get${originalName}List(Page<${originalName}> pageParams, ${originalName}Dto dto);
|
PageResult<${classUppercaseName}Vo> get${classUppercaseName}List(Page<${classUppercaseName}> pageParams, ${classUppercaseName}Dto dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 添加${classTitle}
|
* * 添加${comment}
|
||||||
*
|
*
|
||||||
* @param dto 添加表单
|
* @param dto 添加表单
|
||||||
*/
|
*/
|
||||||
void add${originalName}(@Valid ${originalName}AddDto dto);
|
void add${classUppercaseName}(@Valid ${classUppercaseName}AddDto dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 更新${classTitle}
|
* * 更新${comment}
|
||||||
*
|
*
|
||||||
* @param dto 更新表单
|
* @param dto 更新表单
|
||||||
*/
|
*/
|
||||||
void update${originalName}(@Valid ${originalName}UpdateDto dto);
|
void update${classUppercaseName}(@Valid ${classUppercaseName}UpdateDto dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 删除|批量删除${classTitle}类型
|
* * 删除|批量删除${comment}类型
|
||||||
*
|
*
|
||||||
* @param ids 删除id列表
|
* @param ids 删除id列表
|
||||||
*/
|
*/
|
||||||
void delete${originalName}(List<Long> ids);
|
void delete${classUppercaseName}(List<Long> ids);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package cn.bunny.services.service.impl;
|
package ${package}.service.impl;
|
||||||
|
|
||||||
import cn.bunny.dao.pojo.result.PageResult;
|
import cn.bunny.dao.pojo.result.PageResult;
|
||||||
import cn.bunny.services.mapper.${originalName}Mapper;
|
import ${package}.mapper.${classUppercaseName}Mapper;
|
||||||
import cn.bunny.services.service.${originalName}Service;
|
import ${package}.service.${classUppercaseName}Service;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
@ -13,66 +13,67 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* ${classTitle} 服务实现类
|
* ${comment} 服务实现类
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Bunny
|
* @author Bunny
|
||||||
* @since ${date}
|
* @since ${date}
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ${originalName}ServiceImpl extends ServiceImpl<${originalName}Mapper, ${originalName}> implements ${originalName}Service {
|
public class ${classUppercaseName}ServiceImpl extends ServiceImpl<${classUppercaseName}Mapper, ${classUppercaseName}> implements ${classUppercaseName}Service {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * ${classTitle} 服务实现类
|
* * ${comment} 服务实现类
|
||||||
*
|
*
|
||||||
* @param pageParams ${classTitle}分页查询page对象
|
* @param pageParams ${comment}分页查询page对象
|
||||||
* @param dto ${classTitle}分页查询对象
|
* @param dto ${comment}分页查询对象
|
||||||
* @return 查询分页${classTitle}返回对象
|
* @return 查询分页${comment}返回对象
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResult<${originalName}Vo> get${originalName}List(Page<${originalName}> pageParams, ${originalName}Dto dto) {
|
public PageResult<${classUppercaseName}Vo> get${classUppercaseName}List(Page<${classUppercaseName}> pageParams, ${classUppercaseName}Dto dto) {
|
||||||
IPage<${originalName}Vo> page = baseMapper.selectListByPage(pageParams, dto);
|
IPage<${classUppercaseName}Vo> page = baseMapper.selectListByPage(pageParams, dto);
|
||||||
|
|
||||||
return PageResult.<${originalName}Vo>builder()
|
return PageResult.<${classUppercaseName}Vo>builder()
|
||||||
.list(page.getRecords())
|
.list(page.getRecords())
|
||||||
.pageNo(page.getCurrent())
|
.pageNo(page.getCurrent())
|
||||||
.pageSize(page.getSize())
|
.pageSize(page.getSize())
|
||||||
.total(page.getTotal())
|
.total(page.getTotal())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加${classTitle}
|
* 添加${comment}
|
||||||
*
|
*
|
||||||
* @param dto ${classTitle}添加
|
* @param dto ${comment}添加
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void add${originalName}(@Valid ${originalName}AddDto dto) {
|
public void add${classUppercaseName}(@Valid ${classUppercaseName}AddDto dto) {
|
||||||
// 保存数据
|
// 保存数据
|
||||||
${originalName} ${lowercaseName} = new ${originalName}();
|
${classUppercaseName} ${classLowercaseName} =new ${classUppercaseName}();
|
||||||
BeanUtils.copyProperties(dto, ${lowercaseName});
|
BeanUtils.copyProperties(dto, ${classLowercaseName});
|
||||||
save(${lowercaseName});
|
save(${classLowercaseName});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新${classTitle}
|
* 更新${comment}
|
||||||
*
|
*
|
||||||
* @param dto ${classTitle}更新
|
* @param dto ${comment}更新
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void update${originalName}(@Valid ${originalName}UpdateDto dto) {
|
public void update${classUppercaseName}(@Valid ${classUppercaseName}UpdateDto dto) {
|
||||||
// 更新内容
|
// 更新内容
|
||||||
${originalName} ${lowercaseName} = new ${originalName}();
|
${classUppercaseName} ${classLowercaseName} =new ${classUppercaseName}();
|
||||||
BeanUtils.copyProperties(dto, ${lowercaseName});
|
BeanUtils.copyProperties(dto, ${classLowercaseName});
|
||||||
updateById(${lowercaseName});
|
updateById(${classLowercaseName});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除|批量删除${classTitle}
|
* 删除|批量删除${comment}
|
||||||
*
|
*
|
||||||
* @param ids 删除id列表
|
* @param ids 删除id列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void delete${originalName}(List<Long> ids) {
|
public void delete${classUppercaseName}(List<Long> ids) {
|
||||||
baseMapper.deleteBatchIdsWithPhysics(ids);
|
baseMapper.deleteBatchIdsWithPhysics(ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,22 +1,22 @@
|
||||||
import { http } from '@/api/service/request';
|
import {http} from '@/api/service/request';
|
||||||
import type { BaseResult, ResultTable } from '@/api/service/types';
|
import type {BaseResult, ResultTable} from '@/api/service/types';
|
||||||
|
|
||||||
/** ${classDescription}---获取${classDescription}列表 */
|
/** ${comment}---获取${comment}列表 */
|
||||||
export const fetchGet${originalName}List = (data: any) => {
|
export const fetchGet${classUppercaseName}List = (data: any) => {
|
||||||
return http.request<BaseResult<ResultTable>>('get', `${lowercaseName}/get${originalName}List/${data.currentPage}/${data.pageSize}`, { params: data });
|
return http.request<BaseResult<ResultTable>>('get', `${classLowercaseName}/get${classUppercaseName}List/${data.currentPage}/${data.pageSize}`, {params: data});
|
||||||
};
|
};
|
||||||
|
|
||||||
/** ${classDescription}---添加${classDescription} */
|
/** ${comment}---添加${comment} */
|
||||||
export const fetchAdd${originalName} = (data: any) => {
|
export const fetchAdd${classUppercaseName} = (data: any) => {
|
||||||
return http.request<BaseResult<object>>('post', '${lowercaseName}/add${originalName}', { data });
|
return http.request<BaseResult<any>>('post', '${classLowercaseName}/add${classUppercaseName}', {data});
|
||||||
};
|
};
|
||||||
|
|
||||||
/** ${classDescription}---更新${classDescription} */
|
/** ${comment}---更新${comment} */
|
||||||
export const fetchUpdate${originalName} = (data: any) => {
|
export const fetchUpdate${classUppercaseName} = (data: any) => {
|
||||||
return http.request<BaseResult<object>>('put', '${lowercaseName}/update${originalName}', { data });
|
return http.request<BaseResult<any>>('put', '${classLowercaseName}/update${classUppercaseName}', {data});
|
||||||
};
|
};
|
||||||
|
|
||||||
/** ${classDescription}---删除${classDescription} */
|
/** ${comment}---删除${comment} */
|
||||||
export const fetchDelete${originalName} = (data: any) => {
|
export const fetchDelete${classUppercaseName} = (data: any) => {
|
||||||
return http.request<BaseResult<object>>('delete', '${lowercaseName}/delete${originalName}', { data });
|
return http.request<BaseResult<any>>('delete', '${classLowercaseName}/delete${classUppercaseName}', {data});
|
||||||
};
|
};
|
|
@ -1,27 +1,31 @@
|
||||||
import { reactive, ref } from 'vue';
|
import {reactive} from 'vue';
|
||||||
|
import type {FormRules} from 'element-plus';
|
||||||
import { $t } from '@/plugins/i18n';
|
import { $t } from '@/plugins/i18n';
|
||||||
import type { FormRules } from 'element-plus';
|
|
||||||
|
|
||||||
// 表格列
|
|
||||||
export const columns: TableColumnList = [
|
export const columns: TableColumnList = [
|
||||||
{ type: 'selection', align: 'left' },
|
{type: 'selection', align: 'left'},
|
||||||
{ type: 'index', index: (index: number) => index + 1, label: '序号', width: 60 },
|
{type: 'index', index: (index: number) => index + 1, label: '序号', width: 60},
|
||||||
#foreach($field in $baseFieldList)
|
#foreach($field in $columnInfoList)
|
||||||
// $field.annotation
|
// $field.comment
|
||||||
{ label: $t('$field.name'), prop: '$field.name' },
|
{label: $t('$field.fieldName'), prop: '$field.fieldName'},
|
||||||
#end
|
#end
|
||||||
{ label: $t('table.updateTime'), prop: 'updateTime', sortable: true, width: 160 },
|
{label: $t('table.updateTime'), prop: 'updateTime', sortable: true, width: 160},
|
||||||
{ label: $t('table.createTime'), prop: 'createTime', sortable: true, width: 160 },
|
{label: $t('table.createTime'), prop: 'createTime', sortable: true, width: 160},
|
||||||
{ label: $t('table.createUser'), prop: 'createUser', slot: 'createUser', width: 130 },
|
{label: $t('table.createUser'), prop: 'createUser', slot: 'createUser', width: 130},
|
||||||
{ label: $t('table.updateUser'), prop: 'updateUser', slot: 'updateUser', width: 130 },
|
{label: $t('table.updateUser'), prop: 'updateUser', slot: 'updateUser', width: 130},
|
||||||
{ label: $t('table.operation'), fixed: 'right', width: 210, slot: 'operation' },
|
{label: $t('table.operation'), fixed: 'right', width: 210, slot: 'operation'},
|
||||||
];
|
];
|
||||||
|
|
||||||
// 添加规则
|
// 添加规则
|
||||||
export const rules = reactive
|
export const rules = reactive < FormRules > ({
|
||||||
<FormRules>({
|
#foreach($field in $columnInfoList)
|
||||||
#foreach($field in $baseFieldList)
|
// $field.comment
|
||||||
// $field.annotation
|
$field.fieldName: [{
|
||||||
$field.name: [{ required: true, message: `$leftBrace$t('input')}$leftBrace$t('${field.name}')}`, trigger: 'blur' }],
|
required: true,
|
||||||
|
message: `$leftBrace$t('input')}$leftBrace$t('${field.fieldName}')}`,
|
||||||
|
trigger: 'blur'
|
||||||
|
}],
|
||||||
#end
|
#end
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,36 +1,34 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue';
|
import {ref} from 'vue';
|
||||||
import { FormInstance } from 'element-plus';
|
import {FormInstance} from 'element-plus';
|
||||||
import { rules } from '${columnsPath}';
|
import {FormProps} from '';
|
||||||
import { FormProps } from '${typesPath}';
|
|
||||||
import { frameSureOptions } from '@/enums';
|
|
||||||
import { $t } from '@/plugins/i18n';
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<FormProps>(), {
|
const props = withDefaults(defineProps<FormProps>(), {
|
||||||
formInline: () => ({
|
formInline: () => ({
|
||||||
#foreach($item in $baseFieldList)
|
#foreach($item in $columnInfoList)
|
||||||
#if(${item.name})
|
#if(${item.fieldName})
|
||||||
// $!{item.annotation}
|
// $!{item.comment}
|
||||||
${item.name}: undefined,
|
${item.fieldName}: undefined,
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const formRef = ref<FormInstance>();
|
const formRef = ref<FormInstance>();
|
||||||
const form = ref(props.formInline);
|
const form = ref(props.formInline);
|
||||||
|
|
||||||
defineExpose({ formRef });
|
defineExpose({formRef});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto">
|
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto">
|
||||||
#foreach($item in $baseFieldList)
|
#foreach($item in $columnInfoList)
|
||||||
|
|
||||||
<!-- $item.annotation -->
|
<!-- $item.comment -->
|
||||||
<el-form-item :label="$t('${item.name}')" prop="$item.name">
|
<el-form-item :label="$t('${item.fieldName}')" prop="$item.fieldName">
|
||||||
<el-input v-model="form.$item.name" autocomplete="off" type="text" :placeholder="$t('input') + $t('${item.name}')" />
|
<el-input v-model="form.$item.fieldName" autocomplete="off" type="text"
|
||||||
|
:placeholder="$t('input') + $t('${item.fieldName}')"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#end
|
#end
|
||||||
</el-form>
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,130 +1,124 @@
|
||||||
import { deviceDetection } from '@pureadmin/utils';
|
import {addDialog} from '@/components/BaseDialog/index';
|
||||||
import { addDialog } from '@/components/BaseDialog/index';
|
import {h, ref} from 'vue';
|
||||||
import ${originalName}Dialog from '${dialogPath}';
|
import {message, messageBox} from '@/utils/message';
|
||||||
import { use${originalName}Store } from '${storePath}';
|
|
||||||
import { h, ref } from 'vue';
|
|
||||||
import { messageBox } from '@/utils/message';
|
|
||||||
import type { FormItemProps } from '${typesPath}';
|
|
||||||
import { $t } from '@/plugins/i18n';
|
|
||||||
import { message, messageBox } from "@/utils/message";
|
|
||||||
import DeleteBatchDialog from "@/components/Table/DeleteBatchDialog.vue";
|
import DeleteBatchDialog from "@/components/Table/DeleteBatchDialog.vue";
|
||||||
|
|
||||||
export const formRef = ref();
|
export const formRef = ref();
|
||||||
// 删除ids
|
// 删除ids
|
||||||
export const deleteIds = ref([]);
|
export const deleteIds = ref([]);
|
||||||
const ${lowercaseName}Store = use${originalName}Store();
|
const ${classLowercaseName}Store = use${classUppercaseName}Store();
|
||||||
|
|
||||||
/** 搜索初始化${classTitle} */
|
/** 搜索初始化${comment} */
|
||||||
export async function onSearch() {
|
export async function onSearch() {
|
||||||
${lowercaseName}Store.loading = true;
|
${classLowercaseName}Store.loading = true;
|
||||||
await ${lowercaseName}Store.get${originalName}List();
|
await ${classLowercaseName}Store.get${classUppercaseName}List();
|
||||||
${lowercaseName}Store.loading = false;
|
${classLowercaseName}Store.loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 添加${classTitle} */
|
/** 添加${comment} */
|
||||||
export function onAdd() {
|
export function onAdd() {
|
||||||
addDialog({
|
addDialog({
|
||||||
title: `$leftBrace $t("addNew")}$leftBrace$t("${lowercaseName}")}`,
|
title: `$leftBrace $t("addNew")}$leftBrace$t("${classLowercaseName}")}`,
|
||||||
width: '30%',
|
width: '30%',
|
||||||
props: {
|
props: {
|
||||||
formInline: {
|
formInline: {
|
||||||
#foreach($item in $addFormList)
|
#foreach($item in $columnInfoList)
|
||||||
$!{item}: undefined,
|
$!{item.fieldName}: undefined,
|
||||||
#end
|
#end
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
draggable: true,
|
draggable: true,
|
||||||
fullscreenIcon: true,
|
fullscreenIcon: true,
|
||||||
closeOnClickModal: false,
|
closeOnClickModal: false,
|
||||||
contentRenderer: () => h(${originalName}Dialog, { ref: formRef }),
|
contentRenderer: () => h(${classUppercaseName}Dialog, {ref: formRef}),
|
||||||
beforeSure: (done, { options }) => {
|
beforeSure: (done, {options}) => {
|
||||||
const form = options.props.formInline as FormItemProps;
|
const form = options.props.formInline as FormItemProps;
|
||||||
formRef.value.formRef.validate(async (valid: any) => {
|
formRef.value.formRef.validate(async (valid: any) => {
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
|
|
||||||
const result = await ${lowercaseName}Store.add${originalName}(form);
|
const result = await ${classLowercaseName}Store.add${classUppercaseName}(form);
|
||||||
if (!result) return;
|
if (!result) return;
|
||||||
done();
|
done();
|
||||||
await onSearch();
|
await onSearch();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 更新${classTitle} */
|
/** 更新${comment} */
|
||||||
export function onUpdate(row: any) {
|
export function onUpdate(row: any) {
|
||||||
addDialog({
|
addDialog({
|
||||||
title: `$leftBrace$t("modify")}$leftBrace$t("${lowercaseName}")}`,
|
title: `$leftBrace$t("modify")}$leftBrace$t("${classLowercaseName}")}`,
|
||||||
width: '30%',
|
width: '30%',
|
||||||
props: {
|
props: {
|
||||||
formInline: {
|
formInline: {
|
||||||
#foreach($item in $addFormList)
|
#foreach($item in $columnInfoList)
|
||||||
$!{item}: row.$!{item},
|
$!{item.fieldName}: row.$!{item.fieldName},
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
draggable: true,
|
draggable: true,
|
||||||
fullscreenIcon: true,
|
fullscreenIcon: true,
|
||||||
closeOnClickModal: false,
|
closeOnClickModal: false,
|
||||||
contentRenderer: () => h(${originalName}Dialog, { ref: formRef }),
|
contentRenderer: () => h(${classUppercaseName}Dialog, {ref: formRef}),
|
||||||
beforeSure: (done, { options }) => {
|
beforeSure: (done, {options}) => {
|
||||||
const form = options.props.formInline as FormItemProps;
|
const form = options.props.formInline as FormItemProps;
|
||||||
formRef.value.formRef.validate(async (valid: any) => {
|
formRef.value.formRef.validate(async (valid: any) => {
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
|
|
||||||
const result = await ${lowercaseName}Store.update${originalName}({ ...form, id: row.id });
|
const result = await ${classLowercaseName}Store.update${classUppercaseName}({...form, id: row.id});
|
||||||
if (!result) return;
|
if (!result) return;
|
||||||
done();
|
done();
|
||||||
await onSearch();
|
await onSearch();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除${classTitle} */
|
/** 删除${comment} */
|
||||||
export const onDelete = async (row: any) => {
|
export const onDelete = async (row: any) => {
|
||||||
const id = row.id;
|
const id = row.id;
|
||||||
|
|
||||||
// 是否确认删除
|
// 是否确认删除
|
||||||
const result = await messageBox({
|
const result = await messageBox({
|
||||||
title: $t('confirmDelete'),
|
title: $t('confirmDelete'),
|
||||||
showMessage: false,
|
showMessage: false,
|
||||||
confirmMessage: undefined,
|
confirmMessage: undefined,
|
||||||
cancelMessage: $t("cancel_delete"),
|
cancelMessage: $t("cancel_delete"),
|
||||||
});
|
});
|
||||||
if (!result) return;
|
if (!result) return;
|
||||||
|
|
||||||
// 删除数据
|
// 删除数据
|
||||||
await ${lowercaseName}Store.delete${originalName}([id]);
|
await ${classLowercaseName}Store.delete${classUppercaseName}([id]);
|
||||||
await onSearch();
|
await onSearch();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 批量删除 */
|
/** 批量删除 */
|
||||||
export const onDeleteBatch = async () => {
|
export const onDeleteBatch = async () => {
|
||||||
const ids = deleteIds.value;
|
const ids = deleteIds.value;
|
||||||
const formDeletedBatchRef = ref();
|
const formDeletedBatchRef = ref();
|
||||||
|
|
||||||
addDialog({
|
addDialog({
|
||||||
title: $t('deleteBatchTip'),
|
title: $t('deleteBatchTip'),
|
||||||
width: '30%',
|
width: '30%',
|
||||||
props: { formInline: { confirmText: '' } },
|
props: {formInline: {confirmText: ''}},
|
||||||
draggable: true,
|
draggable: true,
|
||||||
fullscreenIcon: true,
|
fullscreenIcon: true,
|
||||||
closeOnClickModal: false,
|
closeOnClickModal: false,
|
||||||
contentRenderer: () => h(DeleteBatchDialog, { ref: formDeletedBatchRef }),
|
contentRenderer: () => h(DeleteBatchDialog, {ref: formDeletedBatchRef}),
|
||||||
beforeSure: (done, { options }) => {
|
beforeSure: (done, {options}) => {
|
||||||
formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => {
|
formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => {
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
|
|
||||||
const text = options.props.formInline.confirmText.toLowerCase();
|
const text = options.props.formInline.confirmText.toLowerCase();
|
||||||
if (text === 'yes' || text === 'y') {
|
if (text === 'yes' || text === 'y') {
|
||||||
// 删除数据
|
// 删除数据
|
||||||
await ${lowercaseName}Store.delete${originalName}(ids);
|
await ${classLowercaseName}Store.delete${classUppercaseName}(ids);
|
||||||
await onSearch();
|
await onSearch();
|
||||||
|
|
||||||
done();
|
done();
|
||||||
} else message($t('deleteBatchTip'), { type: 'warning' });
|
} else message($t('deleteBatchTip'), {type: 'warning'});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
|
@ -1,121 +1,127 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {onMounted, ref} from 'vue';
|
import {onMounted, ref} from 'vue';
|
||||||
import {deleteIds, onSearch} from '';
|
import {deleteIds, onSearch} from '';
|
||||||
import {FormInstance} from "element-plus";
|
import {FormInstance} from "element-plus";
|
||||||
|
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const ${lowercaseName}Store = use${originalName}Store();
|
const ${classLowercaseName}Store = use${classUppercaseName}Store();
|
||||||
|
|
||||||
/** 当前页改变时 */
|
/** 当前页改变时 */
|
||||||
const onCurrentPageChange = async (value: number) => {
|
const onCurrentPageChange = async (value: number) => {
|
||||||
${lowercaseName}Store.pagination.currentPage = value;
|
${classLowercaseName}Store.pagination.currentPage = value;
|
||||||
await onSearch();
|
await onSearch();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 当分页发生变化 */
|
/** 当分页发生变化 */
|
||||||
const onPageSizeChange = async (value: number) => {
|
const onPageSizeChange = async (value: number) => {
|
||||||
${lowercaseName}Store.pagination.pageSize = value;
|
${classLowercaseName}Store.pagination.pageSize = value;
|
||||||
await onSearch();
|
await onSearch();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 选择多行 */
|
/** 选择多行 */
|
||||||
const onSelectionChange = (rows: Array<any>) => {
|
const onSelectionChange = (rows: Array<any>) => {
|
||||||
deleteIds.value = rows.map((row: any) => row.id);
|
deleteIds.value = rows.map((row: any) => row.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 重置表单 */
|
/** 重置表单 */
|
||||||
const resetForm = async (formEl: FormInstance | undefined) => {
|
const resetForm = async (formEl: FormInstance | undefined) => {
|
||||||
if (!formEl) return;
|
if (!formEl) return;
|
||||||
formEl.resetFields();
|
formEl.resetFields();
|
||||||
await onSearch();
|
await onSearch();
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
onSearch();
|
onSearch();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<el-form ref="formRef" :inline="true" :model="${lowercaseName}Store.form" class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto">
|
<el-form ref="formRef" :inline="true" :model="${classLowercaseName}Store.form"
|
||||||
#foreach($item in $formList)
|
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto">
|
||||||
|
#foreach($item in $columnInfoList)
|
||||||
|
|
||||||
<!-- $item.annotation -->
|
<!-- $item.comment -->
|
||||||
<el-form-item :label="$t('${item.name}')" prop="${item.name}">
|
<el-form-item :label="$t('${item.fieldName}')" prop="${item.fieldName}">
|
||||||
<el-input v-model="${lowercaseName}Store.form.${item.name}" :placeholder="`$leftBrace$t('input')}$leftBrace$t('${item.name}')}`"
|
<el-input v-model="${classLowercaseName}Store.form.${item.fieldName}"
|
||||||
class="!w-[180px]" clearable/>
|
:placeholder="`$leftBrace$t('input')}$leftBrace$t('${item.fieldName}')}`"
|
||||||
</el-form-item>
|
class="!w-[180px]" clearable/>
|
||||||
#end
|
</el-form-item>
|
||||||
<el-form-item>
|
#end
|
||||||
<el-button :icon="useRenderIcon('ri:search-line')" :loading="${lowercaseName}Store.loading" type="primary" @click="onSearch"> {{ $t('search')
|
<el-form-item>
|
||||||
}}
|
<el-button :icon="useRenderIcon('ri:search-line')" :loading="${classLowercaseName}Store.loading" type="primary"
|
||||||
|
@click="onSearch"> {{ $t('search')
|
||||||
|
}}
|
||||||
|
</el-button>
|
||||||
|
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)"> {{ $t('buttons.reset') }}</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<PureTableBar :columns="columns" title="${classDescription}" @fullscreen="tableRef.setAdaptive()"
|
||||||
|
@refresh="onSearch">
|
||||||
|
<template #buttons>
|
||||||
|
<el-button :icon="useRenderIcon(AddFill)" type="primary" @click="onAdd"> {{ $t('addNew') }}</el-button>
|
||||||
|
|
||||||
|
<!-- 批量删除按钮 -->
|
||||||
|
<el-button v-show="deleteIds.length > 0" :icon="useRenderIcon(Delete)" type="danger" @click="onDeleteBatch">
|
||||||
|
{{ $t('delete_batches') }}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot="{ size, dynamicColumns }">
|
||||||
|
<pure-table
|
||||||
|
ref="tableRef"
|
||||||
|
:adaptiveConfig="{ offsetBottom: 96 }"
|
||||||
|
:columns="dynamicColumns"
|
||||||
|
:data="${classLowercaseName}Store.datalist"
|
||||||
|
:header-cell-style="{ background: 'var(--el-fill-color-light)', color: 'var(--el-text-color-primary)' }"
|
||||||
|
:loading="${classLowercaseName}Store.loading"
|
||||||
|
:size="size"
|
||||||
|
adaptive
|
||||||
|
align-whole="center"
|
||||||
|
border
|
||||||
|
highlight-current-row
|
||||||
|
row-key="id"
|
||||||
|
showOverflowTooltip
|
||||||
|
table-layout="auto"
|
||||||
|
:pagination="${classLowercaseName}Store.pagination"
|
||||||
|
@page-size-change="onPageSizeChange"
|
||||||
|
@selection-change="onSelectionChange"
|
||||||
|
@page-current-change="onCurrentPageChange"
|
||||||
|
>
|
||||||
|
|
||||||
|
<template #createUser="{ row }">
|
||||||
|
<el-button v-show="row.createUser" link type="primary" @click="selectUserinfo(row.createUser)">
|
||||||
|
{{ row.createUsername }}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #updateUser="{ row }">
|
||||||
|
<el-button v-show="row.updateUser" link type="primary" @click="selectUserinfo(row.updateUser)">
|
||||||
|
{{ row.updateUsername }}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #operation="{ row }">
|
||||||
|
<el-button :icon="useRenderIcon(EditPen)" :size="size" class="reset-margin" link type="primary"
|
||||||
|
@click="onUpdate(row)"> {{ $t('modify')
|
||||||
|
}}
|
||||||
|
</el-button>
|
||||||
|
<el-button :icon="useRenderIcon(AddFill)" :size="size" class="reset-margin" link type="primary"
|
||||||
|
@click="onAdd"> {{ $t('addNew') }}
|
||||||
|
</el-button>
|
||||||
|
<!-- TODO 待完成 -->
|
||||||
|
<el-popconfirm :title="`${leftBrace}$t('delete')}${row.email}?`" @confirm="onDelete(row)">
|
||||||
|
<template #reference>
|
||||||
|
<el-button :icon="useRenderIcon(Delete)" :size="size" class="reset-margin" link type="primary">
|
||||||
|
{{ $t('delete') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)"> {{ $t('buttons.reset') }}</el-button>
|
</template>
|
||||||
</el-form-item>
|
</el-popconfirm>
|
||||||
</el-form>
|
</template>
|
||||||
|
</pure-table>
|
||||||
<PureTableBar :columns="columns" title="${classDescription}" @fullscreen="tableRef.setAdaptive()" @refresh="onSearch">
|
</template>
|
||||||
<template #buttons>
|
</PureTableBar>
|
||||||
<el-button :icon="useRenderIcon(AddFill)" type="primary" @click="onAdd"> {{ $t('addNew') }}</el-button>
|
</div>
|
||||||
|
|
||||||
<!-- 批量删除按钮 -->
|
|
||||||
<el-button v-show="deleteIds.length > 0" :icon="useRenderIcon(Delete)" type="danger" @click="onDeleteBatch">
|
|
||||||
{{ $t('delete_batches') }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot="{ size, dynamicColumns }">
|
|
||||||
<pure-table
|
|
||||||
ref="tableRef"
|
|
||||||
:adaptiveConfig="{ offsetBottom: 96 }"
|
|
||||||
:columns="dynamicColumns"
|
|
||||||
:data="${lowercaseName}Store.datalist"
|
|
||||||
:header-cell-style="{ background: 'var(--el-fill-color-light)', color: 'var(--el-text-color-primary)' }"
|
|
||||||
:loading="${lowercaseName}Store.loading"
|
|
||||||
:size="size"
|
|
||||||
adaptive
|
|
||||||
align-whole="center"
|
|
||||||
border
|
|
||||||
highlight-current-row
|
|
||||||
row-key="id"
|
|
||||||
showOverflowTooltip
|
|
||||||
table-layout="auto"
|
|
||||||
:pagination="${lowercaseName}Store.pagination"
|
|
||||||
@page-size-change="onPageSizeChange"
|
|
||||||
@selection-change="onSelectionChange"
|
|
||||||
@page-current-change="onCurrentPageChange"
|
|
||||||
>
|
|
||||||
|
|
||||||
<template #createUser="{ row }">
|
|
||||||
<el-button v-show="row.createUser" link type="primary" @click="selectUserinfo(row.createUser)">
|
|
||||||
{{ row.createUsername }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #updateUser="{ row }">
|
|
||||||
<el-button v-show="row.updateUser" link type="primary" @click="selectUserinfo(row.updateUser)">
|
|
||||||
{{ row.updateUsername }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #operation="{ row }">
|
|
||||||
<el-button :icon="useRenderIcon(EditPen)" :size="size" class="reset-margin" link type="primary" @click="onUpdate(row)"> {{ $t('modify')
|
|
||||||
}}
|
|
||||||
</el-button>
|
|
||||||
<el-button :icon="useRenderIcon(AddFill)" :size="size" class="reset-margin" link type="primary" @click="onAdd"> {{ $t('addNew') }}
|
|
||||||
</el-button>
|
|
||||||
<!-- TODO 待完成 -->
|
|
||||||
<el-popconfirm :title="`${leftBrace}$t('delete')}${row.email}?`" @confirm="onDelete(row)">
|
|
||||||
<template #reference>
|
|
||||||
<el-button :icon="useRenderIcon(Delete)" :size="size" class="reset-margin" link type="primary">
|
|
||||||
{{ $t('delete') }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-popconfirm>
|
|
||||||
</template>
|
|
||||||
</pure-table>
|
|
||||||
</template>
|
|
||||||
</PureTableBar>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,69 +1,69 @@
|
||||||
import { defineStore } from 'pinia';
|
import {defineStore} from 'pinia';
|
||||||
import { fetchAdd${originalName}, fetchDelete${originalName}, fetchGet${originalName}List, fetchUpdate${originalName} } from '${apiPath}';
|
import {fetchAdd${classUppercaseName}, fetchDelete${classUppercaseName}, fetchUpdate${classUppercaseName}} from '';
|
||||||
import { pageSizes } from '@/enums/baseConstant';
|
import {pageSizes} from '@/enums/baseConstant';
|
||||||
import { storeMessage } from '@/utils/message';
|
import {storeMessage} from '@/utils/message';
|
||||||
import { storePagination } from '@/store/useStorePagination';
|
import {storePagination} from '@/store/useStorePagination';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${classTitle} Store
|
* ${comment} Store
|
||||||
*/
|
*/
|
||||||
export const use${originalName}Store = defineStore('${lowercaseName}Store', {
|
export const use${classUppercaseName}Store = defineStore('${lowercaseName}Store', {
|
||||||
state() {
|
state() {
|
||||||
return {
|
return {
|
||||||
// ${classTitle}列表
|
// ${comment}列表
|
||||||
datalist: [],
|
datalist: [],
|
||||||
// 查询表单
|
// 查询表单
|
||||||
form: {
|
form: {
|
||||||
#foreach($item in $formList)
|
#foreach($item in $columnInfoList)
|
||||||
// $!{item.annotation}
|
// $!{item.comment}
|
||||||
$!{item.name}: undefined,
|
$!{item.fieldName}: undefined,
|
||||||
#end
|
#end
|
||||||
},
|
},
|
||||||
// 分页查询结果
|
// 分页查询结果
|
||||||
pagination: {
|
pagination: {
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 30,
|
pageSize: 30,
|
||||||
total: 1,
|
total: 1,
|
||||||
pageSizes,
|
pageSizes,
|
||||||
},
|
},
|
||||||
// 加载
|
// 加载
|
||||||
loading: false,
|
loading: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getters: {},
|
getters: {},
|
||||||
actions: {
|
actions: {
|
||||||
/** 获取${classTitle} */
|
/** 获取${comment} */
|
||||||
async get${originalName}List() {
|
async get${classUppercaseName}List() {
|
||||||
// 整理请求参数
|
// 整理请求参数
|
||||||
const data = { ...this.pagination, ...this.form };
|
const data = {...this.pagination, ...this.form};
|
||||||
delete data.pageSizes;
|
delete data.pageSizes;
|
||||||
delete data.total;
|
delete data.total;
|
||||||
delete data.background;
|
delete data.background;
|
||||||
|
|
||||||
// 获取${classTitle}列表
|
// 获取${comment}列表
|
||||||
const result = await fetchGet${originalName}List(data);
|
const result = await fetchGet${classUppercaseName}List(data);
|
||||||
|
|
||||||
// 公共页面函数hook
|
// 公共页面函数hook
|
||||||
const pagination = storePagination.bind(this);
|
const pagination = storePagination.bind(this);
|
||||||
return pagination(result);
|
return pagination(result);
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 添加${classTitle} */
|
/** 添加${comment} */
|
||||||
async add${originalName}(data: any) {
|
async add${classUppercaseName}(data: any) {
|
||||||
const result = await fetchAdd${originalName}(data);
|
const result = await fetchAdd${classUppercaseName}(data);
|
||||||
return storeMessage(result);
|
return storeMessage(result);
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 修改${classTitle} */
|
/** 修改${comment} */
|
||||||
async update${originalName}(data: any) {
|
async update${classUppercaseName}(data: any) {
|
||||||
const result = await fetchUpdate${originalName}(data);
|
const result = await fetchUpdate${classUppercaseName}(data);
|
||||||
return storeMessage(result);
|
return storeMessage(result);
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 删除${classTitle} */
|
/** 删除${comment} */
|
||||||
async delete${originalName}(data: any) {
|
async delete${classUppercaseName}(data: any) {
|
||||||
const result = await fetchDelete${originalName}(data);
|
const result = await fetchDelete${classUppercaseName}(data);
|
||||||
return storeMessage(result);
|
return storeMessage(result);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
// 添加或者修改表单元素
|
// 添加或者修改表单元素
|
||||||
export interface FormItemProps {
|
export interface FormItemProps {
|
||||||
#foreach($field in $baseFieldList)
|
#foreach($field in $columnInfoList)
|
||||||
// $field.annotation
|
// $field.comment
|
||||||
$field.name: $field.type;
|
#if($field.javascriptType == "object")
|
||||||
#end
|
$field.fieldName: any
|
||||||
|
#else
|
||||||
|
$field.fieldName: $field.javascriptType
|
||||||
|
#end
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加或修改表单Props
|
// 添加或修改表单Props
|
||||||
export interface FormProps {
|
export interface FormProps {
|
||||||
formInline: FormItemProps;
|
formInline: FormItemProps;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,34 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.bunny</groupId>
|
||||||
|
<artifactId>dao</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- hutool -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- mysql连接驱动 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- mysql连接池 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zaxxer</groupId>
|
||||||
|
<artifactId>HikariCP</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.bind</groupId>
|
<groupId>javax.xml.bind</groupId>
|
||||||
<artifactId>jaxb-api</artifactId>
|
<artifactId>jaxb-api</artifactId>
|
||||||
|
|
|
@ -12,38 +12,7 @@
|
||||||
<name>common Maven Webapp</name>
|
<name>common Maven Webapp</name>
|
||||||
<url>https://maven.apache.org</url>
|
<url>https://maven.apache.org</url>
|
||||||
<modules>
|
<modules>
|
||||||
<!-- <module>service-utils</module> -->
|
<module>generator-code</module>
|
||||||
<module>generator-v1</module>
|
<module>generator-v1</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.bunny</groupId>
|
|
||||||
<artifactId>dao</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
|
||||||
<artifactId>jjwt</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- hutool -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.hutool</groupId>
|
|
||||||
<artifactId>hutool-all</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- mysql连接驱动 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- mysql连接池 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zaxxer</groupId>
|
|
||||||
<artifactId>HikariCP</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
</project>
|
||||||
|
|
Loading…
Reference in New Issue