| | |
| | | } |
| | | |
| | | /** |
| | | * 查询默认密码策略 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Strategy queryByIsDefault() { |
| | | return this.getOne(Wrappers.<Strategy>query().lambda() |
| | | .eq(Strategy::getIsDefault, CommonConstant.DATA_SCOPE_CATEGORY)); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param query 分页对象 |
| | |
| | | this.update(Wrappers.<Strategy>update().lambda() |
| | | .set(Strategy::getIsDefault, CommonConstant.NOT_SEALED_ID) |
| | | .eq(Strategy::getIsDefault, CommonConstant.DATA_SCOPE_CATEGORY)); |
| | | } |
| | | if(strategy.getRequiredType() > 0){ |
| | | throw new ServiceException("必填种类不能小于等于0!"); |
| | | } |
| | | if(strategy.getRequiredType() > strategy.getCombinationIds().split(",").length){ |
| | | throw new ServiceException("必填种类不能大于所选择的密码组合方式的个数!"); |
| | | } |
| | | if(strategy.getMaxPwdLen() > strategy.getMinPwdLen()){ |
| | | throw new ServiceException("密码最大长度不能小于最小长度!"); |
| | | } |
| | | if(strategy.getMinPwdLen() < strategy.getCombinationIds().split(",").length || strategy.getMaxPwdLen() < strategy.getCombinationIds().split(",").length){ |
| | | throw new ServiceException("密码最小长度不能小于秘密策略的值!"); |
| | | } |
| | | if(Func.isEmpty(strategy.getCreateTime())){ |
| | | strategy.setCreateTime(new Date()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询默认密码策略 |
| | | * 通过租户id以及用户名查询密码策略 |
| | | * @param tenantId |
| | | * @param name |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Long queryByIsDefault() { |
| | | return this.getOne(Wrappers.<Strategy>query().lambda() |
| | | .eq(Strategy::getIsDefault, CommonConstant.DATA_SCOPE_CATEGORY)).getId(); |
| | | public Strategy queryByNameAndTenantId(String tenantId, String name) { |
| | | Strategy strategy = this.strategyMapper.queryByNameAndTenantId(tenantId,name); |
| | | if(!Func.isEmpty(strategy)){ |
| | | return strategy; |
| | | } |
| | | return queryByIsDefault(); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户id查询密码策略 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Strategy queryByUserId(Long userId) { |
| | | Strategy strategy = this.strategyMapper.queryByUserId(userId); |
| | | if(!Func.isEmpty(strategy)){ |
| | | return strategy; |
| | | } |
| | | return queryByIsDefault(); |
| | | } |
| | | |
| | | } |