ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.generator.domain.GenTable; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -14,9 +15,9 @@ public interface GenTableMapper extends BaseMapper<GenTable> { Page<GenTable> selectPageGenTableList(Page<GenTable> page, GenTable genTable); Page<GenTable> selectPageGenTableList(@Param("page") Page<GenTable> page, @Param("genTable") GenTable genTable); Page<GenTable> selectPageDbTableList(Page<GenTable> page, GenTable genTable); Page<GenTable> selectPageDbTableList(@Param("page") Page<GenTable> page, @Param("genTable") GenTable genTable); /** * 查询业务列表 ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml
@@ -60,17 +60,17 @@ <select id="selectPageGenTableList" parameterType="GenTable" resultMap="GenTableResult"> <include refid="selectGenTableVo"/> <where> <if test="tableName != null and tableName != ''"> AND lower(table_name) like lower(concat('%', #{tableName}, '%')) <if test="genTable.tableName != null and genTable.tableName != ''"> AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%')) </if> <if test="tableComment != null and tableComment != ''"> AND lower(table_comment) like lower(concat('%', #{tableComment}, '%')) <if test="genTable.tableComment != null and genTable.tableComment != ''"> AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%')) </if> <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') <if test="genTable.params.beginTime != null and genTable.params.beginTime != ''"><!-- 开始时间检索 --> AND date_format(create_time,'%y%m%d') >= date_format(#{genTable.params.beginTime},'%y%m%d') </if> <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') <if test="genTable.params.endTime != null and genTable.params.endTime != ''"><!-- 结束时间检索 --> AND date_format(create_time,'%y%m%d') <= date_format(#{genTable.params.endTime},'%y%m%d') </if> </where> </select> @@ -80,17 +80,17 @@ where table_schema = (select database()) AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%' AND table_name NOT IN (select table_name from gen_table) <if test="tableName != null and tableName != ''"> AND lower(table_name) like lower(concat('%', #{tableName}, '%')) <if test="genTable.tableName != null and genTable.tableName != ''"> AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%')) </if> <if test="tableComment != null and tableComment != ''"> AND lower(table_comment) like lower(concat('%', #{tableComment}, '%')) <if test="genTable.tableComment != null and genTable.tableComment != ''"> AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%')) </if> <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') <if test="genTable.params.beginTime != null and genTable.params.beginTime != ''"><!-- 开始时间检索 --> AND date_format(create_time,'%y%m%d') >= date_format(#{genTable.params.beginTime},'%y%m%d') </if> <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') <if test="genTable.params.endTime != null and genTable.params.endTime != ''"><!-- 结束时间检索 --> AND date_format(create_time,'%y%m%d') <= date_format(#{genTable.params.endTime},'%y%m%d') </if> </select> ruoyi-generator/src/main/resources/vm/java/controller.java.vm
@@ -56,7 +56,7 @@ return i${ClassName}Service.queryPageList(bo); } #elseif($table.tree) public AjaxResult<${ClassName}Vo> list(${ClassName}QueryBo bo) { public AjaxResult<List<${ClassName}Vo>> list(${ClassName}QueryBo bo) { List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo); return AjaxResult.success(list); } ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
@@ -2,7 +2,11 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.StrUtil; #if($table.crud || $table.sub) import com.ruoyi.common.utils.PageUtils; import com.ruoyi.common.core.page.PagePlus; import com.ruoyi.common.core.page.TableDataInfo; #end import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -17,6 +21,7 @@ import java.util.List; import java.util.Map; import java.util.Collection; /** * ${functionName}Service业务层处理 @@ -29,12 +34,23 @@ @Override public ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}){ ${ClassName} db = this.baseMapper.selectById(${pkColumn.javaField}); return BeanUtil.toBean(db, ${ClassName}Vo.class); return getVoById(${pkColumn.javaField}, ${ClassName}Vo.class); } #if($table.crud || $table.sub) @Override public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}QueryBo bo) { PagePlus<${ClassName}, ${ClassName}Vo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), ${ClassName}Vo.class); return PageUtils.buildDataInfo(result); } #end @Override public List<${ClassName}Vo> queryList(${ClassName}QueryBo bo) { return listVo(buildQueryWrapper(bo), ${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) @@ -58,21 +74,21 @@ #end #end #end return PageUtils.buildDataInfo(page(PageUtils.buildPagePlus(), lqw)); return lqw; } @Override public Boolean insertByAddBo(${ClassName}AddBo bo) { ${ClassName} add = BeanUtil.toBean(bo, ${ClassName}.class); validEntityBeforeSave(add); return this.save(add); return save(add); } @Override public Boolean updateByEditBo(${ClassName}EditBo bo) { ${ClassName} update = BeanUtil.toBean(bo, ${ClassName}.class); validEntityBeforeSave(update); return this.updateById(update); return updateById(update); } /** @@ -89,6 +105,6 @@ if(isValid){ //TODO 做一些业务上的校验,判断是否需要校验 } return this.removeByIds(ids); return removeByIds(ids); } }