fix: 处理问题
This commit is contained in:
parent
4b4ebe9cee
commit
c4a4d6374d
@ -17,6 +17,7 @@ import ink.wgink.pojo.dtos.role.RoleSimpleDTO;
|
|||||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||||
import ink.wgink.properties.ServerProperties;
|
import ink.wgink.properties.ServerProperties;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -59,21 +60,19 @@ public class SystemUserRouteController extends DefaultBaseController {
|
|||||||
UserInfoBO userInfoBO = this.securityComponent.getCurrentUser();
|
UserInfoBO userInfoBO = this.securityComponent.getCurrentUser();
|
||||||
List<RoleSimpleDTO> roleSimpleDTOList = userInfoBO.getRoles();
|
List<RoleSimpleDTO> roleSimpleDTOList = userInfoBO.getRoles();
|
||||||
String url = systemProperties.getUrl();
|
String url = systemProperties.getUrl();
|
||||||
if(userInfoBO == null) {
|
if (userInfoBO.getUserId().equals("1")) {
|
||||||
return new ModelAndView("systemuser/login");
|
|
||||||
}
|
|
||||||
if(userInfoBO.getUserId().equals("1")) {
|
|
||||||
return new ModelAndView("forward:/default-main");
|
return new ModelAndView("forward:/default-main");
|
||||||
}
|
}
|
||||||
if (roleSimpleDTOList == null || roleSimpleDTOList.size() < 1) {
|
if (roleSimpleDTOList == null || roleSimpleDTOList.isEmpty()) {
|
||||||
throw new SaveException("角色不存在");
|
throw new SaveException("角色不存在");
|
||||||
}
|
}
|
||||||
if(roleSimpleDTOList.get(0).getRoleName().contains("普通用户")) {
|
boolean isAdmin = roleSimpleDTOList.stream().anyMatch(roleSimpleDTO -> StringUtils.equals("运营平台", roleSimpleDTO.getRoleName()) ||
|
||||||
return new ModelAndView(new RedirectView(ProjectConfigUtil.getText("AiServerUrl")));
|
StringUtils.equals("项目运营", roleSimpleDTO.getRoleName()) ||
|
||||||
}else if(roleSimpleDTOList.get(0).getRoleName().contains("代理商")) {
|
StringUtils.equals("开发人员", roleSimpleDTO.getRoleName()));
|
||||||
return new ModelAndView(new RedirectView(ProjectConfigUtil.getText("AgentServerUrl")));
|
if (isAdmin || userInfoBO.getUserId().equals("1")) {
|
||||||
}else if(roleSimpleDTOList.get(0).getRoleName().contains("运营平台") || userInfoBO.getUserId().equals("1")){
|
|
||||||
return new ModelAndView("forward:/default-main");
|
return new ModelAndView("forward:/default-main");
|
||||||
|
} else if (roleSimpleDTOList.stream().anyMatch(roleSimpleDTO -> StringUtils.equals("普通用户", roleSimpleDTO.getRoleName()))) {
|
||||||
|
return new ModelAndView(new RedirectView(ProjectConfigUtil.getText("AiServerUrl")));
|
||||||
}
|
}
|
||||||
return new ModelAndView("systemuser/login?error=无权限访问");
|
return new ModelAndView("systemuser/login?error=无权限访问");
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,8 @@ public class UserExpandDTO extends UserDTO {
|
|||||||
* 子账号关联的主账号ID
|
* 子账号关联的主账号ID
|
||||||
*/
|
*/
|
||||||
private String mainUserId;
|
private String mainUserId;
|
||||||
|
private String wxMiniappOpenId;
|
||||||
|
private String wxOfficialAccountOpenId;
|
||||||
|
|
||||||
public String getSubUserIds() {
|
public String getSubUserIds() {
|
||||||
return subUserIds == null ? "" : subUserIds.trim();
|
return subUserIds == null ? "" : subUserIds.trim();
|
||||||
@ -244,4 +246,20 @@ public class UserExpandDTO extends UserDTO {
|
|||||||
public void setRelationIcUserId(String relationIcUserId) {
|
public void setRelationIcUserId(String relationIcUserId) {
|
||||||
this.relationIcUserId = relationIcUserId;
|
this.relationIcUserId = relationIcUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getWxMiniappOpenId() {
|
||||||
|
return wxMiniappOpenId == null ? "" : wxMiniappOpenId.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWxMiniappOpenId(String wxMiniappOpenId) {
|
||||||
|
this.wxMiniappOpenId = wxMiniappOpenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWxOfficialAccountOpenId() {
|
||||||
|
return wxOfficialAccountOpenId == null ? "" : wxOfficialAccountOpenId.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWxOfficialAccountOpenId(String wxOfficialAccountOpenId) {
|
||||||
|
this.wxOfficialAccountOpenId = wxOfficialAccountOpenId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,15 @@ import ink.wgink.register.base.pojo.vos.RegisterPhoneVO;
|
|||||||
import ink.wgink.register.base.service.IRegisterService;
|
import ink.wgink.register.base.service.IRegisterService;
|
||||||
import ink.wgink.service.user.pojo.pos.UserPO;
|
import ink.wgink.service.user.pojo.pos.UserPO;
|
||||||
import ink.wgink.service.user.service.IUserService;
|
import ink.wgink.service.user.service.IUserService;
|
||||||
|
import ink.wgink.util.date.DateUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.joda.time.LocalDateTime;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -56,13 +59,11 @@ public class UserWxMiniappService {
|
|||||||
*/
|
*/
|
||||||
public void refreshAccessToken() {
|
public void refreshAccessToken() {
|
||||||
long currentTimeMillis = System.currentTimeMillis();
|
long currentTimeMillis = System.currentTimeMillis();
|
||||||
if (miniappAccessToken != null) {
|
if (miniappAccessToken != null && (currentTimeMillis - miniappAccessToken.getUpdateTime() < 5400000)) {
|
||||||
long lastTime = miniappAccessToken.getWxAccessToken().getExpires_in() / 4 * 3;
|
LOG.debug("小程序 access_token 不需要刷新, 刷新时间: {}", LocalDateTime.fromDateFields(new Date(miniappAccessToken.getUpdateTime() + 5400000)));
|
||||||
if (currentTimeMillis - miniappAccessToken.getUpdateTime() < lastTime) {
|
|
||||||
LOG.debug("小程序 access_token 不需要刷新, 剩余时间: {}", lastTime);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
LOG.debug("小程序 access_token 刷新");
|
||||||
WxAccessToken wxAccessToken = wxMiniappRemoteService.getAccessToken(WX_API_BASE_URL, new HashMap<String, Object>() {{
|
WxAccessToken wxAccessToken = wxMiniappRemoteService.getAccessToken(WX_API_BASE_URL, new HashMap<String, Object>() {{
|
||||||
put("grant_type", "client_credential");
|
put("grant_type", "client_credential");
|
||||||
put("appid", wxMiniappProperties.getAppid());
|
put("appid", wxMiniappProperties.getAppid());
|
||||||
@ -95,7 +96,7 @@ public class UserWxMiniappService {
|
|||||||
appLoginPhoneVO.setUsername(userPO.getUserUsername());
|
appLoginPhoneVO.setUsername(userPO.getUserUsername());
|
||||||
String token = appSignService.phoneSign(appLoginPhoneVO);
|
String token = appSignService.phoneSign(appLoginPhoneVO);
|
||||||
// 如果有账号返回accessToken
|
// 如果有账号返回accessToken
|
||||||
return new UserWxLoginDTO(wxLoginResult.getOpenid(), token, 0);
|
return new UserWxLoginDTO(wxLoginResult.getOpenid(), token, 0, userPO.getUserUsername());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error(e.getMessage(), e);
|
LOG.error(e.getMessage(), e);
|
||||||
throw new SystemException("登录异常");
|
throw new SystemException("登录异常");
|
||||||
@ -129,7 +130,7 @@ public class UserWxMiniappService {
|
|||||||
appLoginPhoneVO.setUsername(poByUsername.getUserUsername());
|
appLoginPhoneVO.setUsername(poByUsername.getUserUsername());
|
||||||
String token = appSignService.phoneSign(appLoginPhoneVO);
|
String token = appSignService.phoneSign(appLoginPhoneVO);
|
||||||
accessTokenService.set2Redis(poByUsername.getUserId(), token);
|
accessTokenService.set2Redis(poByUsername.getUserId(), token);
|
||||||
return new UserWxLoginDTO(openid, token, 0);
|
return new UserWxLoginDTO(openid, token, 0, poByUsername.getUserUsername());
|
||||||
}
|
}
|
||||||
// 执行注册
|
// 执行注册
|
||||||
RegisterPhoneVO registerPhoneVO = new RegisterPhoneVO();
|
RegisterPhoneVO registerPhoneVO = new RegisterPhoneVO();
|
||||||
@ -146,7 +147,7 @@ public class UserWxMiniappService {
|
|||||||
appLoginPhoneVO.setUsername(poByUsername.getUserUsername());
|
appLoginPhoneVO.setUsername(poByUsername.getUserUsername());
|
||||||
String token = appSignService.phoneSign(appLoginPhoneVO);
|
String token = appSignService.phoneSign(appLoginPhoneVO);
|
||||||
accessTokenService.set2Redis(poByUsername.getUserId(), token);
|
accessTokenService.set2Redis(poByUsername.getUserId(), token);
|
||||||
return new UserWxLoginDTO(openid, token, 0, phone);
|
return new UserWxLoginDTO(openid, token, 1, phone);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error(e.getMessage(), e);
|
LOG.error(e.getMessage(), e);
|
||||||
throw new SystemException("注册异常");
|
throw new SystemException("注册异常");
|
||||||
|
Loading…
Reference in New Issue
Block a user