feat(新增): 查询角色信息返回分页
This commit is contained in:
parent
b0be3b4c76
commit
82b1d8e139
|
@ -2,19 +2,7 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="GitCommitMessageStorage">
|
<component name="GitCommitMessageStorage">
|
||||||
<option name="messageStorage">
|
<option name="messageStorage">
|
||||||
<MessageStorage>
|
<MessageStorage />
|
||||||
<option name="commitTemplate">
|
|
||||||
<CommitTemplate>
|
|
||||||
<option name="body" value="" />
|
|
||||||
<option name="changes" value="" />
|
|
||||||
<option name="closes" value="" />
|
|
||||||
<option name="scope" value="" />
|
|
||||||
<option name="skipCi" value="" />
|
|
||||||
<option name="subject" value="" />
|
|
||||||
<option name="type" value="feat" />
|
|
||||||
</CommitTemplate>
|
|
||||||
</option>
|
|
||||||
</MessageStorage>
|
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -13,7 +13,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@Tag(name = "用户接口")
|
@Tag(name = "用户相关接口")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/admin/system/index")
|
@RequestMapping("/admin/system/index")
|
||||||
public class IndexController {
|
public class IndexController {
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.atguigu.spzx.manger.controller;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.manger.service.SysRoleService;
|
||||||
|
import com.atguigu.spzx.model.dto.system.SysRoleDto;
|
||||||
|
import com.atguigu.spzx.model.entity.system.SysRole;
|
||||||
|
import com.atguigu.spzx.model.vo.result.Result;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Tag(name = "角色相关接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/admin/system/sysRole")
|
||||||
|
public class SysRoleController {
|
||||||
|
@Autowired
|
||||||
|
private SysRoleService sysRoleService;
|
||||||
|
|
||||||
|
@Operation(summary = "查询角色分页", description = "查询角色信息返回分页")
|
||||||
|
@PostMapping("/findByPage/{pageNum}/{pageSize}")
|
||||||
|
public Result<PageInfo<SysRole>> findByPage(@RequestBody SysRoleDto sysRoleDto,
|
||||||
|
@PathVariable(value = "pageNum") Integer pageNum,
|
||||||
|
@PathVariable(value = "pageSize") Integer pageSize) {
|
||||||
|
PageInfo<SysRole> pageInfo = sysRoleService.findByPage(sysRoleDto, pageNum, pageSize);
|
||||||
|
return Result.success(pageInfo);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.atguigu.spzx.manger.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.dto.system.SysRoleDto;
|
||||||
|
import com.atguigu.spzx.model.entity.system.SysRole;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface SysRoleMapper {
|
||||||
|
/**
|
||||||
|
* 查询角色信息
|
||||||
|
*
|
||||||
|
* @param sysRoleDto 请求参数实体类
|
||||||
|
* @return List<SysRole
|
||||||
|
*/
|
||||||
|
List<SysRole> findByPage(SysRoleDto sysRoleDto);
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.atguigu.spzx.manger.service;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.dto.system.SysRoleDto;
|
||||||
|
import com.atguigu.spzx.model.entity.system.SysRole;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
public interface SysRoleService {
|
||||||
|
/**
|
||||||
|
* 查询角色信息返回分页
|
||||||
|
*
|
||||||
|
* @param sysRoleDto 请求参数实体类
|
||||||
|
* @param pageNum 当前也
|
||||||
|
* @param pageSize 分页大小
|
||||||
|
* @return 返回分页结果
|
||||||
|
*/
|
||||||
|
PageInfo<SysRole> findByPage(SysRoleDto sysRoleDto, Integer pageNum, Integer pageSize);
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.atguigu.spzx.manger.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.manger.mapper.SysRoleMapper;
|
||||||
|
import com.atguigu.spzx.manger.service.SysRoleService;
|
||||||
|
import com.atguigu.spzx.model.dto.system.SysRoleDto;
|
||||||
|
import com.atguigu.spzx.model.entity.system.SysRole;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SysRoleServiceImpl implements SysRoleService {
|
||||||
|
@Autowired
|
||||||
|
private SysRoleMapper sysRoleMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询角色信息返回分页
|
||||||
|
*
|
||||||
|
* @param sysRoleDto 请求参数实体类
|
||||||
|
* @param pageNum 当前也
|
||||||
|
* @param pageSize 分页大小
|
||||||
|
* @return 返回分页结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageInfo<SysRole> findByPage(SysRoleDto sysRoleDto, Integer pageNum, Integer pageSize) {
|
||||||
|
Page<Object> startedPage = PageHelper.startPage(pageNum, pageSize);
|
||||||
|
List<SysRole> sysRoles = sysRoleMapper.findByPage(sysRoleDto);
|
||||||
|
PageInfo<SysRole> pageInfo = new PageInfo<>(sysRoles);
|
||||||
|
startedPage.close();
|
||||||
|
return pageInfo;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?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" >
|
||||||
|
<mapper namespace="com.atguigu.spzx.manger.mapper.SysRoleMapper">
|
||||||
|
<!-- 映射查询到的字段 -->
|
||||||
|
<resultMap id="sysRoleMap" type="com.atguigu.spzx.model.entity.system.SysRole" autoMapping="true"/>
|
||||||
|
|
||||||
|
<!-- 用于select查询公用抽取的列 -->
|
||||||
|
<sql id="columns">
|
||||||
|
id,role_name,role_code,description,create_time,update_time,is_deleted
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 查询角色信息 -->
|
||||||
|
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.system.SysRole">
|
||||||
|
select
|
||||||
|
<include refid="columns"/>
|
||||||
|
from sys_role
|
||||||
|
<where>
|
||||||
|
<if test="roleName != null and roleName != ''">
|
||||||
|
and role_name like CONCAT('%',#{roleName},'%')
|
||||||
|
</if>
|
||||||
|
and is_deleted = 0
|
||||||
|
</where>
|
||||||
|
order by id desc
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Binary file not shown.
|
@ -6,8 +6,6 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "请求参数实体类")
|
@Schema(description = "请求参数实体类")
|
||||||
public class SysRoleDto {
|
public class SysRoleDto {
|
||||||
|
|
||||||
@Schema(description = "角色名称")
|
@Schema(description = "角色名称")
|
||||||
private String roleName ;
|
private String roleName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,13 @@ package com.atguigu.spzx.model.entity.system;
|
||||||
|
|
||||||
import com.atguigu.spzx.model.entity.base.BaseEntity;
|
import com.atguigu.spzx.model.entity.base.BaseEntity;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.*;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
@Schema(description = "角色实体类")
|
@Schema(description = "角色实体类")
|
||||||
public class SysRole extends BaseEntity {
|
public class SysRole extends BaseEntity {
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue