add
This commit is contained in:
@ -0,0 +1,28 @@
|
||||
<?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="com.qiaoba.module.generator.mapper.GeneratorTableColumnMapper">
|
||||
|
||||
<resultMap type="com.qiaoba.module.generator.entity.vo.TableColumnVo" id="DbTableColumnVoResult">
|
||||
<result property="columnName" column="column_name"/>
|
||||
<result property="columnComment" column="column_comment"/>
|
||||
<result property="columnType" column="column_type"/>
|
||||
<result property="isRequired" column="is_required"/>
|
||||
<result property="isPk" column="is_pk"/>
|
||||
<result property="sort" column="sort"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectDbColumnList" resultMap="DbTableColumnVoResult">
|
||||
select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, column_type
|
||||
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
|
||||
order by ordinal_position
|
||||
</select>
|
||||
|
||||
<delete id="deleteByTableIds">
|
||||
delete from generator_table_column where table_id in
|
||||
<foreach collection="list" item="tableId" open="(" separator="," close=")">
|
||||
#{tableId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@ -0,0 +1,73 @@
|
||||
<?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="com.qiaoba.module.generator.mapper.GeneratorTableMapper">
|
||||
|
||||
<resultMap type="com.qiaoba.module.generator.entity.vo.DbTableVo" id="DbTableVoResult">
|
||||
<result property="tableName" column="table_name"/>
|
||||
<result property="tableComment" column="table_comment"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectPageDbTableList" resultMap="DbTableVoResult">
|
||||
<if test="dto.dbType=='MySQL'.toString()">
|
||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||
where table_schema = (select database())
|
||||
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'generator_%'
|
||||
AND table_name NOT IN (select table_name from generator_table)
|
||||
<if test="dto.tableName != null and dto.tableName != ''">
|
||||
AND lower(table_name) like lower(concat('%', #{dto.tableName}, '%'))
|
||||
</if>
|
||||
<if test="dto.tableComment != null and dto.tableComment != ''">
|
||||
AND lower(table_comment) like lower(concat('%', #{dto.tableComment}, '%'))
|
||||
</if>
|
||||
order by create_time desc
|
||||
</if>
|
||||
|
||||
<if test="dto.dbType=='Oracle'.toString()">
|
||||
select lower(dt.table_name) as table_name, dtc.comments as table_comment, uo.created as create_time,
|
||||
uo.last_ddl_time as update_time
|
||||
from user_tables dt, user_tab_comments dtc, user_objects uo
|
||||
where dt.table_name = dtc.table_name
|
||||
and dt.table_name = uo.object_name
|
||||
and uo.object_type = 'TABLE'
|
||||
AND dt.table_name NOT LIKE 'XXL_JOB_%' AND dt.table_name NOT LIKE 'GEN_%'
|
||||
AND dt.table_name NOT IN (select table_name from generator_table)
|
||||
<if test="dto.tableName != null and dto.tableName != ''">
|
||||
AND lower(dt.table_name) like lower(concat(concat('%', #{dto.tableName}), '%'))
|
||||
</if>
|
||||
<if test="dto.tableComment != null and dto.tableComment != ''">
|
||||
AND lower(dtc.comments) like lower(concat(concat('%', #{dto.tableComment}), '%'))
|
||||
</if>
|
||||
order by create_time desc
|
||||
</if>
|
||||
|
||||
<if test="dto.dbType=='PostgreSQL'.toString()">
|
||||
select table_name, table_comment, create_time, update_time
|
||||
from (
|
||||
SELECT c.relname AS table_name,
|
||||
obj_description(c.oid) AS table_comment,
|
||||
CURRENT_TIMESTAMP AS create_time,
|
||||
CURRENT_TIMESTAMP AS update_time
|
||||
FROM pg_class c
|
||||
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
|
||||
WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
|
||||
AND c.relname != 'spatial_%'::text
|
||||
AND n.nspname = #{dto.schema}::name
|
||||
AND n.nspname <![CDATA[ <> ]]> ''::name
|
||||
) list_table
|
||||
where table_name NOT LIKE 'xxl_job_%' AND table_name NOT LIKE 'gen_%'
|
||||
AND table_name NOT IN (select table_name from generator_table)
|
||||
<if test="dto.tableName != null and dto.tableName != ''">
|
||||
AND lower(table_name) like lower(concat('%', #{dto.tableName}, '%'))
|
||||
</if>
|
||||
<if test="dto.tableComment != null and dto.tableComment != ''">
|
||||
AND lower(table_comment) like lower(concat('%', #{dto.tableComment}, '%'))
|
||||
</if>
|
||||
order by create_time desc
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
BIN
qiaoba-module/qiaoba-module-generator/src/main/resources/vm.zip
Normal file
BIN
qiaoba-module/qiaoba-module-generator/src/main/resources/vm.zip
Normal file
Binary file not shown.
@ -0,0 +1,127 @@
|
||||
package ${packageName}.controller;
|
||||
|
||||
import com.qiaoba.common.base.result.AjaxResult;
|
||||
import com.qiaoba.common.database.entity.PageQuery;
|
||||
import com.qiaoba.common.database.entity.TableDataInfo;
|
||||
#if($docFlag)
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
#end
|
||||
#if($excelFlag)
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.qiaoba.common.poi.util.ExcelUtil;
|
||||
import ${packageName}.entity.template.${ClassName}Export;
|
||||
#end
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ${packageName}.entity.${ClassName};
|
||||
import ${packageName}.entity.dto.${ClassName}Dto;
|
||||
import ${packageName}.entity.param.${ClassName}Param;
|
||||
import ${packageName}.service.${ClassName}Service;
|
||||
|
||||
|
||||
/**
|
||||
* ${functionName} Web层
|
||||
*
|
||||
* @author ${author}
|
||||
* @version 1.0
|
||||
* @since ${datetime}
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/${moduleName}/${businessName}")
|
||||
@RequiredArgsConstructor
|
||||
#if($docFlag)
|
||||
@Tag(name = "${functionName}管理")
|
||||
#end
|
||||
public class ${ClassName}Controller {
|
||||
|
||||
private final ${ClassName}Service ${className}Service;
|
||||
|
||||
#if($docFlag)
|
||||
@Operation(summary = "获取列表")
|
||||
#else
|
||||
/**
|
||||
* 获取列表
|
||||
*/
|
||||
#end
|
||||
@PreAuthorize("hasAuthority('${permissionPrefix}:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<${ClassName}> list(${ClassName}Param param, PageQuery pageQuery) {
|
||||
return ${className}Service.selectPageList(param, pageQuery);
|
||||
}
|
||||
|
||||
#if($docFlag)
|
||||
@Operation(summary = "获取详情")
|
||||
#else
|
||||
/**
|
||||
* 获取详情
|
||||
*/
|
||||
#end
|
||||
@PreAuthorize("hasAuthority('${permissionPrefix}:query')")
|
||||
@GetMapping(value = "/{${pkColumn.javaField}}")
|
||||
public AjaxResult getInfo(@PathVariable String ${pkColumn.javaField}) {
|
||||
return AjaxResult.success(${className}Service.selectById(${pkColumn.javaField}, false));
|
||||
}
|
||||
|
||||
#if($docFlag)
|
||||
@Operation(summary = "新增${functionName}")
|
||||
#else
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*/
|
||||
#end
|
||||
@PreAuthorize("hasAuthority('${permissionPrefix}:add')")
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ${ClassName}Dto dto) {
|
||||
return AjaxResult.toAjax(${className}Service.insert(dto));
|
||||
|
||||
}
|
||||
|
||||
#if($docFlag)
|
||||
@Operation(summary = "修改${functionName}")
|
||||
#else
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*/
|
||||
#end
|
||||
@PreAuthorize("hasAuthority('${permissionPrefix}:edit')")
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ${ClassName}Dto dto) {
|
||||
return AjaxResult.toAjax(${className}Service.updateById(dto));
|
||||
|
||||
}
|
||||
|
||||
#if($docFlag)
|
||||
@Operation(summary = "删除${functionName}")
|
||||
#else
|
||||
/**
|
||||
* 删除${functionName}
|
||||
*/
|
||||
#end
|
||||
@PreAuthorize("hasAuthority('${permissionPrefix}:remove')")
|
||||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
||||
public AjaxResult remove(@PathVariable List<String> ${pkColumn.javaField}s) {
|
||||
return AjaxResult.toAjax(${className}Service.deleteByIds(${pkColumn.javaField}s));
|
||||
}
|
||||
|
||||
#if($excelFlag)
|
||||
#if($docFlag)
|
||||
@Operation(summary = "导出${functionName}")
|
||||
#else
|
||||
/**
|
||||
* 导出${functionName}
|
||||
*/
|
||||
#end
|
||||
@PreAuthorize("hasAuthority('${permissionPrefix}:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, ${ClassName}Param param) {
|
||||
List<${ClassName}> list = ${className}Service.selectList(param);
|
||||
ExcelUtil.exportExcel(list, ${ClassName}Export.class, "${functionName}数据", response);
|
||||
}
|
||||
|
||||
#end
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package ${packageName}.entity;
|
||||
|
||||
#if($docFlag)
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
#end
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* ${functionName} Dto
|
||||
*
|
||||
* @author ${author}
|
||||
* @version 1.0
|
||||
* @since ${datetime}
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ${ClassName}Dto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
## 遍历字段
|
||||
#foreach ($column in $columns)
|
||||
## 忽略基础(父类)字段
|
||||
#if(!$generator.isBaseColumn($column.javaField))
|
||||
## 是主键
|
||||
#if($generator.isPk($column.isPk))
|
||||
private String $column.javaField;
|
||||
|
||||
## 不是主键
|
||||
#else
|
||||
#if($docFlag)
|
||||
@Schema(description = "$column.columnComment")
|
||||
#else
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package ${packageName}.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.qiaoba.common.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* ${functionName} ${tableName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @version 1.0
|
||||
* @since ${datetime}
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("${tableName}")
|
||||
public class ${ClassName} extends BaseEntity{
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
## 遍历字段
|
||||
#foreach ($column in $columns)
|
||||
## 忽略基础(父类)字段
|
||||
#if(!$generator.isBaseColumn($column.javaField))
|
||||
## 是主键
|
||||
#if($generator.isPk($column.isPk))
|
||||
@TableId
|
||||
private String $column.javaField;
|
||||
|
||||
## 不是主键
|
||||
#else
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package ${packageName}.entity.template;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* ${functionName} 导出模板
|
||||
*
|
||||
* @author ${author}
|
||||
* @version 1.0
|
||||
* @since ${datetime}
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ${ClassName}Export implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if($column.isList == "1")
|
||||
#if($column.javaType == "Date")
|
||||
@Excel(name = "$column.columnComment", width = 30, format = "yyyy-MM-dd HH:mm:ss")
|
||||
#else
|
||||
@Excel(name = "$column.columnComment", width = 20)
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package ${packageName}.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import ${packageName}.entity.${ClassName};
|
||||
|
||||
/**
|
||||
* ${functionName}管理 数据层
|
||||
*
|
||||
* @author ${author}
|
||||
* @version 1.0
|
||||
* @since ${datetime}
|
||||
*/
|
||||
public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> {
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package ${packageName}.entity;
|
||||
|
||||
#if($docFlag)
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
#end
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* ${functionName} 查询参数
|
||||
*
|
||||
* @author ${author}
|
||||
* @version 1.0
|
||||
* @since ${datetime}
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ${ClassName}Param implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
## 遍历字段
|
||||
#foreach ($column in $queryColumns)
|
||||
#if($column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
|
||||
#if($docFlag)
|
||||
@Schema(description = "开始$column.columnComment")
|
||||
#else
|
||||
/**
|
||||
* 开始$column.columnComment
|
||||
*/
|
||||
#end
|
||||
#if($column.javaType == "Date")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
#end
|
||||
private $column.javaType start$AttrName;
|
||||
|
||||
#if($docFlag)
|
||||
@Schema(description = "结束$column.columnComment")
|
||||
#else
|
||||
/**
|
||||
* 结束$column.columnComment
|
||||
*/
|
||||
#end
|
||||
#if($column.javaType == "Date")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
#end
|
||||
private $column.javaType end$AttrName;
|
||||
|
||||
#else
|
||||
|
||||
#if($docFlag)
|
||||
@Schema(description = "$column.columnComment")
|
||||
#else
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
#end
|
||||
#if($column.javaType == "Date")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
#end
|
||||
#end
|
||||
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
package ${packageName}.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.qiaoba.common.database.entity.PageQuery;
|
||||
import com.qiaoba.common.database.entity.TableDataInfo;
|
||||
import ${packageName}.entity.${ClassName};
|
||||
import ${packageName}.entity.dto.${ClassName}Dto;
|
||||
import ${packageName}.entity.param.${ClassName}Param;
|
||||
|
||||
/**
|
||||
* ${functionName} 服务层
|
||||
*
|
||||
* @author ${author}
|
||||
* @version 1.0
|
||||
* @since ${datetime}
|
||||
*/
|
||||
public interface ${ClassName}Service {
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
*
|
||||
* @param param 查询条件
|
||||
* @return ${functionName}集合
|
||||
*/
|
||||
List<${ClassName}> selectList(${ClassName}Param param);
|
||||
|
||||
/**
|
||||
* 分页查询${functionName}列表
|
||||
*
|
||||
* @param param 查询条件
|
||||
* @param pageQuery 分页信息
|
||||
* @return ${functionName}集合
|
||||
*/
|
||||
TableDataInfo<${ClassName}> selectPageList(${ClassName}Param param, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${pkColumn.javaField}
|
||||
* @param allowNull 允许空
|
||||
* @return ${functionName}
|
||||
*/
|
||||
${ClassName} selectById(String ${pkColumn.javaField}, boolean allowNull);
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*
|
||||
* @param dto dto
|
||||
* @return 结果
|
||||
*/
|
||||
int insert(${ClassName}Dto dto);
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*
|
||||
* @param dto dto
|
||||
* @return 结果
|
||||
*/
|
||||
int updateById(${ClassName}Dto dto);
|
||||
|
||||
/**
|
||||
* 删除${functionName}信息
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${pkColumn.javaField}
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteById(String ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s ${pkColumn.javaField}s
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteByIds(List<String> ${pkColumn.javaField}s);
|
||||
|
||||
}
|
||||
@ -0,0 +1,124 @@
|
||||
package ${packageName}.service.impl;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.qiaoba.api.auth.utils.SecurityUtil;
|
||||
import com.qiaoba.common.base.exception.ServiceException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.qiaoba.common.database.entity.PageQuery;
|
||||
import com.qiaoba.common.database.entity.TableDataInfo;
|
||||
|
||||
import ${packageName}.entity.${ClassName};
|
||||
import ${packageName}.entity.dto.${ClassName}Dto;
|
||||
import ${packageName}.entity.param.${ClassName}Param;
|
||||
import ${packageName}.service.${ClassName}Service;
|
||||
import ${packageName}.mapper.${ClassName}Mapper;
|
||||
|
||||
/**
|
||||
* ${functionName} 服务层实现
|
||||
*
|
||||
* @author ${author}
|
||||
* @version 1.0
|
||||
* @since ${datetime}
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ${ClassName}ServiceImpl implements ${ClassName}Service {
|
||||
|
||||
private final ${ClassName}Mapper ${className}Mapper;
|
||||
|
||||
@Override
|
||||
public List<${ClassName}> selectList(${ClassName}Param param) {
|
||||
return ${className}Mapper.selectList(param2Wrapper(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<${ClassName}> selectPageList(${ClassName}Param param, PageQuery pageQuery) {
|
||||
return TableDataInfo.build(${className}Mapper.selectPage(pageQuery.build(), param2Wrapper(param)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ${ClassName} selectById(String ${pkColumn.javaField}, boolean allowNull) {
|
||||
${ClassName} ${className} =${className}Mapper.selectById(${pkColumn.javaField});
|
||||
|
||||
if (!allowNull && Objects.isNull(${className})) {
|
||||
throw new ServiceException("未查询到有关信息");
|
||||
}
|
||||
|
||||
return ${className};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(${ClassName}Dto dto) {
|
||||
|
||||
${ClassName} ${className} =dto2Entity(dto);
|
||||
${className}.setCreateTime(new Date());
|
||||
${className}.setCreateUser(SecurityUtil.getLoginUsername());
|
||||
|
||||
return ${className}Mapper.insert(${className});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateById(${ClassName}Dto dto) {
|
||||
|
||||
${ClassName} ${className} =dto2Entity(dto);
|
||||
${className}.setUpdateTime(new Date());
|
||||
${className}.setUpdateUser(SecurityUtil.getLoginUsername());
|
||||
|
||||
return ${className}Mapper.updateById(${className});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteById(String ${pkColumn.javaField}) {
|
||||
return ${className}Mapper.deleteById(${pkColumn.javaField});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByIds(List<String> ${pkColumn.javaField}s) {
|
||||
return ${className}Mapper.deleteBatchIds(${pkColumn.javaField}s);
|
||||
}
|
||||
|
||||
private ${ClassName} dto2Entity(${ClassName}Dto dto) {
|
||||
${ClassName} ${className} = new ${ClassName}();
|
||||
#foreach ($column in $columns)
|
||||
#if(!$generator.isBaseColumn($column.javaField))
|
||||
## 首字母大写
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
${className}.set$AttrName(dto.get$AttrName());
|
||||
#end
|
||||
#end
|
||||
return ${className};
|
||||
}
|
||||
|
||||
private QueryWrapper<${ClassName}> param2Wrapper(${ClassName}Param param) {
|
||||
QueryWrapper<${ClassName}> wrapper = new QueryWrapper<>();
|
||||
#if($queryColumns.size() > 0)
|
||||
wrapper.lambda()
|
||||
#foreach ($column in $queryColumns)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#if($column.queryType == "EQ")
|
||||
.eq(ObjectUtil.isNotEmpty(param.get${AttrName}()), ${ClassName}::get${AttrName}, param.get${AttrName}())#if($foreach.count == $queryColumns.size());#end
|
||||
#elseif($column.queryType == "NE")
|
||||
.ne(ObjectUtil.isNotEmpty(param.get${AttrName}()), ${ClassName}::get${AttrName}, param.get${AttrName}())#if($foreach.count == $queryColumns.size());#end
|
||||
#elseif($column.queryType == "GT")
|
||||
.gt(ObjectUtil.isNotEmpty(param.get${AttrName}()), ${ClassName}::get${AttrName}, param.get${AttrName}())#if($foreach.count == $queryColumns.size());#end
|
||||
#elseif($column.queryType == "GTE")
|
||||
.ge(ObjectUtil.isNotEmpty(param.get${AttrName}()), ${ClassName}::get${AttrName}, param.get${AttrName}())#if($foreach.count == $queryColumns.size());#end
|
||||
#elseif($column.queryType == "LT")
|
||||
.lt(ObjectUtil.isNotEmpty(param.get${AttrName}()), ${ClassName}::get${AttrName}, param.get${AttrName}())#if($foreach.count == $queryColumns.size());#end
|
||||
#elseif($column.queryType == "LTE")
|
||||
.le(ObjectUtil.isNotEmpty(param.get${AttrName}()), ${ClassName}::get${AttrName}, param.get${AttrName}())#if($foreach.count == $queryColumns.size());#end
|
||||
#elseif($column.queryType == "LIKE")
|
||||
.like(ObjectUtil.isNotEmpty(param.get${AttrName}()), ${ClassName}::get${AttrName}, param.get${AttrName}())#if($foreach.count == $queryColumns.size());#end
|
||||
#elseif($column.queryType == "BETWEEN")
|
||||
.between((ObjectUtil.isNotEmpty(param.getStart${AttrName}()) && ObjectUtil.isNotEmpty(param.getEnd${AttrName}())),
|
||||
${ClassName}::get${AttrName}, param.getStart${AttrName}(), param.getEnd${AttrName}())#if($foreach.count == $queryColumns.size());#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
return wrapper;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询${functionName}列表
|
||||
export function list${BusinessName}(query) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询${functionName}详细
|
||||
export function get${BusinessName}(${pkColumn.javaField}) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增${functionName}
|
||||
export function add${BusinessName}(data) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改${functionName}
|
||||
export function update${BusinessName}(data) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除${functionName}
|
||||
export function del${BusinessName}(${pkColumn.javaField}) {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||
method: 'delete'
|
||||
})
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
||||
values('${parentId}', '${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 0, 0, 'C', '1', '${permissionPrefix}:list', '#', 'admin', '${datetime}', '', null, '${functionName}菜单', '${tenantId}');
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
||||
values('${selectMenuId}', '${functionName}查询', '${parentId}', '1', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:query', '#', 'admin', '${datetime}', '', null, '', '${tenantId}');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
||||
values('${insertMenuId}', '${functionName}新增', '${parentId}', '2', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:add', '#', 'admin', '${datetime}', '', null, '', '${tenantId}');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
||||
values('${updateMenuId}', '${functionName}修改', '${parentId}', '3', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:edit', '#', 'admin', '${datetime}', '', null, '', '${tenantId}');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
||||
values('${deleteMenuId}', '${functionName}删除', '${parentId}', '4', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:remove', '#', 'admin', '${datetime}', '', null, '', '${tenantId}');
|
||||
|
||||
#if($excelFlag)
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
||||
values('${exportMenuId}', '${functionName}导出', '${parentId}', '5', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:export', '#', 'admin', '${datetime}', '', null, '', '${tenantId}');
|
||||
#end
|
||||
@ -0,0 +1,480 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
||||
#foreach($column in $columns)
|
||||
#if($column.isQuery)
|
||||
#set($dictType=$column.dictType)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.htmlType == "input")
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-input
|
||||
v-model="queryParams.${column.javaField}"
|
||||
placeholder="请输入${comment}"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||
<el-option
|
||||
v-for="dict in ${dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.${column.javaField}"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择${comment}">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
<el-form-item label="${comment}" style="width: 308px">
|
||||
<el-date-picker
|
||||
v-model="daterange${AttrName}"
|
||||
value-format="YYYY-MM-DD"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['${moduleName}:${businessName}:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Edit"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
#if($excelFlag)
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['${moduleName}:${businessName}:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
#end
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
#foreach($column in $columns)
|
||||
#set($javaField=$column.javaField)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.isPk == "1")
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
#elseif($column.isList == "1" && $column.htmlType == "datetime")
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.isList == "1" && $column.htmlType == "imageUpload")
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
|
||||
<template #default="scope">
|
||||
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.isList == "1" && "" != $column.dictType)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||
<template #default="scope">
|
||||
#if($column.htmlType == "checkbox")
|
||||
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
|
||||
#else
|
||||
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/>
|
||||
#end
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.isList == "1" && "" != $javaField)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
#end
|
||||
#end
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改${functionName}对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
|
||||
#foreach($column in $columns)
|
||||
#set($field=$column.javaField)
|
||||
#if($column.isInsert == "1" && "1" != $column.isPk)
|
||||
#if(($column.usableColumn) || (!$column.superColumn))
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#set($dictType=$column.dictType)
|
||||
#if($column.htmlType == "input")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "imageUpload")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<image-upload v-model="form.${field}"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "fileUpload")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<file-upload v-model="form.${field}"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "editor")
|
||||
<el-form-item label="${comment}">
|
||||
<editor v-model="form.${field}" :min-height="192"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||
<el-option
|
||||
v-for="dict in ${dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||
:value="parseInt(dict.value)"
|
||||
#else
|
||||
:value="dict.value"
|
||||
#end
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "select" && $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-checkbox-group v-model="form.${field}">
|
||||
<el-checkbox
|
||||
v-for="dict in ${dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.value">
|
||||
{{dict.label}}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-checkbox-group v-model="form.${field}">
|
||||
<el-checkbox>请选择字典生成</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-radio-group v-model="form.${field}">
|
||||
<el-radio
|
||||
v-for="dict in ${dictType}"
|
||||
:key="dict.value"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||
:label="parseInt(dict.value)"
|
||||
#else
|
||||
:label="dict.value"
|
||||
#end
|
||||
>{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "radio" && $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-radio-group v-model="form.${field}">
|
||||
<el-radio label="1">请选择字典生成</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-date-picker clearable
|
||||
v-model="form.${field}"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择${comment}">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "textarea")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="${BusinessName}">
|
||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
#if(${dicts} != '')
|
||||
#set($dictsNoSymbol=$dicts.replace("'", ""))
|
||||
const { ${dictsNoSymbol} } = proxy.useDict(${dicts});
|
||||
#end
|
||||
|
||||
const ${businessName}List = ref([]);
|
||||
const open = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
const title = ref("");
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
const daterange${AttrName} = ref([]);
|
||||
#end
|
||||
#end
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
#foreach ($column in $columns)
|
||||
#if($column.isQuery)
|
||||
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
},
|
||||
rules: {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.isRequired)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
$column.javaField: [
|
||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }
|
||||
]#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询${functionName}列表 */
|
||||
function getList() {
|
||||
loading.value = true;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
queryParams.value.params = {};
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
if (null != daterange${AttrName} && '' != daterange${AttrName}) {
|
||||
queryParams.start${AttrName} = daterange${AttrName}.value[0];
|
||||
queryParams.end${AttrName} = daterange${AttrName}.value[1];
|
||||
}
|
||||
#end
|
||||
#end
|
||||
list${BusinessName}(queryParams.value).then(response => {
|
||||
${businessName}List.value = response.rows;
|
||||
total.value = response.total;
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
open.value = false;
|
||||
reset();
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
function reset() {
|
||||
form.value = {
|
||||
#foreach ($column in $columns)
|
||||
#if(!$generator.isBaseColumn($column.javaField))
|
||||
#if($column.htmlType == "checkbox")
|
||||
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||
#else
|
||||
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
};
|
||||
proxy.resetForm("${businessName}Ref");
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.string(1)})
|
||||
daterange${AttrName}.value = [];
|
||||
#end
|
||||
#end
|
||||
proxy.resetForm("queryRef");
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
// 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map(item => item.${pkColumn.javaField});
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset();
|
||||
open.value = true;
|
||||
title.value = "添加${functionName}";
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset();
|
||||
const _${pkColumn.javaField} = row.${pkColumn.javaField} || ids.value
|
||||
get${BusinessName}(_${pkColumn.javaField}).then(response => {
|
||||
form.value = response.data;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")
|
||||
form.value.$column.javaField = form.value.${column.javaField}.split(",");
|
||||
#end
|
||||
#end
|
||||
open.value = true;
|
||||
title.value = "修改${functionName}";
|
||||
});
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.#[[$]]#refs["${businessName}Ref"].validate(valid => {
|
||||
if (valid) {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")
|
||||
form.value.$column.javaField = form.value.${column.javaField}.join(",");
|
||||
#end
|
||||
#end
|
||||
if (form.value.${pkColumn.javaField} != null) {
|
||||
update${BusinessName}(form.value).then(response => {
|
||||
proxy.#[[$modal]]#.msgSuccess("修改成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
});
|
||||
} else {
|
||||
add${BusinessName}(form.value).then(response => {
|
||||
proxy.#[[$modal]]#.msgSuccess("新增成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const _${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value;
|
||||
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').then(function() {
|
||||
return del${BusinessName}(_${pkColumn.javaField}s);
|
||||
}).then(() => {
|
||||
getList();
|
||||
proxy.#[[$modal]]#.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
#if($excelFlag)
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download('${moduleName}/${businessName}/export', {
|
||||
...queryParams.value
|
||||
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
|
||||
}
|
||||
#end
|
||||
|
||||
getList();
|
||||
</script>
|
||||
Reference in New Issue
Block a user