mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 01:48:47 +08:00
Pre Merge pull request !50 from Yjoioooo/genUpdate
This commit is contained in:
commit
02f414e2fa
@ -0,0 +1,40 @@
|
|||||||
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询基类
|
||||||
|
* @author Yjoioooo
|
||||||
|
* @date 2021/6/6 19:55
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class QueryEntity implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 分页大小 */
|
||||||
|
@ApiModelProperty("分页大小")
|
||||||
|
private Integer pageSize;
|
||||||
|
/** 当前页数 */
|
||||||
|
@ApiModelProperty("当前页数")
|
||||||
|
private Integer pageNum;
|
||||||
|
/** 排序列 */
|
||||||
|
@ApiModelProperty("排序列")
|
||||||
|
private String orderByColumn;
|
||||||
|
/** 排序的方向desc或者asc */
|
||||||
|
@ApiModelProperty(value = "排序的方向", example = "asc,desc")
|
||||||
|
private String isAsc;
|
||||||
|
|
||||||
|
/** 请求参数 */
|
||||||
|
private Map<String, Object> params = new HashMap<>();
|
||||||
|
|
||||||
|
}
|
||||||
@ -4,14 +4,19 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import cn.hutool.core.lang.Validator;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import ${packageName}.domain.${ClassName};
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
#foreach ($import in $importList)
|
#foreach ($import in $importList)
|
||||||
import ${import};
|
import ${import};
|
||||||
#end
|
#end
|
||||||
#if($table.crud || $table.sub)
|
#if($table.crud || $table.sub)
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.QueryEntity;
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
import com.ruoyi.common.core.domain.TreeEntity;
|
import com.ruoyi.common.core.domain.TreeEntity;
|
||||||
#end
|
#end
|
||||||
@ -23,7 +28,7 @@ import com.ruoyi.common.core.domain.TreeEntity;
|
|||||||
* @date ${datetime}
|
* @date ${datetime}
|
||||||
*/
|
*/
|
||||||
#if($table.crud || $table.sub)
|
#if($table.crud || $table.sub)
|
||||||
#set($Entity="BaseEntity")
|
#set($Entity="QueryEntity")
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
#set($Entity="TreeEntity")
|
#set($Entity="TreeEntity")
|
||||||
#end
|
#end
|
||||||
@ -33,29 +38,69 @@ import com.ruoyi.common.core.domain.TreeEntity;
|
|||||||
@ApiModel("${functionName}分页查询对象")
|
@ApiModel("${functionName}分页查询对象")
|
||||||
public class ${ClassName}QueryBo extends ${Entity} {
|
public class ${ClassName}QueryBo extends ${Entity} {
|
||||||
|
|
||||||
/** 分页大小 */
|
|
||||||
@ApiModelProperty("分页大小")
|
|
||||||
private Integer pageSize;
|
|
||||||
/** 当前页数 */
|
|
||||||
@ApiModelProperty("当前页数")
|
|
||||||
private Integer pageNum;
|
|
||||||
/** 排序列 */
|
|
||||||
@ApiModelProperty("排序列")
|
|
||||||
private String orderByColumn;
|
|
||||||
/** 排序的方向desc或者asc */
|
|
||||||
@ApiModelProperty(value = "排序的方向", example = "asc,desc")
|
|
||||||
private String isAsc;
|
|
||||||
|
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if(!$table.isSuperColumn($column.javaField) && $column.query)
|
#if($column.query)
|
||||||
/** $column.columnComment */
|
#if($column.queryType != 'BETWEEN')
|
||||||
|
/** $column.columnComment */
|
||||||
#if($column.javaType == 'Date')
|
#if($column.javaType == 'Date')
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
#end
|
||||||
|
@ApiModelProperty("$column.columnComment")
|
||||||
|
private $column.javaType $column.javaField;
|
||||||
|
#else
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
/** $column.columnComment 开始 */
|
||||||
|
#if($column.javaType == 'Date')
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
#end
|
||||||
|
@ApiModelProperty("$column.columnComment 开始")
|
||||||
|
private $column.javaType begin$AttrName;
|
||||||
|
/** $column.columnComment 结束 */
|
||||||
|
#if($column.javaType == 'Date')
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
#end
|
||||||
|
@ApiModelProperty("$column.columnComment 结束")
|
||||||
|
private $column.javaType end$AttrName;
|
||||||
#end
|
#end
|
||||||
@ApiModelProperty("$column.columnComment")
|
|
||||||
private $column.javaType $column.javaField;
|
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取查询wrapper对象
|
||||||
|
* @return wrapper对象
|
||||||
|
*/
|
||||||
|
public LambdaQueryWrapper<${ClassName}> queryWrapper() {
|
||||||
|
LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery();
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.query)
|
||||||
|
#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)})
|
||||||
|
#set($mpMethod=$column.queryType.toLowerCase())
|
||||||
|
#if($queryType != 'BETWEEN')
|
||||||
|
#if($javaType == 'String')
|
||||||
|
#set($condition='StrUtil.isNotBlank('+$javaField+')')
|
||||||
|
#else
|
||||||
|
#set($condition=$javaField+' != null')
|
||||||
|
#end
|
||||||
|
lqw.$mpMethod($condition, ${ClassName}::get$AttrName, $javaField);
|
||||||
|
#else
|
||||||
|
#if($javaType == 'Date')
|
||||||
|
lqw.apply(Validator.isNotEmpty(begin$AttrName),
|
||||||
|
"date_format($columnName,'%y%m%d') >= date_format({0},'%y%m%d')",
|
||||||
|
begin$AttrName)
|
||||||
|
.apply(Validator.isNotEmpty(end$AttrName),
|
||||||
|
"date_format($columnName,'%y%m%d') <= date_format({0},'%y%m%d')",
|
||||||
|
end$AttrName);
|
||||||
|
#else
|
||||||
|
lqw.between(begin$AttrName != null && end$AttrName != null,
|
||||||
|
${ClassName}::get$AttrName ,begin$AttrName, end$AttrName);
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
return lqw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,42 +40,16 @@ public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${C
|
|||||||
#if($table.crud || $table.sub)
|
#if($table.crud || $table.sub)
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}QueryBo bo) {
|
public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}QueryBo bo) {
|
||||||
PagePlus<${ClassName}, ${ClassName}Vo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), ${ClassName}Vo.class);
|
PagePlus<${ClassName}, ${ClassName}Vo> result = pageVo(PageUtils.buildPagePlus(), bo.queryWrapper(), ${ClassName}Vo.class);
|
||||||
return PageUtils.buildDataInfo(result);
|
return PageUtils.buildDataInfo(result);
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<${ClassName}Vo> queryList(${ClassName}QueryBo bo) {
|
public List<${ClassName}Vo> queryList(${ClassName}QueryBo bo) {
|
||||||
return listVo(buildQueryWrapper(bo), ${ClassName}Vo.class);
|
return listVo(bo.queryWrapper(), ${ClassName}Vo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName}QueryBo bo) {
|
|
||||||
Map<String, Object> params = bo.getParams();
|
|
||||||
LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery();
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if($column.query)
|
|
||||||
#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)})
|
|
||||||
#set($mpMethod=$column.queryType.toLowerCase())
|
|
||||||
#if($queryType != 'BETWEEN')
|
|
||||||
#if($javaType == 'String')
|
|
||||||
#set($condition='StrUtil.isNotBlank(bo.get'+$AttrName+'())')
|
|
||||||
#else
|
|
||||||
#set($condition='bo.get'+$AttrName+'() != null')
|
|
||||||
#end
|
|
||||||
lqw.$mpMethod($condition, ${ClassName}::get$AttrName, bo.get$AttrName());
|
|
||||||
#else
|
|
||||||
lqw.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null,
|
|
||||||
${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName"));
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
return lqw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean insertByAddBo(${ClassName}AddBo bo) {
|
public Boolean insertByAddBo(${ClassName}AddBo bo) {
|
||||||
|
|||||||
@ -404,9 +404,17 @@ export default {
|
|||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
#if($column.query)
|
#if($column.query)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
begin$AttrName: undefined#if($velocityCount != $columns.size()),#end
|
||||||
|
|
||||||
|
end$AttrName: undefined#if($velocityCount != $columns.size()),#end
|
||||||
|
|
||||||
|
#else
|
||||||
$column.javaField: undefined#if($velocityCount != $columns.size()),#end
|
$column.javaField: undefined#if($velocityCount != $columns.size()),#end
|
||||||
|
|
||||||
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
},
|
},
|
||||||
@ -446,17 +454,11 @@ export default {
|
|||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
|
||||||
this.queryParams.params = {};
|
|
||||||
#break
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
|
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
|
||||||
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
|
this.queryParams.begin${AttrName} = this.daterange${AttrName}[0];
|
||||||
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
|
this.queryParams.end${AttrName} = this.daterange${AttrName}[1];
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user