Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-07-13 11:08:50 +08:00
commit ce4b2e8310
18 changed files with 141 additions and 39 deletions

View File

@ -1,3 +1,3 @@
ALTER TABLE `share_platform`.`tb_data_attr`
ADD INDEX `resource_id`(`data_resource_id`),
ADD FULLTEXT INDEX `attr_value`(`attr_type`, `attr_value`);
ADD FULLTEXT INDEX `attr_value_`(`attr_type`, `attr_value`);

View File

@ -5,9 +5,9 @@ alter table `tb_resource_score` ADD INDEX `resourceid`(`resource_id`) USING BTRE
alter table `tb_resource_browse` ADD INDEX `resourceid`(`resource_id`) USING BTREE comment '资源id索引';
alter table `t_ability_application` ADD INDEX `resourceid`(`resource_id`) USING BTREE comment '资源id';
alter table `t_ability_application` ADD INDEX `userId`(`user_id`) USING BTREE comment '用户';
alter table `tb_data_resource` ADD FULLTEXT INDEX `type`(`type`) with parser ngram;
alter table `tb_data_attr` ADD FULLTEXT INDEX `attr_value`(`attr_value`) with parser ngram;
alter table `tb_data_resource` ADD FULLTEXT INDEX `name`(`name`) with parser ngram;
alter table `tb_data_resource` ADD FULLTEXT INDEX `type`(`type`) WITH PARSER NGRAM;
alter table `tb_data_attr` ADD FULLTEXT INDEX `attr_value`(`attr_value`) WITH PARSER NGRAM;
alter table `tb_data_resource` ADD FULLTEXT INDEX `name`(`name`) WITH PARSER NGRAM;
alter table `tb_data_resource` ADD INDEX `deptId`(`dept_id`) USING BTREE;
alter table `sys_dept` ADD INDEX `type`(`type`) USING BTREE;
alter table `sys_dept` ADD INDEX `district`(`district`) USING BTREE;

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,23 @@
DROP PROCEDURE IF EXISTS del_idx;
create procedure del_idx(IN p_tablename varchar(200), IN p_idxname VARCHAR(200))
begin
DECLARE str VARCHAR(250);
set @str=concat(' drop index ',p_idxname,' on ',p_tablename);
select count(*) into @cnt from information_schema.statistics where table_name=p_tablename and index_name=p_idxname ;
if @cnt >0 then
PREPARE stmt FROM @str;
EXECUTE stmt ;
end if;
end ;
call del_idx('sys_user_token','user_id');

View File

@ -0,0 +1,2 @@
alter table `share_platform`.`tb_data_resource` ADD COLUMN `visitor` bigint NULL comment '浏览量';
UPDATE tb_data_resource SET visitor = (SELECT COUNT(id) FROM tb_resource_browse WHERE resource_id = tb_data_resource.id);

View File

@ -0,0 +1,3 @@
alter table `t_ability_application` ADD COLUMN `apply_flag` varchar(255) NULL comment '申请单标识';
alter table `t_ability_application` ADD COLUMN `resource_owner_dept` json NULL comment '资源所属部门信息';
alter table `t_ability_application` ADD COLUMN `enclosure_name` longtext NULL comment '附件文件名';

View File

@ -0,0 +1,12 @@
alter table `t_ability_application` ADD COLUMN `apply_number` varchar(16) NULL comment '能力使用申请单号';
alter table `t_resource_mount_apply` ADD COLUMN `apply_number` varchar(16) NULL comment '能力上架申请单号';
alter table `t_demand_data` ADD COLUMN `apply_number` varchar(16) NULL comment '能力需求申请单号';
alter table `t_demand_comment` ADD COLUMN `apply_number` varchar(16) NULL comment '需求评论申请单号';
alter table `tb_data_resource` ADD COLUMN `apply_number` varchar(16) NULL comment '能力下架申请单号';
alter table `sys_log_operation` ADD COLUMN `operation_table` varchar(500) NULL comment '操作数据库表';

View File

@ -0,0 +1 @@
alter table `t_ability_application` MODIFY COLUMN `instance_id` bigint(20) NULL DEFAULT NULL comment '流程实例ID' ;

