This commit is contained in:
wyd 2024-04-23 08:39:01 +08:00
parent 30f398805a
commit 994384da86
27 changed files with 315 additions and 11 deletions

View File

@ -156,6 +156,7 @@
<version>${bitwalker.version}</version> <version>${bitwalker.version}</version>
</dependency> </dependency>
<!-- 阿里JSON解析器 --> <!-- 阿里JSON解析器 -->
<dependency> <dependency>
<groupId>com.alibaba.fastjson2</groupId> <groupId>com.alibaba.fastjson2</groupId>

View File

@ -0,0 +1,34 @@
package com.ruoyi.common.utils;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author wyd
*/
public class ListPage {
/**
* 利用java8的stream对list进行分页
* @param list 需要分页的list一般为全量
* @param pageNum 当前页
* @param pageSize 每页大小
* @param <E> 元素
* @return list
*/
public static <E> List<E> getLimitList(List<E> list, Integer pageNum, Integer pageSize) {
if (list == null || list.size() <= 0) {
return list;
}
if (pageNum == null || pageNum < 1) {
pageNum = 1;
}
if (pageSize == null || pageSize < 0) {
pageSize = 10;
}
return list.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
}
}

View File

@ -0,0 +1,57 @@
package com.ruoyi.common.utils;
import com.alibaba.fastjson2.JSON;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Map;
/**
* description
*
* @author lxp
* @version V1.0
* @date 2021/12/22 14:23
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "分页参数", description = "分页查询model")
public class QueryPage {
private static final long serialVersionUID = 1L;
/**
* 降序
*/
public static final String DESC = "descend";
/**
* 升序
*/
public static final String ASC = "ascend";
@ApiModelProperty(value = "页号")
private Integer pageNum = 0;
@ApiModelProperty(value = "页面大小")
private Integer pageSize = 10;
@ApiModelProperty("过滤")
protected Map<String, String> filter;
@ApiModelProperty("排序")
protected Map<String, String> sorter;
@SuppressWarnings("unchecked")
public void setFilter(String filter) {
this.filter = JSON.parseObject(filter, Map.class);
}
@SuppressWarnings("unchecked")
public void setSorter(String sorter) {
this.sorter = JSON.parseObject(sorter, Map.class);
}
}

View File

