代码生成器修改
This commit is contained in:
parent
0a5e6fb26b
commit
740235038a
@ -150,6 +150,12 @@
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.10.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.7.18</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
104
base-common/src/main/java/com/agri/common/core/domain/Ztree.java
Normal file
104
base-common/src/main/java/com/agri/common/core/domain/Ztree.java
Normal file
@ -0,0 +1,104 @@
|
||||
package com.agri.common.core.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Ztree树结构实体类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class Ztree implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 节点ID */
|
||||
private Long id;
|
||||
|
||||
/** 节点父ID */
|
||||
private Long pId;
|
||||
|
||||
/** 节点名称 */
|
||||
private String name;
|
||||
|
||||
/** 节点标题 */
|
||||
private String title;
|
||||
|
||||
/** 是否勾选 */
|
||||
private boolean checked = false;
|
||||
|
||||
/** 是否展开 */
|
||||
private boolean open = false;
|
||||
|
||||
/** 是否能勾选 */
|
||||
private boolean nocheck = false;
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getpId()
|
||||
{
|
||||
return pId;
|
||||
}
|
||||
|
||||
public void setpId(Long pId)
|
||||
{
|
||||
this.pId = pId;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public boolean isChecked()
|
||||
{
|
||||
return checked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked)
|
||||
{
|
||||
this.checked = checked;
|
||||
}
|
||||
|
||||
public boolean isOpen()
|
||||
{
|
||||
return open;
|
||||
}
|
||||
|
||||
public void setOpen(boolean open)
|
||||
{
|
||||
this.open = open;
|
||||
}
|
||||
|
||||
public boolean isNocheck()
|
||||
{
|
||||
return nocheck;
|
||||
}
|
||||
|
||||
public void setNocheck(boolean nocheck)
|
||||
{
|
||||
this.nocheck = nocheck;
|
||||
}
|
||||
}
|
75
base-common/src/main/java/com/agri/common/dao/BaseDao.java
Normal file
75
base-common/src/main/java/com/agri/common/dao/BaseDao.java
Normal file
@ -0,0 +1,75 @@
|
||||
package com.agri.common.dao;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface BaseDao<T> {
|
||||
/**
|
||||
* 通过Id查找
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public T find(Long id);
|
||||
|
||||
/**
|
||||
* 通过参数查找
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public T findByParam(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 查找集合
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public List<T> findListByParam(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 查找所有
|
||||
* @return
|
||||
*/
|
||||
public List<T> findAll();
|
||||
|
||||
/**
|
||||
* 查找数量
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public Long count(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 保存对象
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
public Long insert(T t);
|
||||
|
||||
/**
|
||||
* 保存对象
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
public Long update(T t);
|
||||
|
||||
/**
|
||||
* 通过属性删除
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public Long deleteByParam(Map<String, Object> map);
|
||||
/**
|
||||
* 通过id删除
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public Long deleteByIds(Long... ids);
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Long delete(Long id);
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.agri.common.enums;
|
||||
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统导出excel枚举
|
||||
*/
|
||||
@Getter
|
||||
public enum ExportEnum {
|
||||
|
||||
|
||||
|
||||
APP_USER_EXPORT(1, "用户导出"),
|
||||
;
|
||||
|
||||
private final Integer code;
|
||||
|
||||
private final String desc;
|
||||
|
||||
ExportEnum(Integer code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public static Map<String, ExportEnum> getEnumMap() {
|
||||
return EnumUtil.getEnumMap(ExportEnum.class);
|
||||
}
|
||||
|
||||
public static Map<Integer, Object> getExportMap() {
|
||||
Map<String, ExportEnum> enumMap = getEnumMap();
|
||||
Map<Integer, Object> exportEnumMap = new HashMap<>();
|
||||
for (Map.Entry<String, ExportEnum> stringExportEnumEntry : enumMap.entrySet()) {
|
||||
ExportEnum value = stringExportEnumEntry.getValue();
|
||||
exportEnumMap.put(value.getCode(), value.getDesc());
|
||||
}
|
||||
return exportEnumMap;
|
||||
}
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
package com.agri.common.service;
|
||||
|
||||
|
||||
import com.agri.common.utils.web.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public interface BaseService<T> {
|
||||
/**
|
||||
* 通过Id查找
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public T find(Long id);
|
||||
|
||||
/**
|
||||
* 通过参数查找
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public T findByParam(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 通过参数查找对象
|
||||
* @param propertyName
|
||||
* @param propertyValue
|
||||
* @return
|
||||
*/
|
||||
public T findByParam(String propertyName, Object propertyValue);
|
||||
|
||||
/**
|
||||
* 条件查询数据列表,如需分页使用findPageByParam或findListPageByParam方法
|
||||
* @param map 参数
|
||||
* @return 列表
|
||||
*/
|
||||
public List<T> findListByParam(Map<String, Object> map);
|
||||
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param params 查询参数map
|
||||
* @return PageResult<T>
|
||||
*/
|
||||
PageResult<T> findPageByParam(Map<String, Object> params);
|
||||
|
||||
|
||||
/**
|
||||
* pagehelper查询分页数据
|
||||
* @param params 查询参数map
|
||||
* @return PageResult<T>
|
||||
*/
|
||||
PageResult<T> findPageByParam2(Map<String, Object> params);
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询-不查询总条数,仅查询数据列表
|
||||
* @param params 查询参数map
|
||||
* @return List<T>
|
||||
*/
|
||||
List<T> findListPageByParam(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* pagehelpter分页查询-不查询总条数,仅查询数据列表
|
||||
* @param params 查询参数map
|
||||
* @return List<T>
|
||||
*/
|
||||
List<T> findListPageByParam2(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 属性值和属性查找集合
|
||||
* @param propertyName
|
||||
* @param propertyValue
|
||||
* @return
|
||||
*/
|
||||
public List<T> findListByParam(String propertyName, Object propertyValue);
|
||||
|
||||
/**
|
||||
* 查找数量
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public Long count(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 保存对象
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
public Long save(T t);
|
||||
|
||||
/**
|
||||
* 保存对象
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
public Long update(T t);
|
||||
/**
|
||||
* 通过属性删除
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public Long deleteByParam(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 通过属性删除
|
||||
* @param propertyName
|
||||
* @param propertyValue
|
||||
* @return
|
||||
*/
|
||||
public Long deleteByParam(String propertyName, Object propertyValue);
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Long delete(long id);
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public Long deleteByIds(Long... ids);
|
||||
|
||||
/**
|
||||
* 查找所有
|
||||
* @return
|
||||
*/
|
||||
public List<T> findAll();
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
PageResult<T> findAll(Map<String, Object> params);
|
||||
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
package com.agri.common.service.impl;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.agri.common.dao.BaseDao;
|
||||
import com.agri.common.service.BaseService;
|
||||
import com.agri.common.utils.PageUtil;
|
||||
import com.agri.common.utils.web.PageResult;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BaseServiceImpl<T> implements BaseService<T> {
|
||||
|
||||
@Autowired
|
||||
private BaseDao<T> baseDao;
|
||||
|
||||
public void setBaseDao(BaseDao<T> baseDao) {
|
||||
this.baseDao = baseDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T find(Long id) {
|
||||
return baseDao.find(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T findByParam(Map<String, Object> map) {
|
||||
return baseDao.findByParam(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T findByParam(String propertyName, Object propertyValue) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put(propertyName, propertyValue);
|
||||
T t = findByParam(map);
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件查询数据列表,如需分页使用findPageByParam或findListPageByParam方法
|
||||
* @param params 参数,需要排序的话传map中放order参数,值为:字段值 desc 这种
|
||||
* @return 列表
|
||||
*/
|
||||
@Override
|
||||
public List<T> findListByParam(Map<String, Object> params) {
|
||||
PageUtil.adminOrderConvert(params);
|
||||
return baseDao.findListByParam(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param params 查询参数map,需要排序的话传map中放order参数,值为:字段值 desc 这种
|
||||
* @return PageResult<T>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<T> findPageByParam(Map<String, Object> params) {
|
||||
PageUtil.pageParamConvert(params, true);
|
||||
List<T> list = baseDao.findListByParam(params);
|
||||
Long count = baseDao.count(params);
|
||||
Integer pageSize = MapUtils.getInteger(params, "pageSize");
|
||||
return PageResult.buildPageResult(list, count, pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* pagehelper查询分页数据
|
||||
*
|
||||
* @param params 查询参数map,需要排序的话传map中放order参数,值为:字段值 desc 这种
|
||||
* @return PageResult<T>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<T> findPageByParam2(Map<String, Object> params) {
|
||||
try (Page<T> page = PageUtil.startPageWithCountByParam(params)) {
|
||||
baseDao.findListByParam(params);
|
||||
return PageResult.buildPageResult(page.getResult(), page.getTotal(), page.getPageSize());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询-不查询总条数,仅查询数据列表
|
||||
* @param params 查询参数map,需要排序的话传map中放order参数,值为:字段值 desc 这种
|
||||
* @return List<T>
|
||||
*/
|
||||
@Override
|
||||
public List<T> findListPageByParam(Map<String, Object> params) {
|
||||
PageUtil.pageParamConvert(params, true);
|
||||
return baseDao.findListByParam(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* pagehelpter分页查询-不查询总条数,仅查询数据列表
|
||||
*
|
||||
* @param params 查询参数map,需要排序的话传map中放order参数,值为:字段值 desc 这种
|
||||
* @return List<T>
|
||||
*/
|
||||
@Override
|
||||
public List<T> findListPageByParam2(Map<String, Object> params) {
|
||||
try (Page<T> page = PageUtil.startPageNoCountByParam(params)) {
|
||||
baseDao.findListByParam(params);
|
||||
return page.getResult();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> findListByParam(String propertyName, Object propertyValue) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map .put(propertyName, propertyValue);
|
||||
List<T> t = findListByParam(map);
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long count(Map<String, Object> map) {
|
||||
return baseDao.count(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long save(T t) {
|
||||
return baseDao.insert(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long update(T t) {
|
||||
return baseDao.update(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long deleteByParam(Map<String, Object> map) {
|
||||
return baseDao.deleteByParam(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long deleteByParam(String propertyName, Object propertyValue) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map .put(propertyName, propertyValue);
|
||||
Long delete = deleteByParam(map);
|
||||
return delete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long delete(long id) {
|
||||
return baseDao.delete(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long deleteByIds(Long... ids) {
|
||||
return baseDao.deleteByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> findAll() {
|
||||
return baseDao.findAll();
|
||||
}
|
||||
/**
|
||||
* 列表
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageResult<T> findAll(Map<String, Object> params){
|
||||
PageUtil.pageParamConvert(params, true);
|
||||
List<T> list = baseDao.findListByParam(params);
|
||||
PageInfo<T> pageInfo = new PageInfo<T>(list);
|
||||
Long count = baseDao.count(params);
|
||||
Integer length = MapUtils.getInteger(params, "pageSize");
|
||||
int pages = (int) Math.ceil((double) count / (double) length);
|
||||
return PageResult.<T>builder().data(pageInfo.getList()).code(0).count(count).pages(pages).build();
|
||||
}
|
||||
|
||||
}
|
107
base-common/src/main/java/com/agri/common/utils/PageUtil.java
Normal file
107
base-common/src/main/java/com/agri/common/utils/PageUtil.java
Normal file
@ -0,0 +1,107 @@
|
||||
package com.agri.common.utils;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 分页参数处理工具
|
||||
* url 地址重写 ?start=1&length=10
|
||||
*/
|
||||
@Slf4j
|
||||
public class PageUtil {
|
||||
|
||||
/**
|
||||
* 分页参数,起始位置,从0开始
|
||||
*/
|
||||
public static final String PAGE = "pageNum";
|
||||
/**
|
||||
* 分页参数,每页数据条数
|
||||
*/
|
||||
public static final String LIMIT = "pageSize";
|
||||
|
||||
/**
|
||||
* 转换并校验分页参数<br>
|
||||
* mybatis中limit #{start, JdbcType=INTEGER}, #{length,
|
||||
* JdbcType=INTEGER}里的类型转换貌似失效<br>
|
||||
* 我们这里先把他转成Integer的类型
|
||||
*
|
||||
* @param params
|
||||
* @param required 分页参数是否是必填
|
||||
*/
|
||||
public static void pageParamConvert(Map<String, Object> params, boolean required) {
|
||||
if (required) { // 分页参数必填时,校验参数
|
||||
if (params == null || !params.containsKey(PAGE) || !params.containsKey(LIMIT)) {
|
||||
throw new IllegalArgumentException("请检查分页参数," + PAGE + "," + LIMIT);
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(params)) {
|
||||
if (params.containsKey(PAGE)) {
|
||||
Integer start = MapUtils.getInteger(params, PAGE);
|
||||
Integer length = MapUtils.getInteger(params, LIMIT);
|
||||
if (start > 0) {
|
||||
params.put(PAGE, (start - 1) * length);
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey(LIMIT)) {
|
||||
Integer length = MapUtils.getInteger(params, LIMIT);
|
||||
if (length < 0) {
|
||||
length = 0;
|
||||
}
|
||||
params.put(LIMIT, length);
|
||||
}
|
||||
|
||||
adminOrderConvert(params);
|
||||
}
|
||||
}
|
||||
|
||||
public static void adminOrderConvert(Map<String, Object> params) {
|
||||
if (params != null && !params.containsKey("order")) {
|
||||
if (params.containsKey("orderByColumn") && params.containsKey("isAsc")) {
|
||||
String orderByColumn = MapUtils.getString(params, "orderByColumn");
|
||||
String isAsc = MapUtils.getString(params, "isAsc");
|
||||
if (StrUtil.isNotBlank(orderByColumn) && StrUtil.isNotBlank(isAsc)) {
|
||||
params.put("order", StrUtil.toUnderlineCase(orderByColumn) + " " + isAsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> Page<T> startPageWithCountByParam(Map<String, Object> params) {
|
||||
return getTs(params, true);
|
||||
}
|
||||
|
||||
public static <T> Page<T> startPageNoCountByParam(Map<String, Object> params) {
|
||||
return getTs(params, false);
|
||||
}
|
||||
|
||||
private static <T> Page<T> getTs(Map<String, Object> params, boolean isCount) {
|
||||
adminOrderConvert(params);
|
||||
Integer pageSize = MapUtils.getInteger(params, "pageSize");
|
||||
Integer pageNum = MapUtils.getInteger(params, "pageNum");
|
||||
Page<T> page = PageHelper.startPage(pageNum, pageSize, isCount, true, false);
|
||||
String orderBy = MapUtils.getString(params, "order");
|
||||
if (!StringUtils.isEmpty(orderBy)) {
|
||||
String orderByTablePrefix = MapUtil.getStr(params, "orderByTablePrefix");
|
||||
if (!StrUtil.isNotBlank(orderByTablePrefix)) {
|
||||
page.setOrderBy(orderBy);
|
||||
} else {
|
||||
orderBy = orderByTablePrefix.concat(".").concat(orderBy);
|
||||
page.setOrderBy(orderBy);
|
||||
}
|
||||
}
|
||||
// 清空参数中的pageSize, pageNum, order参数,pageHelper会动态代理补全这些参数
|
||||
params.put("pageSize", null);
|
||||
params.put("pageNum", null);
|
||||
params.put("order", null);
|
||||
return page;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.agri.common.utils.web;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 分页实体类
|
||||
* total 总数
|
||||
* code 是否成功
|
||||
* data 当前页结果集
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PageResult<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -275582248840137389L;
|
||||
|
||||
/**
|
||||
* 总条数
|
||||
*/
|
||||
private Long count;
|
||||
|
||||
/**
|
||||
* 总的页数
|
||||
*/
|
||||
private Integer pages;
|
||||
|
||||
/**
|
||||
* code
|
||||
*/
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
*/
|
||||
private List<T> data;
|
||||
|
||||
public static <T> PageResult<T> buildPageResult(List<T> list, Long count, Integer pageSize) {
|
||||
Integer pages = (int) Math.ceil((double) count / (double) pageSize);
|
||||
return PageResult.<T>builder().data(list)
|
||||
.code(0)
|
||||
.count(count)
|
||||
.pages(pages)
|
||||
.build();
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.agri.common.utils.web;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Paramap extends HashMap<String, Object> implements Map<String, Object> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Paramap() {
|
||||
}
|
||||
|
||||
public static Paramap create() {
|
||||
return new Paramap();
|
||||
}
|
||||
|
||||
public Paramap put(String name, Object value) {
|
||||
super.put(name, value);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -3,14 +3,14 @@ package com.agri.generator.domain;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import com.agri.common.core.domain.BaseEntity;
|
||||
import com.agri.common.utils.StringUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* 代码生成业务字段表 gen_table_column
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class GenTableColumn extends BaseEntity
|
||||
{
|
||||
public class GenTableColumn extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
@ -59,7 +59,7 @@ public class GenTableColumn extends BaseEntity
|
||||
/** 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) */
|
||||
private String queryType;
|
||||
|
||||
/** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件) */
|
||||
/** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、upload上传控件、summernote富文本控件) */
|
||||
private String htmlType;
|
||||
|
||||
/** 字典类型 */
|
||||
@ -348,6 +348,54 @@ public class GenTableColumn extends BaseEntity
|
||||
return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户可见的注释
|
||||
*/
|
||||
private String visibleColumnComment;
|
||||
|
||||
public String getVisibleColumnComment() {
|
||||
return visibleColumnComment;
|
||||
}
|
||||
|
||||
public void setVisibleColumnComment(String visibleColumnComment) {
|
||||
this.visibleColumnComment = visibleColumnComment;
|
||||
}
|
||||
/**
|
||||
* 字段字典json
|
||||
*/
|
||||
private String columnDictJson;
|
||||
|
||||
public String getColumnDictJson() {
|
||||
return columnDictJson;
|
||||
}
|
||||
|
||||
public void setColumnDictJson(String columnDictJson) {
|
||||
this.columnDictJson = columnDictJson;
|
||||
}
|
||||
|
||||
private JSONObject columnCommentDict;
|
||||
|
||||
public JSONObject getColumnCommentDict() {
|
||||
return columnCommentDict;
|
||||
}
|
||||
|
||||
public void setColumnCommentDict(JSONObject columnCommentDict) {
|
||||
this.columnCommentDict = columnCommentDict;
|
||||
}
|
||||
|
||||
/**
|
||||
* 首字母大写,例:UserName
|
||||
*/
|
||||
private String upJavaField;
|
||||
|
||||
public String getUpJavaField() {
|
||||
return upJavaField;
|
||||
}
|
||||
|
||||
public void setUpJavaField(String upJavaField) {
|
||||
this.upJavaField = upJavaField;
|
||||
}
|
||||
|
||||
public String readConverterExp()
|
||||
{
|
||||
String remarks = StringUtils.substringBetween(this.columnComment, "(", ")");
|
||||
|
@ -3,6 +3,14 @@ package com.agri.generator.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agri.generator.config.GenConfig;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.agri.common.constant.GenConstants;
|
||||
@ -16,14 +24,16 @@ import com.agri.generator.domain.GenTableColumn;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class VelocityUtils
|
||||
{
|
||||
public class VelocityUtils {
|
||||
/** 项目空间路径 */
|
||||
private static final String PROJECT_PATH = "main/java";
|
||||
|
||||
/** mybatis空间路径 */
|
||||
private static final String MYBATIS_PATH = "main/resources/mapper";
|
||||
|
||||
/** html空间路径 */
|
||||
private static final String TEMPLATES_PATH = "main/resources/templates";
|
||||
|
||||
/** 默认上级菜单,系统工具 */
|
||||
private static final String DEFAULT_PARENT_MENU_ID = "3";
|
||||
|
||||
@ -32,33 +42,60 @@ public class VelocityUtils
|
||||
*
|
||||
* @return 模板列表
|
||||
*/
|
||||
public static VelocityContext prepareContext(GenTable genTable)
|
||||
{
|
||||
String moduleName = genTable.getModuleName();
|
||||
public static VelocityContext prepareContext(GenTable genTable) {
|
||||
String businessName = genTable.getBusinessName();
|
||||
String packageName = genTable.getPackageName();
|
||||
String entityPrefix = packageName + ".domain";
|
||||
String pagePrefix = genTable.getModuleName() + "/" + genTable.getBusinessName();
|
||||
String moduleName = genTable.getModuleName();
|
||||
String controllerPackageName = "com.agri.web.controller.business";
|
||||
String tplCategory = genTable.getTplCategory();
|
||||
String functionName = genTable.getFunctionName();
|
||||
|
||||
VelocityContext velocityContext = new VelocityContext();
|
||||
velocityContext.put("entityPrefix", entityPrefix);
|
||||
velocityContext.put("tplCategory", genTable.getTplCategory());
|
||||
velocityContext.put("tableName", genTable.getTableName());
|
||||
velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
|
||||
velocityContext.put("ClassName", genTable.getClassName());
|
||||
velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
|
||||
velocityContext.put("moduleName", genTable.getModuleName());
|
||||
velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName()));
|
||||
velocityContext.put("moduleName", moduleName);
|
||||
velocityContext.put("businessName", genTable.getBusinessName());
|
||||
velocityContext.put("basePackage", getPackagePrefix(packageName));
|
||||
velocityContext.put("packageName", packageName);
|
||||
velocityContext.put("pagePrefix", pagePrefix);
|
||||
velocityContext.put("controllerPackageName", controllerPackageName);
|
||||
velocityContext.put("author", genTable.getFunctionAuthor());
|
||||
velocityContext.put("datetime", DateUtils.getDate());
|
||||
velocityContext.put("pkColumn", genTable.getPkColumn());
|
||||
velocityContext.put("importList", getImportList(genTable));
|
||||
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
|
||||
velocityContext.put("columns", genTable.getColumns());
|
||||
List<GenTableColumn> columns = genTable.getColumns();
|
||||
velocityContext.put("columns", columns);
|
||||
boolean hasDate = false;
|
||||
boolean hasBigDecimal = false;
|
||||
for (GenTableColumn column : columns) {
|
||||
|
||||
if (column.getJavaType().equals("Date")) {
|
||||
hasDate = true;
|
||||
}
|
||||
if (column.getJavaType().equals("BigDecimal")) {
|
||||
hasBigDecimal = true;
|
||||
}
|
||||
column.setUpJavaField(StrUtil.upperFirst(column.getJavaField()));
|
||||
String columnComment = column.getColumnComment();
|
||||
column.setVisibleColumnComment(getVisibleColumnComment(columnComment));
|
||||
Map<String, String> columnCommentDict = getColumnDict(columnComment);
|
||||
if (!columnCommentDict.isEmpty()) {
|
||||
column.setColumnDictJson(JSON.toJSONString(columnCommentDict));
|
||||
}
|
||||
if (StrUtil.isNotBlank(column.getColumnDictJson())) {
|
||||
column.setColumnCommentDict(JSON.parseObject(column.getColumnDictJson()));
|
||||
}
|
||||
}
|
||||
velocityContext.put("hasDate", hasDate);
|
||||
velocityContext.put("hasBigDecimal", hasBigDecimal);
|
||||
velocityContext.put("table", genTable);
|
||||
velocityContext.put("dicts", getDicts(genTable));
|
||||
setMenuVelocityContext(velocityContext, genTable);
|
||||
if (GenConstants.TPL_TREE.equals(tplCategory))
|
||||
{
|
||||
@ -71,6 +108,30 @@ public class VelocityUtils
|
||||
return velocityContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取注释中的字典,如:1:男,2-女 -》 {1:男,2:女}
|
||||
* @param columnComment 列注释
|
||||
* @return /
|
||||
*/
|
||||
private static Map<String, String> getColumnDict(String columnComment) {
|
||||
List<String> nameList = ReUtil.findAll("(?<=\\d\\-?)([^\\d]+)(?!\\d)?", columnComment, 0)
|
||||
.stream().map(item -> {
|
||||
item = ReUtil.replaceAll(item, "[\\s::=\\-,,\\(\\)()|\\d]", "");
|
||||
return item;
|
||||
}).collect(Collectors.toList());
|
||||
List<String> numberList = ReUtil.findAll("(\\d)", columnComment, 0);
|
||||
return CollUtil.zip(numberList, nameList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户友好的列注释
|
||||
* @param columnComment 列注释
|
||||
* @return /
|
||||
*/
|
||||
private static String getVisibleColumnComment(String columnComment) {
|
||||
return ReUtil.replaceAll(columnComment, "([\\s::=\\-,,\\(\\)()|\\d].*)", "");
|
||||
}
|
||||
|
||||
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable)
|
||||
{
|
||||
String options = genTable.getOptions();
|
||||
@ -122,7 +183,7 @@ public class VelocityUtils
|
||||
/**
|
||||
* 获取模板信息
|
||||
*
|
||||
* @return 模板列表f
|
||||
* @return 模板列表
|
||||
*/
|
||||
public static List<String> getTemplateList(String tplCategory)
|
||||
{
|
||||
@ -132,22 +193,27 @@ public class VelocityUtils
|
||||
templates.add("vm/java/service.java.vm");
|
||||
templates.add("vm/java/serviceImpl.java.vm");
|
||||
templates.add("vm/java/controller.java.vm");
|
||||
templates.add("vm/java/vo.java.vm");
|
||||
templates.add("vm/java/dto.java.vm");
|
||||
templates.add("vm/java/exportdto.java.vm");
|
||||
templates.add("vm/xml/mapper.xml.vm");
|
||||
templates.add("vm/sql/sql.vm");
|
||||
templates.add("vm/js/api.js.vm");
|
||||
if (GenConstants.TPL_CRUD.equals(tplCategory))
|
||||
{
|
||||
templates.add("vm/vue/index.vue.vm");
|
||||
templates.add("vm/html/list.html.vm");
|
||||
}
|
||||
else if (GenConstants.TPL_TREE.equals(tplCategory))
|
||||
{
|
||||
templates.add("vm/vue/index-tree.vue.vm");
|
||||
templates.add("vm/html/tree.html.vm");
|
||||
templates.add("vm/html/list-tree.html.vm");
|
||||
}
|
||||
else if (GenConstants.TPL_SUB.equals(tplCategory))
|
||||
{
|
||||
templates.add("vm/vue/index.vue.vm");
|
||||
templates.add("vm/html/list.html.vm");
|
||||
templates.add("vm/java/sub-domain.java.vm");
|
||||
}
|
||||
templates.add("vm/html/add.html.vm");
|
||||
templates.add("vm/html/edit.html.vm");
|
||||
templates.add("vm/sql/sql.vm");
|
||||
return templates;
|
||||
}
|
||||
|
||||
@ -156,12 +222,37 @@ public class VelocityUtils
|
||||
*/
|
||||
public static String getFileName(String template, GenTable genTable)
|
||||
{
|
||||
template = template.substring(template.lastIndexOf("/") + 1);
|
||||
// 文件名称
|
||||
String fileName = "";
|
||||
// 包路径
|
||||
String packageName = genTable.getPackageName();
|
||||
// 模块名
|
||||
String moduleName = genTable.getModuleName();
|
||||
// boolean isSupplyBusiness = false;
|
||||
// if (genTable.getTableName().startsWith("t_supply") || genTable.getTableName().startsWith("t_purchase")) {
|
||||
// isSupplyBusiness = true;
|
||||
// }
|
||||
// if (isSupplyBusiness) {
|
||||
// packageName = "com.shidian.supply";
|
||||
// }
|
||||
// boolean isTeamBuy = false;
|
||||
// if (genTable.getTableName().startsWith("t_team")) {
|
||||
// isTeamBuy = true;
|
||||
// }
|
||||
// if (isTeamBuy) {
|
||||
// packageName = "com.shidian.teambuy";
|
||||
// }
|
||||
// // 是否是心选业务
|
||||
// boolean isXinxuan = false;
|
||||
// if (genTable.getTableName().startsWith("t_xinxuan")) {
|
||||
// isXinxuan = true;
|
||||
// }
|
||||
// if (isXinxuan) {
|
||||
// packageName = "com.shidian.xinxuan";
|
||||
// moduleName = "xinxuan";
|
||||
// }
|
||||
|
||||
// 大写类名
|
||||
String className = genTable.getClassName();
|
||||
// 业务名称
|
||||
@ -169,55 +260,101 @@ public class VelocityUtils
|
||||
|
||||
String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
|
||||
String mybatisPath = MYBATIS_PATH + "/" + moduleName;
|
||||
String vuePath = "vue";
|
||||
String htmlPath = TEMPLATES_PATH + "/" + moduleName + "/" + businessName;
|
||||
|
||||
if (template.contains("domain.java.vm"))
|
||||
if (template.equals("domain.java.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
|
||||
// if (isSupplyBusiness || isTeamBuy || isXinxuan) {
|
||||
// fileName = StringUtils.format("{}/domain/entity/{}.java", javaPath, className);
|
||||
// }
|
||||
}
|
||||
if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
|
||||
if (template.equals("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
|
||||
{
|
||||
fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
|
||||
// if (isSupplyBusiness || isTeamBuy || isXinxuan) {
|
||||
// fileName = StringUtils.format("{}/domain/entity/{}.java", javaPath, genTable.getSubTable().getClassName());
|
||||
// }
|
||||
}
|
||||
else if (template.contains("mapper.java.vm"))
|
||||
else if (template.equals("mapper.java.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
|
||||
}
|
||||
else if (template.contains("service.java.vm"))
|
||||
else if (template.equals("service.java.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className);
|
||||
}
|
||||
else if (template.contains("serviceImpl.java.vm"))
|
||||
else if (template.equals("serviceImpl.java.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
|
||||
}
|
||||
else if (template.contains("controller.java.vm"))
|
||||
else if (template.equals("controller.java.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
|
||||
String controllerJavaPath = PROJECT_PATH + "/" + "com/shidian/web/controller/business";
|
||||
// if (isSupplyBusiness) {
|
||||
// controllerJavaPath = PROJECT_PATH + "/" + "com/shidian/web/controller/business/supply";
|
||||
// }
|
||||
// if (isTeamBuy) {
|
||||
// controllerJavaPath = PROJECT_PATH + "/" + "com/shidian/web/controller/business/teambuy";
|
||||
// }
|
||||
// if (isXinxuan) {
|
||||
// controllerJavaPath = PROJECT_PATH + "/" + "com/shidian/web/controller/xinxuan";
|
||||
// }
|
||||
fileName = StringUtils.format("{}/{}Controller.java", controllerJavaPath, className);
|
||||
}
|
||||
else if (template.contains("mapper.xml.vm"))
|
||||
else if (template.equals("mapper.xml.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
|
||||
// if (isSupplyBusiness) {
|
||||
// fileName = StringUtils.format("{}/{}Mapper.xml", "supply", className);
|
||||
// } else if (isTeamBuy) {
|
||||
// fileName = StringUtils.format("{}/{}Mapper.xml", "teambuy", className);
|
||||
// } else if (isXinxuan) {
|
||||
// fileName = StringUtils.format("{}/{}Mapper.xml", "xinxuan", className);
|
||||
// }
|
||||
}
|
||||
else if (template.contains("sql.vm"))
|
||||
else if (template.equals("list.html.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/{}.html", htmlPath, businessName);
|
||||
}
|
||||
else if (template.equals("list-tree.html.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/{}.html", htmlPath, businessName);
|
||||
}
|
||||
else if (template.equals("tree.html.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/tree.html", htmlPath);
|
||||
}
|
||||
else if (template.equals("add.html.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/add.html", htmlPath);
|
||||
}
|
||||
else if (template.equals("edit.html.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/edit.html", htmlPath);
|
||||
}
|
||||
else if (template.equals("sql.vm"))
|
||||
{
|
||||
fileName = businessName + "Menu.sql";
|
||||
}
|
||||
else if (template.contains("api.js.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
|
||||
}
|
||||
else if (template.contains("index.vue.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||
}
|
||||
else if (template.contains("index-tree.vue.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目文件路径
|
||||
*
|
||||
* @return 路径
|
||||
*/
|
||||
public static String getProjectPath()
|
||||
{
|
||||
String packageName = GenConfig.getPackageName();
|
||||
StringBuffer projectPath = new StringBuffer();
|
||||
projectPath.append("main/java/");
|
||||
projectPath.append(packageName.replace(".", "/"));
|
||||
projectPath.append("/");
|
||||
return projectPath.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取包前缀
|
||||
*
|
||||
@ -233,7 +370,7 @@ public class VelocityUtils
|
||||
|
||||
/**
|
||||
* 根据列类型获取导入包
|
||||
*
|
||||
*
|
||||
* @param genTable 业务表对象
|
||||
* @return 返回需要导入的包列表
|
||||
*/
|
||||
@ -261,28 +398,6 @@ public class VelocityUtils
|
||||
return importList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据列类型获取字典组
|
||||
*
|
||||
* @param genTable 业务表对象
|
||||
* @return 返回字典组
|
||||
*/
|
||||
public static String getDicts(GenTable genTable)
|
||||
{
|
||||
List<GenTableColumn> columns = genTable.getColumns();
|
||||
List<String> dicts = new ArrayList<String>();
|
||||
for (GenTableColumn column : columns)
|
||||
{
|
||||
if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(
|
||||
column.getHtmlType(),
|
||||
new String[] { GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX }))
|
||||
{
|
||||
dicts.add("'" + column.getDictType() + "'");
|
||||
}
|
||||
}
|
||||
return StringUtils.join(dicts, ", ");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限前缀
|
||||
*
|
||||
@ -297,8 +412,6 @@ public class VelocityUtils
|
||||
|
||||
/**
|
||||
* 获取上级菜单ID字段
|
||||
*
|
||||
* @param paramsObj 生成其他选项
|
||||
* @return 上级菜单ID字段
|
||||
*/
|
||||
public static String getParentMenuId(JSONObject paramsObj)
|
||||
@ -313,8 +426,6 @@ public class VelocityUtils
|
||||
|
||||
/**
|
||||
* 获取树编码
|
||||
*
|
||||
* @param paramsObj 生成其他选项
|
||||
* @return 树编码
|
||||
*/
|
||||
public static String getTreecode(JSONObject paramsObj)
|
||||
@ -328,8 +439,6 @@ public class VelocityUtils
|
||||
|
||||
/**
|
||||
* 获取树父编码
|
||||
*
|
||||
* @param paramsObj 生成其他选项
|
||||
* @return 树父编码
|
||||
*/
|
||||
public static String getTreeParentCode(JSONObject paramsObj)
|
||||
@ -343,8 +452,6 @@ public class VelocityUtils
|
||||
|
||||
/**
|
||||
* 获取树名称
|
||||
*
|
||||
* @param paramsObj 生成其他选项
|
||||
* @return 树名称
|
||||
*/
|
||||
public static String getTreeName(JSONObject paramsObj)
|
||||
|
@ -1,10 +1,10 @@
|
||||
# 代码生成
|
||||
gen:
|
||||
# 作者
|
||||
author: nealtsiao
|
||||
author: wqy
|
||||
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
|
||||
packageName: com.agri.agriculture
|
||||
packageName: com.agri.business
|
||||
# 自动去除表前缀,默认是false
|
||||
autoRemovePre: true
|
||||
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
|
||||
tablePrefix: agriculture_
|
||||
tablePrefix: t_
|
@ -1,105 +1,44 @@
|
||||
package ${packageName}.domain;
|
||||
package ${entityPrefix};
|
||||
|
||||
#foreach ($import in $importList)
|
||||
import ${import};
|
||||
#end
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.agri.common.annotation.Excel;
|
||||
#if($table.crud || $table.sub)
|
||||
import com.agri.common.core.domain.BaseEntity;
|
||||
#elseif($table.tree)
|
||||
import com.agri.common.core.domain.TreeEntity;
|
||||
#end
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
#if(${hasBigDecimal})
|
||||
import java.math.BigDecimal;
|
||||
#end
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ${functionName}对象 ${tableName}
|
||||
*
|
||||
* ${functionName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
#if($table.crud || $table.sub)
|
||||
#set($Entity="BaseEntity")
|
||||
#elseif($table.tree)
|
||||
#set($Entity="TreeEntity")
|
||||
#end
|
||||
public class ${ClassName} extends ${Entity}
|
||||
{
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName(value = "${tableName}")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value="${functionName}",description="${functionName}")
|
||||
public class ${ClassName} implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
#foreach ($column in $columns)
|
||||
|
||||
#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($parentheseIndex != -1)
|
||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||
#elseif($column.javaType == 'Date')
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
#else
|
||||
@Excel(name = "${comment}")
|
||||
#end
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
/** $column.columnComment */
|
||||
#if($column.columnName == $pk.columnName)
|
||||
#end
|
||||
@ApiModelProperty(value = "$column.columnComment")
|
||||
private $column.javaType ${column.javaField};
|
||||
#end
|
||||
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
/** $table.subTable.functionName信息 */
|
||||
private List<${subClassName}> ${subclassName}List;
|
||||
|
||||
#end
|
||||
#foreach ($column in $columns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
public void set${AttrName}($column.javaType $column.javaField)
|
||||
{
|
||||
this.$column.javaField = $column.javaField;
|
||||
}
|
||||
|
||||
public $column.javaType get${AttrName}()
|
||||
{
|
||||
return $column.javaField;
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
#if($table.sub)
|
||||
public List<${subClassName}> get${subClassName}List()
|
||||
{
|
||||
return ${subclassName}List;
|
||||
}
|
||||
|
||||
public void set${subClassName}List(List<${subClassName}> ${subclassName}List)
|
||||
{
|
||||
this.${subclassName}List = ${subclassName}List;
|
||||
}
|
||||
|
||||
#end
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
.append("${column.javaField}", get${AttrName}())
|
||||
#end
|
||||
#if($table.sub)
|
||||
.append("${subclassName}List", get${subClassName}List())
|
||||
#end
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
46
base-generator/src/main/resources/vm/java/dto.java.vm
Normal file
46
base-generator/src/main/resources/vm/java/dto.java.vm
Normal file
@ -0,0 +1,46 @@
|
||||
package ${packageName}.domain.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
#if(${hasBigDecimal})
|
||||
import java.math.BigDecimal;
|
||||
#end
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ${functionName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName(value = "${tableName}" )
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "${functionName}" , description = "${functionName}" )
|
||||
public class ${ClassName}Dto implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField != "createBy" && $column.javaField != "createTime" && $column.javaField !=
|
||||
"updateBy" && $column.javaField != "updateTime")
|
||||
/** $column.columnComment */
|
||||
#if($column.columnName == $pk.columnName)
|
||||
#end
|
||||
@ApiModelProperty(value = "$column.columnComment")
|
||||
private $column.javaType ${column.javaField};
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
57
base-generator/src/main/resources/vm/java/exportdto.java.vm
Normal file
57
base-generator/src/main/resources/vm/java/exportdto.java.vm
Normal file
@ -0,0 +1,57 @@
|
||||
package ${packageName}.domain.excel.expt;
|
||||
|
||||
import com.agri.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
#if(${hasBigDecimal})
|
||||
import java.math.BigDecimal;
|
||||
#end
|
||||
#if(${hasDate})
|
||||
import java.util.Date;
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}导出实体
|
||||
*/
|
||||
@Data
|
||||
public class ${ClassName}ExportDto {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.list)
|
||||
#set($visibleComment=$column.visibleColumnComment)
|
||||
#set($comment=$column.columnComment)
|
||||
#set($commentDict=$column.columnCommentDict)
|
||||
|
||||
#if($column.columnName == $pk.columnName)
|
||||
|
||||
#elseif($column.htmlType == 'datetime')
|
||||
/** $comment */
|
||||
@Excel(name = "${visibleComment}", dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private $column.javaType ${column.javaField};
|
||||
|
||||
#elseif($commentDict)
|
||||
/** $comment */
|
||||
@Excel(name = "${visibleComment}", readConverterExp = "#foreach($mapEntry in $commentDict.entrySet())${mapEntry.key}=${mapEntry.value}#if($foreach.hasNext),#end#end ")
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#else
|
||||
/** $comment */
|
||||
@Excel(name = "${visibleComment}")
|
||||
private $column.javaType $column.javaField;
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
||||
public static List<${ClassName}ExportDto> build(List<${ClassName}> list) {
|
||||
List<${ClassName}ExportDto> resultList = new ArrayList<>();
|
||||
for (${ClassName} ${className} : list) {
|
||||
${ClassName}ExportDto result = new ${ClassName}ExportDto();
|
||||
#foreach($column in $columns)
|
||||
#if($column.list)
|
||||
result.set${column.upJavaField}(${className}.get${column.upJavaField}());
|
||||
#end
|
||||
#end
|
||||
resultList.add(result);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
}
|
@ -1,91 +1,20 @@
|
||||
package ${packageName}.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import ${packageName}.domain.${ClassName};
|
||||
import com.agri.common.dao.BaseDao;
|
||||
import ${entityPrefix}.${ClassName};
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
#if($table.sub)
|
||||
import ${packageName}.domain.${subClassName};
|
||||
import ${entityPrefix}.${subClassName};
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}Mapper接口
|
||||
*
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
* @since ${datetime}
|
||||
*/
|
||||
public interface ${ClassName}Mapper
|
||||
{
|
||||
/**
|
||||
* 查询${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return ${functionName}
|
||||
*/
|
||||
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
@Mapper
|
||||
public interface ${ClassName}Mapper extends BaseDao<${ClassName}> {
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return ${functionName}集合
|
||||
*/
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
#if($table.sub)
|
||||
|
||||
/**
|
||||
* 批量删除${subTable.functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
|
||||
/**
|
||||
* 批量新增${subTable.functionName}
|
||||
*
|
||||
* @param ${subclassName}List ${subTable.functionName}列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
|
||||
|
||||
|
||||
/**
|
||||
* 通过${functionName}主键删除${subTable.functionName}信息
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
#end
|
||||
}
|
||||
|
@ -1,61 +1,25 @@
|
||||
package ${packageName}.service;
|
||||
|
||||
import java.util.List;
|
||||
import ${packageName}.domain.${ClassName};
|
||||
import ${entityPrefix}.${ClassName};
|
||||
#if($table.tree)
|
||||
import com.agri.common.core.domain.Ztree;
|
||||
#end
|
||||
import com.agri.common.service.BaseService;
|
||||
|
||||
/**
|
||||
* ${functionName}Service接口
|
||||
*
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
* @since ${datetime}
|
||||
*/
|
||||
public interface I${ClassName}Service
|
||||
{
|
||||
/**
|
||||
* 查询${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return ${functionName}
|
||||
*/
|
||||
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
public interface I${ClassName}Service extends BaseService<${ClassName}> {
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return ${functionName}集合
|
||||
* 导出${functionName}数据列表
|
||||
* @param list 数据列表
|
||||
* @param sourceType 1-总后台 2-集货中心 3-基地供应商后台
|
||||
*/
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||
void export${ClassName}Excel(List<${ClassName}> list, Integer sourceType);
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
|
||||
/**
|
||||
* 删除${functionName}信息
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
}
|
||||
|
@ -1,195 +1,59 @@
|
||||
package ${packageName}.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.agri.common.annotation.TenantScope;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
|
||||
import com.agri.common.utils.DateUtils;
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'createBy' || $column.javaField == 'updateBy')
|
||||
import com.agri.common.utils.SecurityUtils;
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
#if($table.tree)
|
||||
import java.util.ArrayList;
|
||||
import com.agri.common.core.domain.Ztree;
|
||||
#end
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
#if($table.sub)
|
||||
import java.util.ArrayList;
|
||||
import com.agri.common.utils.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ${packageName}.domain.${subClassName};
|
||||
#end
|
||||
#if($table.sub)
|
||||
import java.util.ArrayList;
|
||||
import com.agri.common.utils.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ${entityPrefix}.${subClassName};
|
||||
#end
|
||||
import ${packageName}.mapper.${ClassName}Mapper;
|
||||
import ${packageName}.domain.${ClassName};
|
||||
import ${entityPrefix}.${ClassName};
|
||||
import ${packageName}.service.I${ClassName}Service;
|
||||
import com.agri.common.service.impl.BaseServiceImpl;
|
||||
import com.agri.common.enums.ExportEnum;
|
||||
|
||||
/**
|
||||
* ${functionName}Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
* @since ${datetime}
|
||||
*/
|
||||
@Service
|
||||
public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
||||
{
|
||||
public class ${ClassName}ServiceImpl extends BaseServiceImpl<${ClassName}> implements I${ClassName}Service {
|
||||
|
||||
@Autowired
|
||||
private ${ClassName}Mapper ${className}Mapper;
|
||||
|
||||
/**
|
||||
* 查询${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return ${functionName}
|
||||
*/
|
||||
@Override
|
||||
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
|
||||
{
|
||||
return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
|
||||
}
|
||||
// @Autowired
|
||||
// private IExportService exportService;
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return ${functionName}
|
||||
* 导出${functionName}数据列表
|
||||
* @param list 数据列表
|
||||
* @param sourceType 1-总后台 2-集货中心 3-基地供应商后台
|
||||
*/
|
||||
@Override
|
||||
@TenantScope
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
|
||||
{
|
||||
return ${className}Mapper.select${ClassName}List(${className});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
#if($table.sub)
|
||||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int insert${ClassName}(${ClassName} ${className})
|
||||
{
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'createBy')
|
||||
${className}.setCreateBy(SecurityUtils.getUserId().toString());
|
||||
#end
|
||||
#if($column.javaField == 'createTime')
|
||||
${className}.setCreateTime(DateUtils.getNowDate());
|
||||
#end
|
||||
#if($column.javaField == 'tenantId')
|
||||
${className}.setTenantId(SecurityUtils.getTenantId());
|
||||
#end
|
||||
#if($column.javaField == 'baseId')
|
||||
${className}.setBaseId(SecurityUtils.getBaseId());
|
||||
#end
|
||||
#if($column.javaField == 'deptId')
|
||||
${className}.setDeptId(SecurityUtils.getDeptId());
|
||||
#end
|
||||
#if($column.javaField == 'userId')
|
||||
${className}.setUserId(SecurityUtils.getUserId());
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
int rows = ${className}Mapper.insert${ClassName}(${className});
|
||||
insert${subClassName}(${className});
|
||||
return rows;
|
||||
#else
|
||||
return ${className}Mapper.insert${ClassName}(${className});
|
||||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*
|
||||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
#if($table.sub)
|
||||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int update${ClassName}(${ClassName} ${className})
|
||||
{
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'updateBy')
|
||||
${className}.setUpdateBy(SecurityUtils.getUserId().toString());
|
||||
#end
|
||||
#if($column.javaField == 'updateTime')
|
||||
${className}.setUpdateTime(DateUtils.getNowDate());
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
|
||||
insert${subClassName}(${className});
|
||||
#end
|
||||
return ${className}Mapper.update${ClassName}(${className});
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键
|
||||
* @return 结果
|
||||
*/
|
||||
#if($table.sub)
|
||||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||
{
|
||||
#if($table.sub)
|
||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
|
||||
#end
|
||||
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${functionName}信息
|
||||
*
|
||||
* @param ${pkColumn.javaField} ${functionName}主键
|
||||
* @return 结果
|
||||
*/
|
||||
#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}信息
|
||||
*
|
||||
* @param ${className} ${functionName}对象
|
||||
*/
|
||||
public void insert${subClassName}(${ClassName} ${className})
|
||||
{
|
||||
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
|
||||
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
|
||||
if (StringUtils.isNotNull(${subclassName}List))
|
||||
{
|
||||
List<${subClassName}> list = new ArrayList<${subClassName}>();
|
||||
for (${subClassName} ${subclassName} : ${subclassName}List)
|
||||
{
|
||||
${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
|
||||
list.add(${subclassName});
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
${className}Mapper.batch${subClassName}(list);
|
||||
}
|
||||
public void export${ClassName}Excel(List<${ClassName}> list, Integer sourceType) {
|
||||
/*if (list == null || list.size() == 0) {
|
||||
throw new BusinessException("没有要导出的记录");
|
||||
}
|
||||
List<${ClassName}ExportDto> exportList = ${ClassName}ExportDto.build(list);
|
||||
ExcelUtil<${ClassName}ExportDto> util = new ExcelUtil<>(${ClassName}ExportDto.class);
|
||||
String sheetName = ExportEnum.APP_USER_EXPORT.getDesc();
|
||||
int code = ExportEnum.APP_USER_EXPORT.getCode()
|
||||
Workbook workHook = util.getWorkHook(exportList, sheetName);
|
||||
exportService.exportRecord(workHook, sheetName, code, sourceType);*/
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package ${packageName}.domain;
|
||||
package ${entityPrefix};
|
||||
|
||||
#foreach ($import in $subImportList)
|
||||
import ${import};
|
||||
#end
|
||||
#foreach ($import in $subImportList)
|
||||
import ${import};
|
||||
#end
|
||||
import com.agri.common.annotation.Excel;
|
||||
|
||||
/**
|
||||
* ${subTable.functionName}对象 ${subTableName}
|
||||
*
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@ -15,59 +15,59 @@ public class ${subClassName} extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $subTable.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($parentheseIndex != -1)
|
||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||
#elseif($column.javaType == 'Date')
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
#else
|
||||
@Excel(name = "${comment}")
|
||||
#end
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
#foreach ($column in $subTable.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($parentheseIndex != -1)
|
||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||
#elseif($column.javaType == 'Date')
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
#else
|
||||
@Excel(name = "${comment}")
|
||||
#end
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#end
|
||||
#end
|
||||
#foreach ($column in $subTable.columns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
public void set${AttrName}($column.javaType $column.javaField)
|
||||
{
|
||||
this.$column.javaField = $column.javaField;
|
||||
}
|
||||
#end
|
||||
#end
|
||||
#foreach ($column in $subTable.columns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
public void set${AttrName}($column.javaType $column.javaField)
|
||||
{
|
||||
this.$column.javaField = $column.javaField;
|
||||
}
|
||||
|
||||
public $column.javaType get${AttrName}()
|
||||
{
|
||||
return $column.javaField;
|
||||
}
|
||||
#end
|
||||
#end
|
||||
public $column.javaType get${AttrName}()
|
||||
{
|
||||
return $column.javaField;
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
#foreach ($column in $subTable.columns)
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
.append("${column.javaField}", get${AttrName}())
|
||||
#end
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
#foreach ($column in $subTable.columns)
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
.append("${column.javaField}", get${AttrName}())
|
||||
#end
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
46
base-generator/src/main/resources/vm/java/vo.java.vm
Normal file
46
base-generator/src/main/resources/vm/java/vo.java.vm
Normal file
@ -0,0 +1,46 @@
|
||||
package ${packageName}.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
#if(${hasBigDecimal})
|
||||
import java.math.BigDecimal;
|
||||
#end
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* ${functionName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName(value = "${tableName}")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "${functionName}", description = "${functionName}")
|
||||
public class ${ClassName}Vo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField != "createBy" && $column.javaField != "createTime" && $column.javaField !=
|
||||
"updateBy" && $column.javaField != "updateTime")
|
||||
/** $column.columnComment */
|
||||
#if($column.columnName == $pk.columnName)
|
||||
#end
|
||||
@ApiModelProperty(value = "$column.columnComment")
|
||||
private $column.javaType ${column.javaField};
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
@ -1,137 +1,230 @@
|
||||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<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 type="${entityPrefix}.${ClassName}" id="${ClassName}Result">
|
||||
#foreach ($column in $columns)
|
||||
<result property="${column.javaField}" column="${column.columnName}"/>
|
||||
#end
|
||||
#if($table.tree)
|
||||
<result property="parentName" column="parent_name" />
|
||||
#end
|
||||
</resultMap>
|
||||
#if($table.sub)
|
||||
<resultMap id="${ClassName}${subClassName}Result" type="${entityPrefix}.${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
|
||||
<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 id="base_column">
|
||||
<trim suffixOverrides=",">
|
||||
#set($count_basecolumn = 1)
|
||||
#foreach($column in $columns)
|
||||
#if($count_basecolumn == 1)
|
||||
${column.columnName}
|
||||
#else
|
||||
,${column.columnName}
|
||||
#end
|
||||
#set( $count_basecolumn = $count_basecolumn + 1 )
|
||||
#end
|
||||
</trim>
|
||||
</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
|
||||
<if test="params.tenantScope != ''"> ${params.tenantScope}</if>
|
||||
and del_flag = 0
|
||||
<sql id="base_value">
|
||||
<trim suffixOverrides=",">
|
||||
#set($count_basevalue = 1)
|
||||
#foreach($column in $columns)
|
||||
#if($count_basevalue == 1)
|
||||
#{${column.javaField}}
|
||||
#else
|
||||
,#{${column.javaField}}
|
||||
#end
|
||||
#set( $count_basevalue = $count_basevalue + 1 )
|
||||
#end
|
||||
</trim>
|
||||
</sql>
|
||||
|
||||
<sql id="where_column">
|
||||
#set($count_where_string_column = 1)
|
||||
#set($count_where_date_column = 1)
|
||||
#foreach($column in $columns)
|
||||
<if test="${column.javaField} != null and ${column.javaField} != ''">
|
||||
AND ${column.columnName} = #{${column.javaField}}
|
||||
</if>
|
||||
#if ($column.javaType == 'String' && $count_where_string_column == 1)
|
||||
<if test="${column.javaField}Like != null and ${column.javaField}Like != ''">
|
||||
AND ${column.columnName} like CONCAT('%', #{${column.javaField}Like}, '%')
|
||||
</if>
|
||||
#set($count_where_string_column = $count_where_string_column + 1)
|
||||
#end
|
||||
#if ($column.javaType == 'Date' && $count_where_date_column == 1)
|
||||
<if test="${column.javaField}s != null and ${column.javaField}s != ''">
|
||||
AND ${column.columnName} <![CDATA[>=]]> #{${column.javaField}s}
|
||||
</if>
|
||||
<if test="${column.javaField}e != null and ${column.javaField}e != ''">
|
||||
AND ${column.columnName} <![CDATA[<=]]> #{${column.javaField}e}
|
||||
</if>
|
||||
<if test="idInList != null">
|
||||
AND id in
|
||||
<if test="idInList.size() > 0">
|
||||
<foreach collection="idInList" item="idInListItem" index="index" open="(" separator="," close=")">
|
||||
#{idInListItem}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="idInList.size() == 0">
|
||||
(-1)
|
||||
</if>
|
||||
</if>
|
||||
#set($count_where_date_column = $count_where_date_column + 1)
|
||||
#end
|
||||
#end
|
||||
</sql>
|
||||
|
||||
<sql id="set_column">
|
||||
#foreach($column in $columns)
|
||||
<if test="${column.javaField} != null">
|
||||
$column.columnName = #{${column.javaField}},
|
||||
</if>
|
||||
#end
|
||||
</sql>
|
||||
|
||||
<!-- 查找单条 -->
|
||||
<select id="find" resultMap="${ClassName}Result">
|
||||
select
|
||||
<include refid="base_column"/>
|
||||
from ${tableName}
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 插入 -->
|
||||
<insert id="insert" parameterType="${entityPrefix}.${ClassName}">
|
||||
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID() AS id
|
||||
</selectKey>
|
||||
INSERT into ${tableName}
|
||||
(<include refid="base_column"/>)
|
||||
VALUES
|
||||
(<include refid="base_value"/>)
|
||||
</insert>
|
||||
|
||||
<!-- 更新 -->
|
||||
<update id="update" parameterType="${entityPrefix}.${ClassName}">
|
||||
update ${tableName}
|
||||
<set>
|
||||
<include refid="set_column"/>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 查询所有 -->
|
||||
<select id="findAll" resultMap="${ClassName}Result">
|
||||
SELECT
|
||||
<include refid="base_column"/>
|
||||
FROM ${tableName}
|
||||
</select>
|
||||
|
||||
<!-- 通过参数查找单条 -->
|
||||
<select id="findByParam" resultMap="${ClassName}Result">
|
||||
SELECT
|
||||
<include refid="base_column"/>
|
||||
FROM ${tableName}
|
||||
<where>
|
||||
<include refid="where_column"/>
|
||||
</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}} and del_flag=0
|
||||
#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 id="findListByParam" resultMap="${ClassName}Result">
|
||||
SELECT
|
||||
<include refid="base_column"/>
|
||||
FROM ${tableName}
|
||||
<where>
|
||||
<include refid="where_column"/>
|
||||
</where>
|
||||
<if test="order != null and order != ''">
|
||||
order by ${order}
|
||||
</if>
|
||||
<if test="offset != null and offset >= 0 and limit != null and limit > 0">
|
||||
limit #{offset},#{limit}
|
||||
</if>
|
||||
</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">
|
||||
DELETE FROM ${tableName}
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="delete${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}">
|
||||
update ${tableName} set del_flag = 2 where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
</update>
|
||||
<!-- 统计记录数 -->
|
||||
<select id="count" resultType="long">
|
||||
SELECT COUNT(id) FROM ${tableName}
|
||||
<where>
|
||||
<include refid="where_column"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="delete${ClassName}By${pkColumn.capJavaField}s" parameterType="String">
|
||||
update ${tableName} set del_flag = 2 where ${pkColumn.columnName} in
|
||||
<foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
|
||||
#{${pkColumn.javaField}}
|
||||
</foreach>
|
||||
</update>
|
||||
#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}}
|
||||
<!-- 通过参数删除 -->
|
||||
<delete id="deleteByParam">
|
||||
DELETE FROM ${tableName}
|
||||
<where>
|
||||
<include refid="where_column"/>
|
||||
</where>
|
||||
</delete>
|
||||
|
||||
<!-- 通过id数组删除多条记录 -->
|
||||
<delete id="deleteByIds">
|
||||
DELETE FROM ${tableName}
|
||||
WHERE id IN
|
||||
<foreach item="id" index="index" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}">
|
||||
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
|
||||
</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>
|
||||
|
||||
<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>
|
||||
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}">
|
||||
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
|
||||
</delete>
|
||||
|
||||
<insert id="batch${subClassName}">
|
||||
insert into ${subTableName} (
|
||||
#set($count2 = 1)
|
||||
#foreach($column in $columns)
|
||||
#if($count2 == 1)
|
||||
${column.columnName}
|
||||
#else
|
||||
,${column.columnName}
|
||||
#end
|
||||
#set( $count2 = $count2 + 1 )
|
||||
#end
|
||||
)
|
||||
values (
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
#set($count3 = 1)
|
||||
#foreach($column in $columns)
|
||||
#if($count3 == 1)
|
||||
#{item.$column.javaField}
|
||||
#else
|
||||
,#{item.$column.javaField}
|
||||
#end
|
||||
#set( $count3 = $count3 + 1 )
|
||||
#end
|
||||
</foreach>
|
||||
)
|
||||
</insert>
|
||||
#end
|
||||
</mapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user