Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
zlg
2024-07-23 13:07:29 +08:00
62 changed files with 482 additions and 1041 deletions

View File

@@ -149,11 +149,21 @@ public class SchisandraAuthUserController {
schisandraAuthAddressBO.setAgent(userAgent.toString()); schisandraAuthAddressBO.setAgent(userAgent.toString());
schisandraAuthAddressBO.setUserId(result.getId()); schisandraAuthAddressBO.setUserId(result.getId());
schisandraAuthAddressBO.setIp(ip); schisandraAuthAddressBO.setIp(ip);
schisandraAuthAddressBO.setBrowser(userAgent.getBrowser().toString()); if (userAgent.getBrowser() != null) {
schisandraAuthAddressBO.setBrowserVersion(userAgent.getBrowserVersion().getVersion()); schisandraAuthAddressBO.setBrowser(userAgent.getBrowser().toString());
}
if (userAgent.getBrowserVersion() != null) {
schisandraAuthAddressBO.setBrowserVersion(userAgent.getBrowserVersion().toString());
}
schisandraAuthAddressBO.setLocation(ip2region); schisandraAuthAddressBO.setLocation(ip2region);
Boolean add = schisandraAuthAddressDomainService.add(schisandraAuthAddressBO); SchisandraAuthAddressBO authAddressBO = schisandraAuthAddressDomainService.queryByUserId(result.getId());
assert add; if (ObjectUtils.isNotEmpty(authAddressBO)) {
schisandraAuthAddressBO.setId(authAddressBO.getId());
schisandraAuthAddressDomainService.update(schisandraAuthAddressBO);
} else {
Boolean add = schisandraAuthAddressDomainService.add(schisandraAuthAddressBO);
assert add;
}
map.put("user", result); map.put("user", result);
if (login != null) { if (login != null) {
if (StpUtil.isLogin(result.getId())) { if (StpUtil.isLogin(result.getId())) {
@@ -211,12 +221,21 @@ public class SchisandraAuthUserController {
schisandraAuthAddressBO.setAgent(userAgent.toString()); schisandraAuthAddressBO.setAgent(userAgent.toString());
schisandraAuthAddressBO.setUserId(result.getId()); schisandraAuthAddressBO.setUserId(result.getId());
schisandraAuthAddressBO.setIp(ip); schisandraAuthAddressBO.setIp(ip);
schisandraAuthAddressBO.setBrowser(userAgent.getBrowser().toString()); if (userAgent.getBrowser() != null) {
schisandraAuthAddressBO.setBrowserVersion(userAgent.getBrowserVersion().getVersion()); schisandraAuthAddressBO.setBrowser(userAgent.getBrowser().toString());
}
if (userAgent.getBrowserVersion() != null) {
schisandraAuthAddressBO.setBrowserVersion(userAgent.getBrowserVersion().toString());
}
schisandraAuthAddressBO.setLocation(ip2region); schisandraAuthAddressBO.setLocation(ip2region);
Boolean add = schisandraAuthAddressDomainService.add(schisandraAuthAddressBO); SchisandraAuthAddressBO authAddressBO = schisandraAuthAddressDomainService.queryByUserId(result.getId());
assert add; if (ObjectUtils.isNotEmpty(authAddressBO)) {
schisandraAuthAddressBO.setId(authAddressBO.getId());
schisandraAuthAddressDomainService.update(schisandraAuthAddressBO);
} else {
Boolean add = schisandraAuthAddressDomainService.add(schisandraAuthAddressBO);
assert add;
}
map.put("user", result); map.put("user", result);
if (loginByPhone != null) { if (loginByPhone != null) {
if (StpUtil.isLogin(result.getId())) { if (StpUtil.isLogin(result.getId())) {
@@ -420,14 +439,20 @@ public class SchisandraAuthUserController {
/** /**
* 用户设置安全信息 * 用户设置安全信息
*
* @param schisandraAuthUserDTO * @param schisandraAuthUserDTO
* @return * @return
*/ */
@PostMapping("update") @PostMapping("update")
public Result update(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO){ public Result update(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
SchisandraAuthUserBO schisandraAuthUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO); SchisandraAuthUserBO schisandraAuthUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
return Result.ok(schisandraAuthUserDomainService.update(schisandraAuthUserBO)); return Result.ok(schisandraAuthUserDomainService.update(schisandraAuthUserBO));
} }
@PostMapping("logout")
public Result logout(@RequestParam("userId") String userId) {
StpUtil.logout(userId);
return Result.ok();
}
} }

View File

@@ -1,54 +1,54 @@
package com.schisandra.auth.application.handler.oauth; package com.schisandra.auth.application.handler.oauth;
import com.schisandra.auth.common.enums.OauthType; import com.schisandra.auth.common.enums.OauthType;
import com.schisandra.auth.common.utils.AuthStateRedisCache; import com.schisandra.auth.common.utils.AuthStateRedisCache;
import com.schisandra.auth.infra.entity.OauthConfigInfo; import com.schisandra.auth.infra.entity.OauthConfigInfo;
import com.schisandra.auth.infra.rpc.OauthConfigRpc; import com.schisandra.auth.infra.rpc.OauthConfigRpc;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.config.AuthConfig; import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.request.AuthOschinaRequest; import me.zhyd.oauth.request.AuthOschinaRequest;
import me.zhyd.oauth.request.AuthRequest; import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.request.AuthWeChatEnterpriseThirdQrcodeRequest; import me.zhyd.oauth.request.AuthWeChatEnterpriseThirdQrcodeRequest;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
/** /**
* @Classname OschinaOauthHandler * @Classname OschinaOauthHandler
* @BelongsProject: schisandra-cloud-storage * @BelongsProject: schisandra-cloud-storage
* @BelongsPackage: com.schisandra.auth.application.handler.oauth * @BelongsPackage: com.schisandra.auth.application.handler.oauth
* @Author: landaiqing * @Author: landaiqing
* @CreateTime: 2024-06-26 14:21 * @CreateTime: 2024-06-26 14:21
* @Description: TODO * @Description: TODO
* @Version: 1.0 * @Version: 1.0
*/ */
@Component @Component
@Slf4j @Slf4j
public class WechatEnterpriseOauthHandler implements SchisandraOauthTypeHandler { public class WechatEnterpriseOauthHandler implements SchisandraOauthTypeHandler {
@Resource @Resource
private OauthConfigRpc oauthConfigRpc; private OauthConfigRpc oauthConfigRpc;
@Resource @Resource
private AuthStateRedisCache stateRedisCache; private AuthStateRedisCache stateRedisCache;
@Override @Override
public OauthType getHandlerType() { public OauthType getHandlerType() {
return OauthType.WECHAT_ENTERPRISE; return OauthType.WECHAT;
} }
@Override @Override
public AuthRequest getAuthRequest(String type) { public AuthRequest getAuthRequest(String type) {
OauthConfigInfo WECHAT_ENTERPRISE = oauthConfigRpc.getOauthConfigInfo(type); OauthConfigInfo WECHAT_ENTERPRISE = oauthConfigRpc.getOauthConfigInfo(type);
if (ObjectUtils.isEmpty(WECHAT_ENTERPRISE)) { if (ObjectUtils.isEmpty(WECHAT_ENTERPRISE)) {
log.error("WECHAT_ENTERPRISE oauth 配置信息获取失败"); log.error("WECHAT_ENTERPRISE oauth 配置信息获取失败");
return null; return null;
} }
return new AuthWeChatEnterpriseThirdQrcodeRequest(AuthConfig.builder() return new AuthWeChatEnterpriseThirdQrcodeRequest(AuthConfig.builder()
.clientId(WECHAT_ENTERPRISE.getClientId()) .clientId(WECHAT_ENTERPRISE.getClientId())
.clientSecret(WECHAT_ENTERPRISE.getClientSecret()) .clientSecret(WECHAT_ENTERPRISE.getClientSecret())
.redirectUri(WECHAT_ENTERPRISE.getRedirectUri()) .redirectUri(WECHAT_ENTERPRISE.getRedirectUri())
.agentId(WECHAT_ENTERPRISE.getAgentId()) .agentId(WECHAT_ENTERPRISE.getAgentId())
.build(), stateRedisCache); .build(), stateRedisCache);
} }
} }

View File

@@ -1,76 +1,76 @@
package com.schisandra.auth.common.enums; package com.schisandra.auth.common.enums;
import lombok.Getter; import lombok.Getter;
/** /**
* @Classname OauthType * @Classname OauthType
* @BelongsProject: schisandra-cloud-storage * @BelongsProject: schisandra-cloud-storage
* @BelongsPackage: com.schisandra.auth.common.enums * @BelongsPackage: com.schisandra.auth.common.enums
* @Author: landaiqing * @Author: landaiqing
* @CreateTime: 2024-05-26 13:36 * @CreateTime: 2024-05-26 13:36
* @Description: TODO * @Description: TODO
* @Version: 1.0 * @Version: 1.0
*/ */
@Getter @Getter
public enum OauthType { public enum OauthType {
/** /**
* 微信登录 * 微信登录
*/ */
WECHAT("wechat"), WECHAT("wechat"),
/** /**
* QQ登录 * QQ登录
*/ */
QQ("qq"), QQ("qq"),
/** /**
* 微博登录 * 微博登录
*/ */
WEIBO("weibo"), WEIBO("weibo"),
/** /**
* 支付宝登录 * 支付宝登录
*/ */
ALIPAY("alipay"), ALIPAY("alipay"),
/** /**
* 钉钉登录 * 钉钉登录
*/ */
DINGTALK("dingtalk"), DINGTALK("dingtalk"),
/** /**
* 企业微信登录 * 企业微信登录
*/ */
WECHAT_ENTERPRISE("WECHAT_ENTERPRISE"), WECHAT_ENTERPRISE("WECHAT_ENTERPRISE"),
/** /**
* Github * Github
*/ */
GITHUB("github"), GITHUB("github"),
/** /**
* Gitee * Gitee
*/ */
GITEE("gitee"), GITEE("gitee"),
/** /**
* System * System
*/ */
SYSTEM("SYSTEM"), SYSTEM("SYSTEM"),
/** /**
* 开源中国 * 开源中国
*/ */
OSCHINA("OSCHINA"), OSCHINA("oschina"),
/** /**
* STACK_OVERFLOW * STACK_OVERFLOW
*/ */
STACK_OVERFLOW("STACK_OVERFLOW"); STACK_OVERFLOW("STACK_OVERFLOW");
public String type; public String type;
OauthType(String type) { OauthType(String type) {
this.type = type; this.type = type;
} }
public static OauthType getByType(String type) { public static OauthType getByType(String type) {
for (OauthType resultKeyEnum : OauthType.values()) { for (OauthType resultKeyEnum : OauthType.values()) {
if (resultKeyEnum.type.equals(type)) { if (resultKeyEnum.type.equals(type)) {
return resultKeyEnum; return resultKeyEnum;
} }
} }
return null; return null;
} }
} }

View File

@@ -49,7 +49,7 @@ public interface SchisandraAuthUserDomainService {
* @author: landaiqing * @author: landaiqing
* @date: 2024/5/26 17:28 * @date: 2024/5/26 17:28
*/ */
SchisandraAuthUserBO login(SchisandraAuthUserBO schisandraAuthUserBO); SchisandraAuthUserBO login(SchisandraAuthUserBO schisandraAuthUserB);
/** /**
* @description: 通过手机号登录 * @description: 通过手机号登录

View File

@@ -235,10 +235,14 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
*/ */
@Override @Override
public Boolean wechatRegister(String appId, String openId,String clientId, HttpServletRequest httpServletRequest) { public Boolean wechatRegister(String appId, String openId,String clientId, HttpServletRequest httpServletRequest) {
SchisandraSocialUser socialUser = schisandraSocialUserService.selectByOpenId(openId); SchisandraSocialUser socialUser = schisandraSocialUserService.selectByOpenId(appId,openId);
if (ObjectUtils.isNotEmpty(socialUser)) { if (ObjectUtils.isNotEmpty(socialUser)) {
String userId = socialUser.getId(); String SocialUserId = socialUser.getId();
SchisandraSocialUserAuth schisandraSocialUserAuth= schisandraSocialUserAuthService.queryBySocialUserId(SocialUserId);
if(ObjectUtils.isEmpty(schisandraSocialUserAuth)){
return false;
}
String userId = schisandraSocialUserAuth.getUserId();
// 加入登录IP地址 // 加入登录IP地址
String ip = IPUtil.getIp(httpServletRequest); String ip = IPUtil.getIp(httpServletRequest);
@@ -250,8 +254,12 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
schisandraAuthAddressBO.setAgent(userAgent.toString()); schisandraAuthAddressBO.setAgent(userAgent.toString());
schisandraAuthAddressBO.setUserId(userId); schisandraAuthAddressBO.setUserId(userId);
schisandraAuthAddressBO.setIp(ip); schisandraAuthAddressBO.setIp(ip);
schisandraAuthAddressBO.setBrowser(userAgent.getBrowser().toString()); if(userAgent.getBrowser() != null) {
schisandraAuthAddressBO.setBrowserVersion(userAgent.getBrowserVersion().getVersion()); schisandraAuthAddressBO.setBrowser(userAgent.getBrowser().toString());
}
if(userAgent.getBrowserVersion() != null){
schisandraAuthAddressBO.setBrowserVersion(userAgent.getBrowserVersion().toString());
}
schisandraAuthAddressBO.setLocation(ip2region); schisandraAuthAddressBO.setLocation(ip2region);
SchisandraAuthAddress schisandraAuthAddress = SchisandraAuthAddressBOConverter.INSTANCE.convertBOToEntity(schisandraAuthAddressBO); SchisandraAuthAddress schisandraAuthAddress = SchisandraAuthAddressBOConverter.INSTANCE.convertBOToEntity(schisandraAuthAddressBO);
int insert = schisandraAuthAddressService.update(schisandraAuthAddress); int insert = schisandraAuthAddressService.update(schisandraAuthAddress);
@@ -268,6 +276,7 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
}else{ }else{
// 插入社会用户信息表 // 插入社会用户信息表
SchisandraSocialUserBO socialUserBO = new SchisandraSocialUserBO(); SchisandraSocialUserBO socialUserBO = new SchisandraSocialUserBO();
socialUserBO.setUuid(appId);
socialUserBO.setOpenId(openId); socialUserBO.setOpenId(openId);
SchisandraSocialUser schisandraSocialUser = SchisandraSocialUserBOConverter.INSTANCE.convertBOToEntity(socialUserBO); SchisandraSocialUser schisandraSocialUser = SchisandraSocialUserBOConverter.INSTANCE.convertBOToEntity(socialUserBO);
int result = schisandraSocialUserService.insertSocialUser(schisandraSocialUser); int result = schisandraSocialUserService.insertSocialUser(schisandraSocialUser);
@@ -299,8 +308,12 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
schisandraAuthAddressBO.setAgent(userAgent.toString()); schisandraAuthAddressBO.setAgent(userAgent.toString());
schisandraAuthAddressBO.setUserId(authUserId); schisandraAuthAddressBO.setUserId(authUserId);
schisandraAuthAddressBO.setIp(ip); schisandraAuthAddressBO.setIp(ip);
schisandraAuthAddressBO.setBrowser(userAgent.getBrowser().toString()); if(userAgent.getBrowser() != null) {
schisandraAuthAddressBO.setBrowserVersion(userAgent.getBrowserVersion().getVersion()); schisandraAuthAddressBO.setBrowser(userAgent.getBrowser().toString());
}
if(userAgent.getBrowserVersion() != null){
schisandraAuthAddressBO.setBrowserVersion(userAgent.getBrowserVersion().toString());
}
schisandraAuthAddressBO.setLocation(ip2region); schisandraAuthAddressBO.setLocation(ip2region);
SchisandraAuthAddress schisandraAuthAddress = SchisandraAuthAddressBOConverter.INSTANCE.convertBOToEntity(schisandraAuthAddressBO); SchisandraAuthAddress schisandraAuthAddress = SchisandraAuthAddressBOConverter.INSTANCE.convertBOToEntity(schisandraAuthAddressBO);
int insertIp = schisandraAuthAddressService.insert(schisandraAuthAddress); int insertIp = schisandraAuthAddressService.insert(schisandraAuthAddress);
@@ -359,6 +372,12 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
AuthToken token = data.getToken(); AuthToken token = data.getToken();
SchisandraSocialUser socialUser = schisandraSocialUserService.selectByUuidAndType(uuid, type); SchisandraSocialUser socialUser = schisandraSocialUserService.selectByUuidAndType(uuid, type);
if (ObjectUtils.isNotEmpty(socialUser)) { if (ObjectUtils.isNotEmpty(socialUser)) {
SchisandraSocialUserAuth schisandraSocialUserAuth= schisandraSocialUserAuthService.queryBySocialUserId(socialUser.getId());
if(ObjectUtils.isEmpty(schisandraSocialUserAuth)){
return Result.fail();
}
String userId = schisandraSocialUserAuth.getUserId();
// 更新用户信息 // 更新用户信息
SchisandraSocialUserBO socialUserBO = new SchisandraSocialUserBO(); SchisandraSocialUserBO socialUserBO = new SchisandraSocialUserBO();
socialUserBO.setAccessToken(token.getAccessToken()); socialUserBO.setAccessToken(token.getAccessToken());
@@ -383,7 +402,6 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
} }
return Result.fail("Social User update fail"); return Result.fail("Social User update fail");
} }
String userId = socialUser.getId();
// 加入登录IP地址 // 加入登录IP地址
String ip = IPUtil.getIp(httpServletRequest); String ip = IPUtil.getIp(httpServletRequest);
@@ -395,8 +413,12 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
schisandraAuthAddressBO.setAgent(userAgent.toString()); schisandraAuthAddressBO.setAgent(userAgent.toString());
schisandraAuthAddressBO.setUserId(userId); schisandraAuthAddressBO.setUserId(userId);
schisandraAuthAddressBO.setIp(ip); schisandraAuthAddressBO.setIp(ip);
schisandraAuthAddressBO.setBrowser(userAgent.getBrowser().toString()); if(userAgent.getBrowser() != null) {
schisandraAuthAddressBO.setBrowserVersion(userAgent.getBrowserVersion().getVersion()); schisandraAuthAddressBO.setBrowser(userAgent.getBrowser().toString());
}
if(userAgent.getBrowserVersion() != null){
schisandraAuthAddressBO.setBrowserVersion(userAgent.getBrowserVersion().toString());
}
schisandraAuthAddressBO.setLocation(ip2region); schisandraAuthAddressBO.setLocation(ip2region);
SchisandraAuthAddress schisandraAuthAddress = SchisandraAuthAddressBOConverter.INSTANCE.convertBOToEntity(schisandraAuthAddressBO); SchisandraAuthAddress schisandraAuthAddress = SchisandraAuthAddressBOConverter.INSTANCE.convertBOToEntity(schisandraAuthAddressBO);
int insert = schisandraAuthAddressService.update(schisandraAuthAddress); int insert = schisandraAuthAddressService.update(schisandraAuthAddress);
@@ -463,8 +485,12 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
schisandraAuthAddressBO.setAgent(userAgent.toString()); schisandraAuthAddressBO.setAgent(userAgent.toString());
schisandraAuthAddressBO.setUserId(authUserId); schisandraAuthAddressBO.setUserId(authUserId);
schisandraAuthAddressBO.setIp(ip); schisandraAuthAddressBO.setIp(ip);
schisandraAuthAddressBO.setBrowser(userAgent.getBrowser().toString()); if(userAgent.getBrowser() != null) {
schisandraAuthAddressBO.setBrowserVersion(userAgent.getBrowserVersion().getVersion()); schisandraAuthAddressBO.setBrowser(userAgent.getBrowser().toString());
}
if(userAgent.getBrowserVersion() != null){
schisandraAuthAddressBO.setBrowserVersion(userAgent.getBrowserVersion().toString());
}
schisandraAuthAddressBO.setLocation(ip2region); schisandraAuthAddressBO.setLocation(ip2region);
SchisandraAuthAddress schisandraAuthAddress = SchisandraAuthAddressBOConverter.INSTANCE.convertBOToEntity(schisandraAuthAddressBO); SchisandraAuthAddress schisandraAuthAddress = SchisandraAuthAddressBOConverter.INSTANCE.convertBOToEntity(schisandraAuthAddressBO);
int insertIp = schisandraAuthAddressService.insert(schisandraAuthAddress); int insertIp = schisandraAuthAddressService.insert(schisandraAuthAddress);

View File

@@ -43,4 +43,5 @@ public interface SchisandraSocialUserAuthService {
boolean deleteById(String id); boolean deleteById(String id);
SchisandraSocialUserAuth queryBySocialUserId(String socialUserId);
} }

View File

@@ -53,5 +53,5 @@ public interface SchisandraSocialUserService {
int insertSocialUser(SchisandraSocialUser schisandraSocialUser); int insertSocialUser(SchisandraSocialUser schisandraSocialUser);
SchisandraSocialUser selectByOpenId(String openId); SchisandraSocialUser selectByOpenId(String appId,String openId);
} }

View File

@@ -1,14 +1,15 @@
package com.schisandra.auth.infra.basic.service.impl; package com.schisandra.auth.infra.basic.service.impl;
import com.schisandra.auth.infra.basic.entity.SchisandraSocialUserAuth;
import com.schisandra.auth.infra.basic.dao.SchisandraSocialUserAuthDao; import com.schisandra.auth.infra.basic.dao.SchisandraSocialUserAuthDao;
import com.schisandra.auth.infra.basic.entity.SchisandraSocialUserAuth;
import com.schisandra.auth.infra.basic.entity.table.SchisandraSocialUserAuthTableDef;
import com.schisandra.auth.infra.basic.service.SchisandraSocialUserAuthService; import com.schisandra.auth.infra.basic.service.SchisandraSocialUserAuthService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
/** /**
* 表服务实现类 * 表服务实现类
* *
* @author landaiqing * @author landaiqing
* @since 2024-06-24 11:10:08 * @since 2024-06-24 11:10:08
@@ -49,7 +50,7 @@ public class SchisandraSocialUserAuthServiceImpl implements SchisandraSocialUser
*/ */
@Override @Override
public int update(SchisandraSocialUserAuth schisandraSocialUserAuth) { public int update(SchisandraSocialUserAuth schisandraSocialUserAuth) {
return this.schisandraSocialUserAuthDao.update(schisandraSocialUserAuth,true); return this.schisandraSocialUserAuthDao.update(schisandraSocialUserAuth, true);
} }
/** /**
@@ -63,5 +64,10 @@ public class SchisandraSocialUserAuthServiceImpl implements SchisandraSocialUser
return this.schisandraSocialUserAuthDao.deleteById(id) > 0; return this.schisandraSocialUserAuthDao.deleteById(id) > 0;
} }
@Override
public SchisandraSocialUserAuth queryBySocialUserId(String socialUserId) {
return this.schisandraSocialUserAuthDao.selectOneByCondition(SchisandraSocialUserAuthTableDef.SCHISANDRA_SOCIAL_USER_AUTH.SOCIAL_USER_ID.eq(socialUserId));
}
} }

View File

@@ -115,8 +115,8 @@ public class SchisandraSocialUserServiceImpl implements SchisandraSocialUserServ
* @date: 2024/6/27 下午3:05 * @date: 2024/6/27 下午3:05
*/ */
@Override @Override
public SchisandraSocialUser selectByOpenId(String openId) { public SchisandraSocialUser selectByOpenId(String appId,String openId) {
return schisandraSocialUserDao.selectOneByCondition(SchisandraSocialUserTableDef.SCHISANDRA_SOCIAL_USER.OPEN_ID.eq(openId)); return schisandraSocialUserDao.selectOneByCondition(SchisandraSocialUserTableDef.SCHISANDRA_SOCIAL_USER.OPEN_ID.eq(openId).and(SchisandraSocialUserTableDef.SCHISANDRA_SOCIAL_USER.UUID.eq(appId)));
} }

View File

@@ -102,7 +102,7 @@ mybatis-flex:
# 前端地址 # 前端地址
web: web:
url: http://127.0.0.1:5173/ url: https://landaiqing.cn/
# MD5加密salt # MD5加密salt
cipher: cipher:

View File

@@ -8,7 +8,7 @@
# 数据库连接信息 # 数据库连接信息
jdbc: jdbc:
dbName: schisandra-cloud-storage dbName: schisandra-cloud-storage
tableName: schisandra_share_message tableName: schisandra_auth_address
url: jdbc:mysql://1.95.0.111:3306/ url: jdbc:mysql://1.95.0.111:3306/
username: root username: root
password: LDQ20020618xxx password: LDQ20020618xxx
@@ -22,9 +22,9 @@ params:
# 作者 # 作者
author: landaiqing author: landaiqing
# 模块 # 模块
module: share module: auth
# controller 通用前缀 # controller 通用前缀
api: /share/message/ api: /auth/address/
# 生成对象是否移除前缀 # 生成对象是否移除前缀
removePre: false removePre: false
# 使用内置函数赋值给变量 FunctionUtils 中替换 # 使用内置函数赋值给变量 FunctionUtils 中替换

View File

@@ -3,30 +3,20 @@ package com.schisandra.oss.application.controller;
import cn.hutool.core.util.ZipUtil; import cn.hutool.core.util.ZipUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.gson.Gson;
import com.mybatisflex.annotation.RelationOneToMany;
import com.schisandra.oss.application.convert.SchisandraOssMinioDTOConverter; import com.schisandra.oss.application.convert.SchisandraOssMinioDTOConverter;
import com.schisandra.oss.application.convert.SchisandraOssQiniuDTOConverter;
import com.schisandra.oss.application.dto.SchisandraOssMinioDTO; import com.schisandra.oss.application.dto.SchisandraOssMinioDTO;
import com.schisandra.oss.application.dto.SchisandraOssQiniuDTO;
import com.schisandra.oss.application.oss.constant.OssConstant; import com.schisandra.oss.application.oss.constant.OssConstant;
import com.schisandra.oss.application.oss.core.minio.MinioOssClient; import com.schisandra.oss.application.oss.core.minio.MinioOssClient;
import com.schisandra.oss.application.oss.core.minio.MinioOssConfiguration; import com.schisandra.oss.application.oss.core.minio.MinioOssConfiguration;
import com.schisandra.oss.application.oss.model.OssInfo; import com.schisandra.oss.application.oss.model.OssInfo;
import com.schisandra.oss.common.entity.Result; import com.schisandra.oss.common.entity.Result;
import com.schisandra.oss.common.utils.CaffeineUtil; import com.schisandra.oss.common.utils.CaffeineUtil;
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO; import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
import com.schisandra.oss.domain.redis.RedisUtil; import com.schisandra.oss.domain.redis.RedisUtil;
import com.schisandra.oss.domain.service.SchisandraOssMinioDomainService; import com.schisandra.oss.domain.service.SchisandraOssMinioDomainService;
import io.minio.errors.*; import io.minio.errors.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.util.StreamUtils; import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -42,7 +32,6 @@ import java.net.URLEncoder;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -81,23 +70,23 @@ public class SchisandraOssMinioController {
public Result returnOneById(String Id) { public Result returnOneById(String Id) {
SchisandraOssMinioBO bo = schisandraOssMinioDomainService.selectOneById(Id); SchisandraOssMinioBO bo = schisandraOssMinioDomainService.selectOneById(Id);
SchisandraOssMinioDTO dto = SchisandraOssMinioDTOConverter.INSTANCE.convertBOToDTO(bo); SchisandraOssMinioDTO dto = SchisandraOssMinioDTOConverter.INSTANCE.convertBOToDTO(bo);
if(dto == null){ if (dto == null) {
return Result.fail("查询失败"); return Result.fail("查询失败");
} }
return Result.ok(dto); return Result.ok(dto);
} }
/** /**
* 返回当前用户minio表所有数据 * 返回当前用户minio表所有数据
*
* @param userId * @param userId
* @return * @return
*/ */
@GetMapping("return_online") @GetMapping("return_online")
public Result returnOnline(String userId) { public Result returnOnline(String userId) {
List<SchisandraOssMinioBO> list = schisandraOssMinioDomainService.selectAllPresent(userId); List<SchisandraOssMinioBO> list = schisandraOssMinioDomainService.selectAllPresent(userId);
if(list.isEmpty()){ if (list.isEmpty()) {
return Result.fail(); return Result.fail();
} }
return Result.ok(SchisandraOssMinioDTOConverter.INSTANCE.convertBOToDTOList(list)); return Result.ok(SchisandraOssMinioDTOConverter.INSTANCE.convertBOToDTOList(list));
@@ -178,12 +167,12 @@ public class SchisandraOssMinioController {
Preconditions.checkNotNull(userId, "不能为空"); Preconditions.checkNotNull(userId, "不能为空");
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId); MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
bean.getMinioOssConfig().setBucketName(bucket); bean.getMinioOssConfig().setBucketName(bucket);
List<OssInfo> object= (List<OssInfo>) caffeineUtil.caffeineBuild().getIfPresent(userId+bucket+dirName); List<OssInfo> object = (List<OssInfo>) caffeineUtil.caffeineBuild().getIfPresent(userId + bucket + dirName);
if (object != null) { if (object != null) {
return Result.ok(object); return Result.ok(object);
}else { } else {
List<OssInfo> list=bean.listDir(bucket,dirName); List<OssInfo> list = bean.listDir(bucket, dirName);
caffeineUtil.caffeineBuild().put(userId+bucket+dirName, list); caffeineUtil.caffeineBuild().put(userId + bucket + dirName, list);
return Result.ok(list); return Result.ok(list);
} }
@@ -245,7 +234,7 @@ public class SchisandraOssMinioController {
Preconditions.checkNotNull(bucket, "不能为空"); Preconditions.checkNotNull(bucket, "不能为空");
Preconditions.checkNotNull(userId, "不能为空"); Preconditions.checkNotNull(userId, "不能为空");
Preconditions.checkNotNull(filePath, "不能为空"); Preconditions.checkNotNull(filePath, "不能为空");
int index=filePath.lastIndexOf("/"); int index = filePath.lastIndexOf("/");
String fileName = filePath.substring(index + 1); String fileName = filePath.substring(index + 1);
caffeineUtil.caffeineBuild().invalidate("MinioListDir" + userId + bucket + fileName); caffeineUtil.caffeineBuild().invalidate("MinioListDir" + userId + bucket + fileName);
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId); MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
@@ -262,17 +251,17 @@ public class SchisandraOssMinioController {
* @date: 2024/6/26 14:34 * @date: 2024/6/26 14:34
*/ */
@PostMapping(value = "uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PostMapping(value = "uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public Result<Object> uploadMinioFile(SchisandraOssMinioDTO schisandraOssMinioDTO,@RequestParam MultipartFile file) throws IOException { public Result<Object> uploadMinioFile(SchisandraOssMinioDTO schisandraOssMinioDTO, @RequestParam MultipartFile file) throws IOException {
String path=schisandraOssMinioDTO.getPath(); String path = schisandraOssMinioDTO.getPath();
String bucket=schisandraOssMinioDTO.getBucketName(); String bucket = schisandraOssMinioDTO.getBucketName();
String userId=schisandraOssMinioDTO.getUserId(); String userId = schisandraOssMinioDTO.getUserId();
Preconditions.checkNotNull(path, "path不能为空"); Preconditions.checkNotNull(path, "path不能为空");
Preconditions.checkNotNull(bucket, "bucket不能为空"); Preconditions.checkNotNull(bucket, "bucket不能为空");
Preconditions.checkNotNull(userId, "userId不能为空"); Preconditions.checkNotNull(userId, "userId不能为空");
if (path.lastIndexOf("") == path.length() - 1) { if (path.lastIndexOf("") == path.length() - 1) {
path=path+file.getName(); path = path + file.getName();
}else{ } else {
path=path+"/"+file.getOriginalFilename(); path = path + "/" + file.getOriginalFilename();
} }
// 获取文件输入流 // 获取文件输入流
InputStream is = file.getInputStream(); InputStream is = file.getInputStream();
@@ -290,7 +279,7 @@ public class SchisandraOssMinioController {
map.put("time", formattedDate); map.put("time", formattedDate);
if (bean.upLoad(is, path, true) != null) { if (bean.upLoad(is, path, true) != null) {
redisUtil.setNx(key, map, 30L, TimeUnit.DAYS); redisUtil.setNx(key, map, 30L, TimeUnit.DAYS);
caffeineUtil.caffeineBuild().invalidate("MinioListDir"+userId+bucket+schisandraOssMinioDTO.getPath()); caffeineUtil.caffeineBuild().invalidate("MinioListDir" + userId + bucket + schisandraOssMinioDTO.getPath());
return Result.ok(); return Result.ok();
} else { } else {
return Result.fail(); return Result.fail();
@@ -312,7 +301,7 @@ public class SchisandraOssMinioController {
Preconditions.checkNotNull(bucket, "不能为空"); Preconditions.checkNotNull(bucket, "不能为空");
Preconditions.checkNotNull(oldFileName, "不能为空"); Preconditions.checkNotNull(oldFileName, "不能为空");
Preconditions.checkNotNull(newFileName, "不能为空"); Preconditions.checkNotNull(newFileName, "不能为空");
String path=oldFileName.substring(0,oldFileName.lastIndexOf("/")+1); String path = oldFileName.substring(0, oldFileName.lastIndexOf("/") + 1);
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId); MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
bean.getMinioOssConfig().setBucketName(bucket); bean.getMinioOssConfig().setBucketName(bucket);
try { try {
@@ -320,7 +309,7 @@ public class SchisandraOssMinioController {
} catch (Exception e) { } catch (Exception e) {
return Result.fail(e.getMessage()); return Result.fail(e.getMessage());
} }
caffeineUtil.caffeineBuild().invalidate("MinioListDir"+userId+bucket+path); caffeineUtil.caffeineBuild().invalidate("MinioListDir" + userId + bucket + path);
return Result.ok(); return Result.ok();
} }
@@ -340,14 +329,14 @@ public class SchisandraOssMinioController {
Preconditions.checkNotNull(oldFilePath, "不能为空"); Preconditions.checkNotNull(oldFilePath, "不能为空");
Preconditions.checkNotNull(newFilePath, "不能为空"); Preconditions.checkNotNull(newFilePath, "不能为空");
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId); MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
String path=oldFilePath.substring(0,oldFilePath.lastIndexOf("/")+1); String path = oldFilePath.substring(0, oldFilePath.lastIndexOf("/") + 1);
bean.getMinioOssConfig().setBucketName(bucket); bean.getMinioOssConfig().setBucketName(bucket);
try { try {
bean.copy(oldFilePath, newFilePath); bean.copy(oldFilePath, newFilePath);
} catch (Exception e) { } catch (Exception e) {
return Result.fail(e.getMessage()); return Result.fail(e.getMessage());
} }
caffeineUtil.caffeineBuild().invalidate("MinioListDir"+userId+bucket+path); caffeineUtil.caffeineBuild().invalidate("MinioListDir" + userId + bucket + path);
return Result.ok(); return Result.ok();
} }
@@ -415,28 +404,28 @@ public class SchisandraOssMinioController {
public Result<String> seleteBucket(@RequestParam String userId) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException { public Result<String> seleteBucket(@RequestParam String userId) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
Preconditions.checkNotNull(userId, "不能为空"); Preconditions.checkNotNull(userId, "不能为空");
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId); MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
List<HashMap<String,String>>list= (List<HashMap<String, String>>) caffeineUtil.caffeineBuild().getIfPresent("MinioBucket"+userId); List<HashMap<String, String>> list = (List<HashMap<String, String>>) caffeineUtil.caffeineBuild().getIfPresent("MinioBucket" + userId);
if (list!=null){ if (list != null) {
return Result.ok(list); return Result.ok(list);
} }
list=bean.selectAllBucket(); list = bean.selectAllBucket();
if (list==null){ if (list == null) {
return Result.fail(); return Result.fail();
} }
caffeineUtil.caffeineBuild().put("MinioBucket",list); caffeineUtil.caffeineBuild().put("MinioBucket", list);
return Result.ok(list); return Result.ok(list);
} }
@PostMapping("getBucketSize") @PostMapping("getBucketSize")
public Result<String> getBucketSize(@RequestParam String userId, @RequestParam String bucket) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException { public Result<String> getBucketSize(@RequestParam String userId, @RequestParam String bucket) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
Preconditions.checkNotNull(userId, "不能为空"); Preconditions.checkNotNull(userId, "不能为空");
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId); MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
String size= (String) caffeineUtil.caffeineBuild().getIfPresent("MinioBucket"+userId+bucket); String size = (String) caffeineUtil.caffeineBuild().getIfPresent("MinioBucket" + userId + bucket);
if (size!=null){ if (size != null) {
return Result.ok(size); return Result.ok(size);
} }
size=bean.getMinioBucketSize(bucket); size = bean.getMinioBucketSize(bucket);
caffeineUtil.caffeineBuild().put("MinioBucket"+userId+bucket,size); caffeineUtil.caffeineBuild().put("MinioBucket" + userId + bucket, size);
return Result.ok(size); return Result.ok(size);
} }
@@ -453,7 +442,7 @@ public class SchisandraOssMinioController {
Preconditions.checkNotNull(bucket, "不能为空"); Preconditions.checkNotNull(bucket, "不能为空");
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId); MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
bean.getMinioOssConfig().setBucketName(bucket); bean.getMinioOssConfig().setBucketName(bucket);
caffeineUtil.caffeineBuild().invalidate("MinioBucket"+userId); caffeineUtil.caffeineBuild().invalidate("MinioBucket" + userId);
return Result.ok(bean.createBucket(bucket)); return Result.ok(bean.createBucket(bucket));
} }
@@ -471,7 +460,7 @@ public class SchisandraOssMinioController {
Preconditions.checkNotNull(bucket, "不能为空"); Preconditions.checkNotNull(bucket, "不能为空");
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId); MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
bean.getMinioOssConfig().setBucketName(bucket); bean.getMinioOssConfig().setBucketName(bucket);
caffeineUtil.caffeineBuild().invalidate("MinioBucket"+userId); caffeineUtil.caffeineBuild().invalidate("MinioBucket" + userId);
return Result.ok(bean.deleteBucket(bucket)); return Result.ok(bean.deleteBucket(bucket));
} }

View File

@@ -78,6 +78,6 @@ xxl:
appname: schisandra-cloud-storage-oss appname: schisandra-cloud-storage-oss
address: address:
ip: 1.95.0.111 ip: 1.95.0.111
port: 9998 port: 9997
logpath: /data/applogs/xxl-job/jobhandler logpath: /data/applogs/xxl-job/jobhandler
logretentiondays: 30 logretentiondays: 30

View File

@@ -75,5 +75,10 @@
<artifactId>schisandra-cloud-storage-share-api</artifactId> <artifactId>schisandra-cloud-storage-share-api</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.github.houbb</groupId>-->
<!-- <artifactId>sensitive-word</artifactId>-->
<!-- <version>0.18.0</version>-->
<!-- </dependency>-->
</dependencies> </dependencies>
</project> </project>

View File

@@ -1,44 +0,0 @@
package com.schisandra.share.application.config;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import java.util.List;
/**
* @Classname GlobalConfig
* @BelongsProject: schisandra-cloud-storage
* @BelongsPackage: com.schisandra.auth.application.common
* @Author: schisandra
* @CreateTime: 2024-02-16 15:57
* @Description: MVC全局处理
* @Version: 1.0
*/
@Configuration
public class GlobalConfig extends WebMvcConfigurationSupport {
@Override
protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
super.configureMessageConverters(converters);
converters.add(mappingJackson2HttpMessageConverter());
}
private MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(objectMapper);
return converter;
}
// @Override
// protected void addInterceptors(InterceptorRegistry registry) {
// registry.addInterceptor(new LoginInterceptor())
// .addPathPatterns("/**").excludePathPatterns("/oauth/**","/system/**","/auth/**","/ReactRotateCaptcha/**","/sms/sendByTemplate");
// }
}

View File

@@ -1,19 +0,0 @@
//package com.schisandra.share.application.config;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//public class SensitiveConfig {
//
// @Bean
// public WordContext wordContext(SensitiveWordsService service) {
// return new WordContext(true, service);
// }
//
// @Bean
// public WordFilter wordFilter(WordContext wordContext) {
// return new WordFilter(wordContext);
// }
//
//}

View File

@@ -73,7 +73,6 @@ public class SchisandraShareCircleController {
/** /**
* 分享圈列表返回 * 分享圈列表返回
*/ */
@Cacheable(value = "sharelist", key = "'sharelist'")
@GetMapping("sharelist") @GetMapping("sharelist")
public Result<List<SchisandraShareCircleDTO>> getShareList() { public Result<List<SchisandraShareCircleDTO>> getShareList() {
try { try {

View File

@@ -40,12 +40,12 @@ public class SchisandraShareCommentReplyController {
@Resource @Resource
RocketMQTemplate rocketMQTemplate; RocketMQTemplate rocketMQTemplate;
@Resource @Resource
CaffeineUtil caffeineUtil; private CaffeineUtil caffeineUtil;
@Resource @Resource
private SchisandraShareCommentReplyDomainService schisandraShareCommentReplyDomainService; private SchisandraShareCommentReplyDomainService schisandraShareCommentReplyDomainService;
@Resource @Resource
RedisUtil redisUtil; RedisUtil redisUtil;
/** /**
* @description: 点赞 * @description: 点赞
* @param: [schisandraUserLikesCommentDTO] * @param: [schisandraUserLikesCommentDTO]
@@ -53,10 +53,10 @@ public class SchisandraShareCommentReplyController {
* @author zlg * @author zlg
* @date: 2024/7/20 14:39 * @date: 2024/7/20 14:39
*/ */
@GetMapping("addlike") @PostMapping("addlike")
public void addLike(@RequestParam SchisandraUserLikesCommentDTO schisandraUserLikesCommentDTO) { public void addLike(@RequestBody SchisandraUserLikesCommentDTO schisandraUserLikesCommentDTO) {
Preconditions.checkNotNull(schisandraUserLikesCommentDTO); Preconditions.checkNotNull(schisandraUserLikesCommentDTO);
SchisandraUserLikesCommentBO schisandraUserLikesCommentBO=SchisandraUserLikesCommentDTOConverter.INSTANCE.convertDTOToBO(schisandraUserLikesCommentDTO); SchisandraUserLikesCommentBO schisandraUserLikesCommentBO = SchisandraUserLikesCommentDTOConverter.INSTANCE.convertDTOToBO(schisandraUserLikesCommentDTO);
schisandraUserLikesCommentBO.setLike(true); schisandraUserLikesCommentBO.setLike(true);
rocketMQTemplate.asyncSend("CommentLikes-topic", schisandraUserLikesCommentBO, new SendCallback() { rocketMQTemplate.asyncSend("CommentLikes-topic", schisandraUserLikesCommentBO, new SendCallback() {
@Override @Override
@@ -72,17 +72,18 @@ public class SchisandraShareCommentReplyController {
); );
} }
@GetMapping("dellike") @PostMapping("dellike")
public void delLike( @RequestParam SchisandraUserLikesCommentDTO schisandraUserLikesCommentDTO) { public void delLike(@RequestBody SchisandraUserLikesCommentDTO schisandraUserLikesCommentDTO) {
Preconditions.checkNotNull(schisandraUserLikesCommentDTO); Preconditions.checkNotNull(schisandraUserLikesCommentDTO);
SchisandraUserLikesCommentBO schisandraUserLikesCommentBO=SchisandraUserLikesCommentDTOConverter.INSTANCE.convertDTOToBO(schisandraUserLikesCommentDTO); SchisandraUserLikesCommentBO schisandraUserLikesCommentBO = SchisandraUserLikesCommentDTOConverter.INSTANCE.convertDTOToBO(schisandraUserLikesCommentDTO);
schisandraUserLikesCommentBO.setLike(false); schisandraUserLikesCommentBO.setLike(false);
rocketMQTemplate.asyncSend("CommentLikes-topic", schisandraUserLikesCommentBO, new SendCallback() { rocketMQTemplate.asyncSend("CommentLikes-topic", schisandraUserLikesCommentBO, new SendCallback() {
@Override @Override
public void onSuccess(SendResult sendResult) { public void onSuccess(SendResult sendResult) {
System.out.println(sendResult); System.out.println(sendResult);
} }
@Override @Override
public void onException(Throwable e) { public void onException(Throwable e) {
e.printStackTrace(); e.printStackTrace();
@@ -93,10 +94,9 @@ public class SchisandraShareCommentReplyController {
} }
/** /**
* 返回点赞总数 * 返回点赞总数
*
* @param Id * @param Id
* @return * @return
*/ */
@@ -117,9 +117,9 @@ public class SchisandraShareCommentReplyController {
* @return * @return
*/ */
@GetMapping(value = "listreply") @GetMapping(value = "listreply")
public Result<SchisandraShareCommentReplyDTO> listReply(@RequestParam String commentId,@RequestParam String userId) { public Result<SchisandraShareCommentReplyDTO> listReply(@RequestParam String commentId, @RequestParam String userId) {
try { try {
List<SchisandraShareCommentReplyBO> result = schisandraShareCommentReplyDomainService.listReply(commentId,userId); List<SchisandraShareCommentReplyBO> result = schisandraShareCommentReplyDomainService.listReply(commentId, userId);
if (log.isInfoEnabled()) { if (log.isInfoEnabled()) {
log.info("获取评论回复{}", JSON.toJSONString(result)); log.info("获取评论回复{}", JSON.toJSONString(result));
} }
@@ -137,14 +137,14 @@ public class SchisandraShareCommentReplyController {
* 查询该动态下的评论 * 查询该动态下的评论
*/ */
@GetMapping(value = "listcomment") @GetMapping(value = "listcomment")
public Result<List<SchisandraShareCommentReplyDTO>> listComment(@RequestParam String detailId,@RequestParam String userId) { public Result<List<SchisandraShareCommentReplyDTO>> listComment(@RequestParam String detailId, @RequestParam String userId) {
try { try {
List<SchisandraShareCommentReplyBO> result = (List<SchisandraShareCommentReplyBO>) caffeineUtil List<SchisandraShareCommentReplyBO> result = (List<SchisandraShareCommentReplyBO>) caffeineUtil
.caffeineBuild().getIfPresent("listcomment" + detailId); .caffeineBuild().getIfPresent("listcomment" + detailId);
if (result != null) { if (result != null) {
return Result.ok(result); return Result.ok(result);
} }
result = schisandraShareCommentReplyDomainService.listComment(detailId,userId); result = schisandraShareCommentReplyDomainService.listComment(detailId, userId);
caffeineUtil.caffeineBuild().put("listcomment" + detailId, result); caffeineUtil.caffeineBuild().put("listcomment" + detailId, result);
if (log.isInfoEnabled()) { if (log.isInfoEnabled()) {
log.info("获取当前文章评论内容{}", JSON.toJSONString(result)); log.info("获取当前文章评论内容{}", JSON.toJSONString(result));
@@ -163,14 +163,14 @@ public class SchisandraShareCommentReplyController {
* 查询该动态下的评论(最热) * 查询该动态下的评论(最热)
*/ */
@GetMapping(value = "listcommenthot") @GetMapping(value = "listcommenthot")
public Result<List<SchisandraShareCommentReplyDTO>> listCommentHot(@RequestParam String detailId,@RequestParam String userId) { public Result<List<SchisandraShareCommentReplyDTO>> listCommentHot(@RequestParam String detailId, @RequestParam String userId) {
try { try {
List<SchisandraShareCommentReplyBO> result = (List<SchisandraShareCommentReplyBO>) caffeineUtil List<SchisandraShareCommentReplyBO> result = (List<SchisandraShareCommentReplyBO>) caffeineUtil
.caffeineBuild().getIfPresent("listcomment" + detailId); .caffeineBuild().getIfPresent("listcomment" + detailId);
if (result != null) { if (result != null) {
return Result.ok(result); return Result.ok(result);
} }
result = schisandraShareCommentReplyDomainService.listCommenthot(detailId,userId); result = schisandraShareCommentReplyDomainService.listCommenthot(detailId, userId);
caffeineUtil.caffeineBuild().put("listcommenthot" + detailId, result); caffeineUtil.caffeineBuild().put("listcommenthot" + detailId, result);
if (log.isInfoEnabled()) { if (log.isInfoEnabled()) {
log.info("获取当前文章评论内容{}", JSON.toJSONString(result)); log.info("获取当前文章评论内容{}", JSON.toJSONString(result));
@@ -203,7 +203,7 @@ public class SchisandraShareCommentReplyController {
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getUserId(), "发布人id不能为空"); Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getUserId(), "发布人id不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getToId(), "评论目标id不能为空"); Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getToId(), "评论目标id不能为空");
SchisandraShareCommentReplyBO SchisandraShareCommentReplyBO = SchisandraShareCommentReplyDTOConverter.INSTANCE.convertDTOToBO(schisandraShareCommentReplyDTO); SchisandraShareCommentReplyBO SchisandraShareCommentReplyBO = SchisandraShareCommentReplyDTOConverter.INSTANCE.convertDTOToBO(schisandraShareCommentReplyDTO);
if (schisandraShareCommentReplyDomainService.addReply(SchisandraShareCommentReplyBO)){ if (schisandraShareCommentReplyDomainService.addReply(SchisandraShareCommentReplyBO)) {
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("Id", schisandraShareCommentReplyDTO.getDetailId()); map.put("Id", schisandraShareCommentReplyDTO.getDetailId());
map.put("isReply", true); map.put("isReply", true);
@@ -211,7 +211,10 @@ public class SchisandraShareCommentReplyController {
String message = gson.toJson(map); String message = gson.toJson(map);
rocketMQTemplate.asyncSend("CommentCounts-topic", message, new SendCallback() { rocketMQTemplate.asyncSend("CommentCounts-topic", message, new SendCallback() {
@Override @Override
public void onSuccess(SendResult sendResult) {System.out.println(sendResult);} public void onSuccess(SendResult sendResult) {
System.out.println(sendResult);
}
@Override @Override
public void onException(Throwable e) { public void onException(Throwable e) {
e.printStackTrace(); e.printStackTrace();
@@ -222,7 +225,7 @@ public class SchisandraShareCommentReplyController {
Date date = new Date(); Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formattedDate = dateFormat.format(date); String formattedDate = dateFormat.format(date);
String key = redisUtil.buildKey(SHARE_USER_RECENT,schisandraShareCommentReplyDTO.getUserId(), formattedDate); String key = redisUtil.buildKey(SHARE_USER_RECENT, schisandraShareCommentReplyDTO.getUserId(), formattedDate);
redisUtil.setNx(key, value, 30L, TimeUnit.DAYS); redisUtil.setNx(key, value, 30L, TimeUnit.DAYS);
return Result.ok(); return Result.ok();
} }
@@ -249,6 +252,8 @@ public class SchisandraShareCommentReplyController {
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getDetailId(), "分享文章id不能为空"); Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getDetailId(), "分享文章id不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getUserId(), "发布人id不能为空"); Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getUserId(), "发布人id不能为空");
SchisandraShareCommentReplyBO schisandraShareCommentReplyBO = SchisandraShareCommentReplyDTOConverter.INSTANCE.convertDTOToBO(schisandraShareCommentReplyDTO); SchisandraShareCommentReplyBO schisandraShareCommentReplyBO = SchisandraShareCommentReplyDTOConverter.INSTANCE.convertDTOToBO(schisandraShareCommentReplyDTO);
// String result = SensitiveWordHelper.replace(schisandraShareCommentReplyBO.getContent());
// schisandraShareCommentReplyBO.setContent(result);
caffeineUtil.caffeineBuild().invalidate("listcommenthot" + schisandraShareCommentReplyBO.getDetailId()); caffeineUtil.caffeineBuild().invalidate("listcommenthot" + schisandraShareCommentReplyBO.getDetailId());
caffeineUtil.caffeineBuild().invalidate("listcomment" + schisandraShareCommentReplyBO.getDetailId()); caffeineUtil.caffeineBuild().invalidate("listcomment" + schisandraShareCommentReplyBO.getDetailId());
return Result.ok(schisandraShareCommentReplyDomainService.addComment(schisandraShareCommentReplyBO)); return Result.ok(schisandraShareCommentReplyDomainService.addComment(schisandraShareCommentReplyBO));
@@ -305,25 +310,8 @@ public class SchisandraShareCommentReplyController {
if (log.isInfoEnabled()) { if (log.isInfoEnabled()) {
log.info("SchisandraShareCommentReplyController.delete.dto:{}", JSON.toJSONString(schisandraShareCommentReplyDTO)); log.info("SchisandraShareCommentReplyController.delete.dto:{}", JSON.toJSONString(schisandraShareCommentReplyDTO));
} }
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getId(), "评论ID不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getDetailId(), "分享文章id不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getReplyType(), "回复类型 0评论 1回复不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getToId(), "评论目标id不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getToUser(), "评论人不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getReplyId(), "回复目标id不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getReplyUser(), "回复人不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getReplayAuthor(), "回复人是否作者 1=是 0=否不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getContent(), "内容不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getPicUrls(), "图片内容不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getLikes(), "点赞数不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getExtJson(), "预留字段不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getIsDeleted(), "不能为空");
SchisandraShareCommentReplyBO schisandraShareCommentReplyBO = SchisandraShareCommentReplyDTOConverter.INSTANCE.convertDTOToBO(schisandraShareCommentReplyDTO); SchisandraShareCommentReplyBO schisandraShareCommentReplyBO = SchisandraShareCommentReplyDTOConverter.INSTANCE.convertDTOToBO(schisandraShareCommentReplyDTO);
if (schisandraShareCommentReplyDomainService.delete(schisandraShareCommentReplyBO)){ if (schisandraShareCommentReplyDomainService.delete(schisandraShareCommentReplyBO)) {
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("Id", schisandraShareCommentReplyDTO.getDetailId()); map.put("Id", schisandraShareCommentReplyDTO.getDetailId());
map.put("isReply", false); map.put("isReply", false);
@@ -331,7 +319,10 @@ public class SchisandraShareCommentReplyController {
String message = gson.toJson(map); String message = gson.toJson(map);
rocketMQTemplate.asyncSend("CommentCounts-topic", message, new SendCallback() { rocketMQTemplate.asyncSend("CommentCounts-topic", message, new SendCallback() {
@Override @Override
public void onSuccess(SendResult sendResult) {System.out.println(sendResult);} public void onSuccess(SendResult sendResult) {
System.out.println(sendResult);
}
@Override @Override
public void onException(Throwable e) { public void onException(Throwable e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -57,8 +57,8 @@ public class SchisandraShareDetailController {
* @author zlg * @author zlg
* @date: 2024/7/20 14:38 * @date: 2024/7/20 14:38
*/ */
@GetMapping("addlike") @PostMapping("addlike")
public void addLike(@RequestParam SchisandraUserLikesDetailDTO schisandraUserLikesDetailDTO) { public void addLike(@RequestBody SchisandraUserLikesDetailDTO schisandraUserLikesDetailDTO) {
Preconditions.checkNotNull(schisandraUserLikesDetailDTO); Preconditions.checkNotNull(schisandraUserLikesDetailDTO);
SchisandraUserLikesDetailBO schisandraUserLikesDetailBO = SchisandraUserLikesDetailDTOConverter.INSTANCE.convertDTOToBO(schisandraUserLikesDetailDTO); SchisandraUserLikesDetailBO schisandraUserLikesDetailBO = SchisandraUserLikesDetailDTOConverter.INSTANCE.convertDTOToBO(schisandraUserLikesDetailDTO);
schisandraUserLikesDetailBO.setLike(true); schisandraUserLikesDetailBO.setLike(true);
@@ -76,8 +76,8 @@ public class SchisandraShareDetailController {
); );
} }
@GetMapping("dellike") @PostMapping("dellike")
public void delLike(@RequestParam SchisandraUserLikesDetailDTO schisandraUserLikesDetailDTO) { public void delLike(@RequestBody SchisandraUserLikesDetailDTO schisandraUserLikesDetailDTO) {
Preconditions.checkNotNull(schisandraUserLikesDetailDTO); Preconditions.checkNotNull(schisandraUserLikesDetailDTO);
SchisandraUserLikesDetailBO schisandraUserLikesDetailBO = SchisandraUserLikesDetailDTOConverter.INSTANCE.convertDTOToBO(schisandraUserLikesDetailDTO); SchisandraUserLikesDetailBO schisandraUserLikesDetailBO = SchisandraUserLikesDetailDTOConverter.INSTANCE.convertDTOToBO(schisandraUserLikesDetailDTO);
schisandraUserLikesDetailBO.setLike(false); schisandraUserLikesDetailBO.setLike(false);

View File

@@ -14,6 +14,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareCircleDTO implements Serializable { public class SchisandraShareCircleDTO implements Serializable {
private static final long serialVersionUID = -6815237089909853606L;
/** /**
* *
*/ */

View File

@@ -15,6 +15,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareCommentReplyDTO implements Serializable { public class SchisandraShareCommentReplyDTO implements Serializable {
private static final long serialVersionUID = -3214292939227938641L;
/** /**
* 评论ID * 评论ID
*/ */

View File

@@ -17,6 +17,7 @@ import java.util.List;
@Data @Data
public class SchisandraShareDetailDTO implements Serializable { public class SchisandraShareDetailDTO implements Serializable {
private static final long serialVersionUID = -3002376009180941583L;
/** /**
* *
*/ */

View File

@@ -14,6 +14,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareDetailTagDTO implements Serializable { public class SchisandraShareDetailTagDTO implements Serializable {
private static final long serialVersionUID = -8303938595676425286L;
/** /**
* *
*/ */

View File

@@ -14,6 +14,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareMessageDTO implements Serializable { public class SchisandraShareMessageDTO implements Serializable {
private static final long serialVersionUID = 1908950625615230476L;
/** /**
* 主键 * 主键
*/ */

View File

@@ -14,10 +14,11 @@ import java.util.Date;
@Data @Data
public class SchisandraShareSensitiveWordsDTO implements Serializable { public class SchisandraShareSensitiveWordsDTO implements Serializable {
private static final long serialVersionUID = 7725249957320038157L;
/** /**
* *
*/ */
private String id; private Long id;
/** /**
* *

View File

@@ -15,6 +15,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareTagsDTO implements Serializable { public class SchisandraShareTagsDTO implements Serializable {
private static final long serialVersionUID = -6740526444819241774L;
/** /**
* *
*/ */

View File

@@ -15,6 +15,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareUrlDTO implements Serializable { public class SchisandraShareUrlDTO implements Serializable {
private static final long serialVersionUID = 4823446869109431346L;
/** /**
* *
*/ */

View File

@@ -14,6 +14,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareUrlDetailDTO implements Serializable { public class SchisandraShareUrlDetailDTO implements Serializable {
private static final long serialVersionUID = 8117565906135520349L;
/** /**
* *
*/ */

View File

@@ -14,6 +14,7 @@ import java.util.Date;
@Data @Data
public class SchisandraUserFavoritesDTO implements Serializable { public class SchisandraUserFavoritesDTO implements Serializable {
private static final long serialVersionUID = -2235627799609388040L;
/** /**
* *
*/ */

View File

@@ -14,6 +14,7 @@ import java.util.Date;
@Data @Data
public class SchisandraUserLikesCommentDTO implements Serializable { public class SchisandraUserLikesCommentDTO implements Serializable {
private static final long serialVersionUID = 3309749734679647591L;
private Boolean like; private Boolean like;
/** /**
* *

View File

@@ -13,6 +13,7 @@ import java.util.Date;
*/ */
@Data @Data
public class SchisandraUserLikesDetailDTO implements Serializable { public class SchisandraUserLikesDetailDTO implements Serializable {
private static final long serialVersionUID = 7588859081028886708L;
private Boolean like; private Boolean like;
/** /**

View File

@@ -1,14 +0,0 @@
package com.schisandra.share.application.sensitive;
/**
* 结束类型定义
*
* @date 11:37 2020/11/11
**/
public enum EndType {
/**
* 有下一个,结束
*/
HAS_NEXT, IS_END
}

View File

@@ -1,47 +0,0 @@
package com.schisandra.share.application.sensitive;
import java.util.List;
/**
* 敏感词标记
*
*/
public class FlagIndex {
/**
* 标记结果
*/
private boolean flag;
/**
* 是否黑名单词汇
*/
private boolean isWhiteWord;
/**
* 标记索引
*/
private List<Integer> index;
public boolean isFlag() {
return flag;
}
public void setFlag(boolean flag) {
this.flag = flag;
}
public List<Integer> getIndex() {
return index;
}
public void setIndex(List<Integer> index) {
this.index = index;
}
public boolean isWhiteWord() {
return isWhiteWord;
}
public void setWhiteWord(boolean whiteWord) {
isWhiteWord = whiteWord;
}
}

View File

@@ -1,276 +0,0 @@
package com.schisandra.share.application.sensitive;
import com.alibaba.fastjson.JSON;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.util.CollectionUtil;
import com.schisandra.share.common.enums.IsDeletedFlagEnum;
import com.schisandra.share.infra.basic.dao.SchisandraShareSensitiveWordsDao;
import com.schisandra.share.infra.basic.entity.SchisandraShareSensitiveWords;
import com.schisandra.share.infra.basic.entity.table.SchisandraShareSensitiveWordsTableDef;
import com.schisandra.share.infra.basic.service.SchisandraShareSensitiveWordsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* 词库上下文环境
* <p>
* 初始化敏感词库将敏感词加入到HashMap中构建DFA算法模型
*
* @author minghu.zhang
*/
@SuppressWarnings({"rawtypes", "unchecked"})
@Slf4j
public class WordContext {
/**
* 敏感词字典
*/
private final Map wordMap = new HashMap(1024);
/**
* 是否已初始化
*/
private boolean init;
private long addLastId;
@Resource
private SchisandraShareSensitiveWordsDao schisandraShareSensitiveWordsDao;
public WordContext(boolean autoLoad) {
clearDelData();
Set<String> black = new HashSet<>();
Set<String> white = new HashSet<>();
QueryWrapper query = new QueryWrapper();
query.where(SchisandraShareSensitiveWordsTableDef.SCHISANDRA_SHARE_SENSITIVE_WORDS.IS_DELETED.eq(IsDeletedFlagEnum.UN_DELETED.getCode()));
List<SchisandraShareSensitiveWords> list = schisandraShareSensitiveWordsDao.selectListByQuery(query);
for (SchisandraShareSensitiveWords words : list) {
if (words.getType() == 1) {
black.add(words.getWords());
} else {
white.add(words.getWords());
}
}
if (CollectionUtil.isNotEmpty(list)) {
this.addLastId = Long.parseLong(list.get(list.size() - 1).getId());
}
initKeyWord(black, white);
if (autoLoad) {
reloadWord();
}
}
private void clearDelData() {
QueryWrapper query = new QueryWrapper();
query.where(SchisandraShareSensitiveWordsTableDef.SCHISANDRA_SHARE_SENSITIVE_WORDS.IS_DELETED.eq(IsDeletedFlagEnum.DELETED.getCode()));
List<SchisandraShareSensitiveWords> list = schisandraShareSensitiveWordsDao.selectListByQuery(query);
schisandraShareSensitiveWordsDao.deleteBatchByIds(list.stream().map(SchisandraShareSensitiveWords::getId).collect(Collectors.toList()));
}
private void reloadWord() {
// 创建一个单线程的定时线程池
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
// 创建一个Runnable任务
Runnable task = () -> {
try {
addNewWords();
removeDelWords();
} catch (Exception e) {
log.error("Sensitive words task error", e);
}
};
// 定时执行任务初始延迟0之后每分钟执行一次
scheduler.scheduleAtFixedRate(task, 0, 1, TimeUnit.MINUTES);
}
private void removeDelWords() {
QueryWrapper query = new QueryWrapper();
query.where(SchisandraShareSensitiveWordsTableDef.SCHISANDRA_SHARE_SENSITIVE_WORDS.IS_DELETED.eq(IsDeletedFlagEnum.DELETED.getCode()));
List<SchisandraShareSensitiveWords> list = schisandraShareSensitiveWordsDao.selectListByQuery(query);
if (CollectionUtil.isNotEmpty(list)) {
log.info("removeDelWords {}", JSON.toJSON(list));
Set<String> black = new HashSet<>();
Set<String> white = new HashSet<>();
for (SchisandraShareSensitiveWords words : list) {
if (words.getType() == 1) {
black.add(words.getWords());
} else {
white.add(words.getWords());
}
}
removeWord(black, WordType.BLACK);
removeWord(white, WordType.WHITE);
}
}
private void addNewWords() {
QueryWrapper query = new QueryWrapper();
query.where(SchisandraShareSensitiveWordsTableDef.SCHISANDRA_SHARE_SENSITIVE_WORDS.ID.gt(addLastId).and(SchisandraShareSensitiveWordsTableDef.SCHISANDRA_SHARE_SENSITIVE_WORDS.IS_DELETED.eq(IsDeletedFlagEnum.UN_DELETED.getCode())));
List<SchisandraShareSensitiveWords> list = schisandraShareSensitiveWordsDao.selectListByQuery(query);
if (CollectionUtil.isNotEmpty(list)) {
log.info("addNewWords {}", JSON.toJSON(list));
this.addLastId = Long.parseLong(list.get(list.size() - 1).getId());
Set<String> black = new HashSet<>();
Set<String> white = new HashSet<>();
for (SchisandraShareSensitiveWords words : list) {
if (words.getType() == 1) {
black.add(words.getWords());
} else {
white.add(words.getWords());
}
}
addWord(black, WordType.BLACK);
addWord(white, WordType.WHITE);
}
}
/**
* 获取初始化的敏感词列表
*
* @return 敏感词列表
*/
public Map getWordMap() {
return wordMap;
}
/**
* 初始化
*/
private synchronized void initKeyWord(Set<String> black, Set<String> white) {
try {
if (!init) {
// 将敏感词库加入到HashMap中
addWord(black, WordType.BLACK);
// 将非敏感词库也加入到HashMap中
addWord(white, WordType.WHITE);
}
init = true;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 读取敏感词库将敏感词放入HashSet中构建一个DFA算法模型<br>
* 中 = { isEnd = 0 国 = {<br>
* isEnd = 1 人 = {isEnd = 0 民 = {isEnd = 1} } 男 = { isEnd = 0 人 = { isEnd = 1 }
* } } } 五 = { isEnd = 0 星 = { isEnd = 0 红 = { isEnd = 0 旗 = { isEnd = 1 } } } }
*/
public void addWord(Collection<String> wordList, WordType wordType) {
if (CollectionUtils.isEmpty(wordList)) {
return;
}
Map nowMap;
Map<String, String> newWorMap;
// 迭代keyWordSet
for (String key : wordList) {
nowMap = wordMap;
for (int i = 0; i < key.length(); i++) {
// 转换成char型
char keyChar = key.charAt(i);
// 获取
Object wordMap = nowMap.get(keyChar);
// 如果存在该key直接赋值
if (wordMap != null) {
nowMap = (Map) wordMap;
} else {
// 不存在则构建一个map同时将isEnd设置为0因为他不是最后一个
newWorMap = new HashMap<>(4);
// 不是最后一个
newWorMap.put("isEnd", String.valueOf(EndType.HAS_NEXT.ordinal()));
nowMap.put(keyChar, newWorMap);
nowMap = newWorMap;
}
if (i == key.length() - 1) {
// 最后一个
nowMap.put("isEnd", String.valueOf(EndType.IS_END.ordinal()));
nowMap.put("isWhiteWord", String.valueOf(wordType.ordinal()));
}
}
}
}
/**
* 在线删除敏感词
*
* @param wordList 敏感词列表
* @param wordType 黑名单 BLACk白名单WHITE
*/
public void removeWord(Collection<String> wordList, WordType wordType) {
if (CollectionUtils.isEmpty(wordList)) {
return;
}
Map nowMap;
for (String key : wordList) {
List<Map> cacheList = new ArrayList<>();
nowMap = wordMap;
for (int i = 0; i < key.length(); i++) {
char keyChar = key.charAt(i);
Object map = nowMap.get(keyChar);
if (map != null) {
nowMap = (Map) map;
cacheList.add(nowMap);
} else {
return;
}
if (i == key.length() - 1) {
char[] keys = key.toCharArray();
boolean cleanable = false;
char lastChar = 0;
for (int j = cacheList.size() - 1; j >= 0; j--) {
Map cacheMap = cacheList.get(j);
if (j == cacheList.size() - 1) {
if (String.valueOf(WordType.BLACK.ordinal()).equals(cacheMap.get("isWhiteWord"))) {
if (wordType == WordType.WHITE) {
return;
}
}
if (String.valueOf(WordType.WHITE.ordinal()).equals(cacheMap.get("isWhiteWord"))) {
if (wordType == WordType.BLACK) {
return;
}
}
cacheMap.remove("isWhiteWord");
cacheMap.remove("isEnd");
if (cacheMap.size() == 0) {
cleanable = true;
continue;
}
}
if (cleanable) {
Object isEnd = cacheMap.get("isEnd");
if (String.valueOf(EndType.IS_END.ordinal()).equals(isEnd)) {
cleanable = false;
}
cacheMap.remove(lastChar);
}
lastChar = keys[j];
}
if (cleanable) {
wordMap.remove(lastChar);
}
}
}
}
}
}

View File

@@ -1,224 +0,0 @@
package com.schisandra.share.application.sensitive;
import com.mybatisflex.core.util.CollectionUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* 敏感词过滤器
*
* @author minghu.zhang
*/
@SuppressWarnings("rawtypes")
public class WordFilter {
/**
* 敏感词表
*/
private final Map wordMap;
/**
* 构造函数
*/
public WordFilter(WordContext context) {
this.wordMap = context.getWordMap();
}
/**
* 替换敏感词
*
* @param text 输入文本
*/
public String replace(final String text) {
return replace(text, 0, '*');
}
/**
* 替换敏感词
*
* @param text 输入文本
* @param symbol 替换符号
*/
public String replace(final String text, final char symbol) {
return replace(text, 0, symbol);
}
/**
* 替换敏感词
*
* @param text 输入文本
* @param skip 文本距离
* @param symbol 替换符号
*/
public String replace(final String text, final int skip, final char symbol) {
char[] charset = text.toCharArray();
for (int i = 0; i < charset.length; i++) {
FlagIndex fi = getFlagIndex(charset, i, skip);
if (fi.isFlag()) {
if (!fi.isWhiteWord()) {
for (int j : fi.getIndex()) {
charset[j] = symbol;
}
} else {
i += fi.getIndex().size() - 1;
}
}
}
return new String(charset);
}
/**
* 是否包含敏感词
*
* @param text 输入文本
*/
public boolean include(final String text) {
return include(text, 0);
}
/**
* 是否包含敏感词
*
* @param text 输入文本
* @param skip 文本距离
*/
public boolean include(final String text, final int skip) {
boolean include = false;
char[] charset = text.toCharArray();
for (int i = 0; i < charset.length; i++) {
FlagIndex fi = getFlagIndex(charset, i, skip);
if (fi.isFlag()) {
if (fi.isWhiteWord()) {
i += fi.getIndex().size() - 1;
} else {
include = true;
break;
}
}
}
return include;
}
/**
* 获取敏感词数量
*
* @param text 输入文本
*/
public int wordCount(final String text) {
return wordCount(text, 0);
}
/**
* 获取敏感词数量
*
* @param text 输入文本
* @param skip 文本距离
*/
public int wordCount(final String text, final int skip) {
int count = 0;
char[] charset = text.toCharArray();
for (int i = 0; i < charset.length; i++) {
FlagIndex fi = getFlagIndex(charset, i, skip);
if (fi.isFlag()) {
if (fi.isWhiteWord()) {
i += fi.getIndex().size() - 1;
} else {
count++;
}
}
}
return count;
}
public void check(final String text) {
List<String> wordList = wordList(text);
if (CollectionUtil.isNotEmpty(wordList)) {
throw new IllegalArgumentException(String.format("内容包含敏感词 【%s】", String.join("", wordList)));
}
}
/**
* 获取敏感词列表
*
* @param text 输入文本
*/
public List<String> wordList(final String text) {
return wordList(text, 0);
}
/**
* 获取敏感词列表
*
* @param text 输入文本
* @param skip 文本距离
*/
public List<String> wordList(final String text, final int skip) {
List<String> wordList = new ArrayList<>();
char[] charset = text.toCharArray();
for (int i = 0; i < charset.length; i++) {
FlagIndex fi = getFlagIndex(charset, i, skip);
if (fi.isFlag()) {
if (fi.isWhiteWord()) {
i += fi.getIndex().size() - 1;
} else {
StringBuilder builder = new StringBuilder();
for (int j : fi.getIndex()) {
char word = text.charAt(j);
builder.append(word);
}
wordList.add(builder.toString());
}
}
}
return wordList;
}
/**
* 获取标记索引
*
* @param charset 输入文本
* @param begin 检测起始
* @param skip 文本距离
*/
private FlagIndex getFlagIndex(final char[] charset, final int begin, final int skip) {
FlagIndex fi = new FlagIndex();
Map current = wordMap;
boolean flag = false;
int count = 0;
List<Integer> index = new ArrayList<>();
for (int i = begin; i < charset.length; i++) {
char word = charset[i];
Map mapTree = (Map) current.get(word);
if (count > skip || (i == begin && Objects.isNull(mapTree))) {
break;
}
if (Objects.nonNull(mapTree)) {
current = mapTree;
count = 0;
index.add(i);
} else {
count++;
if (flag && count > skip) {
break;
}
}
if ("1".equals(current.get("isEnd"))) {
flag = true;
}
if ("1".equals(current.get("isWhiteWord"))) {
fi.setWhiteWord(true);
break;
}
}
fi.setFlag(flag);
fi.setIndex(index);
return fi;
}
}

View File

@@ -1,15 +0,0 @@
package com.schisandra.share.application.sensitive;
/**
* 词汇类型
*
* @author minghu.zhang
* @date 11:37 2020/11/11
**/
public enum WordType {
/**
* 黑名单/白名单
*/
BLACK, WHITE
}

View File

@@ -13,6 +13,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareCircleBO implements Serializable { public class SchisandraShareCircleBO implements Serializable {
private static final long serialVersionUID = -2438275436224488681L;
/** /**
* *
*/ */

View File

@@ -13,6 +13,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareCommentReplyBO implements Serializable { public class SchisandraShareCommentReplyBO implements Serializable {
private static final long serialVersionUID = 7396320253168071925L;
/** /**
* 评论ID * 评论ID
*/ */

View File

@@ -15,6 +15,7 @@ import java.util.List;
@Data @Data
public class SchisandraShareDetailBO implements Serializable { public class SchisandraShareDetailBO implements Serializable {
private static final long serialVersionUID = 3046543086777783698L;
/** /**
* *
*/ */

View File

@@ -13,6 +13,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareDetailTagBO implements Serializable { public class SchisandraShareDetailTagBO implements Serializable {
private static final long serialVersionUID = 3859452433836725561L;
/** /**
* *
*/ */

View File

@@ -13,6 +13,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareMessageBO implements Serializable { public class SchisandraShareMessageBO implements Serializable {
private static final long serialVersionUID = -2393313384087598602L;
/** /**
* 主键 * 主键
*/ */

View File

@@ -13,10 +13,11 @@ import java.util.Date;
@Data @Data
public class SchisandraShareSensitiveWordsBO implements Serializable { public class SchisandraShareSensitiveWordsBO implements Serializable {
private static final long serialVersionUID = -4194683657816043615L;
/** /**
* *
*/ */
private String id; private Long id;
/** /**
* *

View File

@@ -13,6 +13,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareTagsBO implements Serializable { public class SchisandraShareTagsBO implements Serializable {
private static final long serialVersionUID = -3033095062989387977L;
/** /**
* *
*/ */

View File

@@ -13,6 +13,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareUrlBO implements Serializable { public class SchisandraShareUrlBO implements Serializable {
private static final long serialVersionUID = 1041062258519707056L;
/** /**
* *
*/ */

View File

@@ -13,6 +13,7 @@ import java.util.Date;
@Data @Data
public class SchisandraShareUrlDetailBO implements Serializable { public class SchisandraShareUrlDetailBO implements Serializable {
private static final long serialVersionUID = -5026950135938851911L;
/** /**
* *
*/ */

View File

@@ -13,6 +13,7 @@ import java.util.Date;
@Data @Data
public class SchisandraUserFavoritesBO implements Serializable { public class SchisandraUserFavoritesBO implements Serializable {
private static final long serialVersionUID = -8964499260886320865L;
/** /**
* *
*/ */

View File

@@ -13,6 +13,7 @@ import java.util.Date;
@Data @Data
public class SchisandraUserLikesCommentBO implements Serializable { public class SchisandraUserLikesCommentBO implements Serializable {
private static final long serialVersionUID = -7613406145156837697L;
private Boolean like; private Boolean like;
/** /**

View File

@@ -13,6 +13,7 @@ import java.util.Date;
@Data @Data
public class SchisandraUserLikesDetailBO implements Serializable { public class SchisandraUserLikesDetailBO implements Serializable {
private static final long serialVersionUID = 6858213092483046030L;
private Boolean like; private Boolean like;
/** /**
* *

View File

@@ -21,6 +21,7 @@ import java.util.Date;
@Table("schisandra_share_circle") @Table("schisandra_share_circle")
public class SchisandraShareCircle implements Serializable { public class SchisandraShareCircle implements Serializable {
private static final long serialVersionUID = -3141577485929418943L;
/** /**
* *
*/ */

View File

@@ -21,6 +21,7 @@ import java.util.Date;
@Table("schisandra_share_comment_reply") @Table("schisandra_share_comment_reply")
public class SchisandraShareCommentReply implements Serializable { public class SchisandraShareCommentReply implements Serializable {
private static final long serialVersionUID = -2667653332370397307L;
/** /**
* 评论ID * 评论ID
*/ */

View File

@@ -21,6 +21,7 @@ import java.util.Date;
@Table("schisandra_share_detail") @Table("schisandra_share_detail")
public class SchisandraShareDetail implements Serializable { public class SchisandraShareDetail implements Serializable {
private static final long serialVersionUID = -835341590201804474L;
/** /**
* *
*/ */

View File

@@ -20,6 +20,7 @@ import java.util.Date;
@Table("schisandra_share_detail_tag") @Table("schisandra_share_detail_tag")
public class SchisandraShareDetailTag implements Serializable { public class SchisandraShareDetailTag implements Serializable {
private static final long serialVersionUID = -5171975540389176702L;
/** /**
* *
*/ */

View File

@@ -21,6 +21,7 @@ import java.util.Date;
@Table("schisandra_share_message") @Table("schisandra_share_message")
public class SchisandraShareMessage implements Serializable { public class SchisandraShareMessage implements Serializable {
private static final long serialVersionUID = -1459891032874418307L;
/** /**
* 主键 * 主键
*/ */

View File

@@ -20,11 +20,12 @@ import java.util.Date;
@Table("schisandra_share_sensitive_words") @Table("schisandra_share_sensitive_words")
public class SchisandraShareSensitiveWords implements Serializable { public class SchisandraShareSensitiveWords implements Serializable {
private static final long serialVersionUID = 1307657203088513435L;
/** /**
* *
*/ */
@Id(keyType=KeyType.Generator, value= KeyGenerators.flexId) @Id(keyType = KeyType.Auto)
private String id; private Long id;
/** /**
* *

View File

@@ -21,6 +21,7 @@ import java.util.Date;
@Table("schisandra_share_tags") @Table("schisandra_share_tags")
public class SchisandraShareTags implements Serializable { public class SchisandraShareTags implements Serializable {
private static final long serialVersionUID = 7161726685308038455L;
/** /**
* *
*/ */

View File

@@ -21,6 +21,7 @@ import java.util.Date;
@Table("schisandra_share_url") @Table("schisandra_share_url")
public class SchisandraShareUrl implements Serializable { public class SchisandraShareUrl implements Serializable {
private static final long serialVersionUID = 2496949535444560839L;
/** /**
* *
*/ */

View File

@@ -20,6 +20,7 @@ import java.util.Date;
@Table("schisandra_share_url_detail") @Table("schisandra_share_url_detail")
public class SchisandraShareUrlDetail implements Serializable { public class SchisandraShareUrlDetail implements Serializable {
private static final long serialVersionUID = -3349751063344560516L;
/** /**
* *
*/ */

View File

@@ -21,6 +21,7 @@ import java.util.Date;
@Table("schisandra_user_favorites") @Table("schisandra_user_favorites")
public class SchisandraUserFavorites implements Serializable { public class SchisandraUserFavorites implements Serializable {
private static final long serialVersionUID = 4499052437865046423L;
/** /**
* *
*/ */

View File

@@ -4,6 +4,7 @@ import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table; import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@@ -19,10 +20,11 @@ import java.util.Date;
@Table("schisandra_user_likes_comment") @Table("schisandra_user_likes_comment")
public class SchisandraUserLikesComment implements Serializable { public class SchisandraUserLikesComment implements Serializable {
private static final long serialVersionUID = -8536327597714874736L;
/** /**
* *
*/ */
@Id(value = "id", keyType = KeyType.Auto) @Id(keyType=KeyType.Generator, value= KeyGenerators.flexId)
private String id; private String id;
/** /**

View File

@@ -4,6 +4,7 @@ import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table; import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@@ -19,10 +20,11 @@ import java.util.Date;
@Table("schisandra_user_likes_detail") @Table("schisandra_user_likes_detail")
public class SchisandraUserLikesDetail implements Serializable { public class SchisandraUserLikesDetail implements Serializable {
private static final long serialVersionUID = 7754238683204111864L;
/** /**
* *
*/ */
@Id(value = "id", keyType = KeyType.Auto) @Id(keyType=KeyType.Generator, value= KeyGenerators.flexId)
private String id; private String id;
/** /**

View File

@@ -1,98 +1,98 @@
server: server:
port: 5000 port: 5000
spring: spring:
datasource: datasource:
username: root username: root
password: BZbVbGDBePiA2q8/mt0eMxKNpHniDzxBtOxFadQiAOTDzCDlopC4qOKwwBEi9CAZcuFsCrRJdwn0wP6jwsnzxw== password: BZbVbGDBePiA2q8/mt0eMxKNpHniDzxBtOxFadQiAOTDzCDlopC4qOKwwBEi9CAZcuFsCrRJdwn0wP6jwsnzxw==
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://1.95.0.111:3306/schisandra-cloud-storage?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=true url: jdbc:mysql://1.95.0.111:3306/schisandra-cloud-storage?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=true
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
druid: druid:
initial-size: 20 initial-size: 20
min-idle: 20 min-idle: 20
max-active: 100 max-active: 100
max-wait: 60000 max-wait: 60000
connectionProperties: config.decrypt=true;config.decrypt.key=${publicKey}; connectionProperties: config.decrypt=true;config.decrypt.key=${publicKey};
stat-view-servlet: stat-view-servlet:
enabled: true enabled: true
url-pattern: /druid/* url-pattern: /druid/*
login-username: admin login-username: admin
login-password: 123456 login-password: 123456
filter: filter:
stat: stat:
enabled: true enabled: true
slow-sql-millis: 2000 slow-sql-millis: 2000
log-slow-sql: true log-slow-sql: true
wall: wall:
enabled: true enabled: true
config: config:
enabled: true enabled: true
# redis配置 # redis配置
redis: redis:
# Redis数据库索引默认为0 # Redis数据库索引默认为0
database: 1 database: 1
# Redis服务器地址 # Redis服务器地址
host: 1.95.0.111 host: 1.95.0.111
# Redis服务器连接端口 # Redis服务器连接端口
port: 6379 port: 6379
# Redis服务器连接密码默认为空 # Redis服务器连接密码默认为空
password: LDQ20020618xxx password: LDQ20020618xxx
# 连接超时时间 # 连接超时时间
timeout: 2s timeout: 2s
lettuce: lettuce:
pool: pool:
# 连接池最大连接数 # 连接池最大连接数
max-active: 200 max-active: 200
# 连接池最大阻塞等待时间(使用负值表示没有限制) # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms max-wait: -1ms
# 连接池中的最大空闲连接 # 连接池中的最大空闲连接
max-idle: 10 max-idle: 10
# 连接池中的最小空闲连接 # 连接池中的最小空闲连接
min-idle: 0 min-idle: 0
publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANUVxjcrVoirBZaNmDrUqatHEW4FOHbO5ynW6zvhIbRMo6hEFGgglbURkjuHOlgEduxJVz6Xa+sG+FMrxTguOJECAwEAAQ== publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANUVxjcrVoirBZaNmDrUqatHEW4FOHbO5ynW6zvhIbRMo6hEFGgglbURkjuHOlgEduxJVz6Xa+sG+FMrxTguOJECAwEAAQ==
logging: logging:
config: classpath:log4j2-spring.xml config: classpath:log4j2-spring.xml
############## Sa-Token 配置 (文档: https://sa-token.cc) ############## ############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
sa-token: sa-token:
# token 名称(同时也是 cookie 名称) # token 名称(同时也是 cookie 名称)
token-name: token token-name: token
# token 有效期(单位:秒) 默认30天-1 代表永久有效 # token 有效期(单位:秒) 默认30天-1 代表永久有效
timeout: 2592000 timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结 # token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1 active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录) # 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token # 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token
is-share: true is-share: true
# token 风格默认可取值uuid、simple-uuid、random-32、random-64、random-128、tik # token 风格默认可取值uuid、simple-uuid、random-32、random-64、random-128、tik
token-style: random-32 token-style: random-32
# 是否输出操作日志 # 是否输出操作日志
is-log: false is-log: false
token-prefix: schisandra token-prefix: schisandra
is-print: false is-print: false
mybatis-flex: mybatis-flex:
global-config: global-config:
print-banner: false print-banner: false
key-config: key-config:
key-type: generator key-type: generator
normal-value-of-logic-delete: 0 normal-value-of-logic-delete: 0
deleted-value-of-logic-delete: 1 deleted-value-of-logic-delete: 1
logic-delete-column: is_deleted logic-delete-column: is_deleted
mapper-locations: mapper-locations:
- "classpath*:/mapper/**/*.xml" - "classpath*:/mapper/**/*.xml"
# xxl-job配置 # xxl-job配置
xxl: xxl:
job: job:
admin: admin:
addresses: http://1.95.0.111:8088/xxl-job-admin addresses: http://1.95.0.111:8088/xxl-job-admin
accessToken: default_token accessToken: default_token
executor: executor:
appname: schisandra-cloud-storage-system appname: schisandra-cloud-storage-system
address: address:
ip: 1.95.0.111 ip: 1.95.0.111
port: 9999 port: 9998
logpath: /data/applogs/xxl-job/jobhandler logpath: /data/applogs/xxl-job/jobhandler
logretentiondays: 30 logretentiondays: 30

View File

@@ -1,48 +1,48 @@
server: server:
port: 3010 port: 80
spring: spring:
# redis配置 # redis配置
redis: redis:
# Redis数据库索引默认为0 # Redis数据库索引默认为0
database: 1 database: 1
# Redis服务器地址 # Redis服务器地址
host: 1.95.0.111 host: 1.95.0.111
# Redis服务器连接端口 # Redis服务器连接端口
port: 6379 port: 6379
# Redis服务器连接密码默认为空 # Redis服务器连接密码默认为空
password: LDQ20020618xxx password: LDQ20020618xxx
# 连接超时时间 # 连接超时时间
timeout: 2s timeout: 2s
lettuce: lettuce:
pool: pool:
# 连接池最大连接数 # 连接池最大连接数
max-active: 200 max-active: 200
# 连接池最大阻塞等待时间(使用负值表示没有限制) # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms max-wait: -1ms
# 连接池中的最大空闲连接 # 连接池中的最大空闲连接
max-idle: 10 max-idle: 10
# 连接池中的最小空闲连接 # 连接池中的最小空闲连接
min-idle: 0 min-idle: 0
# 微信公众号 # 微信公众号
wx: wx:
mp: mp:
token: LDQ20020618xxx token: LDQ20020618xxx
appid: wx55251c2f83b9fc25 appid: wx7c3b1f52f460e5dd
secret: d511800cd53d248afe1260bb8aeed230 secret: f924c42c90223a0013908e204863c3b8
codeExpire: 3600 codeExpire: 3600
encodingAESKey: encodingAESKey:
# xxl-job配置 # xxl-job配置
xxl: xxl:
job: job:
admin: admin:
addresses: http://127.0.0.1:8081/xxl-job-admin addresses: http://1.95.0.111:8088/xxl-job-admin
accessToken: default_token accessToken: default_token
executor: executor:
appname: schisandra-cloud-storage-wechat appname: schisandra-cloud-storage-wechat
address: address:
ip: 127.0.0.1 ip: 1.95.0.111
port: 9998 port: 9996
logpath: /data/applogs/xxl-job/jobhandler logpath: /data/applogs/xxl-job/jobhandler
logretentiondays: 30 logretentiondays: 30