🎨 题库服务地址变更

🎨 题库服务地址变更
This commit is contained in:
ronger 2023-01-31 19:15:29 +08:00 committed by GitHub
commit accfe10a85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 47 additions and 102 deletions

14
pom.xml
View File

@ -10,7 +10,7 @@
</parent> </parent>
<groupId>com.rymcu</groupId> <groupId>com.rymcu</groupId>
<artifactId>forest</artifactId> <artifactId>forest</artifactId>
<version>0.0.1</version> <version>0.0.2</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>forest</name> <name>forest</name>
<description>forest(森林) —— 一款现代化的知识社区后台项目,使用 SpringBoot + Shiro + MyBatis + JWT + Redis 实现。 <description>forest(森林) —— 一款现代化的知识社区后台项目,使用 SpringBoot + Shiro + MyBatis + JWT + Redis 实现。
@ -56,14 +56,14 @@
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>2.13.4.2</version> <version>2.14.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version> <version>3.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
@ -128,7 +128,7 @@
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>2.0.16</version> <version>2.0.20</version>
</dependency> </dependency>
<!-- shiro权限控制框架 --> <!-- shiro权限控制框架 -->
<dependency> <dependency>
@ -183,7 +183,7 @@
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId> <artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.14</version> <version>1.2.15</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
@ -261,12 +261,12 @@
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId> <artifactId>hutool-core</artifactId>
<version>5.8.9</version> <version>5.8.10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-http</artifactId> <artifactId>hutool-http</artifactId>
<version>5.8.9</version> <version>5.8.10</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -8,6 +8,7 @@ import com.rymcu.forest.entity.User;
import com.rymcu.forest.enumerate.TransactionEnum; import com.rymcu.forest.enumerate.TransactionEnum;
import com.rymcu.forest.util.HttpUtils; import com.rymcu.forest.util.HttpUtils;
import com.rymcu.forest.util.UserUtils; import com.rymcu.forest.util.UserUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashMap; import java.util.HashMap;
@ -20,7 +21,8 @@ import java.util.Map;
@RequestMapping("/api/v1/answer") @RequestMapping("/api/v1/answer")
public class AnswerController { public class AnswerController {
private final static String ANSWER_API_URL = "http://1.116.175.112:8089/question"; @Value("${resource.answer-api-url}")
private String ANSWER_API_URL;
@GetMapping("/today") @GetMapping("/today")
public GlobalResult today() { public GlobalResult today() {

View File

@ -21,7 +21,6 @@ public class VisitableThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
private void showThreadPoolInfo(String prefix) { private void showThreadPoolInfo(String prefix) {
ThreadPoolExecutor threadPoolExecutor = getThreadPoolExecutor(); ThreadPoolExecutor threadPoolExecutor = getThreadPoolExecutor();
logger.info("{}, {},taskCount [{}], completedTaskCount [{}], activeCount [{}], queueSize [{}]", logger.info("{}, {},taskCount [{}], completedTaskCount [{}], activeCount [{}], queueSize [{}]",
this.getThreadNamePrefix(), this.getThreadNamePrefix(),
prefix, prefix,

View File

@ -21,7 +21,7 @@ public class GlobalResult<T> {
} }
public static <T> GlobalResult<T> newInstance() { public static <T> GlobalResult<T> newInstance() {
return new GlobalResult(); return new GlobalResult<>();
} }
} }

View File

@ -134,7 +134,7 @@ public interface RedisService {
* @param expireTime 缓存内容过期时间 单位 若expireTime小于0 则表示该内容不过期 * @param expireTime 缓存内容过期时间 单位 若expireTime小于0 则表示该内容不过期
* @return * @return
*/ */
String set(String key, Object obj, int expireTime); String set(String key, Object obj, long expireTime);
/** /**
@ -145,7 +145,7 @@ public interface RedisService {
* @param expireTime 缓存内容过期时间 单位 若expireTime小于0 则表示该内容不过期 * @param expireTime 缓存内容过期时间 单位 若expireTime小于0 则表示该内容不过期
* @return * @return
*/ */
String set(String key, String value, int expireTime); String set(String key, String value, long expireTime);
/** /**
* 写入/修改 缓存内容 * 写入/修改 缓存内容
@ -212,7 +212,7 @@ public interface RedisService {
* @param key * @param key
* @param seconds * @param seconds
*/ */
void setTTL(String key, int seconds); void setTTL(String key, long seconds);
/** /**
* 根据通配符表达式查询key值的set通配符仅支持* * 根据通配符表达式查询key值的set通配符仅支持*

View File

@ -163,7 +163,7 @@ public class RedisServiceImpl implements RedisService {
* @return * @return
*/ */
@Override @Override
public String set(String key, Object obj, int expireTime) { public String set(String key, Object obj, long expireTime) {
String value = RedisService.BLANK_CONTENT; String value = RedisService.BLANK_CONTENT;
if (obj != null) { if (obj != null) {
try { try {
@ -184,7 +184,7 @@ public class RedisServiceImpl implements RedisService {
* @return * @return
*/ */
@Override @Override
public String set(String key, String value, int expireTime) { public String set(String key, String value, long expireTime) {
if (StringUtils.isBlank(key)) { if (StringUtils.isBlank(key)) {
logger.warn("Params key is blank!"); logger.warn("Params key is blank!");
return null; return null;
@ -460,7 +460,7 @@ public class RedisServiceImpl implements RedisService {
* @param seconds * @param seconds
*/ */
@Override @Override
public void setTTL(String key, int seconds) { public void setTTL(String key, long seconds) {
if (seconds < 0) { if (seconds < 0) {
return; return;
} }

View File

@ -42,7 +42,7 @@ public class DefaultConfig implements Configuration {
* 用户自定义字典路径 * 用户自定义字典路径
*/ */
private static final String PATH_USER_DIC = private static final String PATH_USER_DIC =
System.getProperty("user.dir") + "/lucene/userDic/userDic.dic"; "lucene/userDic/userDic.dic";
/** /**
* 配置属性扩展字典 * 配置属性扩展字典
*/ */

View File

@ -53,7 +53,7 @@ public class Dictionary {
* 用户自定义词典路径 * 用户自定义词典路径
*/ */
private static final String PATH_USER_DIC = private static final String PATH_USER_DIC =
System.getProperty("user.dir") + "/lucene/userDic/userDic.dic"; "lucene/userDic/userDic.dic";
/** /**
* 配置对象 * 配置对象
*/ */

View File

@ -1,6 +1,7 @@
package com.rymcu.forest.lucene.util; package com.rymcu.forest.lucene.util;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.rymcu.forest.lucene.model.ArticleLucene; import com.rymcu.forest.lucene.model.ArticleLucene;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
@ -23,8 +24,7 @@ public class ArticleIndexUtil {
/** /**
* lucene索引保存目录 * lucene索引保存目录
*/ */
private static final String PATH = private static final String PATH = System.getProperty("user.dir") + StrUtil.SLASH + LucenePath.ARTICLE_INDEX_PATH;
System.getProperty("user.dir") + LucenePath.ARTICLE_INDEX_PATH;
/** /**
* 删除所有运行中保存的索引 * 删除所有运行中保存的索引

View File

@ -10,7 +10,7 @@ public final class LucenePath {
/** /**
* lucene 目录 * lucene 目录
*/ */
public static final String INDEX_PATH = "/lucene/index"; public static final String INDEX_PATH = "lucene/index";
/** /**
* 文章 lucene 目录 * 文章 lucene 目录
@ -21,7 +21,7 @@ public final class LucenePath {
* 文章增量 lucene 目录 * 文章增量 lucene 目录
*/ */
public static final String ARTICLE_INCREMENT_INDEX_PATH = public static final String ARTICLE_INCREMENT_INDEX_PATH =
System.getProperty("user.dir") + ARTICLE_INDEX_PATH + "/index777"; ARTICLE_INDEX_PATH + "/index777";
/** /**
* 用户 lucene 目录 * 用户 lucene 目录
@ -32,7 +32,7 @@ public final class LucenePath {
* 用户增量 lucene 目录 * 用户增量 lucene 目录
*/ */
public static final String USER_INCREMENT_INDEX_PATH = public static final String USER_INCREMENT_INDEX_PATH =
System.getProperty("user.dir") + USER_PATH + "/index777"; USER_PATH + "/index777";
/** /**
* 作品集 lucene 目录 * 作品集 lucene 目录
@ -43,5 +43,5 @@ public final class LucenePath {
* 作品集增量 lucene 目录 * 作品集增量 lucene 目录
*/ */
public static final String PORTFOLIO_INCREMENT_INDEX_PATH = public static final String PORTFOLIO_INCREMENT_INDEX_PATH =
System.getProperty("user.dir") + PORTFOLIO_PATH + "/index777"; PORTFOLIO_PATH + "/index777";
} }

View File

@ -23,8 +23,7 @@ public class PortfolioIndexUtil {
/** /**
* lucene索引保存目录 * lucene索引保存目录
*/ */
private static final String PATH = private static final String PATH = System.getProperty("user.dir") + StrUtil.SLASH + LucenePath.PORTFOLIO_PATH;
System.getProperty("user.dir") + StrUtil.SLASH + LucenePath.PORTFOLIO_PATH;
/** /**
* 删除所有运行中保存的索引 * 删除所有运行中保存的索引
@ -54,7 +53,11 @@ public class PortfolioIndexUtil {
System.out.println("创建单个索引"); System.out.println("创建单个索引");
IndexWriter writer; IndexWriter writer;
try { try {
writer = IndexUtil.getIndexWriter(LucenePath.PORTFOLIO_INCREMENT_INDEX_PATH, false); boolean create = true;
if (FileUtil.exist(LucenePath.PORTFOLIO_INCREMENT_INDEX_PATH)) {
create = false;
}
writer = IndexUtil.getIndexWriter(LucenePath.PORTFOLIO_INCREMENT_INDEX_PATH, create);
Document doc = new Document(); Document doc = new Document();
doc.add(new StringField("id", t.getIdPortfolio() + "", Field.Store.YES)); doc.add(new StringField("id", t.getIdPortfolio() + "", Field.Store.YES));
doc.add(new TextField("title", t.getPortfolioTitle(), Field.Store.YES)); doc.add(new TextField("title", t.getPortfolioTitle(), Field.Store.YES));
@ -78,6 +81,7 @@ public class PortfolioIndexUtil {
try { try {
writer = IndexUtil.getIndexWriter(each.getAbsolutePath(), false); writer = IndexUtil.getIndexWriter(each.getAbsolutePath(), false);
writer.deleteDocuments(new Term("id", String.valueOf(id))); writer.deleteDocuments(new Term("id", String.valueOf(id)));
writer.forceMerge(1);
writer.forceMergeDeletes(); // 强制删除 writer.forceMergeDeletes(); // 强制删除
writer.commit(); writer.commit();
writer.close(); writer.close();

View File

@ -60,7 +60,11 @@ public class UserIndexUtil {
System.out.println("创建单个索引"); System.out.println("创建单个索引");
IndexWriter writer; IndexWriter writer;
try { try {
writer = IndexUtil.getIndexWriter(INDEX_PATH, false); boolean create = true;
if (FileUtil.exist(LucenePath.USER_INCREMENT_INDEX_PATH)) {
create = false;
}
writer = IndexUtil.getIndexWriter(INDEX_PATH, create);
Document doc = new Document(); Document doc = new Document();
doc.add(new StringField("id", t.getIdUser() + "", Field.Store.YES)); doc.add(new StringField("id", t.getIdUser() + "", Field.Store.YES));
doc.add(new TextField("nickname", t.getNickname(), Field.Store.YES)); doc.add(new TextField("nickname", t.getNickname(), Field.Store.YES));
@ -85,6 +89,7 @@ public class UserIndexUtil {
try { try {
writer = IndexUtil.getIndexWriter(each.getAbsolutePath(), false); writer = IndexUtil.getIndexWriter(each.getAbsolutePath(), false);
writer.deleteDocuments(new Term("id", id)); writer.deleteDocuments(new Term("id", id));
writer.forceMerge(1);
writer.forceMergeDeletes(); // 强制删除 writer.forceMergeDeletes(); // 强制删除
writer.commit(); writer.commit();
writer.close(); writer.close();

View File

@ -1,31 +0,0 @@
package com.rymcu.forest.task;
import com.rymcu.forest.core.constant.ProjectConstant;
import com.rymcu.forest.util.BaiDuUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
/**
* @author ronger
*/
//@Component
@Slf4j
public class BaiDuCronTask {
@Value("${resource.domain}")
private String domain;
@Value(("${env}"))
private String env;
/**
* 定时推送首页更新
*/
@Scheduled(cron = "0 0 10,14,18 * * ?")
public void pushHome() {
if (!ProjectConstant.ENV.equals(env)) {
BaiDuUtils.sendUpdateSEOData(domain);
}
}
}

View File

@ -34,7 +34,7 @@ spring:
test-while-idle: true test-while-idle: true
test-on-borrow: false test-on-borrow: false
test-on-return: false test-on-return: false
connection-properties: config.decrypt=true;config.decrypt.key=${publickey} connection-properties: config.decrypt=true;config.decrypt.key=${publicKey}
filters: config,stat filters: config,stat
max-pool-prepared-statement-per-connection-size: 100 max-pool-prepared-statement-per-connection-size: 100
stat-view-servlet: stat-view-servlet:
@ -50,29 +50,6 @@ spring:
port: 465 port: 465
username: service@rymcu.com username: service@rymcu.com
password: 4W3tCXdyk0Gm password: 4W3tCXdyk0Gm
wx:
open:
componentAppId: wx9c4a7dfb3238d5f6
componentSecret: e32a6f75ab6b746ec3ae38a39a79ba22
componentToken: rymcu
componentAesKey: NWIwMDQyZjU0YWI2NGFlZThkOWZhZTg3NTg4NzQwN2E
mp:
configs:
- appId: wxf085386aa07c0857
secret: aabd075d2851764714fd14a0d0b1b8b4
token: rymcu
aesKey: lvn3mMSnFOvbnIJVNhHQqjWb9swe66L1xIcerJSs0fm
- appId: wxa49093339a5a822b
secret: 29e9390e6d58d57a2b2a2350dbee8754
token: qwert
aesKey:
miniapp:
configs:
- appid: wxb4fff78a6b878cf7
secret: c8735d0ccc8497b8509dc2762246cb37
token: #微信小程序消息服务器配置的token
aesKey: #微信小程序消息服务器配置的EncodingAESKey
msgDataFormat: JSON
env: dev env: dev
logging: logging:
file: file:
@ -85,16 +62,12 @@ server:
servlet: servlet:
context-path: /forest context-path: /forest
max-http-header-size: 1048576 max-http-header-size: 1048576
shutdown: graceful
tomcat:
reject-illegal-header: false
version: 1.0 version: 1.0
resource: resource:
domain: http://test.rymcu.com domain: https://test.rymcu.com
file-path: http://test.rymcu.com file-path: https://test.rymcu.com
pic-path: /opt/nebula/static pic-path: /opt/nebula/static
baidu: answer-api-url: https://test.rymcu.com/subject/question
data:
site: https://rymcu.com
token: 9cdKR6bVCJzxDEJS
ai:
appId: 22891829
appKey: HKxdO8ioaUmltZh0eaOVMsmW
secretKey: GXOtl3XtiIkVA3CPsc3c29Pqa4V290Yr

View File

@ -71,12 +71,5 @@ resource:
domain: http://yourdomain.com # 网站域名 domain: http://yourdomain.com # 网站域名
file-path: http://yourdomain.com # 上传文件前缀域名 file-path: http://yourdomain.com # 上传文件前缀域名
pic-path: /yoursrc/xx/nebula/static # 上传文件存储地址 pic-path: /yoursrc/xx/nebula/static # 上传文件存储地址
baidu: answer-api-url: https://test.rymcu.com/subject/question
data:
site: https://yourdomain.com # 百度搜索绑定网站域名
token: xxxx
ai:
appId: xxx # 百度AI-文字识别 应用 appId
appKey: xxxx # 百度AI-文字识别 应用 appKey
secretKey: xxxx # 百度AI-文字识别 应用 secretKey