Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -60,7 +60,7 @@ public class ConfigProperties {
|
|||||||
/**
|
/**
|
||||||
* token过期时间, 单位秒
|
* token过期时间, 单位秒
|
||||||
*/
|
*/
|
||||||
private Long tokenExpireTime = 60 * 60 * 30 * 24L;
|
private Long tokenExpireTime = 60 * 60 * 365 * 24L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* token快要过期自动刷新时间, 单位分钟
|
* token快要过期自动刷新时间, 单位分钟
|
||||||
|
|||||||
@@ -145,7 +145,9 @@ public class UserRefereeController extends BaseController {
|
|||||||
|
|
||||||
final UserReferee referee = userRefereeService.getOne(new LambdaQueryWrapper<UserReferee>()
|
final UserReferee referee = userRefereeService.getOne(new LambdaQueryWrapper<UserReferee>()
|
||||||
.eq(UserReferee::getUserId, id)
|
.eq(UserReferee::getUserId, id)
|
||||||
.eq(UserReferee::getDeleted, 0));
|
.eq(UserReferee::getDeleted, 0)
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
|
||||||
if (ObjectUtil.isEmpty(referee)) {
|
if (ObjectUtil.isEmpty(referee)) {
|
||||||
return fail("查询失败", null);
|
return fail("查询失败", null);
|
||||||
|
|||||||
@@ -114,14 +114,14 @@ public class WxLoginController extends BaseController {
|
|||||||
// 查询是否存在
|
// 查询是否存在
|
||||||
User user = userService.getByPhone(phone);
|
User user = userService.getByPhone(phone);
|
||||||
// 超级管理员验证
|
// 超级管理员验证
|
||||||
if(userParam.getIsSuperAdmin() != null){
|
if (userParam.getIsSuperAdmin() != null) {
|
||||||
final LoginParam loginParam = new LoginParam();
|
final LoginParam loginParam = new LoginParam();
|
||||||
loginParam.setIsAdmin(true);
|
loginParam.setIsAdmin(true);
|
||||||
loginParam.setPhone(phone);
|
loginParam.setPhone(phone);
|
||||||
final List<User> adminsByPhone = userService.getAdminsByPhone(loginParam);
|
final List<User> adminsByPhone = userService.getAdminsByPhone(loginParam);
|
||||||
if (!CollectionUtils.isEmpty(adminsByPhone)) {
|
if (!CollectionUtils.isEmpty(adminsByPhone)) {
|
||||||
user = adminsByPhone.get(0);
|
user = adminsByPhone.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 不存在则注册
|
// 不存在则注册
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
@@ -137,18 +137,18 @@ public class WxLoginController extends BaseController {
|
|||||||
userParam.setPhone(phone);
|
userParam.setPhone(phone);
|
||||||
user = addUser(userParam);
|
user = addUser(userParam);
|
||||||
user.setRecommend(1);
|
user.setRecommend(1);
|
||||||
}else {
|
} else {
|
||||||
// 存在则检查绑定上级
|
// 存在则检查绑定上级
|
||||||
if (userParam.getSceneType() != null && userParam.getSceneType().equals("save_referee") && userParam.getRefereeId() != null && userParam.getRefereeId() != 0) {
|
if (userParam.getSceneType() != null && userParam.getSceneType().equals("save_referee") && userParam.getRefereeId() != null && userParam.getRefereeId() != 0) {
|
||||||
UserReferee check = userRefereeService.check(user.getUserId(), userParam.getRefereeId());
|
UserReferee check = userRefereeService.check(user.getUserId(), userParam.getRefereeId());
|
||||||
if (check == null) {
|
if (check == null) {
|
||||||
UserReferee userReferee = new UserReferee();
|
UserReferee userReferee = new UserReferee();
|
||||||
userReferee.setDealerId(userParam.getRefereeId());
|
userReferee.setDealerId(userParam.getRefereeId());
|
||||||
userReferee.setUserId(user.getUserId());
|
userReferee.setUserId(user.getUserId());
|
||||||
userRefereeService.save(userReferee);
|
userRefereeService.save(userReferee);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// 签发token
|
// 签发token
|
||||||
String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()),
|
String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()),
|
||||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||||
@@ -437,16 +437,16 @@ public class WxLoginController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation("openid无感登录")
|
@ApiOperation("openid无感登录")
|
||||||
@PostMapping("/loginByOpenId")
|
@PostMapping("/loginByOpenId")
|
||||||
public ApiResult<?> loginByOpenId(@RequestBody Mp mp,HttpServletRequest request) {
|
public ApiResult<?> loginByOpenId(@RequestBody Mp mp, HttpServletRequest request) {
|
||||||
// 获取小程序配置信息
|
// 获取小程序配置信息
|
||||||
String key1 = "AppId:".concat(mp.getTenantId().toString());
|
String key1 = "AppId:".concat(mp.getTenantId().toString());
|
||||||
String key2 = "AppSecret:".concat(mp.getTenantId().toString());
|
String key2 = "AppSecret:".concat(mp.getTenantId().toString());
|
||||||
String AppId = redisUtil.get(key1);
|
String AppId = redisUtil.get(key1);
|
||||||
String AppSecret = redisUtil.get(key2);
|
String AppSecret = redisUtil.get(key2);
|
||||||
if (StrUtil.isBlank(AppId) || StrUtil.isBlank(AppSecret)) {
|
if (StrUtil.isBlank(AppId) || StrUtil.isBlank(AppSecret)) {
|
||||||
final JSONObject setting = settingService.getBySettingKey("mp-weixin");
|
final JSONObject setting = settingService.getBySettingKey("mp-weixin");
|
||||||
AppId = setting.getString("appId");
|
AppId = setting.getString("appId");
|
||||||
AppSecret = setting.getString("appSecret");
|
AppSecret = setting.getString("appSecret");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 请求微信接口获取openid
|
// 请求微信接口获取openid
|
||||||
@@ -465,11 +465,11 @@ public class WxLoginController extends BaseController {
|
|||||||
if (StrUtil.isNotBlank(openid)) {
|
if (StrUtil.isNotBlank(openid)) {
|
||||||
User user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getOpenid, openid).last("limit 1"));
|
User user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getOpenid, openid).last("limit 1"));
|
||||||
if (ObjectUtil.isNotEmpty(user)) {
|
if (ObjectUtil.isNotEmpty(user)) {
|
||||||
// 签发token
|
// 签发token
|
||||||
String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()),
|
String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()),
|
||||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||||
loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_REGISTER, null, user.getTenantId(), request);
|
loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_REGISTER, null, user.getTenantId(), request);
|
||||||
return success("登录成功", new LoginResult(access_token, user));
|
return success("登录成功", new LoginResult(access_token, user));
|
||||||
}
|
}
|
||||||
return fail("用户未注册", openid);
|
return fail("用户未注册", openid);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user