| | |
| | | private String licensors; |
| | | |
| | | /** |
| | | * 组合方式正则 |
| | | */ |
| | | @ApiModelProperty(value = "授权人") |
| | | private String regex; |
| | | |
| | | /** |
| | | * 组合名称 |
| | | */ |
| | | @ApiModelProperty(value = "组合名称") |
| | |
| | | String STRATEGY = API_PREFIX + "/query-tenantid-name"; |
| | | String STRATEGYBYID = API_PREFIX + "/query-userid"; |
| | | String REGEX = API_PREFIX + "/combination-regex"; |
| | | |
| | | String REGEXONE = API_PREFIX + "/combination-regex-one"; |
| | | /** |
| | | * 获取菜单 |
| | | * |
| | |
| | | @PostMapping(REGEX) |
| | | R<String> getRegex(@RequestBody List<String> combinationIds); |
| | | |
| | | /** |
| | | * 根据组合方式id获取值 |
| | | * @return |
| | | */ |
| | | @PostMapping(REGEXONE) |
| | | R<List<String>> getRegexByList(@RequestBody List<String> combinationIds); |
| | | |
| | | } |
| | |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<String>> getRegexByList(List<String> combinationIds) { |
| | | return R.fail("获取数据失败"); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | return R.data(combinationService.getRegex(combinationIds)); |
| | | } |
| | | |
| | | @Override |
| | | @PostMapping(REGEXONE) |
| | | public R<List<String>> getRegexByList(List<String> combinationIds) { |
| | | return R.data(combinationService.getRegexList(combinationIds)); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | String queryRegex(@Param("combinationIds") List<String> combinationIds); |
| | | |
| | | /** |
| | | * 查询组合方式对应正则集合 |
| | | * |
| | | * @param combinationIds 查询条件 |
| | | * @return 总行数 |
| | | */ |
| | | List<String> queryRegexList(@Param("combinationIds") List<String> combinationIds); |
| | | |
| | | } |
| | | |
| | |
| | | </select> |
| | | |
| | | <select id="queryRegex" resultType="java.lang.String"> |
| | | SELECT REPLACE(WM_CONCAT(psc.REGEX),',[','[') from PL_SYS_COMBINATION psc |
| | | SELECT CONCAT(REPLACE(WM_CONCAT(psc.REGEX),',[',''),']') FROM PL_SYS_COMBINATION psc |
| | | WHERE psc.ID IN ( |
| | | <foreach collection="combinationIds" item="id" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | ) |
| | | </select> |
| | | |
| | | <select id="queryRegexList" resultType="java.lang.String"> |
| | | SELECT concat(psc.REGEX,']{1,}') from PL_SYS_COMBINATION psc |
| | | WHERE psc.ID IN ( |
| | | <foreach collection="combinationIds" item="id" separator=","> |
| | | #{id} |
| | |
| | | */ |
| | | Strategy queryByUserId(@Param("userId") Long userId); |
| | | |
| | | Strategy queryByIsDefault(); |
| | | |
| | | } |
| | | |
| | |
| | | <result property="updateTime" column="UPDATE_TIME" jdbcType="TIMESTAMP"/> |
| | | <result property="updateUser" column="UPDATE_USER" jdbcType="TIMESTAMP"/> |
| | | <result property="combinationNames" column="COMBINATIONNAMES"/> |
| | | <result property="regex" column="REGEX"/> |
| | | </resultMap> |
| | | |
| | | <!--查询指定行数据--> |
| | |
| | | |
| | | |
| | | <select id="queryByNameAndTenantId" resultMap="StrategyMap"> |
| | | SELECT PSS.* FROM PL_SYS_STRATEGY PSS |
| | | SELECT PSS.*,(select WM_CONCAT(psc.NAME) |
| | | from PL_SYS_COMBINATION psc |
| | | where instr(pss.COMBINATION_IDS,psc.ID) > 0) COMBINATIONNAMES |
| | | FROM PL_SYS_STRATEGY PSS |
| | | LEFT JOIN PL_SYS_USER_PWDSTRATEGY PSUP ON PSS.ID=PSUP.PWDSTRATEGY_ID |
| | | LEFT JOIN PL_ORG_USER POU ON POU.ID=PSUP.USER_ID |
| | | WHERE POU.TENANT_ID = #{tenantId} AND POU.NAME=#{name}; |
| | | </select> |
| | | |
| | | <select id="queryByUserId" resultMap="StrategyMap"> |
| | | SELECT PSS.* FROM PL_SYS_STRATEGY PSS LEFT JOIN PL_SYS_USER_PWDSTRATEGY PSUP ON PSS.ID=psup.PWDSTRATEGY_ID |
| | | SELECT PSS.*,(select WM_CONCAT(psc.NAME) |
| | | from PL_SYS_COMBINATION psc |
| | | where instr(pss.COMBINATION_IDS,psc.ID) > 0) COMBINATIONNAMES |
| | | FROM PL_SYS_STRATEGY PSS LEFT JOIN PL_SYS_USER_PWDSTRATEGY PSUP ON PSS.ID=psup.PWDSTRATEGY_ID |
| | | WHERE PSUP.USER_ID = #{userId} |
| | | </select> |
| | | |
| | | <select id="queryByIsDefault" resultType="org.springblade.system.entity.Strategy"> |
| | | SELECT PSS.*,(SELECT WM_CONCAT(psc.NAME) |
| | | FROM PL_SYS_COMBINATION psc |
| | | WHERE instr(pss.COMBINATION_IDS, psc.ID) > 0) COMBINATIONNAMES |
| | | FROM PL_SYS_STRATEGY PSS |
| | | WHERE is_default = 1 |
| | | </select> |
| | | |
| | | </mapper> |
| | | |
| | |
| | | List<Map<String,Object>> selectMaps(); |
| | | |
| | | /** |
| | | * 下拉数据源查询 |
| | | * 查询组合id(key):组合名(value) |
| | | * 查询拼接完整的正则 |
| | | * @param combinationIds |
| | | * @return |
| | | */ |
| | | String getRegex(List<String> combinationIds); |
| | | |
| | | /** |
| | | * 根据组合id查询正则集合 |
| | | * @param combinationIds |
| | | * @return |
| | | */ |
| | | List<String> getRegexList(List<String> combinationIds); |
| | | } |
| | |
| | | return combinationMapper.queryRegex(combinationIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getRegexList(List<String> combinationIds) { |
| | | return combinationMapper.queryRegexList(combinationIds); |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public Strategy queryByIsDefault() { |
| | | return this.getOne(Wrappers.<Strategy>query().lambda() |
| | | .eq(Strategy::getIsDefault, CommonConstant.DATA_SCOPE_CATEGORY)); |
| | | return this.strategyMapper.queryByIsDefault(); |
| | | } |
| | | |
| | | /** |
| | |
| | | ${ew.customSqlSegment} |
| | | </select> |
| | | |
| | | <select id="selectByIdUser" resultType="org.springblade.system.user.entity.User"> |
| | | select id, code, user_type, account, password , name, real_name, avatar, email, phone , birthday, sex, role_id, dept_id, post_id , pwd_update_time, secretgrade, strategy_update_status, tenant_id, create_user , create_dept, create_time, update_user, update_time, status , is_deleted |
| | | from pl_org_user |
| | | where id = #{userId} and is_deleted = 0 |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | |
| | | @Override |
| | | public boolean updatePassword(Long userId, String oldPassword, String newPassword, String newPassword1) { |
| | | String hex = DigestUtil.hex(DigestUtils.md5DigestAsHex((newPassword1).getBytes())); |
| | | User user = getById(userId); |
| | | if (!newPassword.equals(newPassword1)) { |
| | | throw new ServiceException("请输入正确的确认密码!"); |
| | |
| | | } |
| | | //获取用户采用的密码策略 |
| | | Strategy strategy = sysClient.getByUserId(userId).getData(); |
| | | String resException = "密码中必须含有【"+strategy.getCombinationIds()+"】中的【"+strategy.getRequiredType()+"】种密码组合方式,且密码长度必须在【"+strategy.getMinPwdLen()+"-"+strategy.getMaxPwdLen()+"】范围内"; |
| | | //密码长度校验 |
| | | if(newPassword1.length() < strategy.getMinPwdLen() || newPassword1.length() > strategy.getMaxPwdLen()){ |
| | | throw new ServiceException("密码中必须含有【"+strategy.getCombinationNames()+"】中的【"+strategy.getRequiredType()+"】种密码组合方式,且密码长度必须在【"+strategy.getMinPwdLen()+"-"+strategy.getMaxPwdLen()+"】范围内"); |
| | | } |
| | | List<String> regexs = sysClient.getRegexByList(Arrays.asList(strategy.getCombinationIds().split(","))).getData(); |
| | | //判断是否满足组合方式中的必填种类数 |
| | | int reqType = 0; |
| | | for (int i = 0; i < regexs.size(); i++) { |
| | | if(reqType>=strategy.getRequiredType()){ |
| | | break; |
| | | } |
| | | if(!Func.isEmpty(RegexUtil.findResult(regexs.get(i),newPassword1))){ |
| | | reqType++; |
| | | } |
| | | } |
| | | String resException = "密码中必须含有【"+strategy.getCombinationNames()+"】中的【"+strategy.getRequiredType()+"】种类型,请重新输入密码!"; |
| | | if(reqType<strategy.getRequiredType()){ |
| | | throw new ServiceException(resException); |
| | | } |
| | | //查询密码策略取值 |
| | | // 是否属于组合方式中的类型 |
| | | String regex = sysClient.getRegex(Arrays.asList(strategy.getCombinationIds().split(","))).getData(); |
| | | System.out.println("===============regex================"+regex); |
| | | regex = "^"+regex+"$"; |
| | | String result = RegexUtil.findResult(regex, newPassword); |
| | | System.out.println(result); |
| | | return this.update(Wrappers.<User>update().lambda().set(User::getPassword, DigestUtil.hex(DigestUtils.md5DigestAsHex((newPassword1).getBytes()))).eq(User::getId, userId)); |
| | | //return true; |
| | | regex = "^"+regex+"{"+strategy.getRequiredType()+",}$"; |
| | | boolean result = RegexUtil.find(regex, newPassword1); |
| | | if(!result){ |
| | | throw new ServiceException(resException); |
| | | } |
| | | //修改密码同时,改变用户信息中的密码修改状态字段 |
| | | return this.update(Wrappers.<User>update().lambda() |
| | | .set(User::getPassword, DigestUtil.hex(DigestUtils.md5DigestAsHex((newPassword1).getBytes()))) |
| | | .set(User::getStrategyUpdateStatus,CommonConstant.TOP_PARENT_ID) |
| | | .eq(User::getId, userId)); |
| | | } |
| | | |
| | | @Override |