完成单表重构“代码生成”模块,支持mybatis-flex
This commit is contained in:
parent
bd4b1720b7
commit
82f1600d39
@ -41,6 +41,7 @@
|
|||||||
<artifactId>ruoyi-common-web</artifactId>
|
<artifactId>ruoyi-common-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -45,6 +45,7 @@ public class VelocityUtils
|
|||||||
VelocityContext velocityContext = new VelocityContext();
|
VelocityContext velocityContext = new VelocityContext();
|
||||||
velocityContext.put("tplCategory", genTable.getTplCategory());
|
velocityContext.put("tplCategory", genTable.getTplCategory());
|
||||||
velocityContext.put("tableName", genTable.getTableName());
|
velocityContext.put("tableName", genTable.getTableName());
|
||||||
|
velocityContext.put("CapitalTableName", StringUtils.upperCase(genTable.getTableName()));//表名大写:SYS_USER
|
||||||
velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
|
velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
|
||||||
velocityContext.put("ClassName", genTable.getClassName());
|
velocityContext.put("ClassName", genTable.getClassName());
|
||||||
velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
|
velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
|
||||||
@ -130,6 +131,8 @@ public class VelocityUtils
|
|||||||
{
|
{
|
||||||
List<String> templates = new ArrayList<>();
|
List<String> templates = new ArrayList<>();
|
||||||
templates.add("vm/java/domain.java.vm");
|
templates.add("vm/java/domain.java.vm");
|
||||||
|
templates.add("vm/java/vo.java.vm");
|
||||||
|
templates.add("vm/java/bo.java.vm");
|
||||||
templates.add("vm/java/mapper.java.vm");
|
templates.add("vm/java/mapper.java.vm");
|
||||||
templates.add("vm/java/service.java.vm");
|
templates.add("vm/java/service.java.vm");
|
||||||
templates.add("vm/java/serviceImpl.java.vm");
|
templates.add("vm/java/serviceImpl.java.vm");
|
||||||
@ -177,10 +180,16 @@ public class VelocityUtils
|
|||||||
{
|
{
|
||||||
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
|
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
|
||||||
}
|
}
|
||||||
if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
|
else if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
|
||||||
{
|
{
|
||||||
fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
|
fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
|
||||||
}
|
}
|
||||||
|
else if (template.contains("vo.java.vm")) {
|
||||||
|
fileName = StringUtils.format("{}/domain/vo/{}Vo.java", javaPath, className);
|
||||||
|
}
|
||||||
|
else if (template.contains("bo.java.vm")) {
|
||||||
|
fileName = StringUtils.format("{}/domain/bo/{}Bo.java", javaPath, className);
|
||||||
|
}
|
||||||
else if (template.contains("mapper.java.vm"))
|
else if (template.contains("mapper.java.vm"))
|
||||||
{
|
{
|
||||||
fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
|
fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
package ${packageName}.domain.bo;
|
||||||
|
|
||||||
|
import ${packageName}.domain.${ClassName};
|
||||||
|
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||||
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
#foreach ($import in $importList)
|
||||||
|
import ${import};
|
||||||
|
#end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ${functionName}业务对象 ${tableName}
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @date ${datetime}
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@AutoMapper(target = ${ClassName}.class, reverseConvertGenerate = false)
|
||||||
|
public class ${ClassName}Bo extends BaseEntity {
|
||||||
|
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if(!$table.isSuperColumn($column.javaField) && ($column.query || $column.insert || $column.edit))
|
||||||
|
/**
|
||||||
|
* $column.columnComment
|
||||||
|
*/
|
||||||
|
#if($column.required)
|
||||||
|
#if($column.javaType == 'String')
|
||||||
|
@NotBlank(message = "$column.columnComment不能为空")
|
||||||
|
#else
|
||||||
|
@NotNull(message = "$column.columnComment不能为空")
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if($column.javaType == 'Date')
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
#end
|
||||||
|
private $column.javaType $column.javaField;
|
||||||
|
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
}
|
@ -1,27 +1,25 @@
|
|||||||
package ${packageName}.controller;
|
package ${packageName}.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.validation.constraints.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ruoyi.common.core.core.annotation.Log;
|
|
||||||
import com.ruoyi.common.web.core.BaseController;
|
|
||||||
import com.ruoyi.common.core.core.domain.AjaxResult;
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import ${packageName}.domain.${ClassName};
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import com.ruoyi.common.core.core.domain.R;
|
||||||
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.web.annotation.RepeatSubmit;
|
||||||
|
import com.ruoyi.common.web.core.BaseController;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import ${packageName}.domain.vo.${ClassName}Vo;
|
||||||
|
import ${packageName}.domain.bo.${ClassName}Bo;
|
||||||
import ${packageName}.service.I${ClassName}Service;
|
import ${packageName}.service.I${ClassName}Service;
|
||||||
import com.ruoyi.common.core.core.utils.poi.ExcelUtil;
|
|
||||||
|
|
||||||
#if($table.crud || $table.sub)
|
#if($table.crud || $table.sub)
|
||||||
|
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@ -31,6 +29,8 @@ import com.ruoyi.common.core.core.utils.poi.ExcelUtil;
|
|||||||
* @author ${author}
|
* @author ${author}
|
||||||
* ${datetime}
|
* ${datetime}
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/${moduleName}/${businessName}")
|
@RequestMapping("/${moduleName}/${businessName}")
|
||||||
public class ${ClassName}Controller extends BaseController
|
public class ${ClassName}Controller extends BaseController
|
||||||
@ -44,17 +44,15 @@ public class ${ClassName}Controller extends BaseController
|
|||||||
@SaCheckPermission("${permissionPrefix}:list")
|
@SaCheckPermission("${permissionPrefix}:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
#if($table.crud || $table.sub)
|
#if($table.crud || $table.sub)
|
||||||
public TableDataInfo list(${ClassName} ${className})
|
public TableDataInfo<${ClassName}Vo> list(${ClassName}Bo ${className}Bo)
|
||||||
{
|
{
|
||||||
startPage();
|
return ${className}Service.selectPage(${className}Bo);
|
||||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
}
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
public AjaxResult list(${ClassName} ${className})
|
public R<List<${ClassName}Vo>> list(${ClassName}Bo ${className}Bo)
|
||||||
{
|
{
|
||||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
List<${ClassName}Vo> list = ${className}Service.selectList(${className}Bo);
|
||||||
return success(list);
|
return R.ok(list);
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@ -64,11 +62,10 @@ public class ${ClassName}Controller extends BaseController
|
|||||||
@SaCheckPermission("${permissionPrefix}:export")
|
@SaCheckPermission("${permissionPrefix}:export")
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, ${ClassName} ${className})
|
public void export(HttpServletResponse response, ${ClassName}Bo ${className}Bo)
|
||||||
{
|
{
|
||||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
List<${ClassName}Vo> list = ${className}Service.selectList(${className}Bo);
|
||||||
ExcelUtil<${ClassName}> util = new ExcelUtil<>(${ClassName}.class);
|
ExcelUtil.exportExcel(list, "${functionName}", ${ClassName}Vo.class, response);
|
||||||
util.exportExcel(response, list, "${functionName}数据");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,9 +73,9 @@ public class ${ClassName}Controller extends BaseController
|
|||||||
*/
|
*/
|
||||||
@SaCheckPermission("${permissionPrefix}:query")
|
@SaCheckPermission("${permissionPrefix}:query")
|
||||||
@GetMapping(value = "/{${pkColumn.javaField}}")
|
@GetMapping(value = "/{${pkColumn.javaField}}")
|
||||||
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
public R<${ClassName}Vo> getInfo(@PathVariable ${pkColumn.javaType} ${pkColumn.javaField})
|
||||||
{
|
{
|
||||||
return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
|
return R.ok(${className}Service.selectById(${pkColumn.javaField}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,10 +83,15 @@ public class ${ClassName}Controller extends BaseController
|
|||||||
*/
|
*/
|
||||||
@SaCheckPermission("${permissionPrefix}:add")
|
@SaCheckPermission("${permissionPrefix}:add")
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody ${ClassName} ${className})
|
public R<Void> add(@Validated @RequestBody ${ClassName}Bo ${className}Bo)
|
||||||
{
|
{
|
||||||
return toAjax(${className}Service.insert${ClassName}(${className}));
|
boolean inserted = ${className}Service.insert(${className}Bo);
|
||||||
|
if (!inserted) {
|
||||||
|
return R.fail("新增${functionName}记录失败!");
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,10 +99,15 @@ public class ${ClassName}Controller extends BaseController
|
|||||||
*/
|
*/
|
||||||
@SaCheckPermission("${permissionPrefix}:edit")
|
@SaCheckPermission("${permissionPrefix}:edit")
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody ${ClassName} ${className})
|
public R<Void> edit(@Validated @RequestBody ${ClassName}Bo ${className}Bo)
|
||||||
{
|
{
|
||||||
return toAjax(${className}Service.update${ClassName}(${className}));
|
Boolean updated = ${className}Service.update(${className}Bo);
|
||||||
|
if (!updated) {
|
||||||
|
R.fail("修改${functionName}记录失败!");
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,8 +116,12 @@ public class ${ClassName}Controller extends BaseController
|
|||||||
@SaCheckPermission("${permissionPrefix}:remove")
|
@SaCheckPermission("${permissionPrefix}:remove")
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
@DeleteMapping("/{${pkColumn.javaField}s}")
|
||||||
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
public R<Void> remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||||
{
|
{
|
||||||
return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
|
boolean deleted = ${className}Service.deleteByIds(${pkColumn.javaField}s);
|
||||||
|
if (!deleted) {
|
||||||
|
R.fail("删除${functionName}记录失败!");
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package ${packageName}.domain;
|
|||||||
#foreach ($import in $importList)
|
#foreach ($import in $importList)
|
||||||
import ${import};
|
import ${import};
|
||||||
#end
|
#end
|
||||||
import java.io.Serial;
|
|
||||||
import com.mybatisflex.annotation.Id;
|
import com.mybatisflex.annotation.Id;
|
||||||
import com.mybatisflex.annotation.Table;
|
import com.mybatisflex.annotation.Table;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -29,9 +28,6 @@ import com.ruoyi.common.orm.core.domain.BaseEntity;
|
|||||||
@Table(value = "${tableName}")
|
@Table(value = "${tableName}")
|
||||||
public class ${ClassName} extends ${Entity}
|
public class ${ClassName} extends ${Entity}
|
||||||
{
|
{
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if(!$table.isSuperColumn($column.javaField))
|
#if(!$table.isSuperColumn($column.javaField))
|
||||||
/** $column.columnComment */
|
/** $column.columnComment */
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package ${packageName}.mapper;
|
package ${packageName}.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import ${packageName}.domain.${ClassName};
|
import ${packageName}.domain.${ClassName};
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
import ${packageName}.domain.${subClassName};
|
import ${packageName}.domain.${subClassName};
|
||||||
@ -12,80 +13,8 @@ import ${packageName}.domain.${subClassName};
|
|||||||
* @author ${author}
|
* @author ${author}
|
||||||
* ${datetime}
|
* ${datetime}
|
||||||
*/
|
*/
|
||||||
public interface ${ClassName}Mapper
|
@Mapper
|
||||||
|
public interface ${ClassName}Mapper extends BaseMapper<${ClassName}>
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* 查询${functionName}
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField} ${functionName}主键
|
|
||||||
* @return ${functionName}
|
|
||||||
*/
|
|
||||||
${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询${functionName}列表
|
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
|
||||||
* @return ${functionName}集合
|
|
||||||
*/
|
|
||||||
List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增${functionName}
|
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int insert${ClassName}(${ClassName} ${className});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改${functionName}
|
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int update${ClassName}(${ClassName} ${className});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除${functionName}
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField} ${functionName}主键
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除${functionName}
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
|
||||||
#if($table.sub)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除${subTable.functionName}
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量新增${subTable.functionName}
|
|
||||||
*
|
|
||||||
* @param ${subclassName}List ${subTable.functionName}列表
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int batch${subClassName}(List<${subClassName}> ${subclassName}List);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过${functionName}主键删除${subTable.functionName}信息
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
|
||||||
#end
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,12 @@ package ${packageName}.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import ${packageName}.domain.${ClassName};
|
import ${packageName}.domain.${ClassName};
|
||||||
|
import ${packageName}.domain.vo.${ClassName}Vo;
|
||||||
|
import ${packageName}.domain.bo.${ClassName}Bo;
|
||||||
|
import com.ruoyi.common.orm.core.service.IBaseService;
|
||||||
|
#if($table.crud || $table.sub)
|
||||||
|
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||||
|
#end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}Service接口
|
* ${functionName}Service接口
|
||||||
@ -9,7 +15,7 @@ import ${packageName}.domain.${ClassName};
|
|||||||
* @author ${author}
|
* @author ${author}
|
||||||
* ${datetime}
|
* ${datetime}
|
||||||
*/
|
*/
|
||||||
public interface I${ClassName}Service
|
public interface I${ClassName}Service extends IBaseService<${ClassName}>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 查询${functionName}
|
* 查询${functionName}
|
||||||
@ -17,45 +23,48 @@ public interface I${ClassName}Service
|
|||||||
* @param ${pkColumn.javaField} ${functionName}主键
|
* @param ${pkColumn.javaField} ${functionName}主键
|
||||||
* @return ${functionName}
|
* @return ${functionName}
|
||||||
*/
|
*/
|
||||||
${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
${ClassName}Vo selectById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询${functionName}列表
|
* 查询${functionName}列表
|
||||||
*
|
*
|
||||||
* @param ${className} ${functionName}
|
* @param ${className}Bo ${functionName}Bo
|
||||||
* @return ${functionName}集合
|
* @return ${functionName}集合
|
||||||
*/
|
*/
|
||||||
List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
List<${ClassName}Vo> selectList(${ClassName}Bo ${className}Bo);
|
||||||
|
|
||||||
|
#if($table.crud || $table.sub)
|
||||||
|
/**
|
||||||
|
* 分页查询${functionName}列表
|
||||||
|
*
|
||||||
|
* @param ${className}Bo ${functionName}Bo
|
||||||
|
* @return 分页${functionName}集合
|
||||||
|
*/
|
||||||
|
TableDataInfo<${ClassName}Vo> selectPage(${ClassName}Bo ${className}Bo);
|
||||||
|
#end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增${functionName}
|
* 新增${functionName}
|
||||||
*
|
*
|
||||||
* @param ${className} ${functionName}
|
* @param ${className}Bo ${functionName}Bo
|
||||||
* @return 结果
|
* @return 结果:true 操作成功,false 操作失败
|
||||||
*/
|
*/
|
||||||
int insert${ClassName}(${ClassName} ${className});
|
boolean insert(${ClassName}Bo ${className}Bo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改${functionName}
|
* 修改${functionName}
|
||||||
*
|
*
|
||||||
* @param ${className} ${functionName}
|
* @param ${className}Bo ${functionName}Bo
|
||||||
* @return 结果
|
* @return 结果:true 更新成功,false 更新失败
|
||||||
*/
|
*/
|
||||||
int update${ClassName}(${ClassName} ${className});
|
boolean update(${ClassName}Bo ${className}Bo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除${functionName}
|
* 批量删除${functionName}
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
|
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
|
||||||
* @return 结果
|
* @return 结果:true 删除成功,false 删除失败
|
||||||
*/
|
*/
|
||||||
int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
boolean deleteByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除${functionName}信息
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField} ${functionName}主键
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,37 @@
|
|||||||
package ${packageName}.service.impl;
|
package ${packageName}.service.impl;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.ruoyi.common.core.utils.MapstructUtils;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.orm.core.page.PageQuery;
|
||||||
|
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
|
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
|
||||||
import com.ruoyi.common.core.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
#break
|
#break
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import com.ruoyi.common.core.core.utils.StringUtils;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${packageName}.domain.${subClassName};
|
import ${packageName}.domain.${subClassName};
|
||||||
#end
|
#end
|
||||||
import ${packageName}.mapper.${ClassName}Mapper;
|
import ${packageName}.mapper.${ClassName}Mapper;
|
||||||
import ${packageName}.domain.${ClassName};
|
import ${packageName}.domain.${ClassName};
|
||||||
|
import ${packageName}.domain.bo.${ClassName}Bo;
|
||||||
|
import ${packageName}.domain.vo.${ClassName}Vo;
|
||||||
import ${packageName}.service.I${ClassName}Service;
|
import ${packageName}.service.I${ClassName}Service;
|
||||||
|
|
||||||
|
import static ${packageName}.domain.table.${ClassName}TableDef.${CapitalTableName};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}Service业务层处理
|
* ${functionName}Service业务层处理
|
||||||
*
|
*
|
||||||
@ -26,11 +39,49 @@ import ${packageName}.service.I${ClassName}Service;
|
|||||||
* ${datetime}
|
* ${datetime}
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
public class ${ClassName}ServiceImpl extends BaseServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service
|
||||||
{
|
{
|
||||||
@Resource
|
@Resource
|
||||||
private ${ClassName}Mapper ${className}Mapper;
|
private ${ClassName}Mapper ${className}Mapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryWrapper query() {
|
||||||
|
return super.query().from(${CapitalTableName});
|
||||||
|
}
|
||||||
|
|
||||||
|
private QueryWrapper buildQueryWrapper(${ClassName}Bo ${className}Bo) {
|
||||||
|
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
|
||||||
|
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.query)
|
||||||
|
#set($queryType=$column.queryType)
|
||||||
|
#set($javaField=$column.javaField)
|
||||||
|
#set($javaType=$column.javaType)
|
||||||
|
#set($columnName=$column.columnName)
|
||||||
|
#set($capitalColumnName=$column.columnName.toUpperCase())
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
#set($mpMethod=$column.queryType.toLowerCase())
|
||||||
|
#if($queryType != 'BETWEEN')
|
||||||
|
#if($javaType == 'String')
|
||||||
|
#set($condition='StringUtils.isNotBlank('+${className}+'Bo.get'+$AttrName+'())')
|
||||||
|
#else
|
||||||
|
#set($condition=${className}+'Bo.get'+$AttrName+'() != null')
|
||||||
|
#end
|
||||||
|
if ($condition) {
|
||||||
|
queryWrapper.and(${CapitalTableName}.${capitalColumnName}.$mpMethod(${className}Bo.get$AttrName()));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
Map<String, Object> params = ${className}Bo.getParams();
|
||||||
|
if (params.get("begin$AttrName") != null && params.get("end$AttrName") != null) {
|
||||||
|
queryWrapper.and(${CapitalTableName}.${capitalColumnName}.$mpMethod(params.get("begin$AttrName"), params.get("end$AttrName")));
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询${functionName}
|
* 查询${functionName}
|
||||||
*
|
*
|
||||||
@ -38,116 +89,113 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||||||
* @return ${functionName}
|
* @return ${functionName}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
|
public ${ClassName}Vo selectById(${pkColumn.javaType} ${pkColumn.javaField})
|
||||||
{
|
{
|
||||||
return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
|
#set($CapitalPkColumn=${pkColumn.columnName.toUpperCase()})
|
||||||
|
return this.getOneAs(query().where(${CapitalTableName}.${CapitalPkColumn}.eq(${pkColumn.javaField})), ${ClassName}Vo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询${functionName}列表
|
* 查询${functionName}列表
|
||||||
*
|
*
|
||||||
* @param ${className} ${functionName}
|
* @param ${className}Bo ${functionName}Bo
|
||||||
* @return ${functionName}
|
* @return ${functionName}集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
|
public List<${ClassName}Vo> selectList(${ClassName}Bo ${className}Bo)
|
||||||
{
|
{
|
||||||
return ${className}Mapper.select${ClassName}List(${className});
|
QueryWrapper queryWrapper = buildQueryWrapper(${className}Bo);
|
||||||
|
return this.listAs(queryWrapper, ${ClassName}Vo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if($table.crud || $table.sub)
|
||||||
|
/**
|
||||||
|
* 分页查询${functionName}列表
|
||||||
|
*
|
||||||
|
* @param ${className}Bo ${functionName}Bo
|
||||||
|
* @return 分页${functionName}集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<${ClassName}Vo> selectPage(${ClassName}Bo ${className}Bo)
|
||||||
|
{
|
||||||
|
QueryWrapper queryWrapper = buildQueryWrapper(${className}Bo);
|
||||||
|
Page<${ClassName}Vo> page = this.pageAs(PageQuery.build(), queryWrapper, ${ClassName}Vo.class);
|
||||||
|
return TableDataInfo.build(page);
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增${functionName}
|
* 新增${functionName}
|
||||||
*
|
*
|
||||||
* @param ${className} ${functionName}
|
* @param ${className}Bo ${functionName}Bo
|
||||||
* @return 结果
|
* @return 结果:true 操作成功,false 操作失败
|
||||||
*/
|
*/
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
@Transactional
|
@Transactional
|
||||||
#end
|
#end
|
||||||
@Override
|
@Override
|
||||||
public int insert${ClassName}(${ClassName} ${className})
|
public boolean insert(${ClassName}Bo ${className}Bo)
|
||||||
{
|
{
|
||||||
#foreach ($column in $columns)
|
${ClassName} ${className} = MapstructUtils.convert(${className}Bo, ${ClassName}.class);
|
||||||
#if($column.javaField == 'createTime')
|
|
||||||
${className}.setCreateTime(DateUtils.getNowDate());
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
int rows = ${className}Mapper.insert${ClassName}(${className});
|
boolean inserted = this.save(${className});//使用全局配置的雪花算法主键生成器生成ID值
|
||||||
insert${subClassName}(${className});
|
if (inserted) {
|
||||||
return rows;
|
return insert${subClassName}(${className});
|
||||||
|
}
|
||||||
|
return false;
|
||||||
#else
|
#else
|
||||||
return ${className}Mapper.insert${ClassName}(${className});
|
return this.save(${className});//使用全局配置的雪花算法主键生成器生成ID值
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改${functionName}
|
* 修改${functionName}
|
||||||
*
|
*
|
||||||
* @param ${className} ${functionName}
|
* @param ${className}Bo ${functionName}Bo
|
||||||
* @return 结果
|
* @return 结果:true 更新成功,false 更新失败
|
||||||
*/
|
*/
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
@Transactional
|
@Transactional
|
||||||
#end
|
#end
|
||||||
@Override
|
@Override
|
||||||
public int update${ClassName}(${ClassName} ${className})
|
public boolean update(${ClassName}Bo ${className}Bo)
|
||||||
{
|
{
|
||||||
#foreach ($column in $columns)
|
${ClassName} ${className} = MapstructUtils.convert(${className}Bo, ${ClassName}.class);
|
||||||
#if($column.javaField == 'updateTime')
|
boolean updated = this.updateById(${className});
|
||||||
${className}.setUpdateTime(DateUtils.getNowDate());
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
|
if (updated) {
|
||||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
|
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
|
||||||
insert${subClassName}(${className});
|
return insert${subClassName}(${className});
|
||||||
|
}
|
||||||
#end
|
#end
|
||||||
return ${className}Mapper.update${ClassName}(${className});
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除${functionName}
|
* 批量删除${functionName}
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键
|
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
|
||||||
* @return 结果
|
* @return 结果:true 删除成功,false 删除失败
|
||||||
*/
|
*/
|
||||||
#if($table.sub)
|
|
||||||
@Transactional
|
@Transactional
|
||||||
#end
|
|
||||||
@Override
|
@Override
|
||||||
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
public boolean deleteByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||||
{
|
{
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
|
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
|
||||||
#end
|
#end
|
||||||
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s);
|
return this.removeByIds(Arrays.asList(${pkColumn.javaField}s));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除${functionName}信息
|
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField} ${functionName}主键
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
@Transactional
|
|
||||||
#end
|
|
||||||
@Override
|
|
||||||
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
|
|
||||||
{
|
|
||||||
#if($table.sub)
|
|
||||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
|
|
||||||
#end
|
|
||||||
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
|
|
||||||
}
|
|
||||||
#if($table.sub)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增${subTable.functionName}信息
|
* 新增${subTable.functionName}信息
|
||||||
*
|
*
|
||||||
* @param ${className} ${functionName}对象
|
* @param ${className} ${functionName}对象
|
||||||
*/
|
*/
|
||||||
public void insert${subClassName}(${ClassName} ${className})
|
public boolean insert${subClassName}(${ClassName} ${className})
|
||||||
{
|
{
|
||||||
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
|
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
|
||||||
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
|
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
|
||||||
@ -164,6 +212,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||||||
${className}Mapper.batch${subClassName}(list);
|
${className}Mapper.batch${subClassName}(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
package ${packageName}.domain.vo;
|
||||||
|
|
||||||
|
#foreach ($import in $importList)
|
||||||
|
import ${import};
|
||||||
|
#end
|
||||||
|
import ${packageName}.domain.${ClassName};
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import com.ruoyi.common.excel.convert.ExcelDictConvert;
|
||||||
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
#if($table.crud || $table.sub)
|
||||||
|
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||||
|
#elseif($table.tree)
|
||||||
|
#end
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ${functionName}视图对象 ${tableName}
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @date ${datetime}
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
@AutoMapper(target = ${ClassName}.class)
|
||||||
|
public class ${ClassName}Vo extends BaseEntity implements Serializable
|
||||||
|
{
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if(!$table.isSuperColumn($column.javaField))
|
||||||
|
/** $column.columnComment */
|
||||||
|
#if($column.list)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if(${column.dictType} && ${column.dictType} != '')
|
||||||
|
@ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "${column.dictType}")
|
||||||
|
#elseif($parentheseIndex != -1)
|
||||||
|
@ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(readConverterExp = "$column.readConverterExp()")
|
||||||
|
#else
|
||||||
|
@ExcelProperty(value = "${comment}")
|
||||||
|
#end
|
||||||
|
private $column.javaType $column.javaField;
|
||||||
|
|
||||||
|
#else
|
||||||
|
@ExcelProperty(value = "${column.columnComment}")
|
||||||
|
private $column.javaType $column.javaField;
|
||||||
|
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
@ -1,22 +1,22 @@
|
|||||||
-- 菜单 SQL
|
-- 菜单 SQL
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单');
|
values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 1, sysdate(), 1, null, '${functionName}菜单');
|
||||||
|
|
||||||
-- 按钮父菜单ID
|
-- 按钮父菜单ID
|
||||||
SELECT @parentId := LAST_INSERT_ID();
|
SELECT @parentId := LAST_INSERT_ID();
|
||||||
|
|
||||||
-- 按钮 SQL
|
-- 按钮 SQL
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', sysdate(), '', null, '');
|
values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 1, sysdate(), 1, null, '');
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values('${functionName}新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', sysdate(), '', null, '');
|
values('${functionName}新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 1, sysdate(), 1, null, '');
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values('${functionName}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', sysdate(), '', null, '');
|
values('${functionName}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 1, sysdate(), 1, null, '');
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, '');
|
values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 1, sysdate(), 1, null, '');
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', sysdate(), '', null, '');
|
values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 1, sysdate(), 1, null, '');
|
||||||
|
@ -163,7 +163,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 添加或修改${functionName}对话框 -->
|
<!-- 添加或修改${functionName}对话框 -->
|
||||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
<el-dialog :title="title" v-model="open" width="780px" append-to-body>
|
||||||
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
|
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#set($field=$column.javaField)
|
#set($field=$column.javaField)
|
||||||
|
@ -4,132 +4,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="${packageName}.mapper.${ClassName}Mapper">
|
<mapper namespace="${packageName}.mapper.${ClassName}Mapper">
|
||||||
|
|
||||||
<resultMap type="${ClassName}" id="${ClassName}Result">
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
<result property="${column.javaField}" column="${column.columnName}" />
|
|
||||||
#end
|
|
||||||
</resultMap>
|
|
||||||
#if($table.sub)
|
|
||||||
|
|
||||||
<resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result">
|
|
||||||
<collection property="${subclassName}List" notNullColumn="sub_${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<resultMap type="${subClassName}" id="${subClassName}Result">
|
|
||||||
#foreach ($column in $subTable.columns)
|
|
||||||
<result property="${column.javaField}" column="sub_${column.columnName}" />
|
|
||||||
#end
|
|
||||||
</resultMap>
|
|
||||||
#end
|
|
||||||
|
|
||||||
<sql id="select${ClassName}Vo">
|
|
||||||
select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end from ${tableName}
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
|
|
||||||
<include refid="select${ClassName}Vo"/>
|
|
||||||
<where>
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#set($queryType=$column.queryType)
|
|
||||||
#set($javaField=$column.javaField)
|
|
||||||
#set($javaType=$column.javaType)
|
|
||||||
#set($columnName=$column.columnName)
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
#if($column.query)
|
|
||||||
#if($column.queryType == "EQ")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName = #{$javaField}</if>
|
|
||||||
#elseif($queryType == "NE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if>
|
|
||||||
#elseif($queryType == "GT")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName > #{$javaField}</if>
|
|
||||||
#elseif($queryType == "GTE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName >= #{$javaField}</if>
|
|
||||||
#elseif($queryType == "LT")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName < #{$javaField}</if>
|
|
||||||
#elseif($queryType == "LTE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName <= #{$javaField}</if>
|
|
||||||
#elseif($queryType == "LIKE")
|
|
||||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
|
|
||||||
#elseif($queryType == "BETWEEN")
|
|
||||||
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="select${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
|
||||||
#if($table.crud || $table.tree)
|
|
||||||
<include refid="select${ClassName}Vo"/>
|
|
||||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
|
||||||
#elseif($table.sub)
|
|
||||||
select#foreach($column in $columns) a.$column.columnName#if($foreach.count != $columns.size()),#end#end,
|
|
||||||
#foreach($column in $subTable.columns) b.$column.columnName as sub_$column.columnName#if($foreach.count != $subTable.columns.size()),#end#end
|
|
||||||
|
|
||||||
from ${tableName} a
|
|
||||||
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
|
|
||||||
where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
|
||||||
#end
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
|
|
||||||
insert into ${tableName}
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
|
|
||||||
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName,</if>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
</trim>
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
|
|
||||||
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">#{$column.javaField},</if>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="update${ClassName}" parameterType="${ClassName}">
|
|
||||||
update ${tableName}
|
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.columnName != $pkColumn.columnName)
|
|
||||||
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName = #{$column.javaField},</if>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
</trim>
|
|
||||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="delete${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}">
|
|
||||||
delete from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="delete${ClassName}By${pkColumn.capJavaField}s" parameterType="String">
|
|
||||||
delete from ${tableName} where ${pkColumn.columnName} in
|
|
||||||
<foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
|
|
||||||
#{${pkColumn.javaField}}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
#if($table.sub)
|
|
||||||
|
|
||||||
<delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String">
|
|
||||||
delete from ${subTableName} where ${subTableFkName} in
|
|
||||||
<foreach item="${subTableFkclassName}" collection="array" open="(" separator="," close=")">
|
|
||||||
#{${subTableFkclassName}}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}">
|
|
||||||
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<insert id="batch${subClassName}">
|
|
||||||
insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($foreach.count != $subTable.columns.size()),#end#end) values
|
|
||||||
<foreach item="item" index="index" collection="list" separator=",">
|
|
||||||
(#foreach($column in $subTable.columns) #{item.$column.javaField}#if($foreach.count != $subTable.columns.size()),#end#end)
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
#end
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue
Block a user