View File

@ -13,4 +13,5 @@ public class YaweiSSOProperties {
private String domain;
private String ssoKey;
private String keeperUrl;
private String logoutUrl;
}

View File

@ -13,6 +13,7 @@ import io.renren.modules.log.enums.LoginStatusEnum;
import io.renren.modules.log.service.SysLogLoginService;
import io.renren.modules.security.dto.LoginDTO;
import io.renren.modules.security.oauth2.Oauth2Filter;
import io.renren.modules.security.oauth2.SSOValidator;
import io.renren.modules.security.oauth2.YaWeiCookieManage;
import io.renren.modules.security.password.PasswordUtils;
import io.renren.modules.security.service.CaptchaService;
@ -26,6 +27,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -59,6 +61,9 @@ public class LoginController {
@Autowired
private SysLogLoginService sysLogLoginService;
@Autowired(required = false)
private SSOValidator ssoValidator;
@Value("${yawei.enable}")
private Boolean yaweiEnable; // 亚微登录
@ -158,7 +163,14 @@ public class LoginController {
UserDetail user = SecurityUser.getUser();
//退出
sysUserTokenService.logout(user.getId());
// sysUserTokenService.logout(user.getId());
String token = request.getHeader(Constant.TOKEN_HEADER);
if (StringUtils.isBlank(token)) {
return new Result<>().error("请传入token");
}
sysUserTokenService.logoutByToken(token);
//用户信息
SysLogLoginEntity log = new SysLogLoginEntity();
@ -172,6 +184,10 @@ public class LoginController {
log.setCreateDate(new Date());
sysLogLoginService.save(log);
if (ssoValidator != null && ssoValidator.getLogoutUrl() != null) {
response.addHeader("REDIRECT", ssoValidator.getLogoutUrl());
}
return new Result();
}

View File

@ -24,8 +24,8 @@ public class CasSSOValidator implements SSOValidator {
private String serverUrlPrefix;
@Value("${cas.server-login-url}")
private String serverLoginUrl;
@Value("${cas.client-host-url}")
private String clientHostUrl;
@Value("${cas.server-logout-url}")
private String serverLogoutUrl;
private Cas30JsonServiceTicketValidator ticketValidator;
@ -88,6 +88,11 @@ public class CasSSOValidator implements SSOValidator {
return serverLoginUrl + "?service=" + URLEncoder.encode(removeCreditParame(callBackUrl));
}
@Override
public String getLogoutUrl() {
return serverLogoutUrl;
}
private static String getParema(String urlStr, String field) {
String result = "";
Pattern pXM = Pattern.compile(field + "=([^&|^#]*)");

View File

@ -11,4 +11,6 @@ public interface SSOValidator {
String removeCreditParame(String url);
String getLoginUrl(String callBackUrl);
String getLogoutUrl();
}

View File

@ -77,6 +77,11 @@ public class YaweiSSOValidator implements SSOValidator {
return keeperUrl;
}
@Override
public String getLogoutUrl() {
return yaweiSSOProperties.getLogoutUrl();
}
private String getSSOToken(String url){
String ssoMatchKey = yaweiSSOProperties.getSsoKey() + "=";
int startIndex = url.indexOf(ssoMatchKey) + ssoMatchKey.length();

View File

@ -26,6 +26,12 @@ public interface SysUserTokenService extends BaseService<SysUserTokenEntity> {
*/
void logout(Long userId);
/**
* 退出
* @param token 用户token
*/
void logoutByToken(String token);
/**
* 在线用户分页
*/

View File

@ -1,5 +1,6 @@
package io.renren.modules.security.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.renren.common.constant.Constant;
import io.renren.common.page.PageData;
@ -21,9 +22,9 @@ import java.util.Map;
@Service
public class SysUserTokenServiceImpl extends BaseServiceImpl<SysUserTokenDao, SysUserTokenEntity> implements SysUserTokenService {
/**
* 12小时后过期 修改成 7天
* 12小时后过期
*/
private final static int EXPIRE = 3600 * 24 * 7;
private final static int EXPIRE = 3600 * 12;
@Override
public Result createToken(Long userId) {
@ -34,37 +35,47 @@ public class SysUserTokenServiceImpl extends BaseServiceImpl<SysUserTokenDao, Sy
Date now = new Date();
//过期时间
Date expireTime = new Date(now.getTime() + EXPIRE * 1000);
token = TokenGenerator.generateValue();
SysUserTokenEntity tokenEntity = new SysUserTokenEntity();
tokenEntity = new SysUserTokenEntity();
tokenEntity.setUserId(userId);
tokenEntity.setToken(token);
tokenEntity.setUpdateDate(now);
tokenEntity.setExpireDate(expireTime);
//保存token
this.insert(tokenEntity);
//支持单账号多地登录
//判断是否生成过token
SysUserTokenEntity tokenEntity = baseDao.getByUserId(userId);
if(tokenEntity == null){
//生成一个token
token = TokenGenerator.generateValue();
tokenEntity = new SysUserTokenEntity();
tokenEntity.setUserId(userId);
tokenEntity.setToken(token);
tokenEntity.setUpdateDate(now);
tokenEntity.setExpireDate(expireTime);
//保存token
this.insert(tokenEntity);
}else{
//判断token是否过期
// if(tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()){
// //token过期重新生成token
// token = TokenGenerator.generateValue();
// }else {
// token = tokenEntity.getToken();
// }
token = TokenGenerator.generateValue();
tokenEntity.setToken(token);
tokenEntity.setUpdateDate(now);
tokenEntity.setExpireDate(expireTime);
//更新token
this.updateById(tokenEntity);
}
// SysUserTokenEntity tokenEntity = baseDao.getByUserId(userId);
// if(tokenEntity == null){
// //生成一个token
// token = TokenGenerator.generateValue();
//
// tokenEntity = new SysUserTokenEntity();
// tokenEntity.setUserId(userId);
// tokenEntity.setToken(token);
// tokenEntity.setUpdateDate(now);
// tokenEntity.setExpireDate(expireTime);
//
// //保存token
// this.insert(tokenEntity);
// }else{
// //判断token是否过期
//// if(tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()){
//// //token过期重新生成token
//// token = TokenGenerator.generateValue();
//// }else {
//// token = tokenEntity.getToken();
//// }
// token = TokenGenerator.generateValue();
// tokenEntity.setToken(token);
// tokenEntity.setUpdateDate(now);
// tokenEntity.setExpireDate(expireTime);
//
// //更新token
// this.updateById(tokenEntity);
// }
Map<String, Object> map = new HashMap<>(2);
map.put(Constant.TOKEN_HEADER, token);
@ -78,6 +89,14 @@ public class SysUserTokenServiceImpl extends BaseServiceImpl<SysUserTokenDao, Sy
baseDao.logout(userId, expireDate);
}
@Override
public void logoutByToken(String token) {
LambdaQueryWrapper<SysUserTokenEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysUserTokenEntity::getToken, token);
baseDao.delete(wrapper);
}
@Override
public PageData<SysOnlineEntity> onlinePage(Map<String, Object> params) {
//转换成like

View File

@ -119,6 +119,7 @@ sso:
cas:
server-url-prefix: http://10.134.135.81:11188/cas
server-login-url: http://10.134.135.81:11188/cas/login
server-logout-url: http://10.134.135.81:11188/cas/logout
client-host-url: http://localhost:9999/#/
use-session: false
validation-type: cas3

View File

@ -0,0 +1 @@
alter table `t_ability_application` MODIFY COLUMN `instance_id` bigint(20) NULL DEFAULT NULL comment '流程实例ID' ;

View File

@ -1,3 +1,4 @@
sso.domain=jhoa.qd.gov.cn
sso.ssoKey=SSOToken
sso.keeperUrl=http://jhoa.qd.gov.cn/Keeper.aspx
sso.keeperUrl=http://jhoa.qd.gov.cn/Keeper.aspx
sso.logoutUrl=http://jhoa.qd.gov.cn/LogoutSSO.aspx