Compare commits
30 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
60667991c7 | |
|
|
3bc6e80c1c | |
|
|
db20e6514c | |
|
|
40576bf75b | |
|
|
5b52697a78 | |
|
|
818d8af74b | |
|
|
98871dd611 | |
|
|
4d7c936bab | |
|
|
10a7d86281 | |
|
|
6f1315d73b | |
|
|
cb43fe4523 | |
|
|
49b8a7a7ce | |
|
|
960d76f4f0 | |
|
|
8fa55acb45 | |
|
|
0c631ec70f | |
|
|
54f3855a28 | |
|
|
0980714dfb | |
|
|
1fe1373832 | |
|
|
7e6b964f0b | |
|
|
927a68fa63 | |
|
|
491ce132d6 | |
|
|
60aedf35ed | |
|
|
1d6e65af0f | |
|
|
f3a9db9e6c | |
|
|
d062ffc4c2 | |
|
|
4eeeb80e18 | |
|
|
2bf4368c87 | |
|
|
4133365bdf | |
|
|
c4c313c691 | |
|
|
1c5c2471c4 |
|
|
@ -31,6 +31,8 @@ public interface RemoteUserService {
|
|||
@GetMapping("/user/list}")
|
||||
public TableDataInfo list(SysUser user, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
@PostMapping("/user/listByPost")
|
||||
public TableDataInfo listByPost(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户信息
|
||||
|
|
@ -52,6 +54,15 @@ public interface RemoteUserService {
|
|||
@GetMapping("/user/infoPhoto/{phone}")
|
||||
public R<LoginUser> getUserInfoByPhone(@PathVariable("phone") String phone, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户信息
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @param source 请求来源
|
||||
* @return 结果
|
||||
*/
|
||||
@GetMapping("/user/custInfoPhoto/{phone}")
|
||||
public R<LoginUser> getCustInfoByPhone(@PathVariable("phone") String phone, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户信息
|
||||
|
|
@ -169,6 +180,9 @@ public interface RemoteUserService {
|
|||
@GetMapping("/user/deptTree")
|
||||
public AjaxResult deptTree(SysDept dept, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
@PostMapping("/user/deptTreeByPost")
|
||||
public AjaxResult deptTreeByPost(@RequestBody SysDept sysDept, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 查询部门人员树列表
|
||||
*
|
||||
|
|
|
|||
|
|
@ -112,6 +112,8 @@ public class SysDept extends BaseEntity {
|
|||
*/
|
||||
private String logo;
|
||||
|
||||
private Long nodeId;
|
||||
|
||||
//公司管理员用户ID
|
||||
private Long adminUserId;
|
||||
|
||||
|
|
@ -203,6 +205,14 @@ public class SysDept extends BaseEntity {
|
|||
this.logo = logo;
|
||||
}
|
||||
|
||||
public Long getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
public void setNodeId(Long nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
|
||||
public Long getAdminUserId() {
|
||||
return adminUserId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import com.bonus.common.core.annotation.Excel.Type;
|
|||
import com.bonus.common.core.annotation.Excels;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import com.bonus.common.core.xss.Xss;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
|
|
@ -51,6 +53,8 @@ public class SysUser extends BaseEntity {
|
|||
@Excel(name = "登录名称")
|
||||
private String userName;
|
||||
|
||||
private String[] userNames;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
|
|
@ -137,6 +141,11 @@ public class SysUser extends BaseEntity {
|
|||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 用户组
|
||||
*/
|
||||
private Long[] userIds;
|
||||
|
||||
/**
|
||||
* 登录权限
|
||||
*/
|
||||
|
|
@ -153,6 +162,19 @@ public class SysUser extends BaseEntity {
|
|||
/**是否内置,0内置,1非内置*/
|
||||
private String isBuiltIn = "1";
|
||||
|
||||
private boolean pagination;
|
||||
|
||||
@ApiModelProperty("人员id")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Long custId;
|
||||
@ApiModelProperty("人员姓名")
|
||||
private String custName;
|
||||
@ApiModelProperty("人员编号")
|
||||
private String custNum;
|
||||
@ApiModelProperty("人脸照片地址")
|
||||
private String custPhotoUrl;
|
||||
|
||||
|
||||
public SysUser() {
|
||||
|
||||
}
|
||||
|
|
@ -215,6 +237,14 @@ public class SysUser extends BaseEntity {
|
|||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String[] getUserNames() {
|
||||
return userNames;
|
||||
}
|
||||
|
||||
public void setUserNames(String[] userNames) {
|
||||
this.userNames = userNames;
|
||||
}
|
||||
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||
public String getEmail() {
|
||||
|
|
@ -330,6 +360,14 @@ public class SysUser extends BaseEntity {
|
|||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public Long[] getUserIds() {
|
||||
return userIds;
|
||||
}
|
||||
|
||||
public void setUserIds(Long[] userIds) {
|
||||
this.userIds = userIds;
|
||||
}
|
||||
|
||||
public String getLoginType() {
|
||||
return loginType;
|
||||
}
|
||||
|
|
@ -354,6 +392,38 @@ public class SysUser extends BaseEntity {
|
|||
this.isPermanent = isPermanent;
|
||||
}
|
||||
|
||||
public Long getCustId() {
|
||||
return custId;
|
||||
}
|
||||
|
||||
public void setCustId(Long custId) {
|
||||
this.custId = custId;
|
||||
}
|
||||
|
||||
public String getCustName() {
|
||||
return custName;
|
||||
}
|
||||
|
||||
public void setCustName(String custName) {
|
||||
this.custName = custName;
|
||||
}
|
||||
|
||||
public String getCustNum() {
|
||||
return custNum;
|
||||
}
|
||||
|
||||
public void setCustNum(String custNum) {
|
||||
this.custNum = custNum;
|
||||
}
|
||||
|
||||
public String getCustPhotoUrl() {
|
||||
return custPhotoUrl;
|
||||
}
|
||||
|
||||
public void setCustPhotoUrl(String custPhotoUrl) {
|
||||
this.custPhotoUrl = custPhotoUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
@ -387,4 +457,12 @@ public class SysUser extends BaseEntity {
|
|||
public void setIsBuiltIn(String isBuiltIn) {
|
||||
this.isBuiltIn = isBuiltIn;
|
||||
}
|
||||
|
||||
public boolean isPagination() {
|
||||
return pagination;
|
||||
}
|
||||
|
||||
public void setPagination(boolean pagination) {
|
||||
this.pagination = pagination;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,11 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
return getDataTableError(new ArrayList<SysUser>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo listByPost(SysUser user, String source) {
|
||||
return getDataTableError(new ArrayList<SysUser>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<LoginUser> getUserInfo(String username, String source)
|
||||
{
|
||||
|
|
@ -56,6 +61,11 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
return R.fail("获取用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<LoginUser> getCustInfoByPhone(String phone, String source) {
|
||||
return R.fail("获取用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户信息
|
||||
*
|
||||
|
|
@ -136,6 +146,11 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
return AjaxResult.error("获取部门权限下的部门树列表:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult deptTreeByPost(SysDept sysDept, String source) {
|
||||
return AjaxResult.error("获取部门权限下的部门树列表:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult deptUserTree(SysUser sysUser, String source) {
|
||||
return AjaxResult.error("查询部门人员树列表:" + throwable.getMessage());
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.bonus.system.api.model;
|
|||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
|
|
@ -23,6 +25,12 @@ public class LoginUser implements Serializable
|
|||
*/
|
||||
private Long userid;
|
||||
|
||||
/**
|
||||
* 客户id
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Long custId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
|
|
@ -58,6 +66,12 @@ public class LoginUser implements Serializable
|
|||
*/
|
||||
private SysUser sysUser;
|
||||
|
||||
@ApiModelProperty("过期时间")
|
||||
private Long expireIn;
|
||||
|
||||
@ApiModelProperty("是否登录")
|
||||
private boolean isLogin;
|
||||
|
||||
public String getToken()
|
||||
{
|
||||
return token;
|
||||
|
|
@ -78,6 +92,14 @@ public class LoginUser implements Serializable
|
|||
this.userid = userid;
|
||||
}
|
||||
|
||||
public Long getCustId() {
|
||||
return custId;
|
||||
}
|
||||
|
||||
public void setCustId(Long custId) {
|
||||
this.custId = custId;
|
||||
}
|
||||
|
||||
public String getUsername()
|
||||
{
|
||||
return username;
|
||||
|
|
@ -147,4 +169,20 @@ public class LoginUser implements Serializable
|
|||
{
|
||||
this.sysUser = sysUser;
|
||||
}
|
||||
|
||||
public Long getExpireIn() {
|
||||
return expireIn;
|
||||
}
|
||||
|
||||
public void setExpireIn(Long expireIn) {
|
||||
this.expireIn = expireIn;
|
||||
}
|
||||
|
||||
public boolean isLogin() {
|
||||
return isLogin;
|
||||
}
|
||||
|
||||
public void setLogin(boolean login) {
|
||||
isLogin = login;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -100,6 +100,15 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 省公司短信平台sms-util -->
|
||||
<dependency>
|
||||
<groupId>com.ahsbd</groupId>
|
||||
<artifactId>sms-util</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/sms-util-1.0.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
@ -108,6 +117,9 @@
|
|||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,15 @@ public enum LoginType {
|
|||
/**
|
||||
* 邮箱验证码
|
||||
*/
|
||||
EMAIL_OTP;
|
||||
EMAIL_OTP,
|
||||
/**
|
||||
* 客户手机号密码
|
||||
*/
|
||||
CUST_PHONE_PASSWORD,
|
||||
/**
|
||||
* 客户手机号验证码
|
||||
*/
|
||||
CUST_PHONE_OPT;
|
||||
|
||||
@JsonCreator
|
||||
public static LoginType fromString(String key) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.bonus.auth.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bonus.auth.config.LoginType;
|
||||
import com.bonus.auth.factory.LoginStrategyFactory;
|
||||
import com.bonus.auth.form.LoginBody;
|
||||
|
|
@ -12,6 +11,7 @@ import com.bonus.common.core.domain.R;
|
|||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.JwtUtils;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.redis.service.RedisService;
|
||||
import com.bonus.common.security.auth.AuthUtil;
|
||||
|
|
@ -19,24 +19,19 @@ import com.bonus.common.security.service.TokenService;
|
|||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.config.SystemConfig;
|
||||
import com.bonus.system.api.RemoteConfigService;
|
||||
import com.bonus.system.api.RemoteLogService;
|
||||
import com.bonus.system.api.RemoteUserService;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
|
@ -136,7 +131,7 @@ public class TokenController {
|
|||
if (strategy == null) {
|
||||
return R.fail("不支持的登录方式");
|
||||
}
|
||||
if (form.getLoginType()== LoginType.EMAIL_OTP || form.getLoginType()== LoginType.PHONE_OTP ){
|
||||
if (form.getLoginType()== LoginType.EMAIL_OTP || form.getLoginType()== LoginType.PHONE_OTP || form.getLoginType()== LoginType.CUST_PHONE_OPT){
|
||||
form.setPassword(form.getVerificationCode());
|
||||
}
|
||||
|
||||
|
|
@ -154,8 +149,16 @@ public class TokenController {
|
|||
|
||||
LoginUser login = strategy.login(form.getUsername(), form.getPassword());
|
||||
logService.saveLogin(form.getUsername(), "登录", "登录成功", null, "成功");
|
||||
return R.ok(tokenService.createToken(login));
|
||||
|
||||
if (LoginType.CUST_PHONE_PASSWORD.equals(form.getLoginType()) || LoginType.CUST_PHONE_OPT.equals(form.getLoginType())) {
|
||||
Map<String, Object> map = tokenService.createCustToken(login);
|
||||
login.setToken((String) map.get("access_token"));
|
||||
login.setExpireIn((Long) map.get("expires_in"));
|
||||
login.setLogin((boolean) map.get("isLogin"));
|
||||
return R.ok(login);
|
||||
} else {
|
||||
return R.ok(tokenService.createToken(login));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ public class LoginStrategyFactory {
|
|||
strategyMap.put(LoginType.EMAIL_PASSWORD, strategy);
|
||||
} else if (strategy instanceof EmailOtpLoginStrategy) {
|
||||
strategyMap.put(LoginType.EMAIL_OTP, strategy);
|
||||
} else if (strategy instanceof CustPhonePasswordLoginStrategy) {
|
||||
strategyMap.put(LoginType.CUST_PHONE_PASSWORD, strategy);
|
||||
} else if (strategy instanceof CustPhoneOtpLoginStrategy) {
|
||||
strategyMap.put(LoginType.CUST_PHONE_OPT, strategy);
|
||||
}
|
||||
// 继续添加其他策略
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
package com.bonus.auth.service;
|
||||
|
||||
import com.bonus.common.core.constant.SecurityConstants;
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.config.SystemConfig;
|
||||
import com.bonus.system.api.RemoteUserService;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author bonus
|
||||
*/
|
||||
@Service
|
||||
public class CustPhoneOtpLoginStrategy implements LoginStrategy {
|
||||
@Resource
|
||||
private SystemConfig systemConfig;
|
||||
|
||||
@Resource
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@Resource
|
||||
private PasswordValidatorService passwordValidatorService;
|
||||
|
||||
|
||||
@Override
|
||||
public LoginUser login(String phone, String otp) {
|
||||
if (!systemConfig.getLoginConfig().isPhoneCode()) {
|
||||
throw new ServiceException("用户不存在/验证码错误");
|
||||
}
|
||||
passwordValidatorService.checkPhoneCaptcha(phone, otp);
|
||||
R<LoginUser> userResult = remoteUserService.getCustInfoByPhone(phone, SecurityConstants.INNER);
|
||||
//验证用户是否存在
|
||||
passwordValidatorService.validateUserResult(phone, userResult);
|
||||
LoginUser userInfo = userResult.getData();
|
||||
//SysUser user = userInfo.getSysUser();
|
||||
//passwordValidatorService.validateApprovalStatus(phone, user);
|
||||
// 验证用户状态
|
||||
//passwordValidatorService.validateUserStatus(phone, user);
|
||||
|
||||
//passwordValidatorService.processLoginBlackList(user);
|
||||
//返回信息
|
||||
return userInfo;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package com.bonus.auth.service;
|
||||
|
||||
import com.bonus.common.core.constant.SecurityConstants;
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.encryption.AesEncryptUtil;
|
||||
import com.bonus.config.SystemConfig;
|
||||
import com.bonus.system.api.RemoteUserService;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author bonus
|
||||
*/
|
||||
@Service
|
||||
public class CustPhonePasswordLoginStrategy implements LoginStrategy {
|
||||
|
||||
@Resource
|
||||
private SystemConfig systemConfig;
|
||||
|
||||
@Resource
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@Resource
|
||||
private PasswordValidatorService passwordValidatorService;
|
||||
|
||||
@Resource
|
||||
private SysPasswordService passwordService;
|
||||
|
||||
private static final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
|
||||
|
||||
@Override
|
||||
public LoginUser login(String phone, String password) {
|
||||
if (!systemConfig.getLoginConfig().isPhonePassword()) {
|
||||
throw new ServiceException("用户不存在/密码错误");
|
||||
}
|
||||
//通过手机号获取用户信息
|
||||
R<LoginUser> userResult = remoteUserService.getCustInfoByPhone(phone, SecurityConstants.INNER);
|
||||
//验证用户是否存在
|
||||
passwordValidatorService.validateUserResult(phone, userResult);
|
||||
//获取用户信息
|
||||
LoginUser userInfo = userResult.getData();
|
||||
SysUser user = userInfo.getSysUser();
|
||||
//校验用户审批状态
|
||||
//passwordValidatorService.validateApprovalStatus(user.getUserName(), user);
|
||||
// 处理IP校验
|
||||
//passwordValidatorService.validateIpBlacklist(user.getUserName());
|
||||
// 验证密码
|
||||
String decodedPassword = AesEncryptUtil.aesDecode(password);
|
||||
if (!encoder.matches(decodedPassword, user.getPassword())) {
|
||||
throw new ServiceException("密码错误");
|
||||
}
|
||||
//passwordService.validate(user, password, System.currentTimeMillis());
|
||||
//校验用户启用状态
|
||||
//passwordValidatorService.validateUserStatus(user.getUserName(), user);
|
||||
|
||||
//passwordValidatorService.processLoginBlackList(user);
|
||||
//返回信息
|
||||
return userInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -4,7 +4,6 @@ import com.bonus.common.core.constant.SecurityConstants;
|
|||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.security.service.EmailService;
|
||||
import com.bonus.common.security.service.SmsService;
|
||||
import com.bonus.system.api.RemoteUserService;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import com.bonus.common.core.domain.R;
|
|||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.common.security.service.EmailService;
|
||||
import com.bonus.common.security.service.SmsService;
|
||||
import com.bonus.config.SystemConfig;
|
||||
import com.bonus.system.api.RemoteUserService;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
package com.bonus.auth.service;
|
||||
|
||||
import com.bonus.common.core.constant.CacheConstants;
|
||||
import com.bonus.common.core.exception.CaptchaException;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.VerificationCodeUtils;
|
||||
import com.bonus.auth.utils.SmsUtils;
|
||||
import com.bonus.common.redis.service.RedisService;
|
||||
import com.bonus.common.security.config.VerificationCodeConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.bonus.common.core.utils.VerificationCodeUtils.CodeType.NUMERIC;
|
||||
|
||||
/**
|
||||
* @author bonus
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SmsService {
|
||||
@Resource
|
||||
private VerificationCodeConfig verificationCodeConfig;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 生成手机验证码
|
||||
*
|
||||
* @return AjaxResult
|
||||
* @throws CaptchaException 自定义captcha 异常
|
||||
*/
|
||||
public void sendSimplePhone(String to) {
|
||||
if (StringUtils.isEmpty(to)) {
|
||||
throw new CaptchaException("手机号不能为空");
|
||||
}
|
||||
String code = VerificationCodeUtils.generateVerificationCode(NUMERIC);
|
||||
String str = verificationCodeConfig.getContent().replace("<code>", code);
|
||||
str = str.replace("<time>", verificationCodeConfig.getTime().toString());
|
||||
String s = SmsUtils.sendMsgToSms(Arrays.asList(to), str);
|
||||
log.error("省公司短信平台发送短信返回结果=" + s);
|
||||
if (StringUtils.isNotEmpty(s)) {
|
||||
if (s.contains("ok")) {
|
||||
String verifyKey = CacheConstants.VERIFICATION_CODE + StringUtils.nvl(to, "");
|
||||
redisService.setCacheObject(verifyKey, code, verificationCodeConfig.getTime(), TimeUnit.MINUTES);
|
||||
} else {
|
||||
throw new CaptchaException("获取短信失败");
|
||||
}
|
||||
} else {
|
||||
throw new CaptchaException("获取短信失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.auth.service;
|
||||
|
||||
import com.bonus.auth.utils.SmsUtils;
|
||||
import com.bonus.common.core.constant.CacheConstants;
|
||||
import com.bonus.common.core.constant.Constants;
|
||||
import com.bonus.common.core.domain.R;
|
||||
|
|
@ -7,7 +8,6 @@ import com.bonus.common.core.exception.CaptchaException;
|
|||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.VerificationCodeUtils;
|
||||
import com.bonus.common.core.utils.sms.SmsUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.redis.service.RedisService;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
|
|
@ -19,6 +19,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
|
|
@ -107,7 +108,7 @@ public class SysPasswordService {
|
|||
String code = VerificationCodeUtils.generateVerificationCode(VerificationCodeUtils.CodeType.NUMERIC);
|
||||
String str = "您的验证码为" + code + ",尊敬的客户,以上验证码3分钟有效,微服务平台提醒您:转发可能导致账号被盗,请勿将验证码泄露于他人";
|
||||
String verifyKey = CacheConstants.VERIFICATION_CODE + phone;
|
||||
String s = SmsUtils.smsToken(phone, str, "");
|
||||
String s = SmsUtils.sendMsgToSms(Arrays.asList(phone), str);
|
||||
if (StringUtils.isNotEmpty(s)) {
|
||||
if (s.contains("ok")) {
|
||||
redisService.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
package com.bonus.auth.utils;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.ah.sbd.SmsTool;
|
||||
import com.ah.sbd.utils.param.BatchSmsByContentParam;
|
||||
import com.ah.sbd.utils.param.SmsParam;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SmsUtils {
|
||||
// 安徽省公司短信平台key
|
||||
public static final String ANHUI_COMPANY_SMS_KEY = "Wq1FZobZC5iJIAGKWh6gpKUmdGKBOQq7koHmx+Vg49g/dSjSFlw+2qRQmMmyXvJT";
|
||||
|
||||
/**
|
||||
* 发送消息到短信
|
||||
*
|
||||
* @param phoneNumbers 电话号码列表,可能包含无效或重复的号码
|
||||
* @param msg 要发送的短信消息内容
|
||||
* @return 发送短信的结果,具体形式依赖于SmsUtils.smsToken的实现
|
||||
* 此方法首先检查电话号码列表是否为空,如果为空,则直接返回空字符串。
|
||||
* 接下来,它会移除列表中所有为空的电话号码,
|
||||
* 然后对列表中超过11位的电话号码进行解密处理,
|
||||
* 确保只有有效的电话号码被用来发送短信。
|
||||
*/
|
||||
public static String sendMsgToSms(List<String> phoneNumbers, String msg) {
|
||||
// 检查电话号码列表和消息内容是否有效
|
||||
if (CollectionUtils.isEmpty(phoneNumbers) || StringUtils.isBlank(msg)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// 过滤掉无效的电话号码
|
||||
phoneNumbers.removeIf(StringUtils::isEmpty);
|
||||
|
||||
// 对超过11位的电话号码进行解密处理
|
||||
phoneNumbers.replaceAll(phoneNumber ->
|
||||
phoneNumber.length() > 11 ? Sm4Utils.decrypt(phoneNumber) : phoneNumber
|
||||
);
|
||||
|
||||
// 根据电话号码数量发送短信
|
||||
if (phoneNumbers.isEmpty()) {
|
||||
return "";
|
||||
} else if (phoneNumbers.size() == 1) {
|
||||
JSONObject sendResult = SmsTool.sendSms(new SmsParam(phoneNumbers.get(0), msg), ANHUI_COMPANY_SMS_KEY);
|
||||
return sendResult.toString();
|
||||
} else {
|
||||
JSONObject sendResult = SmsTool.sendSms(new BatchSmsByContentParam(phoneNumbers, msg), ANHUI_COMPANY_SMS_KEY);
|
||||
return sendResult.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ spring:
|
|||
name: bonus-auth
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
active: smart_canteen_local
|
||||
|
||||
#加密组件
|
||||
jasypt:
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@
|
|||
<version>1.10.19</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
package com.bonus.common.core.utils.encryption;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.Mode;
|
||||
import cn.hutool.crypto.Padding;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Component
|
||||
public class AesEncryptUtil {
|
||||
private static final Logger log = LoggerFactory.getLogger(AesEncryptUtil.class);
|
||||
private static final String KEY_ALGORITHM = "AES";
|
||||
private static final String AES_ENCRYPT_KEY = "pigxpigxpigxpigx";
|
||||
|
||||
|
||||
// @Resource
|
||||
// private EncryptProperties encryptProperties;
|
||||
//
|
||||
// public static AesEncryptUtil getInstance() {
|
||||
// return (AesEncryptUtil) SpringContextHolder.getBean(AesEncryptUtil.class);
|
||||
// }
|
||||
|
||||
public static String aesEncrypt(String encryptStr) {
|
||||
if (StrUtil.isBlank(encryptStr)) {
|
||||
return encryptStr;
|
||||
} else {
|
||||
AES aes = new AES(Mode.CBC, Padding.ZeroPadding, new SecretKeySpec(AES_ENCRYPT_KEY.getBytes(), "AES"), new IvParameterSpec(AES_ENCRYPT_KEY.getBytes()));
|
||||
return aes.encryptBase64(encryptStr);
|
||||
}
|
||||
}
|
||||
|
||||
public static String aesDecode(String decodeStr) {
|
||||
if (StrUtil.isBlank(decodeStr)) {
|
||||
return decodeStr;
|
||||
} else {
|
||||
AES aes = new AES(Mode.CBC, Padding.ZeroPadding, new SecretKeySpec(AES_ENCRYPT_KEY.getBytes(), "AES"), new IvParameterSpec(AES_ENCRYPT_KEY.getBytes()));
|
||||
|
||||
byte[] resultByte;
|
||||
try {
|
||||
resultByte = aes.decrypt(Base64.decode(decodeStr.getBytes(StandardCharsets.UTF_8)));
|
||||
} catch (Exception var5) {
|
||||
log.info("字段解密异常:" + var5.getMessage());
|
||||
return decodeStr;
|
||||
}
|
||||
|
||||
return (new String(resultByte, StandardCharsets.UTF_8)).trim();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(aesEncrypt("Bonus$2026"));
|
||||
System.out.println(aesDecode("PCAGz8j5ByU2AzoT6vtlLA=="));
|
||||
System.out.println();
|
||||
|
||||
System.out.println(aesEncrypt("Bonus$2027"));
|
||||
System.out.println(aesDecode("MF1Nui79h/OHRGoUx1jhcg=="));
|
||||
System.out.println();
|
||||
|
||||
System.out.println(aesEncrypt("18110922397"));
|
||||
System.out.println(aesDecode("poEWO1yyC/EaUR9vmrrNSA=="));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,11 +3,15 @@ package com.bonus.common.core.utils.encryption;
|
|||
import cn.hutool.core.util.HexUtil;
|
||||
import cn.hutool.crypto.Mode;
|
||||
import cn.hutool.crypto.Padding;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.SmUtil;
|
||||
import cn.hutool.crypto.symmetric.SM4;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author bonus
|
||||
*/
|
||||
@Slf4j
|
||||
public class Sm4Utils {
|
||||
/**
|
||||
* 必须是16字节
|
||||
|
|
@ -15,6 +19,8 @@ public class Sm4Utils {
|
|||
private static final String KEY = "78d1295afa99449b99d6f83820e6965c";
|
||||
|
||||
private static final String IV = "f555adf6c01d0ab0761e626a2dae34a2";
|
||||
|
||||
private static final String CUST_KEY = "jY7bZz6Pjml+H/WZYfNSNA==";
|
||||
/**
|
||||
* 加密数据,使用固定盐
|
||||
*
|
||||
|
|
@ -33,6 +39,15 @@ public class Sm4Utils {
|
|||
}
|
||||
}
|
||||
|
||||
public static String custEncrypt(String data) {
|
||||
try {
|
||||
return SmUtil.sm4(SecureUtil.decode(CUST_KEY)).encryptBase64(data) + "##encrypted";
|
||||
} catch (Exception var2) {
|
||||
log.debug("SM4加密异常:{}", var2.getMessage());
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密数据,使用固定盐
|
||||
*
|
||||
|
|
@ -51,6 +66,20 @@ public class Sm4Utils {
|
|||
}
|
||||
}
|
||||
|
||||
public static String custDecrypt(String data) {
|
||||
try {
|
||||
if (data.endsWith("##encrypted")) {
|
||||
data = data.substring(0, data.length() - "##encrypted".length());
|
||||
return SmUtil.sm4(SecureUtil.decode(CUST_KEY)).decryptStr(data);
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
} catch (Exception var2) {
|
||||
log.debug("SM4解密异常:{}", var2.getMessage());
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
// 测试方法,演示加密和解密过程
|
||||
public static void main(String[] args) {
|
||||
String plainText = "15398187429";
|
||||
|
|
@ -63,5 +92,7 @@ public class Sm4Utils {
|
|||
// 解密密文
|
||||
String decryptedText = Sm4Utils.decrypt(plainText);
|
||||
System.out.println("解密后: " + decryptedText);
|
||||
|
||||
System.out.println(custEncrypt("13866134935"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
package com.bonus.common.core.utils.sms;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.common.core.utils.http.HttpRequestHelper;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SmsUtils {
|
||||
/**
|
||||
/**
|
||||
* 发送短信验证码
|
||||
*
|
||||
* @param mobile 发信发送的目的号码.多个号码之间用半角逗号隔开
|
||||
|
|
@ -45,4 +50,5 @@ public class SmsUtils {
|
|||
String json = JSON.toJSONString(mapJson);
|
||||
return HttpRequestHelper.postJson(SmsConfig.DOMAIN, urlWithParams, json, headers);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@ import com.bonus.common.core.utils.VerificationCodeUtils;
|
|||
import com.bonus.common.core.utils.sms.SmsUtils;
|
||||
import com.bonus.common.redis.service.RedisService;
|
||||
import com.bonus.common.security.config.VerificationCodeConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.bonus.common.core.utils.VerificationCodeUtils.CodeType.NUMERIC;
|
||||
|
|
@ -18,6 +20,7 @@ import static com.bonus.common.core.utils.VerificationCodeUtils.CodeType.NUMERIC
|
|||
* @author bonus
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SmsService {
|
||||
@Resource
|
||||
private VerificationCodeConfig verificationCodeConfig;
|
||||
|
|
@ -38,6 +41,7 @@ public class SmsService {
|
|||
String str = verificationCodeConfig.getContent().replace("<code>", code);
|
||||
str = str.replace("<time>", verificationCodeConfig.getTime().toString());
|
||||
String s = SmsUtils.smsToken(to, str, "");
|
||||
log.error("省公司短信平台发送短信返回结果=" + s);
|
||||
if (StringUtils.isNotEmpty(s)) {
|
||||
if (s.contains("ok")) {
|
||||
String verifyKey = CacheConstants.VERIFICATION_CODE + StringUtils.nvl(to, "");
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.bonus.common.core.constant.SecurityConstants;
|
|||
import com.bonus.common.core.utils.JwtUtils;
|
||||
import com.bonus.common.core.utils.ServletUtils;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.common.core.utils.ip.IpUtils;
|
||||
import com.bonus.common.core.utils.uuid.IdUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -65,7 +66,7 @@ public class TokenService {
|
|||
*/
|
||||
public Map<String, Object> createToken(LoginUser loginUser) {
|
||||
// 检查并删除已有的token
|
||||
delExistingToken(loginUser.getSysUser().getUserId());
|
||||
//delExistingToken(loginUser.getSysUser().getUserId());
|
||||
String token = IdUtils.fastUUID();
|
||||
Long userId = loginUser.getSysUser().getUserId();
|
||||
String userName = loginUser.getSysUser().getUserName();
|
||||
|
|
@ -94,6 +95,38 @@ public class TokenService {
|
|||
return rspMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建客户令牌
|
||||
*/
|
||||
public Map<String, Object> createCustToken(LoginUser loginUser) {
|
||||
// 检查并删除已有的token
|
||||
//delExistingToken(loginUser.getCustId());
|
||||
String token = IdUtils.fastUUID();
|
||||
Long custId = loginUser.getCustId();
|
||||
String custName = Sm4Utils.custDecrypt(loginUser.getSysUser().getCustName());
|
||||
String phoneNumber = Sm4Utils.custDecrypt(loginUser.getSysUser().getPhonenumber());
|
||||
loginUser.setToken(token);
|
||||
loginUser.setCustId(custId);
|
||||
loginUser.getSysUser().setCustName(custName);
|
||||
loginUser.setIpaddr(IpUtils.getIpAddr());
|
||||
loginUser.getSysUser().setPhonenumber(phoneNumber);
|
||||
refreshToken(loginUser);
|
||||
// Jwt存储信息
|
||||
Map<String, Object> claimsMap = new HashMap<String, Object>(16);
|
||||
claimsMap.put(SecurityConstants.USER_KEY, token);
|
||||
claimsMap.put(SecurityConstants.DETAILS_USER_ID, custId);
|
||||
claimsMap.put(SecurityConstants.DETAILS_USERNAME, phoneNumber);
|
||||
String accessToken = JwtUtils.createToken(claimsMap);
|
||||
Map<String, Object> rspMap = new HashMap<String, Object>(16);
|
||||
rspMap.put("access_token", accessToken);
|
||||
rspMap.put("expires_in", EXPIRETIME);
|
||||
rspMap.put("isLogin", isLogin(String.valueOf(custId)));
|
||||
long tokenTime = getTokenTime();
|
||||
//对token进行存储
|
||||
redisService.setCacheObject(LOGIN_USER_KEY + custId, token, tokenTime, TimeUnit.MINUTES);
|
||||
return rspMap;
|
||||
}
|
||||
|
||||
public boolean isLogin(String userId) {
|
||||
String existingTokenKey = redisService.getCacheObject(LOGIN_USER_KEY + userId);
|
||||
return existingTokenKey != null;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.bonus.gateway.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.reactive.CorsWebFilter;
|
||||
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.util.pattern.PathPatternParser;
|
||||
|
||||
/**
|
||||
* Description: 全局跨域配置
|
||||
*/
|
||||
@Configuration
|
||||
public class GlobalCorsConfig {
|
||||
@Bean
|
||||
public CorsWebFilter corsFilter() {
|
||||
// 创建一个新的CorsConfiguration对象,用于配置跨域请求
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
// 允许所有的HTTP请求方法(GET, POST, PUT, DELETE等)
|
||||
config.addAllowedMethod("*");
|
||||
// 允许所有的域名发起的请求 比如http://localhost:8080、
|
||||
config.addAllowedOrigin("*");
|
||||
// 允许所有的域名发起的请求(支持正则表达式) 比如http://localhost:8080
|
||||
config.addAllowedOriginPattern("*");
|
||||
// 允许所有的请求头部信息 比如token、Content-Type
|
||||
config.addAllowedHeader("*");
|
||||
// 创建一个UrlBasedCorsConfigurationSource对象,并使用PathPatternParser进行路径匹配
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
|
||||
// 注册跨域配置,应用于所有的URL路径
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
return new CorsWebFilter(source);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ spring:
|
|||
name: bonus-gateway
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
active: smart_canteen_local
|
||||
|
||||
#加密组件
|
||||
jasypt:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ spring:
|
|||
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
active: smart_canteen_local
|
||||
|
||||
#加密组件
|
||||
jasypt:
|
||||
|
|
|
|||
|
|
@ -81,7 +81,25 @@ public class SysUserController extends BaseController {
|
|||
@SysLog(title = "用户管理", businessType = OperaType.QUERY, logType = 0, module = "系统管理->用户管理", details = "查询用户列表")
|
||||
public TableDataInfo list(SysUser user) {
|
||||
try {
|
||||
startPage();
|
||||
if (user.isPagination()) {
|
||||
startPage();
|
||||
}
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
return getDataTable(list);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
|
||||
//@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false), requiresPermissions = @RequiresPermissions("system:user:list"))
|
||||
@PostMapping("/listByPost")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.QUERY, logType = 0, module = "系统管理->用户管理", details = "查询用户列表")
|
||||
public TableDataInfo listByPost(@RequestBody SysUser user) {
|
||||
try {
|
||||
if (user.isPagination()) {
|
||||
startPage();
|
||||
}
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
return getDataTable(list);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -206,6 +224,32 @@ public class SysUserController extends BaseController {
|
|||
return R.ok(sysUserVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户信息
|
||||
*/
|
||||
@InnerAuth
|
||||
@GetMapping("/custInfoPhoto/{photoNumber}")
|
||||
public R<LoginUser> custInfoPhotoNumber(@PathVariable("photoNumber") String photoNumber) {
|
||||
SysUser sysUser = userService.selectCustInfoByPhoneNumber(photoNumber);
|
||||
if (StringUtils.isNull(sysUser)) {
|
||||
return R.fail("用户名或密码错误");
|
||||
}
|
||||
// SysDept sysDept = deptService.selectActiveDeptById(sysUser.getCompanyId());
|
||||
// if (StringUtils.isNull(sysDept)) {
|
||||
// return R.fail("用户所在公司停用或注销");
|
||||
// }
|
||||
// 角色集合
|
||||
//Set<String> roles = permissionService.getRolePermission(sysUser);
|
||||
// 权限集合
|
||||
//Set<String> permissions = permissionService.getMenuPermission(sysUser);
|
||||
LoginUser loginUser = new LoginUser();
|
||||
loginUser.setCustId(sysUser.getCustId());
|
||||
loginUser.setSysUser(sysUser);
|
||||
//sysUserVo.setRoles(roles);
|
||||
//sysUserVo.setPermissions(permissions);
|
||||
return R.ok(loginUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*/
|
||||
|
|
@ -465,7 +509,7 @@ public class SysUserController extends BaseController {
|
|||
/**
|
||||
* 获取部门树列表
|
||||
*/
|
||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:user:list"))
|
||||
//@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:user:list"))
|
||||
@GetMapping("/deptTree")
|
||||
public AjaxResult deptTree(SysDept dept) {
|
||||
try {
|
||||
|
|
@ -476,10 +520,20 @@ public class SysUserController extends BaseController {
|
|||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
@PostMapping("/deptTreeByPost")
|
||||
public AjaxResult deptTreeByPost(SysDept dept) {
|
||||
try {
|
||||
return success(deptService.selectDeptTreeList(dept));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门人员树列表
|
||||
*/
|
||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:user:list"))
|
||||
//@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:user:list"))
|
||||
@PostMapping("/deptUserTree")
|
||||
public AjaxResult deptUserTree(@RequestBody SysUser sysUser) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ public class TreeSelect implements Serializable {
|
|||
/** 父部门ID */
|
||||
private Long parentId;
|
||||
|
||||
private Long nodeId;
|
||||
|
||||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
|
|
@ -48,6 +50,7 @@ public class TreeSelect implements Serializable {
|
|||
public TreeSelect(SysDept dept) {
|
||||
this.id = dept.getDeptId();
|
||||
this.parentId = dept.getParentId();
|
||||
this.nodeId = dept.getNodeId();
|
||||
this.status = dept.getStatus();
|
||||
this.label = dept.getDeptName();
|
||||
this.level = dept.getLevel();
|
||||
|
|
@ -85,6 +88,14 @@ public class TreeSelect implements Serializable {
|
|||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Long getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
public void setNodeId(Long nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,4 +155,13 @@ public interface SysUserMapper {
|
|||
Integer approvalStatus(Long userId);
|
||||
|
||||
int systemUpdateUser(SysUser user);
|
||||
|
||||
/**
|
||||
* 通过手机号查询用户
|
||||
*
|
||||
* @param phoneNumber 手机号
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectCustInfoByPhoneNumber(@Param("phoneNumber") String phoneNumber);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -237,5 +237,5 @@ public interface ISysUserService {
|
|||
|
||||
public AjaxResult systemUpdateUser(SysUser user);
|
||||
|
||||
|
||||
public SysUser selectCustInfoByPhoneNumber(String photoNumber);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@ import com.bonus.common.datascope.annotation.DataScope;
|
|||
import com.bonus.common.datascope.utils.CommonDataPermissionInfo;
|
||||
import com.bonus.common.security.config.VerificationCodeConfig;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.system.api.domain.SysPost;
|
||||
import com.bonus.system.api.domain.SysRole;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.domain.SysUserRole;
|
||||
import com.bonus.system.api.domain.*;
|
||||
import com.bonus.system.domain.SysUserPost;
|
||||
import com.bonus.system.mapper.*;
|
||||
import com.bonus.system.service.ISysConfigService;
|
||||
|
|
@ -38,6 +35,7 @@ import org.springframework.util.CollectionUtils;
|
|||
import javax.annotation.Resource;
|
||||
import javax.validation.Validator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -109,7 +107,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
String phone =user.getPhonenumber().replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_");
|
||||
user.setPhonenumber(phone);
|
||||
}
|
||||
user.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
//user.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
List<SysUser> sysUsers = userMapper.selectUserList(user);
|
||||
return sysUsers;
|
||||
}
|
||||
|
|
@ -649,4 +647,15 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param photoNumber 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectCustInfoByPhoneNumber(String photoNumber) {
|
||||
return userMapper.selectCustInfoByPhoneNumber(Sm4Utils.custEncrypt(photoNumber));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ spring:
|
|||
name: bonus-system
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
active: smart_canteen_local
|
||||
task:
|
||||
scheduling:
|
||||
pool:
|
||||
|
|
|
|||
|
|
@ -112,9 +112,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
SELECT
|
||||
d.dept_id AS deptId,
|
||||
d.parent_id AS parentId,
|
||||
d.dept_id as nodeId,
|
||||
d.dept_name AS deptName,
|
||||
LENGTH( d.ancestors ) - LENGTH(
|
||||
REPLACE ( d.ancestors, ',', '' )) AS LEVEL
|
||||
REPLACE ( d.ancestors, ',', '' )) AS level
|
||||
FROM
|
||||
sys_dept d
|
||||
WHERE
|
||||
|
|
@ -124,10 +125,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
UNION
|
||||
|
||||
SELECT
|
||||
su.user_id AS deptId,
|
||||
CONCAT(sd.dept_id,'9999',su.user_id) AS deptId,
|
||||
sd.dept_id AS parentId,
|
||||
su.user_id as nodeId,
|
||||
su.nick_name AS deptName,
|
||||
99 AS LEVEL
|
||||
99 AS level
|
||||
FROM
|
||||
sys_user su
|
||||
LEFT JOIN sys_user_role sr ON su.user_id = sr.user_id
|
||||
|
|
|
|||
|
|
@ -144,6 +144,24 @@
|
|||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="roles != null and roles.size() > 0">
|
||||
and r.role_key in
|
||||
<foreach collection="roles" item="item" index="index" separator="," open="(" close=")">
|
||||
#{item.roleKey}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="userIds != null and userIds.length > 0">
|
||||
and u.user_id in
|
||||
<foreach collection="userIds" item="item" index="index" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="userNames != null and userNames.length > 0">
|
||||
and u.user_name in
|
||||
<foreach collection="userNames" item="item" index="index" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<include refid="com.bonus.system.mapper.DataScopeMapper.dataScopeFilter"/>
|
||||
GROUP BY u.user_id
|
||||
</select>
|
||||
|
|
@ -369,5 +387,17 @@
|
|||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!--根据人员id集合获取人员信息-->
|
||||
<select id="selectCustInfoByPhoneNumber" resultType="com.bonus.system.api.domain.SysUser">
|
||||
select cust_id as custId, cust_name as custName, cust_num as custNum, cust_photo_url as custPhotoUrl,
|
||||
mobile as phonenumber, pwd as password
|
||||
from cust_info
|
||||
<where>
|
||||
cust_state = 1 and (psn_type != 999 or psn_type is null)
|
||||
<if test="phoneNumber != null and phoneNumber != ''">
|
||||
and mobile = #{phoneNumber}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue