for gz
This commit is contained in:
parent
869b534c5e
commit
2d75b41377
|
|
@ -17,6 +17,7 @@ import com.bonus.sgzb.system.api.RemoteUserService;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import com.bonus.sgzb.auth.service.SysLoginService;
|
import com.bonus.sgzb.auth.service.SysLoginService;
|
||||||
import com.bonus.sgzb.common.core.domain.R;
|
import com.bonus.sgzb.common.core.domain.R;
|
||||||
|
|
@ -38,10 +39,8 @@ import java.util.Map;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class TokenController {
|
public class TokenController {
|
||||||
|
|
||||||
private final String USER_PASSWORD = "NwCc@2024*";
|
@Value("${sgzb.customer}")
|
||||||
|
private String customer;
|
||||||
private final String privateKey = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKNPuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gAkM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWowcSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99EcvDQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthhYhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3UP8iWi1Qw0Y=";
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
|
|
@ -64,33 +63,7 @@ public class TokenController {
|
||||||
//web端登录
|
//web端登录
|
||||||
@PostMapping("login")
|
@PostMapping("login")
|
||||||
public R<?> login(@RequestBody LoginBody form) throws Exception {
|
public R<?> login(@RequestBody LoginBody form) throws Exception {
|
||||||
String decryptedData = RsaUtil.decryptByPrivateKey(form.getPassword(), Constants.privateKey);
|
if (Constants.CUSTOMER_GZ.equals(customer)) {
|
||||||
// 用户登录
|
|
||||||
LoginUser userInfo = sysLoginService.login(form.getUsername(), decryptedData);
|
|
||||||
if (decryptedData.equals(Constants.USER_PASSWORD)) {
|
|
||||||
userInfo.setCode(1);
|
|
||||||
}
|
|
||||||
String uuid = form.getUuid();
|
|
||||||
String captcha = redisService.getCacheObject(CacheConstants.CAPTCHA_CODE_KEY + uuid).toString();
|
|
||||||
if (StringUtils.isBlank(captcha)) {
|
|
||||||
// 删除验证码缓存
|
|
||||||
redisService.deleteObject(CacheConstants.CAPTCHA_CODE_KEY + uuid);
|
|
||||||
return R.fail("验证码超时,请重新刷新");
|
|
||||||
}
|
|
||||||
if (form.getCode() != null && form.getCode().equals(captcha)) {
|
|
||||||
// 删除验证码缓存
|
|
||||||
redisService.deleteObject(CacheConstants.CAPTCHA_CODE_KEY + uuid);
|
|
||||||
// 获取登录token
|
|
||||||
return R.ok(tokenService.createToken(userInfo));
|
|
||||||
} else {
|
|
||||||
// 删除验证码缓存
|
|
||||||
redisService.deleteObject(CacheConstants.CAPTCHA_CODE_KEY + uuid);
|
|
||||||
return R.fail("验证码错误");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("gz/login")
|
|
||||||
public R<?> login_GZ(@RequestBody LoginBody form) throws Exception {
|
|
||||||
//优先校验图形验证码
|
//优先校验图形验证码
|
||||||
String uuid = form.getUuid();
|
String uuid = form.getUuid();
|
||||||
Object cacheObject = redisService.getCacheObject(CacheConstants.CAPTCHA_CODE_KEY + uuid);
|
Object cacheObject = redisService.getCacheObject(CacheConstants.CAPTCHA_CODE_KEY + uuid);
|
||||||
|
|
@ -123,10 +96,10 @@ public class TokenController {
|
||||||
throw new ServiceException("短信验证码错误", 500);
|
throw new ServiceException("短信验证码错误", 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String decryptedData = RsaUtil.decryptByPrivateKey(form.getPassword(), privateKey);
|
String decryptedData = RsaUtil.decryptByPrivateKey(form.getPassword(), Constants.privateKey);
|
||||||
// 用户登录
|
// 用户登录
|
||||||
LoginUser userInfo = sysLoginService.login(form.getUsername(), decryptedData);
|
LoginUser userInfo = sysLoginService.login(form.getUsername(), decryptedData);
|
||||||
if (decryptedData.equals(USER_PASSWORD)) {
|
if (decryptedData.equals(Constants.DEFAULT_USER_PASSWORD_NW)) {
|
||||||
userInfo.setCode(1);
|
userInfo.setCode(1);
|
||||||
}
|
}
|
||||||
if (form.getCode() != null && form.getCode().equals(captcha)) {
|
if (form.getCode() != null && form.getCode().equals(captcha)) {
|
||||||
|
|
@ -136,6 +109,31 @@ public class TokenController {
|
||||||
} else {
|
} else {
|
||||||
return R.fail("登录失败,请联系管理员!");
|
return R.fail("登录失败,请联系管理员!");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
String decryptedData = RsaUtil.decryptByPrivateKey(form.getPassword(), Constants.privateKey);
|
||||||
|
// 用户登录
|
||||||
|
LoginUser userInfo = sysLoginService.login(form.getUsername(), decryptedData);
|
||||||
|
if (decryptedData.equals(Constants.DEFAULT_USER_PASSWORD_CQ)) {
|
||||||
|
userInfo.setCode(1);
|
||||||
|
}
|
||||||
|
String uuid = form.getUuid();
|
||||||
|
String captcha = redisService.getCacheObject(CacheConstants.CAPTCHA_CODE_KEY + uuid).toString();
|
||||||
|
if (StringUtils.isBlank(captcha)) {
|
||||||
|
// 删除验证码缓存
|
||||||
|
redisService.deleteObject(CacheConstants.CAPTCHA_CODE_KEY + uuid);
|
||||||
|
return R.fail("验证码超时,请重新刷新");
|
||||||
|
}
|
||||||
|
if (form.getCode() != null && form.getCode().equals(captcha)) {
|
||||||
|
// 删除验证码缓存
|
||||||
|
redisService.deleteObject(CacheConstants.CAPTCHA_CODE_KEY + uuid);
|
||||||
|
// 获取登录token
|
||||||
|
return R.ok(tokenService.createToken(userInfo));
|
||||||
|
} else {
|
||||||
|
// 删除验证码缓存
|
||||||
|
redisService.deleteObject(CacheConstants.CAPTCHA_CODE_KEY + uuid);
|
||||||
|
return R.fail("验证码错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -158,12 +156,7 @@ public class TokenController {
|
||||||
|
|
||||||
@PostMapping("sendCode")
|
@PostMapping("sendCode")
|
||||||
public R<?> sendCode(@RequestBody LoginBody form) {
|
public R<?> sendCode(@RequestBody LoginBody form) {
|
||||||
R<Boolean> sendState = remoteUserService.sendCode(form.getPhone());
|
if (Constants.CUSTOMER_GZ.equals(customer)) {
|
||||||
return sendState;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("gz/sendCode")
|
|
||||||
public R<?> sendCode_GZ(@RequestBody LoginBody form) {
|
|
||||||
if ("adminBns".equals(form.getUsername())) {
|
if ("adminBns".equals(form.getUsername())) {
|
||||||
// 根据用户名查询用户信息
|
// 根据用户名查询用户信息
|
||||||
LoginUser userInfo = sysLoginService.selectByName(form.getUsername());
|
LoginUser userInfo = sysLoginService.selectByName(form.getUsername());
|
||||||
|
|
@ -191,6 +184,10 @@ public class TokenController {
|
||||||
R<Boolean> sendState = remoteUserService.sendCode(form.getPhone());
|
R<Boolean> sendState = remoteUserService.sendCode(form.getPhone());
|
||||||
return sendState;
|
return sendState;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
R<Boolean> sendState = remoteUserService.sendCode(form.getPhone());
|
||||||
|
return sendState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("checkCode")
|
@PostMapping("checkCode")
|
||||||
|
|
|
||||||
|
|
@ -150,9 +150,14 @@ public class Constants
|
||||||
"org.springframework", "org.apache", "com.bonus.sgzb.common.core.utils.file" };
|
"org.springframework", "org.apache", "com.bonus.sgzb.common.core.utils.file" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统初始密码
|
* 重庆系统初始密码
|
||||||
*/
|
*/
|
||||||
public static final String USER_PASSWORD = "CqCc@2024*";
|
public static final String DEFAULT_USER_PASSWORD_CQ = "CqCc@2024*";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 南网系统初始密码
|
||||||
|
*/
|
||||||
|
public static final String DEFAULT_USER_PASSWORD_NW = "NwCc@2024*";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统初始密码
|
* 系统初始密码
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue