登录部分
This commit is contained in:
@@ -320,18 +320,21 @@ public class LoginContoller {
|
|||||||
@PostMapping("/app/login")
|
@PostMapping("/app/login")
|
||||||
public Result applogin(@RequestBody AuthUserDto authUserDto) {
|
public Result applogin(@RequestBody AuthUserDto authUserDto) {
|
||||||
boolean tf = false;
|
boolean tf = false;
|
||||||
|
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(authUserDto.getOpencode(), customAppId, customSecrete);
|
||||||
|
// 3.接收微信接口服务 获取返回的参数
|
||||||
|
String openid = SessionKeyOpenId.getString("openid");
|
||||||
if (ObjectUtil.isNull(authUserDto.getCode())) {
|
if (ObjectUtil.isNull(authUserDto.getCode())) {
|
||||||
if (StringUtils.isBlank(authUserDto.getPassword())) {
|
if (StringUtils.isBlank(authUserDto.getPassword())) {
|
||||||
return Result.fail("请输入密码,或使用验证码登录");
|
return Result.fail("请输入密码,或使用验证码登录");
|
||||||
}
|
}
|
||||||
//验证密码
|
//验证密码
|
||||||
String mdPasswordString = MD5Utils.MD5Encode(authUserDto.getPassword(), "utf-8");
|
String mdPasswordString = MD5Utils.MD5Encode(authUserDto.getPassword(), "utf-8");
|
||||||
return loginService.appLogin(authUserDto.getUsername(), mdPasswordString);
|
return loginService.appLogin(authUserDto.getUsername(),openid, mdPasswordString);
|
||||||
} else {
|
} else {
|
||||||
// tf = true;
|
// tf = true;
|
||||||
tf = loginService.validate(authUserDto.getCode(), authUserDto.getUsername());
|
tf = loginService.validate(authUserDto.getCode(), authUserDto.getUsername());
|
||||||
if (tf) {
|
if (tf) {
|
||||||
return loginService.appLogin(authUserDto.getUsername(), null);
|
return loginService.appLogin(authUserDto.getUsername(),openid, null);
|
||||||
} else {
|
} else {
|
||||||
return Result.fail("验证码输入有误");
|
return Result.fail("验证码输入有误");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class AuthUserDto {
|
|||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
|
private String opencode;
|
||||||
|
|
||||||
private String uuid = "";
|
private String uuid = "";
|
||||||
|
|
||||||
@@ -47,4 +48,12 @@ public class AuthUserDto {
|
|||||||
public void setUuid(String uuid) {
|
public void setUuid(String uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getOpencode() {
|
||||||
|
return opencode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpencode(String opencode) {
|
||||||
|
this.opencode = opencode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ public class LoginService {
|
|||||||
* @param nickName
|
* @param nickName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TbUserInfo register(String phone, String password, String nickName) {
|
public TbUserInfo register(String phone, String openId,String password, String nickName) {
|
||||||
|
|
||||||
TbUserInfo userInfo = new TbUserInfo();
|
TbUserInfo userInfo = new TbUserInfo();
|
||||||
userInfo.setAmount(BigDecimal.ZERO);
|
userInfo.setAmount(BigDecimal.ZERO);
|
||||||
@@ -202,6 +202,9 @@ public class LoginService {
|
|||||||
userInfo.setLastLogInAt(System.currentTimeMillis());
|
userInfo.setLastLogInAt(System.currentTimeMillis());
|
||||||
userInfo.setCreatedAt(System.currentTimeMillis());
|
userInfo.setCreatedAt(System.currentTimeMillis());
|
||||||
userInfo.setUpdatedAt(System.currentTimeMillis());
|
userInfo.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
userInfo.setMiniAppOpenId(openId);
|
||||||
|
userInfo.setIsPwd("0");
|
||||||
|
userInfo.setPwd(MD5Utils.md5("123456"));
|
||||||
if (StringUtils.isNotBlank(password)) {
|
if (StringUtils.isNotBlank(password)) {
|
||||||
userInfo.setPassword(MD5Utils.MD5Encode(password, "UTF-8"));
|
userInfo.setPassword(MD5Utils.MD5Encode(password, "UTF-8"));
|
||||||
}
|
}
|
||||||
@@ -234,14 +237,19 @@ public class LoginService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result appLogin(String username, String password) {
|
public Result appLogin(String username,String openId, String password) {
|
||||||
TbUserInfo userInfo = tbUserInfoMapper.selectByPhone(username);
|
TbUserInfo userInfo = tbUserInfoMapper.selectByPhone(username);
|
||||||
if (ObjectUtil.isNull(userInfo)) {
|
if (ObjectUtil.isNull(userInfo)) {
|
||||||
if (StringUtils.isNotBlank(password)) {
|
if (StringUtils.isNotBlank(password)) {
|
||||||
return Result.fail("暂未设置密码,请使用验证码登录");
|
return Result.fail("暂未设置密码,请使用验证码登录");
|
||||||
}
|
}
|
||||||
userInfo = register(username, password, username);
|
userInfo = register(username,openId, password, username);
|
||||||
} else {
|
} else {
|
||||||
|
if (StringUtils.isNotBlank(userInfo.getMiniAppOpenId())) {
|
||||||
|
if (!userInfo.getMiniAppOpenId().equals(openId)) {
|
||||||
|
userInfo.setMiniAppOpenId(openId);
|
||||||
|
}
|
||||||
|
}
|
||||||
String searchWord = userInfo.getSearchWord();
|
String searchWord = userInfo.getSearchWord();
|
||||||
if (!searchWord.contains("移动端用户")) {
|
if (!searchWord.contains("移动端用户")) {
|
||||||
userInfo.setSearchWord(userInfo.getSearchWord() + "||移动端用户");
|
userInfo.setSearchWord(userInfo.getSearchWord() + "||移动端用户");
|
||||||
|
|||||||
Reference in New Issue
Block a user