🐛 新用户注册提示服务器开小差问题修复
This commit is contained in:
parent
8795621531
commit
91796ade67
@ -3,6 +3,7 @@ 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 cn.hutool.core.util.StrUtil;
|
||||||
import com.rymcu.forest.lucene.model.UserLucene;
|
import com.rymcu.forest.lucene.model.UserLucene;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
import org.apache.lucene.document.Field;
|
import org.apache.lucene.document.Field;
|
||||||
import org.apache.lucene.document.StringField;
|
import org.apache.lucene.document.StringField;
|
||||||
@ -21,13 +22,19 @@ import java.util.Arrays;
|
|||||||
*/
|
*/
|
||||||
public class UserIndexUtil {
|
public class UserIndexUtil {
|
||||||
|
|
||||||
/** lucene索引保存目录 */
|
/**
|
||||||
|
* lucene索引保存目录
|
||||||
|
*/
|
||||||
private static final String PATH = System.getProperty("user.dir") + StrUtil.SLASH + LucenePath.USER_PATH;
|
private static final String PATH = System.getProperty("user.dir") + StrUtil.SLASH + LucenePath.USER_PATH;
|
||||||
|
|
||||||
/** 系统运行时索引保存目录 */
|
/**
|
||||||
|
* 系统运行时索引保存目录
|
||||||
|
*/
|
||||||
private static final String INDEX_PATH = LucenePath.USER_INCREMENT_INDEX_PATH;
|
private static final String INDEX_PATH = LucenePath.USER_INCREMENT_INDEX_PATH;
|
||||||
|
|
||||||
/** 删除所有运行中保存的索引 */
|
/**
|
||||||
|
* 删除所有运行中保存的索引
|
||||||
|
*/
|
||||||
public static void deleteAllIndex() {
|
public static void deleteAllIndex() {
|
||||||
if (FileUtil.exist(INDEX_PATH)) {
|
if (FileUtil.exist(INDEX_PATH)) {
|
||||||
FileUtil.del(INDEX_PATH);
|
FileUtil.del(INDEX_PATH);
|
||||||
@ -57,7 +64,8 @@ public class UserIndexUtil {
|
|||||||
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));
|
||||||
doc.add(new TextField("signature", t.getSignature(), Field.Store.YES));
|
// 新注册用户无签名
|
||||||
|
doc.add(new TextField("signature", StringUtils.isNotBlank(t.getSignature()) ? t.getSignature() : "", Field.Store.YES));
|
||||||
writer.addDocument(doc);
|
writer.addDocument(doc);
|
||||||
writer.close();
|
writer.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -65,7 +73,9 @@ public class UserIndexUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除单个索引 */
|
/**
|
||||||
|
* 删除单个索引
|
||||||
|
*/
|
||||||
public static synchronized void deleteIndex(String id) {
|
public static synchronized void deleteIndex(String id) {
|
||||||
Arrays.stream(FileUtil.ls(PATH))
|
Arrays.stream(FileUtil.ls(PATH))
|
||||||
.forEach(
|
.forEach(
|
||||||
|
Loading…
Reference in New Issue
Block a user