| | |
| | | * ç¨æ·è¯¦æ
|
| | | */ |
| | | private final Kv detail; |
| | | /** |
| | | * å¯ç çç¥ä¿®æ¹ç¶æ |
| | | */ |
| | | private Long strategyUpdateStatus; |
| | | |
| | | |
| | | public BladeUserDetails(Long userId, String tenantId, String oauthId, String name, String realName, String deptId, String postId, String roleId, String roleName, String avatar, String username, String password, Kv detail, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities,Long strategyUpdateStatus) { |
| | | super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities); |
| | | this.userId = userId; |
| | | this.tenantId = tenantId; |
| | | this.oauthId = oauthId; |
| | | this.name = name; |
| | | this.realName = realName; |
| | | this.account = username; |
| | | this.deptId = deptId; |
| | | this.postId = postId; |
| | | this.roleId = roleId; |
| | | this.roleName = roleName; |
| | | this.avatar = avatar; |
| | | this.detail = detail; |
| | | this.strategyUpdateStatus = strategyUpdateStatus; |
| | | } |
| | | |
| | | public BladeUserDetails(Long userId, String tenantId, String oauthId, String name, String realName, String deptId, String postId, String roleId, String roleName, String avatar, String username, String password, Kv detail, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) { |
| | | super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities); |
| | |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.*; |
| | | import org.springblade.system.cache.ParamCache; |
| | | import org.springblade.system.entity.Strategy; |
| | | import org.springblade.system.entity.Tenant; |
| | | import org.springblade.system.feign.ISysClient; |
| | | import org.springblade.system.user.entity.User; |
| | |
| | | |
| | | private final JwtProperties jwtProperties; |
| | | |
| | | |
| | | /** |
| | | * è¶
级管çåä¿¡æ¯ |
| | | */ |
| | |
| | | |
| | | // æå®ç§æ·ID |
| | | String tenantId = StringUtils.isBlank(headerTenant) ? paramTenant : headerTenant; |
| | | |
| | | Log.debug("å½åç»å½ç¨æ·çç§æ·Id为ï¼"+tenantId+"å½åç»å½ç¨æ·å为ï¼"+username); |
| | | Strategy strategy = sysClient.getByTenantIdAndName(tenantId, username).getData(); |
| | | |
| | | // 夿ç»å½æ¯å¦éå® |
| | | int count = getFailCount(tenantId, username); |
| | | int failCount = Func.toInt(ParamCache.getValue(FAIL_COUNT_VALUE), FAIL_COUNT); |
| | | int failCount = Func.toInt(ParamCache.getValue(FAIL_COUNT_VALUE), Func.toInt(strategy.getLockingNum())); |
| | | |
| | | if (count >= failCount) { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_TOO_MANY_FAILS); |
| | | } |
| | | //è¶
级管çåé
ç½®æä»¶é
置账å·å¯ç ï¼å®ç°ç»å½, é»è®¤ç§æ·id为000000 |
| | | if(tenantId.equals(this.tenantId)){ |
| | | if (!this.userName.equals(username) && !password.equalsIgnoreCase(this.password)) { |
| | | setFailCount(tenantId, username, count); |
| | | setFailCount(tenantId, username, count,strategy.getLockingTime()); |
| | | throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND); |
| | | } |
| | | //妿ipæ¯å¯¹ågetæåºå¼å¸¸No value presentå°±ç´æ¥æå¼å¸¸ç»æç»å½ |
| | |
| | | User user = userInfo.getUser(); |
| | | // ç¨æ·ä¸åå¨,ä½æç¤ºç¨æ·åä¸å¯ç é误并éå®è´¦å· |
| | | if (user == null || user.getId() == null) { |
| | | setFailCount(tenantId, username, count); |
| | | setFailCount(tenantId, username, count,strategy.getLockingTime()); |
| | | throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND); |
| | | } |
| | | String hex = DigestUtil.hex(password); |
| | | // ç¨æ·åå¨ä½å¯ç é误,è¶
è¿æ¬¡æ°åéå®è´¦å· |
| | | if (grantType != null && !grantType.equals(TokenUtil.REFRESH_TOKEN_KEY) && !user.getPassword().equals(DigestUtil.hex(password))) { |
| | | setFailCount(tenantId, username, count); |
| | | if (grantType != null && !grantType.equals(TokenUtil.REFRESH_TOKEN_KEY) && !user.getPassword().equals(hex)) { |
| | | setFailCount(tenantId, username, count,strategy.getLockingTime()); |
| | | throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND); |
| | | } |
| | | // ç¨æ·è§è²ä¸åå¨ |
| | |
| | | BladeUserDetails bladeUserDetails = new BladeUserDetails(user.getId(), |
| | | user.getTenantId(), StringPool.EMPTY, user.getName(), user.getRealName(), user.getDeptId(), user.getPostId(), user.getRoleId(), Func.join(userInfo.getRoles()), Func.toStr(user.getAvatar(), TokenUtil.DEFAULT_AVATAR), |
| | | username, AuthConstant.ENCRYPT + user.getPassword(), userInfo.getDetail(), true, true, true, true, |
| | | AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(result.getData().getRoles()))); |
| | | AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(result.getData().getRoles())),user.getStrategyUpdateStatus()); |
| | | return bladeUserDetails; |
| | | } else { |
| | | throw new UsernameNotFoundException(result.getMsg()); |
| | |
| | | * @param username è´¦å· |
| | | * @param count æ¬¡æ° |
| | | */ |
| | | private void setFailCount(String tenantId, String username, int count) { |
| | | bladeRedis.setEx(CacheNames.tenantKey(tenantId, CacheNames.USER_FAIL_KEY, username), count + 1, Duration.ofMinutes(30)); |
| | | private void setFailCount(String tenantId, String username, int count, Long expir) { |
| | | bladeRedis.setEx(CacheNames.tenantKey(tenantId, CacheNames.USER_FAIL_KEY, username), count + 1, Duration.ofMinutes(expir)); |
| | | } |
| | | |
| | | /** |
| | |
| | | info.put(TokenUtil.AVATAR, principal.getAvatar()); |
| | | info.put(TokenUtil.DETAIL, principal.getDetail()); |
| | | info.put(TokenUtil.LICENSE, TokenUtil.LICENSE_NAME); |
| | | info.put(TokenUtil.STRATEGYUPDATESTATUS, principal.getStrategyUpdateStatus()); |
| | | ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(info); |
| | | |
| | | //tokenç¶æè®¾ç½® |
| | |
| | | import org.springblade.core.launch.constant.TokenConstant; |
| | | import org.springblade.core.tenant.BladeTenantProperties; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.jackson.JsonUtil; |
| | | import org.springblade.core.tool.utils.*; |
| | | import org.springblade.system.entity.Tenant; |
| | | import org.springframework.security.authentication.BadCredentialsException; |
| | |
| | | |
| | | import java.util.Base64; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 认è¯å·¥å
·ç±» |
| | |
| | | public final static String DETAIL = TokenConstant.DETAIL; |
| | | public final static String LICENSE = TokenConstant.LICENSE; |
| | | public final static String LICENSE_NAME = TokenConstant.LICENSE_NAME; |
| | | public final static String STRATEGYUPDATESTATUS = "strategyUpdateStatus"; |
| | | |
| | | public final static String DEPT_HEADER_KEY = "Dept-Id"; |
| | | public final static String ROLE_HEADER_KEY = "Role-Id"; |
| | |
| | | /** |
| | | * nacos dev å°å |
| | | */ |
| | | String NACOS_DEV_ADDR = "dev.vci-tech.com:38848"; |
| | | //String NACOS_DEV_ADDR = "192.168.93.133:38848"; |
| | | //String NACOS_DEV_ADDR = "dev.vci-tech.com:38848"; |
| | | String NACOS_DEV_ADDR = "192.168.93.133:38848"; |
| | | |
| | | /** |
| | | * nacos prod å°å |
| | |
| | | private String licensors; |
| | | |
| | | /** |
| | | * ç»åæ¹å¼æ£å |
| | | */ |
| | | @ApiModelProperty(value = "ææäºº") |
| | | private String regex; |
| | | |
| | | /** |
| | | * ç»ååç§° |
| | | */ |
| | | @ApiModelProperty(value = "ç»ååç§°") |
| | |
| | | package org.springblade.system.entity; |
| | | |
| | | 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.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | |
| | | @ApiModel(value = "UserPwdStrtategy", description = "UserPwdStrtategy") |
| | | public class UserPwdstrategy implements Serializable { |
| | | |
| | | private static final long serialVersionUID = -556926788101426521L; |
| | | private static final long serialVersionUid = -556926788101426521L; |
| | | |
| | | /** |
| | | * ä¸»é® |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @ApiModelProperty(value = "主é®") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long Id; |
| | | @TableId(value = "ID", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * ç¨æ·id |
| | |
| | | * å¯ç çç¥id |
| | | */ |
| | | @ApiModelProperty(value = "å¯ç çç¥id") |
| | | @TableField(value = "PWDSTRATEGY_ID") |
| | | private Long pwdstrategyId; |
| | | |
| | | public UserPwdstrategy(Long userId, Long pwdStrategyId) { |
| | |
| | | return false; |
| | | } |
| | | UserPwdstrategy that = (UserPwdstrategy) o; |
| | | return Objects.equals(Id, that.Id) && Objects.equals(userId, that.userId) && Objects.equals(pwdstrategyId, that.pwdstrategyId); |
| | | return Objects.equals(id, that.id) && Objects.equals(userId, that.userId) && Objects.equals(pwdstrategyId, that.pwdstrategyId); |
| | | } |
| | | |
| | | @Override |
| | | public int hashCode() { |
| | | return Objects.hash(Id, userId, pwdstrategyId); |
| | | return Objects.hash(id, userId, pwdstrategyId); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import org.springblade.system.entity.*; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | |
| | | String PARAM = API_PREFIX + "/param"; |
| | | String PARAM_VALUE = API_PREFIX + "/param-value"; |
| | | String REGION = API_PREFIX + "/region"; |
| | | String STRATEGY = API_PREFIX + "/query-tenantid-name"; |
| | | String STRATEGYBYID = API_PREFIX + "/query-userid"; |
| | | String REGEX = API_PREFIX + "/combination-regex"; |
| | | |
| | | /** |
| | | * è·åèå |
| | |
| | | @GetMapping(REGION) |
| | | R<Region> getRegion(@RequestParam("code") String code); |
| | | |
| | | /** |
| | | * æ ¹æ®ç§æ·id以åç¨æ·åè·åå¯ç çç¥ |
| | | * @param tenantId |
| | | * @param name |
| | | * @return |
| | | */ |
| | | @PostMapping(STRATEGY) |
| | | R<Strategy> getByTenantIdAndName(@RequestParam("tenantId") String tenantId, @RequestParam("name") String name); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·idè·åå¯ç çç¥ |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @PostMapping(STRATEGYBYID) |
| | | R<Strategy> getByUserId(@RequestParam("id") Long userId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç»åæ¹å¼idè·åå¼ |
| | | * @return |
| | | */ |
| | | @PostMapping(REGEX) |
| | | R<String> getRegex(@RequestBody List<String> combinationIds); |
| | | |
| | | } |
| | |
| | | return R.fail("è·åæ°æ®å¤±è´¥"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Strategy> getByTenantIdAndName(String tenantId, String name) { |
| | | return R.fail("è·åæ°æ®å¤±è´¥"); |
| | | } |
| | | |
| | | @Override |
| | | public R<Strategy> getByUserId(Long userId) { |
| | | return R.fail("è·åæ°æ®å¤±è´¥"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> getRegex(List<String> combinationIds) { |
| | | return R.fail("è·åæ°æ®å¤±è´¥"); |
| | | } |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.springblade.system.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.system.entity.UserPwdstrategy; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * (UserPwdStrtategy)å®ä½ç±» |
| | | * |
| | | * @author makejava |
| | | * @since 2023-03-20 14:59:29 |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "TenantVO对象", description = "TenantVO对象") |
| | | public class UserPwdstrategyVO extends UserPwdstrategy { |
| | | |
| | | private static final long serialVersionUID = 336389756425054417L; |
| | | |
| | | @ApiModelProperty(value = "éè¦ä¿®æ¹æè
æ°å¢å¯ç çç¥çç¨æ·id") |
| | | private List<Long> userIds; |
| | | |
| | | |
| | | } |
| | |
| | | * å¯ç |
| | | */ |
| | | private String password; |
| | | @TableField(exist = false) |
| | | /** |
| | | * å¯ç çç¥ |
| | | */ |
| | | private String pwdStrategy; |
| | | /** |
| | | * æµç§° |
| | | */ |
| | |
| | | */ |
| | | private String deptId; |
| | | /** |
| | | * å¯ç çç¥ |
| | | */ |
| | | @TableField(exist = false) |
| | | private String pwdStrategy; |
| | | /** |
| | | * å²ä½id |
| | | */ |
| | | private String postId; |
| | | /** |
| | | * å¯ç ä¿®æ¹æ¶é´ |
| | | */ |
| | | private Date pwdUpdateTime; |
| | | /** |
| | | * ç¨æ·å¯çº§ |
| | | */ |
| | | private String secretgrade; |
| | | /** |
| | | * å¯ç çç¥ä¿®æ¹ç¶æ |
| | | */ |
| | | private Long strategyUpdateStatus; |
| | | |
| | | } |
| | |
| | | String SAVE_USER = API_PREFIX + "/save-user"; |
| | | String SAVE_USER_LIST = API_PREFIX + "/save-user-list"; |
| | | String REMOVE_USER = API_PREFIX + "/remove-user"; |
| | | String UPDATE_USER = API_PREFIX+"/update-user"; |
| | | |
| | | /** |
| | | * è·åç¨æ·ä¿¡æ¯ |
| | |
| | | */ |
| | | @GetMapping(USER_INFO_BY_ID) |
| | | R<User> userInfoById(@RequestParam("userId") Long userId); |
| | | |
| | | |
| | | /** |
| | | * æ ¹æ®è´¦å·è·åç¨æ·ä¿¡æ¯ |
| | |
| | | @PostMapping(REMOVE_USER) |
| | | R<Boolean> removeUser(@RequestParam("tenantIds") String tenantIds); |
| | | |
| | | /** |
| | | * ä¿®æ¹ç¨æ·åºç¡ä¿¡æ¯ |
| | | * @param user |
| | | * @return |
| | | */ |
| | | @PostMapping(UPDATE_USER) |
| | | R<Boolean> updateUser(@RequestBody User user); |
| | | |
| | | } |
| | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å¯ç çç¥(PlSysStrategy)表æ§å¶å± |
| | | * å¯ç çç¥(Strategy)表æ§å¶å± |
| | | * |
| | | * @author makejava |
| | | * @since 2023-03-20 16:45:31 |
| | |
| | | */ |
| | | @GetMapping("/page") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "å页æ¥è¯¢", notes = "ä¼ å
¥combinationï¼å页忰query") |
| | | @ApiOperation(value = "å页æ¥è¯¢", notes = "ä¼ å
¥å页忰query") |
| | | public R<Page<Strategy>> queryByPage(Query query) { |
| | | Page<Strategy> strategyPage = strategyService.queryAllByPage(query); |
| | | return R.data(strategyPage); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢é»è®¤å¯ç çç¥ |
| | | * |
| | | * @return æ¥è¯¢ç»æ |
| | | */ |
| | | @GetMapping("/default") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "æ¥è¯¢é»è®¤å¯ç çç¥") |
| | | public R<Strategy> queryByIsDefault() { |
| | | Strategy strategy = strategyService.queryByIsDefault(); |
| | | return R.data(strategy); |
| | | } |
| | | |
| | | /** |
| | |
| | | return ResponseEntity.ok(this.strategyService.deleteByIds(ids)); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·idæ¥è¯¢å¯ç çç¥ |
| | | * |
| | | * @param userId å®ä½ |
| | | * @return æ°å¢ç»æ |
| | | */ |
| | | @PostMapping("/query-userid") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "æ ¹æ®ç¨æ·idæ¥è¯¢å¯ç çç¥", notes = "ä¼ å
¥userId") |
| | | public R<Strategy> queryByUserId(@Valid @RequestParam Long userId) { |
| | | return R.data(this.strategyService.queryByUserId(userId)); |
| | | } |
| | | |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.springblade.system.controller; |
| | | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.system.service.IUserPwdstrategyService; |
| | | import org.springblade.system.vo.UserPwdstrategyVO; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | |
| | | /** |
| | | * ç¨æ·å¯ç çç¥å
³è(UserPwdstrategy)表æ§å¶å± |
| | | * |
| | | * @author ludc |
| | | * @since 2023-03-20 15:23:24 |
| | | */ |
| | | @NonDS |
| | | @ApiIgnore |
| | | @AllArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/user-pwdstrategy") |
| | | @Api(value = "ç¨æ·å¯ç å®å
¨çç¥å
³è表", tags = "æ¥å£") |
| | | public class UserPwdstrategyController { |
| | | |
| | | @Resource |
| | | private IUserPwdstrategyService userPwdstrategyService; |
| | | |
| | | /** |
| | | * æ°å¢åä¿®æ¹æ°æ® |
| | | * |
| | | * @param userPwdstrategyVO å®ä½ |
| | | * @return æ°å¢ç»æ |
| | | */ |
| | | @PutMapping("/insert") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "æ°å¢æ°æ®", notes = "ä¼ å
¥userPwdstrategy") |
| | | public ResponseEntity<Boolean> insert(@Valid @RequestBody UserPwdstrategyVO userPwdstrategyVO) { |
| | | return ResponseEntity.ok(this.userPwdstrategyService.submit(userPwdstrategyVO)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢åä¿®æ¹æ°æ® |
| | | * |
| | | * @param userPwdstrategyVO å®ä½ |
| | | * @return æ°å¢ç»æ |
| | | */ |
| | | @PostMapping("/update") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "ä¿®æ¹æ°æ®", notes = "ä¼ å
¥userPwdstrategy") |
| | | public ResponseEntity<Boolean> update(@Valid @RequestBody UserPwdstrategyVO userPwdstrategyVO) { |
| | | return ResponseEntity.ok(this.userPwdstrategyService.submit(userPwdstrategyVO)); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * (ValueRange)表æ§å¶å± |
| | | * (ValueRangeController)表æ§å¶å± |
| | | * |
| | | * @author makejava |
| | | * @author ludc |
| | | * @since 2023-03-20 15:23:24 |
| | | */ |
| | | @NonDS |
| | |
| | | import org.springblade.system.entity.*; |
| | | import org.springblade.system.service.*; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | |
| | | private final IParamService paramService; |
| | | |
| | | private final IRegionService regionService; |
| | | |
| | | private final IStrategyService strategyService; |
| | | |
| | | private final ICombinationService combinationService; |
| | | |
| | | @Override |
| | | @GetMapping(MENU) |
| | |
| | | return R.data(regionService.getById(code)); |
| | | } |
| | | |
| | | @Override |
| | | @PostMapping(STRATEGY) |
| | | public R<Strategy> getByTenantIdAndName(String tenantId, String name) { |
| | | return R.data(strategyService.queryByNameAndTenantId(tenantId,name)); |
| | | } |
| | | |
| | | @Override |
| | | @PostMapping(STRATEGYBYID) |
| | | public R<Strategy> getByUserId(Long userId) { |
| | | return R.data(strategyService.queryByUserId(userId)); |
| | | } |
| | | |
| | | @Override |
| | | @PostMapping(REGEX) |
| | | public R<String> getRegex(@RequestBody List<String> combinationIds) { |
| | | return R.data(combinationService.getRegex(combinationIds)); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springblade.system.entity.Combination; |
| | | |
| | | import java.util.List; |
| | |
| | | */ |
| | | long count(Combination combination); |
| | | |
| | | /** |
| | | * æ¥è¯¢ç»åæ¹å¼æ£å |
| | | * |
| | | * @param combinationIds æ¥è¯¢æ¡ä»¶ |
| | | * @return æ»è¡æ° |
| | | */ |
| | | String queryRegex(@Param("combinationIds") List<String> combinationIds); |
| | | |
| | | } |
| | | |
| | |
| | | <result property="id" column="ID" jdbcType="VARCHAR"/> |
| | | <result property="name" column="NAME" jdbcType="VARCHAR"/> |
| | | <result property="desc" column="DESC" jdbcType="VARCHAR"/> |
| | | <result property="createtime" column="CREATETIME" jdbcType="TIMESTAMP"/> |
| | | <result property="createuser" column="CREATEUSER" jdbcType="VARCHAR"/> |
| | | <result property="updatetime" column="UPDATETIME" jdbcType="TIMESTAMP"/> |
| | | <result property="updateuser" column="UPDATEUSER" jdbcType="VARCHAR"/> |
| | | <result property="createTime" column="CREATETIME" jdbcType="TIMESTAMP"/> |
| | | <result property="createUser" column="CREATEUSER" jdbcType="VARCHAR"/> |
| | | <result property="updateTime" column="UPDATETIME" jdbcType="TIMESTAMP"/> |
| | | <result property="updateUser" column="UPDATEUSER" jdbcType="VARCHAR"/> |
| | | <result property="licensors" column="LICENSORS" jdbcType="VARCHAR"/> |
| | | </resultMap> |
| | | |
| | |
| | | limit #{pageable.offset}, #{pageable.pageSize} |
| | | </select> |
| | | |
| | | <select id="queryRegex" resultType="java.lang.String"> |
| | | SELECT REPLACE(WM_CONCAT(psc.REGEX),',[','[') from PL_SYS_COMBINATION psc |
| | | WHERE psc.ID IN ( |
| | | <foreach collection="combinationIds" item="id" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | ) |
| | | </select> |
| | | |
| | | </mapper> |
| | | |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springblade.system.entity.Strategy; |
| | | |
| | | import java.util.List; |
| | |
| | | */ |
| | | long count(Strategy plSysStrategy); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·å以åç§æ·IDæ¥è¯¢å¯ç çç¥ |
| | | * @return |
| | | */ |
| | | Strategy queryByNameAndTenantId(@Param("tenantId") String tenantId,@Param("name") String name); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·idè¿è¡æ¥è¯¢ |
| | | * |
| | | * @param userId ç¨æ·id |
| | | * @return 对象 |
| | | */ |
| | | Strategy queryByUserId(@Param("userId") Long userId); |
| | | |
| | | } |
| | | |
| | |
| | | <result property="strategyName" column="STRATEGY_NAME" jdbcType="VARCHAR"/> |
| | | <result property="minPwdLen" column="MIN_PWD_LEN" jdbcType="VARCHAR"/> |
| | | <result property="maxPwdLen" column="MAX_PWD_LEN" jdbcType="VARCHAR"/> |
| | | <result property="combinationIds" column="COMBINATION " jdbcType="VARCHAR"/> |
| | | <result property="combinationIds" column="COMBINATION_IDS" jdbcType="VARCHAR"/> |
| | | <result property="requiredType" column="REQUIRED_TYPE" jdbcType="VARCHAR"/> |
| | | <result property="expirationTime" column="EXPIRATION_TIME" jdbcType="TIMESTAMP"/> |
| | | <result property="reminderTime" column="REMINDER_TIME" jdbcType="TIMESTAMP"/> |
| | |
| | | <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> |
| | | |
| | | <!--æ¥è¯¢æå®è¡æ°æ®--> |
| | |
| | | </where> |
| | | </select> |
| | | |
| | | <!--éè¿ä¸»é®ä¿®æ¹æ°æ®--> |
| | | <!--<update id="update"> |
| | | update PL_SYS_STRATEGY |
| | | <set> |
| | | <if test="strategyName != null and strategyName != ''"> |
| | | STRATEGY_NAME = #{strategyName}, |
| | | </if> |
| | | <if test="minPwdLen != null and minPwdLen != ''"> |
| | | MIN_PWD_LEN = #{minPwdLen}, |
| | | </if> |
| | | <if test="maxPwdLen != null and maxPwdLen != ''"> |
| | | MAX_PWD_LEN = #{maxPwdLen}, |
| | | </if> |
| | | <if test="combination != null and combination != ''"> |
| | | COMBINATION = #{combination }, |
| | | </if> |
| | | <if test="requiredType != null and requiredType != ''"> |
| | | REQUIRED_TYPE = #{requiredType}, |
| | | </if> |
| | | <if test="expirationTime != null"> |
| | | EXPIRATION_TIME = #{expirationTime}, |
| | | </if> |
| | | <if test="reminderTime != null"> |
| | | REMINDER_TIME = #{reminderTime}, |
| | | </if> |
| | | <if test="lockingNum != null and lockingNum != ''"> |
| | | LOCKING_NUM = #{lockingNum}, |
| | | </if> |
| | | <if test="lockingTime != null"> |
| | | LOCKING_TIME = #{lockingTime}, |
| | | </if> |
| | | <if test="desc != null and desc != ''"> |
| | | DESC = #{desc}, |
| | | </if> |
| | | <if test="isDefault != null and isDefault != ''"> |
| | | IS_DEFAULT = #{isDefault}, |
| | | </if> |
| | | <if test="createDate != null"> |
| | | CREATE_DATE = #{createDate}, |
| | | </if> |
| | | <if test="createUser != null"> |
| | | CREATE_USER = #{createUser}, |
| | | </if> |
| | | <if test="updateDate != null"> |
| | | UPDATE_DATE = #{updateDate}, |
| | | </if> |
| | | <if test="updateUser != null"> |
| | | UPDATE_USER = #{updateUser}, |
| | | </if> |
| | | </set> |
| | | where ID = #{id} |
| | | </update> |
| | | |
| | | <!–éè¿ä¸»é®å 餖> |
| | | <delete id="deleteById"> |
| | | delete from PL_SYS_STRATEGY where ID = #{id} |
| | | </delete>--> |
| | | <select id="queryByNameAndTenantId" resultMap="StrategyMap"> |
| | | SELECT PSS.* 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 |
| | | WHERE PSUP.USER_ID = #{userId} |
| | | </select> |
| | | |
| | | </mapper> |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.springblade.system.entity.UserPwdstrategy; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ç¨æ·å¯ç çç¥ç®¡ç表(UserPwdstrategy)è¡¨æ°æ®åºè®¿é®å± |
| | | * |
| | |
| | | UserPwdstrategy queryById(Long id); |
| | | |
| | | /** |
| | | * ç»è®¡æ»è¡æ° |
| | | * |
| | | * @param UserPwdstrategy æ¥è¯¢æ¡ä»¶ |
| | | * @return æ»è¡æ° |
| | | */ |
| | | long count(UserPwdstrategy UserPwdstrategy); |
| | | |
| | | /** |
| | | * ä¿®æ¹æ°æ® |
| | | * |
| | | * @param UserPwdstrategy å®ä¾å¯¹è±¡ |
| | |
| | | int update(UserPwdstrategy UserPwdstrategy); |
| | | |
| | | /** |
| | | * éè¿ä¸»é®å 餿°æ® |
| | | * éè¿ç¨æ·idè¿è¡å 餿°æ® |
| | | * |
| | | * @param id ä¸»é® |
| | | * @param userIds ç¨æ·id |
| | | * @return å½±åè¡æ° |
| | | */ |
| | | int deleteById(Long id); |
| | | int deleteByUserIds(List<Long> userIds); |
| | | |
| | | } |
| | | |
| | |
| | | where ID = #{id} |
| | | </update> |
| | | |
| | | <!--éè¿ä¸»é®å é¤--> |
| | | <delete id="deleteById"> |
| | | delete |
| | | from PL_SYS_USER_PWDSTRATEGY |
| | | where ID = #{id} |
| | | <delete id="deleteByUserIds"> |
| | | DELETE FROM PL_SYS_USER_PWDSTRATEGY WHERE USER_ID IN ( |
| | | <foreach collection="userIds" item="uId" separator=","> |
| | | #{uId} |
| | | </foreach> |
| | | ) |
| | | </delete> |
| | | |
| | | </mapper> |
| | |
| | | */ |
| | | long count(ValueRange valueRannge); |
| | | |
| | | |
| | | /** |
| | | * æ ¹ç©¶ç»åidæ¥è¯¢åå¼ |
| | | * @return |
| | | */ |
| | | List<String> queryByCombinationIds(@Param("combinationIds") List<String> combinationIds); |
| | | |
| | | } |
| | | |
| | |
| | | <result property="id" column="ID" jdbcType="VARCHAR"/> |
| | | <result property="value" column="VALUE" jdbcType="VARCHAR"/> |
| | | <result property="combinationId" column="COMBINATION_ID" jdbcType="VARCHAR"/> |
| | | <result property="createuser" column="CREATEUSER" jdbcType="VARCHAR"/> |
| | | <result property="updatetime" column="UPDATETIME" jdbcType="TIMESTAMP"/> |
| | | <result property="updateuser" column="UPDATEUSER" jdbcType="VARCHAR"/> |
| | | <result property="createtime" column="CREATETIME" jdbcType="TIMESTAMP"/> |
| | | <result property="updateTime" column="CREATEUSER" jdbcType="VARCHAR"/> |
| | | <result property="updateTime" column="UPDATETIME" jdbcType="TIMESTAMP"/> |
| | | <result property="createUser" column="UPDATEUSER" jdbcType="VARCHAR"/> |
| | | <result property="createTime" column="CREATETIME" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | |
| | | <!--æ¥è¯¢æå®è¡æ°æ®--> |
| | |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="queryByCombinationIds" resultType="java.util.List"> |
| | | SELECT "VALUE" FROM PL_SYS_VALUE_RANGE PSVR |
| | | WHERE PSVR.COMBINATION_ID IN ( |
| | | <foreach collection="combinationIds" item="id" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | ) |
| | | </select> |
| | | |
| | | </mapper> |
| | | |
| | |
| | | */ |
| | | List<Map<String,Object>> selectMaps(); |
| | | |
| | | /** |
| | | * ä¸ææ°æ®æºæ¥è¯¢ |
| | | * æ¥è¯¢ç»åidï¼keyï¼ï¼ç»ååï¼valueï¼ |
| | | * @return |
| | | */ |
| | | String getRegex(List<String> combinationIds); |
| | | |
| | | } |
| | |
| | | Strategy queryById(String id); |
| | | |
| | | /** |
| | | * æ¥è¯¢é»è®¤å¯ç çç¥ |
| | | * |
| | | * @return å®ä¾å¯¹è±¡ |
| | | */ |
| | | Strategy queryByIsDefault(); |
| | | |
| | | /** |
| | | * å页æ¥è¯¢ |
| | | * |
| | | * @param query å页对象 |
| | |
| | | boolean deleteByIds(List<String> ids); |
| | | |
| | | /** |
| | | * æ¥è¯¢é»è®¤å¯ç çç¥ |
| | | * éè¿ç§æ·id以åç¨æ·åæ¥è¯¢å¯ç çç¥ |
| | | * @param tenantId |
| | | * @param name |
| | | * @return |
| | | */ |
| | | Long queryByIsDefault(); |
| | | Strategy queryByNameAndTenantId(String tenantId, String name); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·idæ¥è¯¢å¯ç çç¥ |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | Strategy queryByUserId(Long userId); |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.system.entity.UserPwdstrategy; |
| | | import org.springblade.system.vo.UserPwdstrategyVO; |
| | | |
| | | /** |
| | | * ç¨æ·å¯ç çç¥ç®¡ç表(UserPwdstrategy)表æå¡æ¥å£ |
| | |
| | | public interface IUserPwdstrategyService extends IService<UserPwdstrategy> { |
| | | |
| | | /** |
| | | * æ°å¢æä¿®æ¹æ°æ® |
| | | * éè¿IDæ¥è¯¢åæ¡æ°æ® |
| | | * |
| | | * @param UserPwdstrategy å®ä¾å¯¹è±¡ |
| | | * @param id ä¸»é® |
| | | * @return å®ä¾å¯¹è±¡ |
| | | */ |
| | | boolean submit(UserPwdstrategy UserPwdstrategy); |
| | | UserPwdstrategy queryById(Long id); |
| | | |
| | | /** |
| | | * æ°å¢æä¿®æ¹æ°æ® |
| | | * |
| | | * @param userPwdstrategyVO å®ä¾å¯¹è±¡ |
| | | * @return å®ä¾å¯¹è±¡ |
| | | */ |
| | | Boolean submit(UserPwdstrategyVO userPwdstrategyVO); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | boolean deleteByIds(List<String> ids); |
| | | |
| | | /** |
| | | * è·ååå¼ |
| | | * |
| | | * @return æ¯å¦æå |
| | | */ |
| | | List<String> getByAllString(List<String> combinationIds); |
| | | |
| | | } |
| | |
| | | return maps; |
| | | } |
| | | |
| | | @Override |
| | | public String getRegex(List<String> combinationIds) { |
| | | return combinationMapper.queryRegex(combinationIds); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢é»è®¤å¯ç çç¥ |
| | | * @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(); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | |
| | | user.setName(role.getRoleAlias()); |
| | | user.setRealName(role.getRoleName()); |
| | | user.setAccount(role.getRoleAlias()); |
| | | user.setStrategyUpdateStatus(CommonConstant.TOP_PARENT_ID); |
| | | // è·ååæ°é
ç½®çå¯ç |
| | | String password = Func.toStr(ParamCache.getValue(PASSWORD_KEY), DEFAULT_PASSWORD); |
| | | user.setPassword(password); |
| | |
| | | package org.springblade.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.system.entity.UserPwdstrategy; |
| | | import org.springblade.system.mapper.UserPwdstrategyMapper; |
| | | import org.springblade.system.service.IUserPwdstrategyService; |
| | | import org.springblade.system.user.entity.User; |
| | | import org.springblade.system.user.feign.IUserClient; |
| | | import org.springblade.system.vo.UserPwdstrategyVO; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ç¨æ·å¯ç çç¥ç®¡ç表(UserPwdstrategy)表æå¡å®ç°ç±» |
| | |
| | | * @since 2023-03-22 15:24:55 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class UserPwdstrategyServiceImpl extends ServiceImpl<UserPwdstrategyMapper,UserPwdstrategy> implements IUserPwdstrategyService { |
| | | |
| | | @Resource |
| | | private UserPwdstrategyMapper userPwdstrategyMapper; |
| | | |
| | | /** |
| | | * æ°å¢æ°æ® |
| | | * |
| | | * @param userPwdstrategy å®ä¾å¯¹è±¡ |
| | | * @return å®ä¾å¯¹è±¡ |
| | | * useræå¡è°ç¨ç±» |
| | | */ |
| | | private final IUserClient userClient; |
| | | |
| | | @Override |
| | | public UserPwdstrategy queryById(Long id) { |
| | | return this.getById(id); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢æä¿®æ¹ |
| | | * @param userPwdstrategyVO å®ä¾å¯¹è±¡ |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean submit(UserPwdstrategy userPwdstrategy) { |
| | | if(Func.isEmpty(userPwdstrategy.getId())){ |
| | | return this.saveOrUpdate(userPwdstrategy); |
| | | }else { |
| | | CacheUtil.clear(SYS_CACHE,Boolean.FALSE); |
| | | return this.saveOrUpdate(userPwdstrategy); |
| | | } |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean submit(UserPwdstrategyVO userPwdstrategyVO) { |
| | | //å
å é¤ |
| | | int eft = this.userPwdstrategyMapper.deleteByUserIds(userPwdstrategyVO.getUserIds()); |
| | | //卿°å¢ |
| | | List<UserPwdstrategy> userPwdstrategyList = new ArrayList<>(); |
| | | userPwdstrategyVO.getUserIds().forEach(id->{ |
| | | boolean temp = userPwdstrategyList.add(new UserPwdstrategy(id, userPwdstrategyVO.getPwdstrategyId())); |
| | | if(temp){ |
| | | //å¯ç çç¥æ¹å¨æåä¹åä¿®æ¹ç¨æ·ç¶æ |
| | | User user = new User(); |
| | | user.setId(id); |
| | | user.setStrategyUpdateStatus(CommonConstant.TOP_PARENT_ID); |
| | | userClient.updateUser(user); |
| | | } |
| | | }); |
| | | return this.saveBatch(userPwdstrategyList); |
| | | } |
| | | |
| | | } |
| | |
| | | return tenantTemp; |
| | | } |
| | | |
| | | /** |
| | | * è·ååå¼ |
| | | * |
| | | * @return æ¯å¦æå |
| | | */ |
| | | @Override |
| | | public List<String> getByAllString(List<String> combinationIds) { |
| | | List<String> list = valueRangeMapper.queryByCombinationIds(combinationIds); |
| | | return list; |
| | | } |
| | | |
| | | } |
| | |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.annotation.PreAuth; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | |
| | | return R.data(userService.selectUserSearch(user, query)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * ç¨æ·è§£é |
| | | */ |
| | |
| | | return R.success("æä½æå"); |
| | | } |
| | | |
| | | /** |
| | | * ç¨æ·è§£é |
| | | */ |
| | | @PostMapping("/check-renexpr") |
| | | @ApiOperationSupport(order = 19) |
| | | @ApiOperation(value = "æ¥è¯¢ç¨æ·å¯ç çç¥æ¯å¦éè¦æé", notes = "ä¼ å
¥id") |
| | | public R<Long> checkRenAndExpr(@RequestParam Long userId) { |
| | | Long res = userService.checkRenAndExpr(userId); |
| | | return R.data(res); |
| | | } |
| | | |
| | | } |
| | |
| | | return R.data(service.remove(Wrappers.<User>query().lambda().in(User::getTenantId, Func.toStrList(tenantIds)))); |
| | | } |
| | | |
| | | @Override |
| | | @PostMapping(UPDATE_USER) |
| | | public R<Boolean> updateUser(@RequestBody User user) { |
| | | return R.data(service.updateUser(user)); |
| | | } |
| | | |
| | | } |
| | |
| | | <result column="user_type" property="userType"/> |
| | | <result column="account" property="account"/> |
| | | <result column="password" property="password"/> |
| | | <result column="strategy_name" property="pwdStrategy"/> |
| | | <result column="name" property="name"/> |
| | | <result column="real_name" property="realName"/> |
| | | <result column="email" property="email"/> |
| | |
| | | <result column="role_id" property="roleId"/> |
| | | <result column="dept_id" property="deptId"/> |
| | | <result column="post_id" property="postId"/> |
| | | <result column="strategy_name" property="pwdStrategy"/> |
| | | <result column="pwd_update_time" property="pwdUpdateTime"/> |
| | | <result column="secretgrade" property="secretgrade"/> |
| | | <result column="strategy_update_status" property="strategyUpdateStatus"/> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="selectUserPage" resultMap="userResultMap"> |
| | | SELECT pou.id, pou.tenant_id, user_type, account, name, real_name, email, phone, birthday,role_id, dept_id, post_id,nvl(pss.STRATEGY_NAME,(SELECT STRATEGY_NAME FROM PL_SYS_STRATEGY WHERE IS_DEFAULT=1)) strategy_name |
| | | SELECT |
| | | pou.*,nvl(pss.STRATEGY_NAME,(SELECT STRATEGY_NAME FROM PL_SYS_STRATEGY WHERE IS_DEFAULT=1)) strategy_name |
| | | FROM pl_org_user pou |
| | | LEFT JOIN PL_SYS_USER_PWDSTRATEGY plup on plup.USER_ID=pou.ID |
| | | LEFT JOIN PL_SYS_STRATEGY pss on pss.ID=plup.PWDSTRATEGY_ID |
| | |
| | | </select> |
| | | |
| | | <select id="getUser" resultMap="userResultMap"> |
| | | SELECT pou.id, tenant_id, user_type, account, name, real_name, email, phone, birthday,role_id, dept_id, post_id,nvl(pss.STRATEGY_NAME,(SELECT STRATEGY_NAME FROM PL_SYS_STRATEGY WHERE IS_DEFAULT=1)) strategy_name |
| | | SELECT |
| | | pou.*,nvl(pss.STRATEGY_NAME,(SELECT STRATEGY_NAME FROM PL_SYS_STRATEGY WHERE IS_DEFAULT=1)) strategy_name |
| | | FROM pl_org_user pou |
| | | LEFT JOIN PL_SYS_USER_PWDSTRATEGY plup on plup.USER_ID=pou.ID |
| | | LEFT JOIN PL_SYS_STRATEGY pss on pss.ID=plup.PWDSTRATEGY_ID |
| | |
| | | </select> |
| | | |
| | | <select id="exportUser" resultType="org.springblade.system.user.excel.UserExcel"> |
| | | SELECT pou.id, tenant_id, user_type, account, name, real_name, email, phone, birthday,role_id, dept_id, post_id,nvl(pss.STRATEGY_NAME,(SELECT STRATEGY_NAME FROM PL_SYS_STRATEGY WHERE IS_DEFAULT=1)) strategy_name |
| | | SELECT |
| | | pou.*,nvl(pss.STRATEGY_NAME,(SELECT STRATEGY_NAME FROM PL_SYS_STRATEGY WHERE IS_DEFAULT=1)) strategy_name |
| | | FROM pl_org_user pou |
| | | LEFT JOIN PL_SYS_USER_PWDSTRATEGY plup on plup.USER_ID=pou.ID |
| | | LEFT JOIN PL_SYS_STRATEGY pss on pss.ID=plup.PWDSTRATEGY_ID |
| | |
| | | * @return |
| | | */ |
| | | UserVO platformDetail(User user); |
| | | |
| | | /** |
| | | * æ£æ¥ç¨æ·æ¯å¦å°äºæéç¨æ·ä¿®æ¹å¯ç æè
å¯ç è¿æçæ¶é´ |
| | | * |
| | | */ |
| | | Long checkRenAndExpr(Long userId); |
| | | |
| | | } |
| | |
| | | import org.springblade.system.cache.DictCache; |
| | | import org.springblade.system.cache.ParamCache; |
| | | import org.springblade.system.cache.SysCache; |
| | | import org.springblade.system.entity.Strategy; |
| | | import org.springblade.system.entity.Tenant; |
| | | import org.springblade.system.enums.DictEnum; |
| | | import org.springblade.system.feign.ISysClient; |
| | |
| | | import org.springblade.system.user.wrapper.UserWrapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.DigestUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | |
| | | import static org.springblade.common.constant.CommonConstant.DEFAULT_PARAM_PASSWORD; |
| | | |
| | |
| | | |
| | | @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("请è¾å
¥æ£ç¡®ç确认å¯ç !"); |
| | |
| | | if (!user.getPassword().equals(DigestUtil.hex(oldPassword))) { |
| | | throw new ServiceException("åå¯ç 䏿£ç¡®!"); |
| | | } |
| | | return this.update(Wrappers.<User>update().lambda().set(User::getPassword, DigestUtil.hex(newPassword)).eq(User::getId, userId)); |
| | | //è·åç¨æ·éç¨çå¯ç çç¥ |
| | | 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(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; |
| | | } |
| | | |
| | | @Override |
| | |
| | | return userVO; |
| | | } |
| | | |
| | | @Override |
| | | public Long checkRenAndExpr(Long userId) { |
| | | //è·åå°å¯ç ä¿®æ¹æ¶é´ |
| | | Date pwdUpdateTime = this.getOne(Wrappers.<User>query().eq("ID", userId)).getPwdUpdateTime(); |
| | | Long pwdupdateday = 0L; |
| | | if(!Func.isEmpty(pwdUpdateTime)){ |
| | | pwdupdateday = dateToDay(pwdUpdateTime); |
| | | } |
| | | Strategy strategy = sysClient.getByUserId(userId).getData(); |
| | | System.out.println("å½åæ¶é´=================="+dateToDay(new Date())); |
| | | System.out.println("å¯ç ä¿®æ¹æ¶é´======================"+pwdupdateday); |
| | | System.out.println("æéæ¶é´======================"+strategy.getReminderTime()); |
| | | System.out.println("è¿ææ¶é´======================="+strategy.getExpirationTime()); |
| | | //æ¯å¦æééè¿æå䏿¬¡ä¿®æ¹å¯ç çæ¶é´å ä¸è¿ææ¶é´åå»å½åæ¶é´ï¼å¦æå°äºè¿ææéæ¶é´å°±è¿è¡æéï¼å¦æ<=0å°±æéå¿
须修æ¹å¯ç |
| | | long reminder = pwdupdateday+strategy.getExpirationTime()-dateToDay(pwdUpdateTime); |
| | | //å¿
é¡»å»ä¿®æ¹å¯ç |
| | | if(reminder<=0){ |
| | | return -1L; |
| | | } |
| | | //æéç¨æ·è¿æå¤ä¹
è¿æ |
| | | if(reminder<=strategy.getReminderTime()){ |
| | | long res = (strategy.getReminderTime()+pwdupdateday)-dateToDay(new Date()); |
| | | return res; |
| | | } |
| | | //代表æ£å¸¸ç¶æè¿æªå°æéä¸è¿ææ¶é´ï¼æ¢ä¸æéä¹ä¸è¦æ±ä¿®æ¹ |
| | | return 0L; |
| | | } |
| | | |
| | | private Long dateToDay(Date date){ |
| | | long time = date.getTime(); |
| | | return time/(1000 * 60 * 60 * 24); |
| | | } |
| | | |
| | | |
| | | } |