| | |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-data-redis</artifactId> |
| | | <exclusions> |
| | | <!--过滤lettuce,使用jedis作为redis客户端--> |
| | | <exclusion> |
| | | <groupId>io.lettuce</groupId> |
| | | <artifactId>lettuce-core</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>redis.clients</groupId> |
| | | <artifactId>jedis</artifactId> |
| | | </dependency> |
| | | <!--postgresql--> |
| | | <dependency> |
| | |
| | | PermsService permsService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据角色ID查询资源") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "roleid", value = "角色ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectResByRole") |
| | | public ResponseMsg<List<RoleResEntity>> selectResByRole(Integer roleid) { |
| | | try { |
| | | List<RoleResEntity> rs = roleResService.selectResByRole(roleid); |
| | | |
| | | return success(null == rs ? 0 : rs.size(), rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "roleid", value = "角色ID", dataType = "Integer", paramType = "query", required = false, example = "") |
| | |
| | | |
| | | private Timestamp updateTime; |
| | | |
| | | private String resName; |
| | | private String cnName; |
| | | |
| | | private String server; |
| | | private Integer pid; |
| | | |
| | | private Integer level; |
| | | |
| | | private Integer sort; |
| | | |
| | | public RoleResEntity() { |
| | | } |
| | |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public String getResName() { |
| | | return resName; |
| | | public String getCnName() { |
| | | return cnName; |
| | | } |
| | | |
| | | public void setResName(String resName) { |
| | | this.resName = resName; |
| | | } |
| | | public String getServer() { |
| | | return server; |
| | | public void setCnName(String cnName) { |
| | | this.cnName = cnName; |
| | | } |
| | | |
| | | public void setServer(String server) { |
| | | this.server = server; |
| | | public Integer getPid() { |
| | | return pid; |
| | | } |
| | | |
| | | public void setPid(Integer pid) { |
| | | this.pid = pid; |
| | | } |
| | | |
| | | public Integer getLevel() { |
| | | return level; |
| | | } |
| | | |
| | | public void setLevel(Integer level) { |
| | | this.level = level; |
| | | } |
| | | |
| | | public Integer getSort() { |
| | | return sort; |
| | | } |
| | | |
| | | public void setSort(Integer sort) { |
| | | this.sort = sort; |
| | | } |
| | | } |
| | |
| | | @Repository |
| | | public interface RoleResMapper { |
| | | /** |
| | | * 根据角色ID查询资源 |
| | | * |
| | | * @param roleid |
| | | * @return |
| | | */ |
| | | public List<RoleResEntity> selectResByRole(Integer roleid); |
| | | |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param roleid 角色ID |
| | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param roleid 角色ID |
| | | * @param roleid 角色ID |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | |
| | | |
| | | // 9.获取资源实体 |
| | | ResEntity entity = getResEntity(ue, resId); |
| | | if (null == entity) { |
| | | if (null == entity || entity.getType() != 3|| StringHelper.isNull(entity.getProxy())||StringHelper.isNull(entity.getUrl())) { |
| | | WebHelper.writeStr2Page(res, ILLEGAL_RESOURCE); |
| | | return; |
| | | } |
| | |
| | | |
| | | import com.moon.server.entity.sys.RoleResEntity; |
| | | import com.moon.server.mapper.sys.RoleResMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Service |
| | | public class RoleResService implements RoleResMapper { |
| | | @Autowired |
| | | @Resource |
| | | RoleResMapper roleResMapper; |
| | | |
| | | @Override |
| | | public List<RoleResEntity> selectResByRole(Integer roleid) { |
| | | return roleResMapper.selectResByRole(roleid); |
| | | } |
| | | |
| | | @Override |
| | | public Integer selectCount(Integer roleid) { |
| | | return roleResMapper.selectCount(roleid); |
| | | } |
| | |
| | | <?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.moon.server.mapper.sys.RoleResMapper"> |
| | | <select id="selectResByRole" resultType="com.moon.server.entity.sys.RoleResEntity"> |
| | | with rs as (select id, resid from lf.sys_role_res where roleid = #{roleid}) |
| | | select (select id from rs b where b.resid = a.id) "id", a.id "resid", a.cn_name, a.pid, a.level, a.sort |
| | | from lf.sys_res a; |
| | | </select> |
| | | |
| | | <select id="selectCount" resultType="java.lang.Integer"> |
| | | select count(*) from lf.sys_role_res |
| | | <where> |
| | |
| | | </select> |
| | | |
| | | <select id="selectByPage" resultType="com.moon.server.entity.sys.RoleResEntity"> |
| | | select a.*,b.name as resName from lf.sys_role_res a inner join lf.sys_res b |
| | | on a.resid = b.id |
| | | select a.* |
| | | from lf.sys_role_res a |
| | | <where> |
| | | <if test="roleid != null"> |
| | | a.roleid = #{roleid} |
| | | </if> |
| | | </where> |
| | | order by id |
| | | order by a.id |
| | | limit #{limit} offset #{offset} |
| | | </select> |
| | | |
| | |
| | | </select> |
| | | |
| | | <select id="selectById" resultType="com.moon.server.entity.sys.RoleResEntity"> |
| | | select * from lf.sys_role_res where id = #{id} |
| | | select * from lf.sys_role_res where id = #{id}; |
| | | </select> |
| | | |
| | | <insert id="insert" parameterType="com.moon.server.entity.sys.RoleResEntity"> |
| | |
| | | </delete> |
| | | |
| | | <update id="update"> |
| | | update lf.sys_role_res |
| | | set roleid=#{roleid},resid=#{resid},update_user=#{updateUser},update_time=now() |
| | | where id=#{id} |
| | | update lf.sys_role_res |
| | | set roleid=#{roleid},resid=#{resid},update_user=#{updateUser},update_time=now() |
| | | where id=#{id} |
| | | </update> |
| | | |
| | | <update id="updates"> |