1.增加允许账号多地同时在线功能
2.去除无用注入 3.云资源和云视频调用失败异常处理 4.菜单管理新增按名称模糊查询 5.同步字典表新增数据
This commit is contained in:
parent
3199f917e7
commit
acdcf5b25c
|
@ -82,33 +82,6 @@ public class ResourceController {
|
||||||
@Value("${qdyjj.ipAndPort}")
|
@Value("${qdyjj.ipAndPort}")
|
||||||
private String 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}")
|
@Value("${resource.path}")
|
||||||
private String uploadPath;
|
private String uploadPath;
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.LinkedMultiValueMap;
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.web.client.RestClientException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -2742,7 +2743,13 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
param.add("userAccount", userAccount);
|
param.add("userAccount", userAccount);
|
||||||
param.add("status", status);
|
param.add("status", status);
|
||||||
HttpEntity<String> requestEntity = new HttpEntity(param, new HttpHeaders());
|
HttpEntity<String> 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
|
@Override
|
||||||
|
@ -2752,7 +2759,13 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
param.add("userAccount", userAccount);
|
param.add("userAccount", userAccount);
|
||||||
param.add("status", status);
|
param.add("status", status);
|
||||||
HttpEntity<String> requestEntity = new HttpEntity(param, new HttpHeaders());
|
HttpEntity<String> 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -13,6 +13,7 @@ import org.apache.shiro.authz.SimpleAuthorizationInfo;
|
||||||
import org.apache.shiro.realm.AuthorizingRealm;
|
import org.apache.shiro.realm.AuthorizingRealm;
|
||||||
import org.apache.shiro.subject.PrincipalCollection;
|
import org.apache.shiro.subject.PrincipalCollection;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -26,6 +27,9 @@ public class Oauth2Realm extends AuthorizingRealm {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShiroService shiroService;
|
private ShiroService shiroService;
|
||||||
|
|
||||||
|
@Value("${system.allowSimultaneousLogin}")
|
||||||
|
private int allowSimultaneousLogin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supports(AuthenticationToken token) {
|
public boolean supports(AuthenticationToken token) {
|
||||||
return token instanceof Oauth2Token;
|
return token instanceof Oauth2Token;
|
||||||
|
@ -55,8 +59,15 @@ public class Oauth2Realm extends AuthorizingRealm {
|
||||||
|
|
||||||
//根据accessToken,查询用户信息
|
//根据accessToken,查询用户信息
|
||||||
SysUserTokenEntity tokenEntity = shiroService.getByToken(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失效
|
//token失效
|
||||||
if (tokenEntity == null || tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()) {
|
if (tokenEntity == null) {
|
||||||
throw new IncorrectCredentialsException(MessageUtils.getMessage(ErrorCode.TOKEN_INVALID));
|
throw new IncorrectCredentialsException(MessageUtils.getMessage(ErrorCode.TOKEN_INVALID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,11 +77,15 @@ public class Oauth2Realm extends AuthorizingRealm {
|
||||||
//转换成UserDetail对象
|
//转换成UserDetail对象
|
||||||
UserDetail userDetail = ConvertUtils.sourceToTarget(userEntity, UserDetail.class);
|
UserDetail userDetail = ConvertUtils.sourceToTarget(userEntity, UserDetail.class);
|
||||||
|
|
||||||
//账号锁定
|
//账号停用
|
||||||
if (userDetail.getStatus() == 0) {
|
if (userDetail.getStatus() == 0) {
|
||||||
throw new LockedAccountException(MessageUtils.getMessage(ErrorCode.ACCOUNT_LOCK));
|
throw new LockedAccountException(MessageUtils.getMessage(ErrorCode.ACCOUNT_LOCK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (userDetail.getStatus() == 2) {
|
||||||
|
throw new LockedAccountException(MessageUtils.getMessage(500 ,"账号已锁定!"));
|
||||||
|
}
|
||||||
|
|
||||||
//获取用户对应的部门数据权限
|
//获取用户对应的部门数据权限
|
||||||
List<Long> deptIdList = shiroService.getDataScopeList(userDetail.getId());
|
List<Long> deptIdList = shiroService.getDataScopeList(userDetail.getId());
|
||||||
userDetail.setDeptIdList(deptIdList);
|
userDetail.setDeptIdList(deptIdList);
|
||||||
|
|
|
@ -55,8 +55,8 @@ public class SysMenuController {
|
||||||
@ApiOperation("列表")
|
@ApiOperation("列表")
|
||||||
@ApiImplicitParam(name = "type", value = "菜单类型 0:菜单 1:按钮 null:全部", paramType = "query", dataType = "int")
|
@ApiImplicitParam(name = "type", value = "菜单类型 0:菜单 1:按钮 null:全部", paramType = "query", dataType = "int")
|
||||||
// @RequiresPermissions("sys:menu:list")
|
// @RequiresPermissions("sys:menu:list")
|
||||||
public Result<List<SysMenuDTO>> list(Integer type) {
|
public Result<List<SysMenuDTO>> list(Integer type, String name) {
|
||||||
List<SysMenuDTO> list = sysMenuService.getAllMenuList(type);
|
List<SysMenuDTO> list = sysMenuService.getAllMenuList(type, name);
|
||||||
|
|
||||||
return new Result<List<SysMenuDTO>>().ok(list);
|
return new Result<List<SysMenuDTO>>().ok(list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public interface SysMenuDao extends BaseDao<SysMenuEntity> {
|
||||||
* @param type 菜单类型
|
* @param type 菜单类型
|
||||||
* @param language 语言
|
* @param language 语言
|
||||||
*/
|
*/
|
||||||
List<SysMenuEntity> getMenuList(@Param("type") Integer type, @Param("language") String language);
|
List<SysMenuEntity> getMenuList(@Param("type") Integer type, @Param("language") String language, @Param("name") String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户菜单列表
|
* 查询用户菜单列表
|
||||||
|
|
|
@ -26,7 +26,7 @@ public interface SysMenuService extends BaseService<SysMenuEntity> {
|
||||||
*
|
*
|
||||||
* @param type 菜单类型
|
* @param type 菜单类型
|
||||||
*/
|
*/
|
||||||
List<SysMenuDTO> getAllMenuList(Integer type);
|
List<SysMenuDTO> getAllMenuList(Integer type, String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户菜单列表
|
* 用户菜单列表
|
||||||
|
|
|
@ -76,8 +76,8 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuDao, SysMenuEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysMenuDTO> getAllMenuList(Integer type) {
|
public List<SysMenuDTO> getAllMenuList(Integer type, String name) {
|
||||||
List<SysMenuEntity> menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage());
|
List<SysMenuEntity> menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage(), name);
|
||||||
|
|
||||||
List<SysMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, SysMenuDTO.class);
|
List<SysMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, SysMenuDTO.class);
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuDao, SysMenuEntit
|
||||||
|
|
||||||
//系统管理员,拥有最高权限
|
//系统管理员,拥有最高权限
|
||||||
if (user.getSuperAdmin() == SuperAdminEnum.YES.value()) {
|
if (user.getSuperAdmin() == SuperAdminEnum.YES.value()) {
|
||||||
menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage());
|
menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage(), null);
|
||||||
} else {
|
} else {
|
||||||
menuList = baseDao.getUserMenuList(user.getId(), type, HttpContextUtils.getLanguage());
|
menuList = baseDao.getUserMenuList(user.getId(), type, HttpContextUtils.getLanguage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
DELETE
|
||||||
|
FROM sys_user_token
|
||||||
|
WHERE id NOT IN (SELECT s.id
|
||||||
|
FROM (SELECT sut.id,
|
||||||
|
ROW_NUMBER() OVER ( PARTITION BY sut.user_id ORDER BY sut.create_date DESC ) AS group_idx
|
||||||
|
FROM sys_user_token sut) s
|
||||||
|
WHERE s.group_idx = 1);
|
|
@ -0,0 +1,11 @@
|
||||||
|
INSERT INTO `sys_dict_type`(`id`, `dict_type`, `dict_name`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`, `status`) VALUES (1592357067014803457, ' encryptedRoute', '加密路由', '', 0, 1067246875800000001, '2022-11-15 11:21:24', 1067246875800000001, '2022-11-15 11:21:24', 1);
|
||||||
|
|
||||||
|
INSERT INTO `sys_dict_data`(`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`, `status`) VALUES (1592357815098281986, 1592357067014803457, '个人中心', '/personalCenter', '', 0, 1067246875800000001, '2022-11-15 11:24:22', 1067246875800000001, '2022-11-15 11:24:22', 1);
|
||||||
|
INSERT INTO `sys_dict_data`(`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`, `status`) VALUES (1592357749759414274, 1592357067014803457, '消息通知', '/mynoticeView', '', 0, 1067246875800000001, '2022-11-15 11:24:07', 1067246875800000001, '2022-11-15 11:24:07', 1);
|
||||||
|
INSERT INTO `sys_dict_data`(`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`, `status`) VALUES (1592357668599631874, 1592357067014803457, '融合服务详情', '/integrationServicesDetails', '', 0, 1067246875800000001, '2022-11-15 11:23:47', 1067246875800000001, '2022-11-15 11:23:47', 1);
|
||||||
|
INSERT INTO `sys_dict_data`(`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`, `status`) VALUES (1592357561145757698, 1592357067014803457, '融合服务', '/integrationServices', '', 0, 1067246875800000001, '2022-11-15 11:23:22', 1067246875800000001, '2022-11-15 11:23:22', 1);
|
||||||
|
INSERT INTO `sys_dict_data`(`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`, `status`) VALUES (1592357495567814658, 1592357067014803457, '能力统计', '/abilityStatistics', '', 0, 1067246875800000001, '2022-11-15 11:23:06', 1067246875800000001, '2022-11-15 11:23:06', 1);
|
||||||
|
INSERT INTO `sys_dict_data`(`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`, `status`) VALUES (1592357417113358338, 1592357067014803457, '能力详情', '/details', '', 0, 1067246875800000001, '2022-11-15 11:22:47', 1067246875800000001, '2022-11-15 11:22:47', 1);
|
||||||
|
INSERT INTO `sys_dict_data`(`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`, `status`) VALUES (1592357337807458305, 1592357067014803457, '能力集市', '/DetailsPageconetent', '', 0, 1067246875800000001, '2022-11-15 11:22:29', 1067246875800000001, '2022-11-15 11:22:29', 1);
|
||||||
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
|
|
||||||
<mapper namespace="io.renren.modules.security.dao.SysUserTokenDao">
|
|
||||||
|
|
||||||
<select id="getByToken" resultType="io.renren.modules.security.entity.SysUserTokenEntity">
|
|
||||||
select * from sys_user_token where token = #{value}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getByUserId" resultType="io.renren.modules.security.entity.SysUserTokenEntity">
|
|
||||||
select * from sys_user_token where user_id = #{value}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<update id="logout">
|
|
||||||
update sys_user_token set expire_date = #{expireDate} where user_id = #{userId}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<select id="getOnlineList" resultType="io.renren.modules.sys.entity.SysOnlineEntity">
|
|
||||||
select t1.user_id, t1.expire_date, t1.update_date as login_date, t2.username, t2.real_name
|
|
||||||
from sys_user_token t1, sys_user t2
|
|
||||||
where t1.user_id = t2.id and expire_date > #{expireDate}
|
|
||||||
<if test="username != null and username.trim() != ''">
|
|
||||||
and t2.username like #{username}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
|
@ -14,14 +14,20 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getMenuList" resultType="io.renren.modules.sys.entity.SysMenuEntity">
|
<select id="getMenuList" resultType="io.renren.modules.sys.entity.SysMenuEntity">
|
||||||
select t1.*, (select lang.field_value from sys_language lang where lang.table_name='sys_menu' and
|
select t1.*, lang.field_value as "name"
|
||||||
lang.field_name='name'
|
from sys_menu t1, sys_language lang
|
||||||
and lang.table_id=t1.id and lang.language=#{language}) as name
|
|
||||||
from sys_menu t1
|
|
||||||
<where>
|
<where>
|
||||||
|
1 = 1
|
||||||
<if test="type != null">
|
<if test="type != null">
|
||||||
t1.type = #{type}
|
and t1.type = #{type}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
and lang.field_value like CONCAT('%', #{name}, '%')
|
||||||
|
</if>
|
||||||
|
and lang.table_name = 'sys_menu'
|
||||||
|
and lang.field_name = 'name'
|
||||||
|
and lang.table_id = t1.id
|
||||||
|
and lang.language = #{language}
|
||||||
</where>
|
</where>
|
||||||
order by t1.sort asc
|
order by t1.sort asc
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getByUserId" resultType="io.renren.modules.security.entity.SysUserTokenEntity">
|
<select id="getByUserId" resultType="io.renren.modules.security.entity.SysUserTokenEntity">
|
||||||
select * from sys_user_token where user_id = #{value}
|
select * from sys_user_token where user_id = #{value} ORDER BY create_date DESC LIMIT 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="logout">
|
<update id="logout">
|
||||||
|
|
Loading…
Reference in New Issue