🐛 修复了一些 bug
🐛 修复了一些 bug
This commit is contained in:
commit
b0139bcb55
@ -1,5 +1,6 @@
|
||||
package com.rymcu.forest.dto;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@ -44,6 +45,7 @@ public class ArticleDTO {
|
||||
/** 文章状态 */
|
||||
private String articleStatus;
|
||||
/** 更新时间 */
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updatedTime;
|
||||
|
||||
private Author articleAuthor;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.rymcu.forest.dto;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@ -35,9 +36,12 @@ public class CommentDTO {
|
||||
/** 0:所有人可见,1:仅楼主和自己可见 */
|
||||
private String commentVisible;
|
||||
/** 创建时间 */
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createdTime;
|
||||
|
||||
private Author commenter;
|
||||
|
||||
private String timeAgo;
|
||||
|
||||
private String articleTitle;
|
||||
}
|
||||
|
@ -19,8 +19,12 @@ public class TransactionRecordDTO {
|
||||
private String funds;
|
||||
/** 交易发起方 */
|
||||
private String formBankAccount;
|
||||
/** 交易发起方 */
|
||||
private BankAccountDTO formBankAccountInfo;
|
||||
/** 交易收款方 */
|
||||
private String toBankAccount;
|
||||
/** 交易收款方 */
|
||||
private BankAccountDTO toBankAccountInfo;
|
||||
/** 交易金额 */
|
||||
private BigDecimal money;
|
||||
/** 交易类型 */
|
||||
|
@ -1,6 +1,11 @@
|
||||
package com.rymcu.forest.lucene.service.impl;
|
||||
|
||||
import com.rymcu.forest.dto.ArticleDTO;
|
||||
import com.rymcu.forest.dto.ArticleTagDTO;
|
||||
import com.rymcu.forest.dto.Author;
|
||||
import com.rymcu.forest.dto.PortfolioArticleDTO;
|
||||
import com.rymcu.forest.entity.ArticleContent;
|
||||
import com.rymcu.forest.entity.User;
|
||||
import com.rymcu.forest.lucene.lucene.ArticleBeanIndex;
|
||||
import com.rymcu.forest.lucene.lucene.IKAnalyzer;
|
||||
import com.rymcu.forest.lucene.mapper.ArticleLuceneMapper;
|
||||
@ -9,6 +14,10 @@ import com.rymcu.forest.lucene.service.LuceneService;
|
||||
import com.rymcu.forest.lucene.util.ArticleIndexUtil;
|
||||
import com.rymcu.forest.lucene.util.LucenePath;
|
||||
import com.rymcu.forest.lucene.util.SearchUtil;
|
||||
import com.rymcu.forest.mapper.ArticleMapper;
|
||||
import com.rymcu.forest.service.UserService;
|
||||
import com.rymcu.forest.util.Html2TextUtil;
|
||||
import com.rymcu.forest.util.Utils;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.document.Document;
|
||||
@ -41,157 +50,187 @@ import java.util.concurrent.Executors;
|
||||
@Service
|
||||
public class LuceneServiceImpl implements LuceneService {
|
||||
|
||||
@Resource private ArticleLuceneMapper luceneMapper;
|
||||
@Resource
|
||||
private ArticleLuceneMapper luceneMapper;
|
||||
@Resource
|
||||
private ArticleMapper articleMapper;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 将文章的数据解析为一个个关键字词存储到索引文件中
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
@Override
|
||||
public void writeArticle(List<ArticleLucene> list) {
|
||||
try {
|
||||
int totalCount = list.size();
|
||||
int perThreadCount = 3000;
|
||||
int threadCount = totalCount / perThreadCount + (totalCount % perThreadCount == 0 ? 0 : 1);
|
||||
ExecutorService pool = Executors.newFixedThreadPool(threadCount);
|
||||
CountDownLatch countDownLatch1 = new CountDownLatch(1);
|
||||
CountDownLatch countDownLatch2 = new CountDownLatch(threadCount);
|
||||
/**
|
||||
* 将文章的数据解析为一个个关键字词存储到索引文件中
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
@Override
|
||||
public void writeArticle(List<ArticleLucene> list) {
|
||||
try {
|
||||
int totalCount = list.size();
|
||||
int perThreadCount = 3000;
|
||||
int threadCount = totalCount / perThreadCount + (totalCount % perThreadCount == 0 ? 0 : 1);
|
||||
ExecutorService pool = Executors.newFixedThreadPool(threadCount);
|
||||
CountDownLatch countDownLatch1 = new CountDownLatch(1);
|
||||
CountDownLatch countDownLatch2 = new CountDownLatch(threadCount);
|
||||
|
||||
for (int i = 0; i < threadCount; i++) {
|
||||
int start = i * perThreadCount;
|
||||
int end = Math.min((i + 1) * perThreadCount, totalCount);
|
||||
List<ArticleLucene> subList = list.subList(start, end);
|
||||
Runnable runnable =
|
||||
new ArticleBeanIndex(
|
||||
LucenePath.ARTICLE_INDEX_PATH, i, countDownLatch1, countDownLatch2, subList);
|
||||
// 子线程交给线程池管理
|
||||
pool.execute(runnable);
|
||||
}
|
||||
countDownLatch1.countDown();
|
||||
System.out.println("开始创建索引");
|
||||
// 等待所有线程都完成
|
||||
countDownLatch2.await();
|
||||
// 线程全部完成工作
|
||||
System.out.println("所有线程都创建索引完毕");
|
||||
// 释放线程池资源
|
||||
pool.shutdown();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeArticle(String id) {
|
||||
writeArticle(luceneMapper.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeArticle(ArticleLucene articleLucene) {
|
||||
ArticleIndexUtil.addIndex(articleLucene);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateArticle(String id) {
|
||||
ArticleIndexUtil.updateIndex(luceneMapper.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteArticle(String id) {
|
||||
ArticleIndexUtil.deleteIndex(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关键词搜索
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public List<ArticleLucene> searchArticle(String value) {
|
||||
List<ArticleLucene> resList = new ArrayList<>();
|
||||
ExecutorService service = Executors.newCachedThreadPool();
|
||||
// 定义分词器
|
||||
Analyzer analyzer = new IKAnalyzer();
|
||||
try {
|
||||
IndexSearcher searcher =
|
||||
SearchUtil.getIndexSearcherByParentPath(LucenePath.ARTICLE_INDEX_PATH, service);
|
||||
String[] fields = {"title", "summary"};
|
||||
// 构造Query对象
|
||||
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, analyzer);
|
||||
|
||||
BufferedReader in =
|
||||
new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
|
||||
String line = value != null ? value : in.readLine();
|
||||
Query query = parser.parse(line);
|
||||
// 最终被分词后添加的前缀和后缀处理器,默认是粗体<B></B>
|
||||
SimpleHTMLFormatter htmlFormatter =
|
||||
new SimpleHTMLFormatter("<font color=" + "\"" + "red" + "\"" + ">", "</font>");
|
||||
// 高亮搜索的词添加到高亮处理器中
|
||||
Highlighter highlighter = new Highlighter(htmlFormatter, new QueryScorer(query));
|
||||
|
||||
// 获取搜索的结果,指定返回document返回的个数
|
||||
// TODO 默认搜索结果为显示第一页,1000 条,可以优化
|
||||
TopDocs results = SearchUtil.getScoreDocsByPerPage(1, 100, searcher, query);
|
||||
ScoreDoc[] hits = results.scoreDocs;
|
||||
|
||||
// 遍历,输出
|
||||
for (ScoreDoc hit : hits) {
|
||||
int id = hit.doc;
|
||||
float score = hit.score;
|
||||
Document hitDoc = searcher.doc(hit.doc);
|
||||
// 获取到summary
|
||||
String name = hitDoc.get("summary");
|
||||
// 将查询的词和搜索词匹配,匹配到添加前缀和后缀
|
||||
TokenStream tokenStream =
|
||||
TokenSources.getAnyTokenStream(searcher.getIndexReader(), id, "summary", analyzer);
|
||||
// 传入的第二个参数是查询的值
|
||||
TextFragment[] frag = highlighter.getBestTextFragments(tokenStream, name, false, 10);
|
||||
StringBuilder baikeValue = new StringBuilder();
|
||||
for (TextFragment textFragment : frag) {
|
||||
if ((textFragment != null) && (textFragment.getScore() > 0)) {
|
||||
// if ((frag[j] != null)) {
|
||||
// 获取 summary 的值
|
||||
baikeValue.append(textFragment);
|
||||
}
|
||||
for (int i = 0; i < threadCount; i++) {
|
||||
int start = i * perThreadCount;
|
||||
int end = Math.min((i + 1) * perThreadCount, totalCount);
|
||||
List<ArticleLucene> subList = list.subList(start, end);
|
||||
Runnable runnable =
|
||||
new ArticleBeanIndex(
|
||||
LucenePath.ARTICLE_INDEX_PATH, i, countDownLatch1, countDownLatch2, subList);
|
||||
// 子线程交给线程池管理
|
||||
pool.execute(runnable);
|
||||
}
|
||||
countDownLatch1.countDown();
|
||||
System.out.println("开始创建索引");
|
||||
// 等待所有线程都完成
|
||||
countDownLatch2.await();
|
||||
// 线程全部完成工作
|
||||
System.out.println("所有线程都创建索引完毕");
|
||||
// 释放线程池资源
|
||||
pool.shutdown();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 获取到title
|
||||
String title = hitDoc.get("title");
|
||||
TokenStream titleTokenStream =
|
||||
TokenSources.getAnyTokenStream(searcher.getIndexReader(), id, "title", analyzer);
|
||||
TextFragment[] titleFrag =
|
||||
highlighter.getBestTextFragments(titleTokenStream, title, false, 10);
|
||||
StringBuilder titleValue = new StringBuilder();
|
||||
for (int j = 0; j < titleFrag.length; j++) {
|
||||
if ((frag[j] != null)) {
|
||||
titleValue.append(titleFrag[j].toString());
|
||||
}
|
||||
}
|
||||
resList.add(
|
||||
ArticleLucene.builder()
|
||||
.idArticle(hitDoc.get("id"))
|
||||
.articleTitle(titleValue.toString())
|
||||
.articleContent(baikeValue.toString())
|
||||
.score(String.valueOf(score))
|
||||
.build());
|
||||
}
|
||||
} catch (IOException | ParseException | InvalidTokenOffsetsException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
service.shutdownNow();
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleLucene> getAllArticleLucene() {
|
||||
return luceneMapper.getAllArticleLucene();
|
||||
}
|
||||
@Override
|
||||
public void writeArticle(String id) {
|
||||
writeArticle(luceneMapper.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleDTO> getArticlesByIds(String[] ids) {
|
||||
return luceneMapper.getArticlesByIds(ids);
|
||||
}
|
||||
@Override
|
||||
public void writeArticle(ArticleLucene articleLucene) {
|
||||
ArticleIndexUtil.addIndex(articleLucene);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateArticle(String id) {
|
||||
ArticleIndexUtil.updateIndex(luceneMapper.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteArticle(String id) {
|
||||
ArticleIndexUtil.deleteIndex(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关键词搜索
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public List<ArticleLucene> searchArticle(String value) {
|
||||
List<ArticleLucene> resList = new ArrayList<>();
|
||||
ExecutorService service = Executors.newCachedThreadPool();
|
||||
// 定义分词器
|
||||
Analyzer analyzer = new IKAnalyzer();
|
||||
try {
|
||||
IndexSearcher searcher =
|
||||
SearchUtil.getIndexSearcherByParentPath(LucenePath.ARTICLE_INDEX_PATH, service);
|
||||
String[] fields = {"title", "summary"};
|
||||
// 构造Query对象
|
||||
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, analyzer);
|
||||
|
||||
BufferedReader in =
|
||||
new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
|
||||
String line = value != null ? value : in.readLine();
|
||||
Query query = parser.parse(line);
|
||||
// 最终被分词后添加的前缀和后缀处理器,默认是粗体<B></B>
|
||||
SimpleHTMLFormatter htmlFormatter =
|
||||
new SimpleHTMLFormatter("<font color=" + "\"" + "red" + "\"" + ">", "</font>");
|
||||
// 高亮搜索的词添加到高亮处理器中
|
||||
Highlighter highlighter = new Highlighter(htmlFormatter, new QueryScorer(query));
|
||||
|
||||
// 获取搜索的结果,指定返回document返回的个数
|
||||
// TODO 默认搜索结果为显示第一页,1000 条,可以优化
|
||||
TopDocs results = SearchUtil.getScoreDocsByPerPage(1, 100, searcher, query);
|
||||
ScoreDoc[] hits = results.scoreDocs;
|
||||
|
||||
// 遍历,输出
|
||||
for (ScoreDoc hit : hits) {
|
||||
int id = hit.doc;
|
||||
float score = hit.score;
|
||||
Document hitDoc = searcher.doc(hit.doc);
|
||||
// 获取到summary
|
||||
String name = hitDoc.get("summary");
|
||||
// 将查询的词和搜索词匹配,匹配到添加前缀和后缀
|
||||
TokenStream tokenStream =
|
||||
TokenSources.getAnyTokenStream(searcher.getIndexReader(), id, "summary", analyzer);
|
||||
// 传入的第二个参数是查询的值
|
||||
TextFragment[] frag = highlighter.getBestTextFragments(tokenStream, name, false, 10);
|
||||
StringBuilder baikeValue = new StringBuilder();
|
||||
for (TextFragment textFragment : frag) {
|
||||
if ((textFragment != null) && (textFragment.getScore() > 0)) {
|
||||
// if ((frag[j] != null)) {
|
||||
// 获取 summary 的值
|
||||
baikeValue.append(textFragment);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取到title
|
||||
String title = hitDoc.get("title");
|
||||
TokenStream titleTokenStream =
|
||||
TokenSources.getAnyTokenStream(searcher.getIndexReader(), id, "title", analyzer);
|
||||
TextFragment[] titleFrag =
|
||||
highlighter.getBestTextFragments(titleTokenStream, title, false, 10);
|
||||
StringBuilder titleValue = new StringBuilder();
|
||||
for (int j = 0; j < titleFrag.length; j++) {
|
||||
if ((frag[j] != null)) {
|
||||
titleValue.append(titleFrag[j].toString());
|
||||
}
|
||||
}
|
||||
resList.add(
|
||||
ArticleLucene.builder()
|
||||
.idArticle(hitDoc.get("id"))
|
||||
.articleTitle(titleValue.toString())
|
||||
.articleContent(baikeValue.toString())
|
||||
.score(String.valueOf(score))
|
||||
.build());
|
||||
}
|
||||
} catch (IOException | ParseException | InvalidTokenOffsetsException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
service.shutdownNow();
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleLucene> getAllArticleLucene() {
|
||||
List<ArticleLucene> list = luceneMapper.getAllArticleLucene();
|
||||
for (ArticleLucene articleLucene : list) {
|
||||
articleLucene.setArticleContent(Html2TextUtil.getContent(articleLucene.getArticleContent()));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleDTO> getArticlesByIds(String[] ids) {
|
||||
List<ArticleDTO> list = luceneMapper.getArticlesByIds(ids);
|
||||
list.forEach(articleDTO -> genArticle(articleDTO));
|
||||
return list;
|
||||
}
|
||||
|
||||
private ArticleDTO genArticle(ArticleDTO article) {
|
||||
Author author = genAuthor(article);
|
||||
article.setArticleAuthor(author);
|
||||
article.setTimeAgo(Utils.getTimeAgo(article.getUpdatedTime()));
|
||||
List<ArticleTagDTO> tags = articleMapper.selectTags(article.getIdArticle());
|
||||
article.setTags(tags);
|
||||
return article;
|
||||
}
|
||||
|
||||
private Author genAuthor(ArticleDTO article) {
|
||||
Author author = new Author();
|
||||
User user = userService.findById(String.valueOf(article.getArticleAuthorId()));
|
||||
author.setUserNickname(article.getArticleAuthorName());
|
||||
author.setUserAvatarURL(article.getArticleAuthorAvatarUrl());
|
||||
author.setIdUser(article.getArticleAuthorId());
|
||||
author.setUserAccount(user.getAccount());
|
||||
return author;
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,11 @@ public interface BankAccountMapper extends Mapper<BankAccount> {
|
||||
* @return
|
||||
*/
|
||||
String selectMaxBankAccount();
|
||||
|
||||
/**
|
||||
* 根据卡号获取银行账号信息
|
||||
* @param bankAccount
|
||||
* @return
|
||||
*/
|
||||
BankAccountDTO selectByBankAccount(@Param("bankAccount") String bankAccount);
|
||||
}
|
||||
|
@ -40,4 +40,10 @@ public interface CommentMapper extends Mapper<Comment> {
|
||||
* @return
|
||||
*/
|
||||
Integer updateCommentSharpUrl(@Param("idComment") Integer idComment, @Param("commentSharpUrl") String commentSharpUrl);
|
||||
|
||||
/**
|
||||
* 获取评论列表数据
|
||||
* @return
|
||||
*/
|
||||
List<CommentDTO> selectComments();
|
||||
}
|
||||
|
@ -31,11 +31,18 @@ public interface BankAccountService extends Service<BankAccount> {
|
||||
* @param bankAccount
|
||||
* @return
|
||||
*/
|
||||
BankAccount findByBankAccount(String bankAccount);
|
||||
BankAccountDTO findByBankAccount(String bankAccount);
|
||||
|
||||
/**
|
||||
* 查询系统社区银行
|
||||
* @return
|
||||
*/
|
||||
BankAccount findSystemBankAccount();
|
||||
|
||||
/**
|
||||
* 查询账号信息
|
||||
* @param formBankAccount
|
||||
* @return
|
||||
*/
|
||||
BankAccount findInfoByBankAccount(String formBankAccount);
|
||||
}
|
||||
|
@ -13,7 +13,24 @@ import java.util.Map;
|
||||
*/
|
||||
public interface CommentService extends Service<Comment> {
|
||||
|
||||
/**
|
||||
* 获取文章评论数据
|
||||
* @param idArticle
|
||||
* @return
|
||||
*/
|
||||
List<CommentDTO> getArticleComments(Integer idArticle);
|
||||
|
||||
/**
|
||||
* 评论
|
||||
* @param comment
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
Map postComment(Comment comment, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 获取评论列表数据
|
||||
* @return
|
||||
*/
|
||||
List<CommentDTO> findComments();
|
||||
}
|
||||
|
@ -11,12 +11,10 @@ import com.rymcu.forest.entity.User;
|
||||
import com.rymcu.forest.lucene.service.LuceneService;
|
||||
import com.rymcu.forest.mapper.ArticleMapper;
|
||||
import com.rymcu.forest.service.ArticleService;
|
||||
import com.rymcu.forest.service.CommentService;
|
||||
import com.rymcu.forest.service.TagService;
|
||||
import com.rymcu.forest.service.UserService;
|
||||
import com.rymcu.forest.util.*;
|
||||
import com.rymcu.forest.web.api.exception.BaseApiException;
|
||||
import lombok.extern.java.Log;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
@ -44,8 +42,6 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private CommentService commentService;
|
||||
@Resource
|
||||
private LuceneService luceneService;
|
||||
|
||||
@Value("${resource.domain}")
|
||||
|
@ -61,10 +61,8 @@ public class BankAccountServiceImpl extends AbstractService<BankAccount> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public BankAccount findByBankAccount(String bankAccount) {
|
||||
BankAccount searchBankAccount = new BankAccount();
|
||||
searchBankAccount.setBankAccount(bankAccount);
|
||||
return bankAccountMapper.selectOne(searchBankAccount);
|
||||
public BankAccountDTO findByBankAccount(String bankAccount) {
|
||||
return bankAccountMapper.selectByBankAccount(bankAccount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,6 +74,13 @@ public class BankAccountServiceImpl extends AbstractService<BankAccount> impleme
|
||||
return bankAccountMapper.selectOne(bankAccount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BankAccount findInfoByBankAccount(String bankAccount) {
|
||||
BankAccount searchBankAccount = new BankAccount();
|
||||
searchBankAccount.setBankAccount(bankAccount);
|
||||
return bankAccountMapper.selectOne(searchBankAccount);
|
||||
}
|
||||
|
||||
private String nextBankAccount() {
|
||||
String bankAccount = "600000001";
|
||||
String maxBankAccount = bankAccountMapper.selectMaxBankAccount();
|
||||
|
@ -36,6 +36,10 @@ public class CommentServiceImpl extends AbstractService<Comment> implements Comm
|
||||
@Override
|
||||
public List<CommentDTO> getArticleComments(Integer idArticle) {
|
||||
List<CommentDTO> commentDTOList = commentMapper.selectArticleComments(idArticle);
|
||||
return genComments(commentDTOList);
|
||||
}
|
||||
|
||||
private List<CommentDTO> genComments(List<CommentDTO> commentDTOList) {
|
||||
commentDTOList.forEach(commentDTO -> {
|
||||
commentDTO.setTimeAgo(Utils.getTimeAgo(commentDTO.getCreatedTime()));
|
||||
if (commentDTO.getCommentAuthorId() != null) {
|
||||
@ -113,4 +117,10 @@ public class CommentServiceImpl extends AbstractService<Comment> implements Comm
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommentDTO> findComments() {
|
||||
List<CommentDTO> commentDTOList = commentMapper.selectComments();
|
||||
return genComments(commentDTOList);
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,19 @@ import com.rymcu.forest.core.exception.TransactionException;
|
||||
import com.rymcu.forest.core.service.AbstractService;
|
||||
import com.rymcu.forest.core.service.redis.RedisService;
|
||||
import com.rymcu.forest.dto.BankAccountDTO;
|
||||
import com.rymcu.forest.dto.BankAccountSearchDTO;
|
||||
import com.rymcu.forest.dto.TransactionRecordDTO;
|
||||
import com.rymcu.forest.entity.BankAccount;
|
||||
import com.rymcu.forest.entity.TransactionRecord;
|
||||
import com.rymcu.forest.entity.User;
|
||||
import com.rymcu.forest.enumerate.TransactionCode;
|
||||
import com.rymcu.forest.enumerate.TransactionEnum;
|
||||
import com.rymcu.forest.mapper.TransactionRecordMapper;
|
||||
import com.rymcu.forest.service.BankAccountService;
|
||||
import com.rymcu.forest.service.TransactionRecordService;
|
||||
import com.rymcu.forest.util.DateUtil;
|
||||
import com.rymcu.forest.util.UserUtils;
|
||||
import com.rymcu.forest.web.api.exception.BaseApiException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -56,7 +60,17 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
|
||||
|
||||
@Override
|
||||
public List<TransactionRecordDTO> findTransactionRecords(String bankAccount) {
|
||||
return transactionRecordMapper.selectTransactionRecords(bankAccount);
|
||||
List<TransactionRecordDTO> list = transactionRecordMapper.selectTransactionRecords(bankAccount);
|
||||
list.forEach(transactionRecordDTO -> genTransactionRecord(transactionRecordDTO));
|
||||
return list;
|
||||
}
|
||||
|
||||
private TransactionRecordDTO genTransactionRecord(TransactionRecordDTO transactionRecordDTO) {
|
||||
BankAccountDTO toBankAccount = bankAccountService.findByBankAccount(transactionRecordDTO.getToBankAccount());
|
||||
BankAccountDTO formBankAccount = bankAccountService.findByBankAccount(transactionRecordDTO.getFormBankAccount());
|
||||
transactionRecordDTO.setFormBankAccountInfo(formBankAccount);
|
||||
transactionRecordDTO.setToBankAccountInfo(toBankAccount);
|
||||
return transactionRecordDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -122,7 +136,7 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
|
||||
}
|
||||
|
||||
private boolean checkFormAccountStatus(String formBankAccount, BigDecimal money) {
|
||||
BankAccount bankAccount = bankAccountService.findByBankAccount(formBankAccount);
|
||||
BankAccount bankAccount = bankAccountService.findInfoByBankAccount(formBankAccount);
|
||||
if (Objects.nonNull(bankAccount)) {
|
||||
if (bankAccount.getAccountBalance().compareTo(money) > 0) {
|
||||
return true;
|
||||
|
@ -4,6 +4,9 @@ import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.rymcu.forest.core.result.GlobalResult;
|
||||
import com.rymcu.forest.core.result.GlobalResultGenerator;
|
||||
import com.rymcu.forest.dto.ArticleDTO;
|
||||
import com.rymcu.forest.dto.ArticleSearchDTO;
|
||||
import com.rymcu.forest.dto.CommentDTO;
|
||||
import com.rymcu.forest.dto.UserSearchDTO;
|
||||
import com.rymcu.forest.dto.admin.TopicTagDTO;
|
||||
import com.rymcu.forest.dto.admin.UserRoleDTO;
|
||||
@ -36,6 +39,10 @@ public class AdminController {
|
||||
private TagService tagService;
|
||||
@Resource
|
||||
private SpecialDayService specialDayService;
|
||||
@Resource
|
||||
private ArticleService articleService;
|
||||
@Resource
|
||||
private CommentService commentService;
|
||||
|
||||
@GetMapping("/users")
|
||||
public GlobalResult<Map<String, Object>> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, UserSearchDTO searchDTO){
|
||||
@ -219,4 +226,30 @@ public class AdminController {
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
||||
@GetMapping("/articles")
|
||||
public GlobalResult<Map> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO articleSearchDTO) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ArticleDTO> list = articleService.findArticles(articleSearchDTO);
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("articles", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
||||
@GetMapping("/comments")
|
||||
public GlobalResult<Map> comments(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<CommentDTO> list = commentService.findComments();
|
||||
PageInfo<CommentDTO> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("comments", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.rymcu.forest.core.result.GlobalResultGenerator;
|
||||
import com.rymcu.forest.core.result.GlobalResultMessage;
|
||||
import com.rymcu.forest.core.service.log.annotation.VisitLogger;
|
||||
import com.rymcu.forest.dto.*;
|
||||
import com.rymcu.forest.entity.Portfolio;
|
||||
import com.rymcu.forest.entity.User;
|
||||
import com.rymcu.forest.service.*;
|
||||
import com.rymcu.forest.util.UserUtils;
|
||||
@ -142,4 +143,16 @@ public class CommonApiController {
|
||||
Map map = Utils.getArticlesGlobalResult(pageInfo);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
||||
@GetMapping("/portfolios")
|
||||
public GlobalResult portfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<Portfolio> list = portfolioService.findPortfolios();
|
||||
PageInfo<Portfolio> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("portfolios", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
}
|
||||
|
@ -12,24 +12,30 @@
|
||||
<result column="created_time" property="createdTime"></result>
|
||||
</resultMap>
|
||||
<select id="selectBankAccounts" resultMap="DTOResultMap">
|
||||
select vb.bank_name, vu.nickname as account_owner_name, vba.* from forest_bank_account vba
|
||||
join forest_bank vb on vba.id_bank = vb.id
|
||||
join forest_user vu on vba.account_owner = vu.id where vba.account_type = 0
|
||||
select fb.bank_name, ifnull(fu.nickname, '系统') as account_owner_name, fba.* from forest_bank_account fba
|
||||
join forest_bank fb on fba.id_bank = fb.id
|
||||
left join forest_user fu on fba.account_owner = fu.id where fba.account_type = 0
|
||||
<if test="bankName != null and bankName != ''">
|
||||
and vb.bank_name = #{bankName}
|
||||
and fb.bank_name = #{bankName}
|
||||
</if>
|
||||
<if test="accountOwnerName != null and accountOwnerName != ''">
|
||||
and vu.nickname = #{accountOwnerName}
|
||||
and fu.nickname = #{accountOwnerName}
|
||||
</if>
|
||||
<if test="bankAccount != null and bankAccount != ''">
|
||||
and vba.bank_account = #{bankAccount}
|
||||
and fba.bank_account = #{bankAccount}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectBankAccount" resultMap="DTOResultMap">
|
||||
select vb.bank_name, vba.* from forest_bank_account vba
|
||||
join forest_bank vb on vba.id_bank = vb.id where vba.id = #{idBank}
|
||||
select fb.bank_name, fu.nickname as account_owner_name, fba.* from forest_bank_account fba
|
||||
join forest_bank fb on fba.id_bank = fb.id
|
||||
join forest_user fu on fba.account_owner = fu.id where fba.id = #{idBank}
|
||||
</select>
|
||||
<select id="selectMaxBankAccount" resultType="java.lang.String">
|
||||
select max(bank_account) as max_bank_account from forest_bank_account where account_type = 0
|
||||
</select>
|
||||
<select id="selectByBankAccount" resultMap="DTOResultMap">
|
||||
select fb.bank_name, ifnull(fu.nickname, '系统') as account_owner_name, fba.bank_account from forest_bank_account fba
|
||||
join forest_bank fb on fba.id_bank = fb.id
|
||||
left join forest_user fu on fba.account_owner = fu.id where fba.bank_account = #{bankAccount}
|
||||
</select>
|
||||
</mapper>
|
@ -28,6 +28,7 @@
|
||||
<result column="comment_reply_count" property="commentReplyCount"></result>
|
||||
<result column="comment_visible" property="commentVisible"></result>
|
||||
<result column="created_time" property="createdTime"></result>
|
||||
<result column="article_title" property="articleTitle"></result>
|
||||
</resultMap>
|
||||
<resultMap id="AuthorResultMap" type="com.rymcu.forest.dto.Author">
|
||||
<result column="id" property="idUser"/>
|
||||
@ -39,7 +40,7 @@
|
||||
update forest_comment set comment_sharp_url = #{commentSharpUrl} where id = #{idComment}
|
||||
</update>
|
||||
<select id="selectArticleComments" resultMap="DTOResultMap">
|
||||
select * from forest_comment where comment_article_id = #{idArticle} order by created_time desc
|
||||
select fc.*, fa.article_title from forest_comment fc join forest_article fa on fc.comment_article_id = fa.id where comment_article_id = #{idArticle} order by fc.created_time desc
|
||||
</select>
|
||||
<select id="selectAuthor" resultMap="AuthorResultMap">
|
||||
select id,nickname,avatar_url,account from forest_user where id = #{commentAuthorId}
|
||||
@ -47,4 +48,7 @@
|
||||
<select id="selectCommentOriginalAuthor" resultMap="AuthorResultMap">
|
||||
select vu.id,vu.nickname,vu.avatar_url,vu.account from forest_comment vc left join forest_user vu on vu.id = vc.comment_author_id where vc.id = #{commentOriginalCommentId}
|
||||
</select>
|
||||
<select id="selectComments" resultMap="DTOResultMap">
|
||||
select fc.*, fa.article_title from forest_comment fc join forest_article fa on fc.comment_article_id = fa.id order by fc.created_time desc
|
||||
</select>
|
||||
</mapper>
|
@ -52,6 +52,7 @@
|
||||
select ifnull(max(sort_no),0) + 1 from forest_portfolio_article where id_portfolio = #{idPortfolio}
|
||||
</select>
|
||||
<select id="selectPortfolios" resultMap="BaseResultMap">
|
||||
select * from forest_portfolio order by updated_time desc
|
||||
select fp.* from forest_portfolio fp left join (select id_portfolio, count(id_portfolio) numbers from forest_portfolio_article group by id_portfolio) fpa
|
||||
on fp.id = fpa.id_portfolio order by fpa.numbers desc, updated_time desc
|
||||
</select>
|
||||
</mapper>
|
@ -16,7 +16,7 @@
|
||||
update forest_bank_account set account_balance = account_balance + #{money} where bank_account = #{toBankAccount};
|
||||
</update>
|
||||
<select id="selectTransactionRecords" resultMap="DTOResultMap">
|
||||
select * from forest_transaction_record where form_bank_account = #{bankAccount} or to_bank_account = #{bankAccount} order by transaction_time desc
|
||||
select * from forest_transaction_record ftr where form_bank_account = #{bankAccount} or to_bank_account = #{bankAccount} order by transaction_time desc
|
||||
</select>
|
||||
<select id="existsWithBankAccountAndFunds" resultType="java.lang.Boolean">
|
||||
select ifnull((select false from forest_transaction_record where to_bank_account = #{bankAccount}
|
||||
|
@ -32,7 +32,7 @@
|
||||
<result column="article_sponsor_count" property="articleSponsorCount"></result>
|
||||
</resultMap>
|
||||
<select id="getAllArticleLucene" resultMap="ResultMapWithBLOBs">
|
||||
select art.id, art.article_title, content.article_content
|
||||
select art.id, art.article_title, content.article_content_html as article_content
|
||||
from forest_article art
|
||||
join forest_article_content content on art.id = content.id_article
|
||||
where article_status = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user