Merge branch 'master' of http://8.140.179.55:20000/r/pms-SV
| | |
| | | * @return List<BaPrivilege> |
| | | */ |
| | | List<BaPrivilege> selectAll() ; |
| | | List<BaPrivilege> selectByIds(List<String> ids) ; |
| | | |
| | | /** |
| | | * 查询某个用户所隶属所有角色的所有权限 |
| | |
| | | package com.dy.pmsGlobal.daoBa; |
| | | |
| | | import com.dy.pmsGlobal.pojoBa.BaRole; |
| | | import com.dy.pmsGlobal.pojoBa.BaUser; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Mapper |
| | | public interface BaRoleMapper { |
| | |
| | | |
| | | |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | /** |
| | | * 逻辑删除 |
| | | * @param id primaryKey |
| | | * @return update count |
| | | */ |
| | | int deleteLogicById(Long id); |
| | | |
| | | Long selectSomeCount(Map<String, Object> params); |
| | | |
| | | List<BaRole> selectSome(Map<String, Object> params); |
| | | } |
| | |
| | | @Mapper |
| | | public interface BaRolePrivilegeMapper { |
| | | int deleteByPrimaryKey(@Param("roleId") Long roleId, @Param("privilegeId") Long privilegeId); |
| | | int deleteByRoleId(@Param("roleId") Long roleId); |
| | | |
| | | int insert(BaRolePrivilege record); |
| | | |
| | |
| | | |
| | | import com.alibaba.fastjson2.annotation.JSONField; |
| | | import com.alibaba.fastjson2.writer.ObjectWriterImplToString; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.dy.common.po.BaseEntity; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import lombok.*; |
| | | import org.hibernate.validator.constraints.Length; |
| | | |
| | | /** |
| | | * 用户 |
| | | */ |
| | | //2024-04-12下面TableName不用配置表名称(value="BaUser"或“ba_user”) |
| | | //只要通过驼峰命名法则类名与表名对应起来就可以了,如果不能对应起来,需要指定表名称 |
| | | //例如@TableName(value="TestUser" autoResultMap = true) |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @TableName(value="ba_role", autoResultMap = true) |
| | | @Data |
| | | @Builder |
| | |
| | | /** |
| | | * 角色名称 |
| | | */ |
| | | @NotEmpty(message = "姓名不能为空") //不能为空也不能为null |
| | | @Length(message = "姓名不大于{max}字,不小于{min}字", min = 2, max = 50) |
| | | @NotEmpty(message = "角色名称不能为空") //不能为空也不能为null |
| | | @Length(message = "角色名称不大于{max}字,不小于{min}字", min = 2, max = 50) |
| | | public String name; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public Boolean deleted; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @TableField(value = "create_dt", fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | public Date createDt; |
| | | |
| | | /** |
| | | * 前端web界面提交的角色所属权限的id,其是一个字符串数组 |
| | | */ |
| | | @TableField(exist = false) |
| | | public List<Integer> priIds ; |
| | | |
| | | } |
| | |
| | | |
| | | import com.alibaba.fastjson2.annotation.JSONField; |
| | | import com.alibaba.fastjson2.writer.ObjectWriterImplToString; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.dy.common.po.BaseEntity; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import lombok.*; |
| | | import org.hibernate.validator.constraints.Length; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @NotEmpty(message = "密码不能为空") //不能为空也不能为null |
| | | @Length(message = "密码必须{max}位数据", min = 6, max = 6) |
| | | @JSONField(serialize = false) |
| | | public String password; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public Boolean deleted; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @TableField(value = "create_dt", fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | public Date createDt; |
| | | |
| | | ////////////////////////////////////// |
| | | // 以下不是数据库实体属性 |
| | | ////////////////////////////////////// |
| | |
| | | </if> |
| | | </select> |
| | | |
| | | <!-- <select id="selectByRole" resultType="com.dy.pmsGlobal.pojoBa.BaPrivilege">--> |
| | | <!-- select p.id,p.num,p.name,p.type--> |
| | | <!-- from ba_privilege p--> |
| | | <!-- inner join ba_role_privilege rp on p.id = rp.privilege_id--> |
| | | <!-- <if test="roleId != null">--> |
| | | <!-- where rp.role_id = #{roleId, jdbcType=BIGINT}--> |
| | | <!-- </if>--> |
| | | <!-- </select>--> |
| | | |
| | | |
| | | |
| | | <insert id="insert" parameterType="com.dy.pmsGlobal.pojoBa.BaPrivilege"> |
| | |
| | | delete from ba_privilege |
| | | where id = #{id} |
| | | </delete> |
| | | |
| | | <select id="selectByIds" parameterType="arraylist" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from ba_privilege where id in |
| | | <foreach item="id" collection="ids" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </select> |
| | | </mapper> |
| | |
| | | <result column="name" property="name" /> |
| | | <result column="disabled" property="disabled" /> |
| | | <result column="deleted" property="deleted" /> |
| | | <result column="create_dt" property="createDt" /> |
| | | </resultMap> |
| | | <resultMap id="partResultMap" type="com.dy.pmsGlobal.pojoBa.BaRole"> |
| | | <result column="id" property="id" /> |
| | | <result column="name" property="name" /> |
| | | </resultMap> |
| | | |
| | | <resultMap id="someResultMap" extends="partResultMap" type="com.dy.pmsGlobal.pojoBa.BaRole"> |
| | | <collection property="priIds" ofType="java.lang.Integer" fetchType="eager" column="{roleId=id}" select="com.dy.pmsGlobal.daoBa.BaPrivilegeMapper.selectPrivilegeByRoleId" /> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, `name`, disabled, deleted |
| | | id, `name`, disabled, deleted,create_dt |
| | | </sql> |
| | | |
| | | <sql id="Part_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, `name`, disabled |
| | | id, `name`, disabled,create_dt |
| | | </sql> |
| | | |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="someResultMap"> |
| | | <!--@mbg.generated--> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | |
| | | deleted = #{deleted} |
| | | where id = #{id} |
| | | </update> |
| | | |
| | | <delete id="deleteLogicById" parameterType="java.lang.Long"> |
| | | update ba_role set deleted = 1 |
| | | where id = #{id} |
| | | </delete> |
| | | |
| | | <select id="selectSomeCount" resultType="java.lang.Long"> |
| | | select |
| | | count(*) |
| | | from ba_role r |
| | | inner join (select DISTINCT role_id from ba_role_privilege) rp on r.id=rp.role_id |
| | | where r.disabled!=1 and r.deleted!=1 |
| | | <trim prefix="and" suffixOverrides="and"> |
| | | <if test="name != null and name != ''"> |
| | | r.name like concat('%', #{name}, '%') and |
| | | </if> |
| | | </trim> |
| | | </select> |
| | | |
| | | <select id="selectSome" resultMap="someResultMap"> |
| | | select |
| | | <include refid="Part_Column_List" > |
| | | <property name="alias" value="r"/> |
| | | </include> |
| | | from ba_role r |
| | | inner join (select DISTINCT role_id from ba_role_privilege) rp on r.id=rp.role_id |
| | | where r.disabled!=1 and r.deleted!=1 |
| | | <trim prefix="and" suffixOverrides="and"> |
| | | <if test="name != null and name != ''"> |
| | | r.name like concat('%', #{name}, '%') and |
| | | </if> |
| | | </trim> |
| | | order by id DESC |
| | | <trim prefix="limit " > |
| | | <if test="start != null and count != null"> |
| | | #{start}, #{count} |
| | | </if> |
| | | </trim> |
| | | </select> |
| | | </mapper> |
| | |
| | | where role_id = #{roleId} |
| | | and privilege_id = #{privilegeId} |
| | | </delete> |
| | | |
| | | <delete id="deleteByRoleId" parameterType="map"> |
| | | <!--@mbg.generated--> |
| | | delete from ba_role_privilege |
| | | where role_id = #{roleId} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pmsGlobal.pojoBa.BaRolePrivilege"> |
| | | <!--@mbg.generated--> |
| | | insert into ba_role_privilege (role_id, privilege_id) |
| | |
| | | <result column="supper_admin" property="supperAdmin" /> |
| | | <result column="disabled" property="disabled" typeHandler="com.dy.common.mybatis.BooleanTypeHandler" /> |
| | | <result column="deleted" property="deleted" typeHandler="com.dy.common.mybatis.BooleanTypeHandler" /> |
| | | <result column="create_dt" property="createDt" /> |
| | | </resultMap> |
| | | <resultMap id="partResultMap" type="com.dy.pmsGlobal.pojoBa.BaUser"> |
| | | <!--@mbg.generated--> |
| | |
| | | |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, `name`, phone, `password`, supper_admin, disabled, deleted |
| | | id, `name`, phone, `password`, supper_admin, disabled, deleted,create_dt |
| | | </sql> |
| | | <sql id="part_Column_List"> |
| | | ${alias}.id, ${alias}.name, ${alias}.phone, ${alias}.password, ${alias}.disabled |
| | | ${alias}.id, ${alias}.name, ${alias}.phone, ${alias}.password, ${alias}.disabled,${alias}.create_dt |
| | | </sql> |
| | | <sql id="Login_Column_List"> |
| | | id, name, phone, supper_admin |
New file |
| | |
| | | package com.dy.pmsBase.config; |
| | | |
| | | //import com.dy.common.webFilter.DevOfDataSourceNameSetFilter; |
| | | import com.dy.common.webFilter.UserTokenFilter; |
| | | import jakarta.servlet.Filter; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.web.servlet.FilterRegistrationBean; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | | public class WebFilterConfiguration { |
| | | |
| | | @Value("${pms.global.dev}") |
| | | public String isDevStage ;//是否为开发阶段 |
| | | // @Value("${pipIrr.global.dsName}") |
| | | // public String dsName ;//开发阶段的数据源名称 |
| | | |
| | | /** |
| | | * DevOfDataSourceNameSetFilter与UserTokenFilter只能一个被配置上, |
| | | * 所以他们的order都是1 |
| | | */ |
| | | private static final int order_UserTokenFilter = 1 ;//与下面 |
| | | private static final int order_DevOfDataSourceNameSetFilter = 1 ; |
| | | |
| | | |
| | | @Bean |
| | | public FilterRegistrationBean<? extends Filter> RegFilter() { |
| | | FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>(); |
| | | if(this.isDevStage != null && !this.isDevStage.trim().equals("") && this.isDevStage.trim().equalsIgnoreCase("true")){ |
| | | // filterRegistrationBean.setFilter(new DevOfDataSourceNameSetFilter()); |
| | | // filterRegistrationBean.addUrlPatterns("/*");//配置过滤规则 |
| | | // filterRegistrationBean.addInitParameter("dataSourceName",dsName);//设置init参数 |
| | | // filterRegistrationBean.setName("DevOfDataSourceNameSetFilter");//设置过滤器名称 |
| | | // filterRegistrationBean.setOrder(order_DevOfDataSourceNameSetFilter);//执行次序 |
| | | }else{ |
| | | filterRegistrationBean.setFilter(new UserTokenFilter()); |
| | | filterRegistrationBean.addUrlPatterns("/*");//配置过滤规则 |
| | | filterRegistrationBean.setName("UserTokenFilter");//设置过滤器名称 |
| | | filterRegistrationBean.setOrder(order_UserTokenFilter);//执行次序 |
| | | } |
| | | return filterRegistrationBean; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pmsBase.config; |
| | | |
| | | import com.dy.common.webListener.GenerateIdSetSuffixListener; |
| | | import jakarta.servlet.ServletContextListener; |
| | | import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | | public class WebListenerConfiguration { |
| | | |
| | | /** |
| | | * 启动顺序 |
| | | */ |
| | | //private static final int order_config = 0 ; |
| | | private static final int order_idSetSuffix = 1 ; |
| | | //private static final int order_init = 2 ; |
| | | |
| | | /* |
| | | * 解析各种***.config配置的ConfigListener,暂时不采用此种配置方式 |
| | | * |
| | | @Bean |
| | | public ConfigListener getGlConfigListener(){ |
| | | return new ConfigListener() ; |
| | | } |
| | | /** |
| | | * 外部提供Listener |
| | | * @param listener 外部提供Listener |
| | | * @return 注册Bean |
| | | @Bean |
| | | public ServletListenerRegistrationBean<? extends ServletContextListener> regConfigListener(ConfigListener listener) { |
| | | ServletListenerRegistrationBean<ConfigListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); |
| | | listenerRegistrationBean.setListener(listener); |
| | | listenerRegistrationBean.setOrder(order_config); |
| | | return listenerRegistrationBean; |
| | | } |
| | | */ |
| | | |
| | | /** |
| | | * 内部提供listener,该listener在系统启动时,根据配置 设置ID产生器的后缀 |
| | | * @return 注册Bean |
| | | */ |
| | | @Bean |
| | | public ServletListenerRegistrationBean<? extends ServletContextListener> regSsoListener() { |
| | | ServletListenerRegistrationBean<GenerateIdSetSuffixListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); |
| | | listenerRegistrationBean.setListener(new GenerateIdSetSuffixListener()); |
| | | listenerRegistrationBean.setOrder(order_idSetSuffix); |
| | | return listenerRegistrationBean; |
| | | } |
| | | |
| | | // /** |
| | | // * 内部提供listener,该listener在系统启动时,初始化数据库数据 |
| | | // * @return 注册Bean |
| | | // */ |
| | | // @Bean |
| | | // public ServletListenerRegistrationBean<? extends ServletContextListener> regInitListener() { |
| | | // ServletListenerRegistrationBean<InitListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); |
| | | // listenerRegistrationBean.setListener(new InitListener()); |
| | | // listenerRegistrationBean.setOrder(order_init); |
| | | // return listenerRegistrationBean; |
| | | // } |
| | | } |
New file |
| | |
| | | package com.dy.pmsBase.role; |
| | | |
| | | import com.dy.common.webUtil.QueryConditionVo; |
| | | import lombok.*; |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ToString(callSuper = true) |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Builder |
| | | public class QueryVo extends QueryConditionVo { |
| | | public String name; |
| | | } |
New file |
| | |
| | | package com.dy.pmsBase.role; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.dy.common.aop.SsoPowerAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pmsGlobal.pojoBa.BaRole; |
| | | import jakarta.validation.Valid; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色管理 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping(path="role") |
| | | @SuppressWarnings("unchecked") |
| | | public class RoleCtrl { |
| | | private RoleSv roleSv; |
| | | @Autowired |
| | | public RoleCtrl(RoleSv roleSv){ |
| | | this.roleSv = roleSv; |
| | | } |
| | | |
| | | /** |
| | | * 保存角色信息 |
| | | * @param role |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path="save") |
| | | @SsoPowerAop(power = "10100011") |
| | | public BaseResponse<BaRole> save(@RequestBody @Valid BaRole role,BindingResult bindingResult){ |
| | | try { |
| | | role.setDeleted(false); |
| | | role.setDisabled(false); |
| | | return BaseResponseUtils.buildSuccess(roleSv.save(role)); |
| | | }catch (Exception e){ |
| | | log.error("保存角色异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新角色信息 |
| | | * @param role |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path="update") |
| | | @SsoPowerAop(power = "10100011") |
| | | public BaseResponse<BaRole> update(@RequestBody @Valid BaRole role,BindingResult bindingResult){ |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(roleSv.update(role)); |
| | | }catch (Exception e){ |
| | | log.error("更新角色异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除角色信息 |
| | | * @param id |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path="delete") |
| | | @SsoPowerAop(power = "10100011") |
| | | public BaseResponse<BaRole> delete(String id,BindingResult bindingResult){ |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(roleSv.delete(Long.parseLong(id))); |
| | | }catch (Exception e){ |
| | | log.error("删除角色异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据ID查询角色信息 |
| | | * @return |
| | | */ |
| | | @GetMapping(path="one") |
| | | @SsoPowerAop(power = "10100010") //登录与权限同时验证 |
| | | public BaseResponse<BaRole> one(String id){ |
| | | try{ |
| | | BaRole role=roleSv.selectById(id); |
| | | return BaseResponseUtils.buildSuccess(JSON.toJSON(role)); |
| | | }catch (Exception e){ |
| | | log.error("查询角色异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 分页查询角色信息 |
| | | * @param vo |
| | | * @return |
| | | */ |
| | | @PostMapping(path="some") |
| | | @SsoPowerAop(power = "10100010") |
| | | public BaseResponse<QueryResultVo<List<BaRole>>> some(@RequestBody QueryVo vo){ |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(roleSv.selectSome(vo)); |
| | | }catch (Exception e){ |
| | | log.error("分页查询角色异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.dy.pmsBase.role; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pmsBase.role.QueryVo; |
| | | import com.dy.pmsGlobal.daoBa.BaPrivilegeMapper; |
| | | import com.dy.pmsGlobal.daoBa.BaRoleMapper; |
| | | import com.dy.pmsGlobal.daoBa.BaRolePrivilegeMapper; |
| | | import com.dy.pmsGlobal.pojoBa.BaRole; |
| | | import com.dy.pmsGlobal.pojoBa.BaRolePrivilege; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class RoleSv { |
| | | |
| | | private BaRoleMapper dao; |
| | | private BaRolePrivilegeMapper rpDao; |
| | | private BaPrivilegeMapper priDao; |
| | | |
| | | @Autowired |
| | | public RoleSv(BaRoleMapper dao, BaRolePrivilegeMapper rpDao,BaPrivilegeMapper priDao) { |
| | | this.dao = dao; |
| | | this.rpDao = rpDao; |
| | | this.priDao = priDao; |
| | | } |
| | | |
| | | @Transactional |
| | | public int save(BaRole role) { |
| | | int count = dao.insert(role); |
| | | // 添加角色权限 |
| | | updateRolePrivileges(role.id,role.priIds); |
| | | return count; |
| | | } |
| | | |
| | | /** |
| | | * 逻辑删除实体 |
| | | * @param id 实体ID |
| | | * @return 影响记录数量 |
| | | */ |
| | | @Transactional |
| | | public int delete(Long id) { |
| | | return this.dao.deleteLogicById(id); |
| | | } |
| | | |
| | | @Transactional |
| | | public int update(BaRole role) { |
| | | int count = dao.updateByPrimaryKeySelective(role); |
| | | // 更新角色权限 |
| | | updateRolePrivileges(role.id,role.priIds); |
| | | return count; |
| | | } |
| | | |
| | | /** |
| | | * 添加或更新角色权限 |
| | | * @param roleId 角色ID |
| | | * @param priIds 权限id |
| | | * @return |
| | | */ |
| | | private void updateRolePrivileges(Long roleId,List<Integer> priIds) { |
| | | if(CollectionUtils.isEmpty(priIds)){ |
| | | throw new RuntimeException("权限id不能为空"); |
| | | } |
| | | // 删除角色权限 |
| | | rpDao.deleteByRoleId(roleId); |
| | | priIds.stream().forEach(rp -> { |
| | | if(priDao.selectByPrimaryKey(rp.longValue()) != null){ |
| | | rpDao.insert(new BaRolePrivilege(roleId, rp.longValue())); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public BaRole selectById(String roleId) { |
| | | return dao.selectByPrimaryKey(Long.valueOf(roleId)); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色列表 |
| | | */ |
| | | public QueryResultVo<List<BaRole>> selectSome(QueryVo queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | |
| | | //查询符合条件的记录总数 |
| | | Long itemTotal = this.dao.selectSomeCount(params); |
| | | |
| | | QueryResultVo<List<BaRole>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ; |
| | | //计算分页等信息 |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | |
| | | //查询符合条件的记录 |
| | | rsVo.obj = this.dao.selectSome(params) ; |
| | | return rsVo ; |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | if (count <= 0) { |
| | | return BaseResponseUtils.buildFail("数据库存储失败"); |
| | | } else { |
| | | return BaseResponseUtils.buildSuccess("修改密码成功"); |
| | | return BaseResponseUtils.buildSuccess("重置密码成功"); |
| | | } |
| | | } |
| | | |
| | |
| | | * @return 插入用户与角色关联记录数量 |
| | | */ |
| | | @Transactional |
| | | private int saveUserRoles(Long userId, String[] roleIds) { |
| | | public int saveUserRoles(Long userId, String[] roleIds) { |
| | | this.urDao.deleteByUserId(userId); |
| | | int count = 0; |
| | | if (roleIds != null && roleIds.length > 0) { |