@ -22,6 +22,7 @@ public class MybatisPlusConfig
public MybatisPlusInterceptor mybatisPlusInterceptor() public MybatisPlusInterceptor mybatisPlusInterceptor()
{ {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 分页插件 // 分页插件
interceptor.addInnerInterceptor(paginationInnerInterceptor()); interceptor.addInnerInterceptor(paginationInnerInterceptor());
// 乐观锁插件 // 乐观锁插件

View File

@ -1,6 +1,8 @@
package com.ruoyi.framework.web.domain; package com.ruoyi.framework.web.domain;
import java.io.Serializable; import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.constant.HttpStatus;
/** /**
@ -22,6 +24,15 @@ public class R<T> implements Serializable
private String msg; private String msg;
@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer pageNum;
@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer pageSize;
@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer total;
private T data; private T data;
public static <T> R<T> ok() public static <T> R<T> ok()
@ -39,6 +50,12 @@ public class R<T> implements Serializable
return restResult(data, SUCCESS, msg); return restResult(data, SUCCESS, msg);
} }
/*分页*/
public static <T> R<T> page(Integer pageNum,Integer pageSize,Integer total,T data)
{
return restResultPage(SUCCESS,pageNum,pageSize,total,data, "操作成功");
}
public static <T> R<T> fail() public static <T> R<T> fail()
{ {
return restResult(null, FAIL, "操作失败"); return restResult(null, FAIL, "操作失败");
@ -72,6 +89,17 @@ public class R<T> implements Serializable
apiResult.setMsg(msg); apiResult.setMsg(msg);
return apiResult; return apiResult;
} }
private static <T> R<T> restResultPage(int code,Integer pageNum,Integer pageSize,Integer total,T data,String msg)
{
R<T> apiResult = new R<>();
apiResult.setCode(code);
apiResult.setMsg(msg);
apiResult.setPageNum(pageNum);
apiResult.setPageSize(pageSize);
apiResult.setTotal(total);
apiResult.setData(data);
return apiResult;
}
public int getCode() public int getCode()
{ {
@ -112,4 +140,28 @@ public class R<T> implements Serializable
{ {
return R.SUCCESS == ret.getCode(); return R.SUCCESS == ret.getCode();
} }
public Integer getPageNum() {
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
} }

View File

@ -1,6 +1,18 @@
package com.ruoyi.project.about.controller; package com.ruoyi.project.about.controller;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.utils.ListPage;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.QueryPage;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.about.mapper.AboutPartThreeMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -24,7 +36,7 @@ import com.ruoyi.framework.web.domain.R;
@Api(tags = "关于第三部分") @Api(tags = "关于第三部分")
@RestController @RestController
@RequestMapping("/PartThree") @RequestMapping("/PartThree")
public class AboutPartThreeController { public class AboutPartThreeController extends BaseController {
@Resource @Resource
private IAboutPartThreeService aboutPartThreeService; private IAboutPartThreeService aboutPartThreeService;
@ -38,6 +50,17 @@ public class AboutPartThreeController {
List<AboutPartThree> list = aboutPartThreeService.list(); List<AboutPartThree> list = aboutPartThreeService.list();
return R.ok(list); return R.ok(list);
} }
/**
* 关于第三部分分页列表
*/
@PreAuthorize("@ss.hasPermi('PartThree:partthree:listpage')")
@ApiOperation(value = "关于第三部分分页列表", notes = "关于第三部分分页列表信息")
@GetMapping("/listPage")
public R listPage(QueryPage queryPage, AboutPartThree aboutPartThree) {
startPage();
List<AboutPartThree> list = aboutPartThreeService.selectAboutPartThreeList(aboutPartThree);
return R.page(queryPage.getPageNum(),queryPage.getPageSize(),list.size(),list);
}
/** /**
* 关于第三部分id详细信息 * 关于第三部分id详细信息
*/ */

View File

@ -57,12 +57,12 @@ private static final long serialVersionUID=1L;
@TableField("sorts") @TableField("sorts")
private Long sorts; private Long sorts;
/** 创建时间 */ /** 创建时间 */
@ApiModelProperty("创建时间") @ApiModelProperty(value = "创建时间",hidden = true)
@TableField("create_time") @TableField("create_time")
@JSONField(serializeUsing = ToStringSerializer.class) @JSONField(serializeUsing = ToStringSerializer.class)
private String createTime; private String createTime;
/** 更新时间 */ /** 更新时间 */
@ApiModelProperty("更新时间") @ApiModelProperty(value = "更新时间",hidden = true)
@TableField("update_time") @TableField("update_time")
@JSONField(serializeUsing = ToStringSerializer.class) @JSONField(serializeUsing = ToStringSerializer.class)
private String updateTime; private String updateTime;

View File

@ -3,6 +3,9 @@ package com.ruoyi.project.about.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.project.about.domain.AboutPartThree; import com.ruoyi.project.about.domain.AboutPartThree;
import java.util.List;
/** /**
* 关于第三部分Mapper接口 * 关于第三部分Mapper接口
* *
@ -10,5 +13,5 @@ import com.ruoyi.project.about.domain.AboutPartThree;
* @date 2024-04-19 * @date 2024-04-19
*/ */
public interface AboutPartThreeMapper extends BaseMapper<AboutPartThree> { public interface AboutPartThreeMapper extends BaseMapper<AboutPartThree> {
public List<AboutPartThree> selectAboutPartThreeList(AboutPartThree aboutPartThree);
} }

View File

@ -4,6 +4,8 @@ package com.ruoyi.project.about.service;
import com.ruoyi.project.about.domain.AboutPartThree; import com.ruoyi.project.about.domain.AboutPartThree;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/** /**
* 关于第三部分Service接口 * 关于第三部分Service接口
* *
@ -11,5 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @date 2024-04-19 * @date 2024-04-19
*/ */
public interface IAboutPartThreeService extends IService<AboutPartThree> { public interface IAboutPartThreeService extends IService<AboutPartThree> {
public List<AboutPartThree> selectAboutPartThreeList(AboutPartThree aboutPartThree);
} }

View File

@ -4,7 +4,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.project.about.mapper.AboutPartThreeMapper; import com.ruoyi.project.about.mapper.AboutPartThreeMapper;
import com.ruoyi.project.about.domain.AboutPartThree; import com.ruoyi.project.about.domain.AboutPartThree;
import com.ruoyi.project.about.service.IAboutPartThreeService; import com.ruoyi.project.about.service.IAboutPartThreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* 关于第三部分Service业务层处理 * 关于第三部分Service业务层处理
* *
@ -13,5 +17,11 @@ import org.springframework.stereotype.Service;
*/ */
@Service @Service
public class AboutPartThreeServiceImpl extends ServiceImpl<AboutPartThreeMapper, AboutPartThree> implements IAboutPartThreeService { public class AboutPartThreeServiceImpl extends ServiceImpl<AboutPartThreeMapper, AboutPartThree> implements IAboutPartThreeService {
@Autowired
private AboutPartThreeMapper aboutPartThreeMapper;
@Override
public List<AboutPartThree> selectAboutPartThreeList(AboutPartThree aboutPartThree) {
return aboutPartThreeMapper.selectAboutPartThreeList(aboutPartThree);
}
} }

View File

@ -3,4 +3,26 @@
<mapper namespace="com.ruoyi.project.about.mapper.AboutPartThreeMapper"> <mapper namespace="com.ruoyi.project.about.mapper.AboutPartThreeMapper">
<resultMap type="AboutPartThree" id="AboutPartThreeResult">
<result property="id" column="id" />
<result property="titleOne" column="title_one" />
<result property="titleTwo" column="title_two" />
<result property="remarks" column="remarks" />
<result property="icon" column="icon" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectAboutPartThreeVo">
select id, title_one, title_two, remarks, icon, create_time, update_time from about_part_three
</sql>
<select id="selectAboutPartThreeList" parameterType="AboutPartThree" resultMap="AboutPartThreeResult">
<include refid="selectAboutPartThreeVo"/>
<where>
<if test="titleOne != null and titleOne != ''"> and title_one = #{titleOne}</if>
<if test="titleTwo != null and titleTwo != ''"> and title_two = #{titleTwo}</if>
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
<if test="icon != null and icon != ''"> and icon = #{icon}</if>
</where>
</select>
</mapper> </mapper>

View File

@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jg.framework.web.controller.BaseController;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service; import ${packageName}.service.I${ClassName}Service;
import com.ruoyi.framework.web.domain.R; import com.ruoyi.framework.web.domain.R;
@ -27,10 +28,23 @@ import com.ruoyi.framework.web.domain.R;
@Api(tags = "${functionName}") @Api(tags = "${functionName}")
@RestController @RestController
@RequestMapping("/${moduleName}") @RequestMapping("/${moduleName}")
public class ${ClassName}Controller { public class ${ClassName}Controller extends BaseController{
@Resource @Resource
private I${ClassName}Service ${className}Service; private I${ClassName}Service ${className}Service;
/**
* ${functionName}分页列表
*/
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:listPage')")
@ApiOperation(value = "${functionName}分页列表", notes = "${functionName}分页列表信息")
@PostMapping("/listPage")
public R listPage(QueryPage queryPage,${ClassName} ${className}) {
startPage();
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return R.page(queryPage.getPageNum(),queryPage.getPageSize(),list.size(),list);
}
/** /**
* ${functionName}列表 * ${functionName}列表
*/ */

View File

@ -55,7 +55,7 @@ private static final long serialVersionUID=1L;
#else #else
#if($column.javaType == 'Date') #if($column.javaType == 'Date')
/** $column.columnComment */ /** $column.columnComment */
@ApiModelProperty("$column.columnComment") @ApiModelProperty(value = "$column.columnComment",hidden = true)
@TableField("$column.columnName") @TableField("$column.columnName")
@JSONField(serializeUsing = ToStringSerializer.class) @JSONField(serializeUsing = ToStringSerializer.class)
private String $column.javaField; private String $column.javaField;

View File

@ -10,5 +10,11 @@ import ${packageName}.domain.${ClassName};
* @date ${datetime} * @date ${datetime}
*/ */
public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> { public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> {
/**
* 查询${functionName}列表
*
* @param ${className} ${functionName}
* @return ${functionName}集合
*/
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
} }

View File

@ -11,5 +11,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @date ${datetime} * @date ${datetime}
*/ */
public interface I${ClassName}Service extends IService<${ClassName}> { public interface I${ClassName}Service extends IService<${ClassName}> {
/**
* 查询${functionName}列表
*
* @param ${className} ${functionName}
* @return ${functionName}集合
*/
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
} }

View File

@ -5,6 +5,9 @@ import ${packageName}.mapper.${ClassName}Mapper;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service; import ${packageName}.service.I${ClassName}Service;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/** /**
* ${functionName}Service业务层处理 * ${functionName}Service业务层处理
* *
@ -14,4 +17,18 @@ import org.springframework.stereotype.Service;
@Service @Service
public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service { public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service {
@Resource
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});
}
} }

View File

@ -2,5 +2,25 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${packageName}.mapper.${ClassName}Mapper"> <mapper namespace="${packageName}.mapper.${ClassName}Mapper">
<resultMap type="${ClassName}" id="${ClassName}Result">
#foreach ($column in $columns)
<result property="${column.javaField}" column="${column.columnName}" />
#end
</resultMap>
#if($table.sub)
<resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result">
<collection property="${subclassName}List" notNullColumn="sub_${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" />
</resultMap>
<resultMap type="${subClassName}" id="${subClassName}Result">
#foreach ($column in $subTable.columns)
<result property="${column.javaField}" column="sub_${column.columnName}" />
#end
</resultMap>
#end
<sql id="select${ClassName}Vo">
select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end from ${tableName}
</sql>
</mapper> </mapper>

View File

@ -3,4 +3,26 @@
<mapper namespace="com.ruoyi.project.about.mapper.AboutPartThreeMapper"> <mapper namespace="com.ruoyi.project.about.mapper.AboutPartThreeMapper">
<resultMap type="AboutPartThree" id="AboutPartThreeResult">
<result property="id" column="id" />
<result property="titleOne" column="title_one" />
<result property="titleTwo" column="title_two" />
<result property="remarks" column="remarks" />
<result property="icon" column="icon" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectAboutPartThreeVo">
select id, title_one, title_two, remarks, icon, create_time, update_time from about_part_three
</sql>
<select id="selectAboutPartThreeList" parameterType="AboutPartThree" resultMap="AboutPartThreeResult">
<include refid="selectAboutPartThreeVo"/>
<where>
<if test="titleOne != null and titleOne != ''"> and title_one = #{titleOne}</if>
<if test="titleTwo != null and titleTwo != ''"> and title_two = #{titleTwo}</if>
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
<if test="icon != null and icon != ''"> and icon = #{icon}</if>
</where>
</select>
</mapper> </mapper>

View File

@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jg.framework.web.controller.BaseController;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service; import ${packageName}.service.I${ClassName}Service;
import com.ruoyi.framework.web.domain.R; import com.ruoyi.framework.web.domain.R;
@ -27,10 +28,23 @@ import com.ruoyi.framework.web.domain.R;
@Api(tags = "${functionName}") @Api(tags = "${functionName}")
@RestController @RestController
@RequestMapping("/${moduleName}") @RequestMapping("/${moduleName}")
public class ${ClassName}Controller { public class ${ClassName}Controller extends BaseController{
@Resource @Resource
private I${ClassName}Service ${className}Service; private I${ClassName}Service ${className}Service;
/**
* ${functionName}分页列表
*/
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:listPage')")
@ApiOperation(value = "${functionName}分页列表", notes = "${functionName}分页列表信息")
@PostMapping("/listPage")
public R listPage(QueryPage queryPage,${ClassName} ${className}) {
startPage();
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return R.page(queryPage.getPageNum(),queryPage.getPageSize(),list.size(),list);
}
/** /**
* ${functionName}列表 * ${functionName}列表
*/ */

View File

@ -55,7 +55,7 @@ private static final long serialVersionUID=1L;
#else #else
#if($column.javaType == 'Date') #if($column.javaType == 'Date')
/** $column.columnComment */ /** $column.columnComment */
@ApiModelProperty("$column.columnComment") @ApiModelProperty(value = "$column.columnComment",hidden = true)
@TableField("$column.columnName") @TableField("$column.columnName")
@JSONField(serializeUsing = ToStringSerializer.class) @JSONField(serializeUsing = ToStringSerializer.class)
private String $column.javaField; private String $column.javaField;