diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index 836306fe..fc628c0f 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -82,33 +82,6 @@ public class ResourceController { @Value("${qdyjj.ipAndPort}") private String ipAndPort; - @Value("${zsk.appid}") - private String appId; - - @Value("${zsk.appkey}") - private String appKey; - - @Value("${zsk.url.sign}") - private String sign; - - @Value("${zsk.url.gateway}") - private String gateway; - - @Value("${zsk.methodId}") - private String methodId; - - @Value("${zsk.param.charset}") - private String charset; - - @Value("${zsk.param.origin}") - private String origin; - - @Value("${zsk.param.version}") - private String version; - - @Value("${zsk.catalogIds}") - private String[] catalogIds; - @Value("${resource.path}") private String uploadPath; diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index c472dd83..3efa2614 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -83,6 +83,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; import javax.annotation.Resource; @@ -2742,7 +2743,13 @@ public class ResourceServiceImpl extends CrudServiceImpl requestEntity = new HttpEntity(param, new HttpHeaders()); - return restTemplate.postForEntity("http://15.72.183.88:8760/yzy/main/cloudresource/getResourceBusinessList", requestEntity, String.class).getBody(); + String body; + try { + body = restTemplate.postForEntity("http://15.72.183.88:8760/yzy/main/cloudresource/getResourceBusinessList", requestEntity, String.class).getBody(); + } catch (RestClientException e) { + throw new RuntimeException("云资源数据查询失败!"); + } + return body; } @Override @@ -2752,7 +2759,13 @@ public class ResourceServiceImpl extends CrudServiceImpl requestEntity = new HttpEntity(param, new HttpHeaders()); - return restTemplate.postForEntity("http://15.72.183.88:8760/yzy/main/cloudresource/getVideoBusinessList", requestEntity, String.class).getBody(); + String body; + try { + body = restTemplate.postForEntity("http://15.72.183.88:8760/yzy/main/cloudresource/getVideoBusinessList", requestEntity, String.class).getBody(); + } catch (RestClientException e) { + throw new RuntimeException("云视频查询失败!"); + } + return body; } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Realm.java b/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Realm.java index 4e1a7d41..88f2405e 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Realm.java +++ b/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Realm.java @@ -13,6 +13,7 @@ import org.apache.shiro.authz.SimpleAuthorizationInfo; import org.apache.shiro.realm.AuthorizingRealm; import org.apache.shiro.subject.PrincipalCollection; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.util.List; @@ -26,6 +27,9 @@ public class Oauth2Realm extends AuthorizingRealm { @Autowired private ShiroService shiroService; + @Value("${system.allowSimultaneousLogin}") + private int allowSimultaneousLogin; + @Override public boolean supports(AuthenticationToken token) { return token instanceof Oauth2Token; @@ -55,8 +59,15 @@ public class Oauth2Realm extends AuthorizingRealm { //根据accessToken,查询用户信息 SysUserTokenEntity tokenEntity = shiroService.getByToken(accessToken); + + //判断是否允许同时登录,0:不允许,1:允许 + //允许同时在线时不校验过期时间 + if (allowSimultaneousLogin != 1 && tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()) { + throw new IncorrectCredentialsException(MessageUtils.getMessage(ErrorCode.TOKEN_INVALID)); + } + //token失效 - if (tokenEntity == null || tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()) { + if (tokenEntity == null) { throw new IncorrectCredentialsException(MessageUtils.getMessage(ErrorCode.TOKEN_INVALID)); } @@ -66,11 +77,15 @@ public class Oauth2Realm extends AuthorizingRealm { //转换成UserDetail对象 UserDetail userDetail = ConvertUtils.sourceToTarget(userEntity, UserDetail.class); - //账号锁定 + //账号停用 if (userDetail.getStatus() == 0) { throw new LockedAccountException(MessageUtils.getMessage(ErrorCode.ACCOUNT_LOCK)); } + if (userDetail.getStatus() == 2) { + throw new LockedAccountException(MessageUtils.getMessage(500 ,"账号已锁定!")); + } + //获取用户对应的部门数据权限 List deptIdList = shiroService.getDataScopeList(userDetail.getId()); userDetail.setDeptIdList(deptIdList); diff --git a/renren-admin/src/main/java/io/renren/modules/security/service/impl/SysUserTokenServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/security/service/impl/SysUserTokenServiceImpl.java index afc3307b..5b2460e3 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/service/impl/SysUserTokenServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/security/service/impl/SysUserTokenServiceImpl.java @@ -12,6 +12,7 @@ import io.renren.modules.security.entity.SysUserTokenEntity; import io.renren.modules.security.oauth2.TokenGenerator; import io.renren.modules.security.service.SysUserTokenService; import io.renren.modules.sys.entity.SysOnlineEntity; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.util.Date; @@ -21,11 +22,17 @@ import java.util.Map; @Service public class SysUserTokenServiceImpl extends BaseServiceImpl implements SysUserTokenService { + + /** * 12小时后过期 */ private final static int EXPIRE = 3600 * 12; + @Value("${system.allowSimultaneousLogin}") + private int allowSimultaneousLogin; + + /* @Override public Result createToken(Long userId) { //用户token @@ -81,6 +88,56 @@ public class SysUserTokenServiceImpl extends BaseServiceImpl map = new HashMap<>(2); + map.put(Constant.TOKEN_HEADER, token); + map.put("expire", EXPIRE); + return new Result().ok(map); + } + @Override public void logout(Long userId) { diff --git a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysMenuController.java b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysMenuController.java index cb808686..b56a5de4 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysMenuController.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysMenuController.java @@ -55,8 +55,8 @@ public class SysMenuController { @ApiOperation("列表") @ApiImplicitParam(name = "type", value = "菜单类型 0:菜单 1:按钮 null:全部", paramType = "query", dataType = "int") // @RequiresPermissions("sys:menu:list") - public Result> list(Integer type) { - List list = sysMenuService.getAllMenuList(type); + public Result> list(Integer type, String name) { + List list = sysMenuService.getAllMenuList(type, name); return new Result>().ok(list); } diff --git a/renren-admin/src/main/java/io/renren/modules/sys/dao/SysMenuDao.java b/renren-admin/src/main/java/io/renren/modules/sys/dao/SysMenuDao.java index e9470d12..4a1467a2 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/dao/SysMenuDao.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/dao/SysMenuDao.java @@ -21,7 +21,7 @@ public interface SysMenuDao extends BaseDao { * @param type 菜单类型 * @param language 语言 */ - List getMenuList(@Param("type") Integer type, @Param("language") String language); + List getMenuList(@Param("type") Integer type, @Param("language") String language, @Param("name") String name); /** * 查询用户菜单列表 diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/SysMenuService.java b/renren-admin/src/main/java/io/renren/modules/sys/service/SysMenuService.java index 28c007f4..57a8a328 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/SysMenuService.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/SysMenuService.java @@ -26,7 +26,7 @@ public interface SysMenuService extends BaseService { * * @param type 菜单类型 */ - List getAllMenuList(Integer type); + List getAllMenuList(Integer type, String name); /** * 用户菜单列表 diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysMenuServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysMenuServiceImpl.java index a505fa67..f97029c7 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysMenuServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysMenuServiceImpl.java @@ -76,8 +76,8 @@ public class SysMenuServiceImpl extends BaseServiceImpl getAllMenuList(Integer type) { - List menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage()); + public List getAllMenuList(Integer type, String name) { + List menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage(), name); List dtoList = ConvertUtils.sourceToTarget(menuList, SysMenuDTO.class); @@ -90,7 +90,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl - - - - - - - - - - update sys_user_token set expire_date = #{expireDate} where user_id = #{userId} - - - - \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/sys/SysMenuDao.xml b/renren-admin/src/main/resources/mapper/sys/SysMenuDao.xml index bae830e0..8832dd90 100644 --- a/renren-admin/src/main/resources/mapper/sys/SysMenuDao.xml +++ b/renren-admin/src/main/resources/mapper/sys/SysMenuDao.xml @@ -14,14 +14,20 @@ diff --git a/renren-admin/src/main/resources/mapper/sys/SysUserTokenDao.xml b/renren-admin/src/main/resources/mapper/sys/SysUserTokenDao.xml index a740f630..29328e61 100644 --- a/renren-admin/src/main/resources/mapper/sys/SysUserTokenDao.xml +++ b/renren-admin/src/main/resources/mapper/sys/SysUserTokenDao.xml @@ -8,7 +8,7 @@