🐛 修复了一些 bug

🐛 修复了一些 bug
This commit is contained in:
ronger 2021-07-01 13:53:54 +08:00 committed by GitHub
commit b0139bcb55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 338 additions and 170 deletions

View File

@ -1,5 +1,6 @@
package com.rymcu.forest.dto; package com.rymcu.forest.dto;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
@ -44,6 +45,7 @@ public class ArticleDTO {
/** 文章状态 */ /** 文章状态 */
private String articleStatus; private String articleStatus;
/** 更新时间 */ /** 更新时间 */
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date updatedTime; private Date updatedTime;
private Author articleAuthor; private Author articleAuthor;

View File

@ -1,5 +1,6 @@
package com.rymcu.forest.dto; package com.rymcu.forest.dto;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
@ -35,9 +36,12 @@ public class CommentDTO {
/** 0所有人可见1仅楼主和自己可见 */ /** 0所有人可见1仅楼主和自己可见 */
private String commentVisible; private String commentVisible;
/** 创建时间 */ /** 创建时间 */
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date createdTime; private Date createdTime;
private Author commenter; private Author commenter;
private String timeAgo; private String timeAgo;
private String articleTitle;
} }

View File

@ -19,8 +19,12 @@ public class TransactionRecordDTO {
private String funds; private String funds;
/** 交易发起方 */ /** 交易发起方 */
private String formBankAccount; private String formBankAccount;
/** 交易发起方 */
private BankAccountDTO formBankAccountInfo;
/** 交易收款方 */ /** 交易收款方 */
private String toBankAccount; private String toBankAccount;
/** 交易收款方 */
private BankAccountDTO toBankAccountInfo;
/** 交易金额 */ /** 交易金额 */
private BigDecimal money; private BigDecimal money;
/** 交易类型 */ /** 交易类型 */

View File

@ -1,6 +1,11 @@
package com.rymcu.forest.lucene.service.impl; package com.rymcu.forest.lucene.service.impl;
import com.rymcu.forest.dto.ArticleDTO; 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.ArticleBeanIndex;
import com.rymcu.forest.lucene.lucene.IKAnalyzer; import com.rymcu.forest.lucene.lucene.IKAnalyzer;
import com.rymcu.forest.lucene.mapper.ArticleLuceneMapper; 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.ArticleIndexUtil;
import com.rymcu.forest.lucene.util.LucenePath; import com.rymcu.forest.lucene.util.LucenePath;
import com.rymcu.forest.lucene.util.SearchUtil; 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.Analyzer;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;
@ -41,157 +50,187 @@ import java.util.concurrent.Executors;
@Service @Service
public class LuceneServiceImpl implements LuceneService { public class LuceneServiceImpl implements LuceneService {
@Resource private ArticleLuceneMapper luceneMapper; @Resource
private ArticleLuceneMapper luceneMapper;
@Resource
private ArticleMapper articleMapper;
@Resource
private UserService userService;
/** /**
* 将文章的数据解析为一个个关键字词存储到索引文件中 * 将文章的数据解析为一个个关键字词存储到索引文件中
* *
* @param list * @param list
*/ */
@Override @Override
public void writeArticle(List<ArticleLucene> list) { public void writeArticle(List<ArticleLucene> list) {
try { try {
int totalCount = list.size(); int totalCount = list.size();
int perThreadCount = 3000; int perThreadCount = 3000;
int threadCount = totalCount / perThreadCount + (totalCount % perThreadCount == 0 ? 0 : 1); int threadCount = totalCount / perThreadCount + (totalCount % perThreadCount == 0 ? 0 : 1);
ExecutorService pool = Executors.newFixedThreadPool(threadCount); ExecutorService pool = Executors.newFixedThreadPool(threadCount);
CountDownLatch countDownLatch1 = new CountDownLatch(1); CountDownLatch countDownLatch1 = new CountDownLatch(1);
CountDownLatch countDownLatch2 = new CountDownLatch(threadCount); CountDownLatch countDownLatch2 = new CountDownLatch(threadCount);
for (int i = 0; i < threadCount; i++) { for (int i = 0; i < threadCount; i++) {
int start = i * perThreadCount; int start = i * perThreadCount;
int end = Math.min((i + 1) * perThreadCount, totalCount); int end = Math.min((i + 1) * perThreadCount, totalCount);
List<ArticleLucene> subList = list.subList(start, end); List<ArticleLucene> subList = list.subList(start, end);
Runnable runnable = Runnable runnable =
new ArticleBeanIndex( new ArticleBeanIndex(
LucenePath.ARTICLE_INDEX_PATH, i, countDownLatch1, countDownLatch2, subList); LucenePath.ARTICLE_INDEX_PATH, i, countDownLatch1, countDownLatch2, subList);
// 子线程交给线程池管理 // 子线程交给线程池管理
pool.execute(runnable); pool.execute(runnable);
} }
countDownLatch1.countDown(); countDownLatch1.countDown();
System.out.println("开始创建索引"); System.out.println("开始创建索引");
// 等待所有线程都完成 // 等待所有线程都完成
countDownLatch2.await(); countDownLatch2.await();
// 线程全部完成工作 // 线程全部完成工作
System.out.println("所有线程都创建索引完毕"); System.out.println("所有线程都创建索引完毕");
// 释放线程池资源 // 释放线程池资源
pool.shutdown(); pool.shutdown();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); 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);
}
} }
// 获取到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 @Override
public List<ArticleLucene> getAllArticleLucene() { public void writeArticle(String id) {
return luceneMapper.getAllArticleLucene(); writeArticle(luceneMapper.getById(id));
} }
@Override @Override
public List<ArticleDTO> getArticlesByIds(String[] ids) { public void writeArticle(ArticleLucene articleLucene) {
return luceneMapper.getArticlesByIds(ids); 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;
}
} }

View File

@ -32,4 +32,11 @@ public interface BankAccountMapper extends Mapper<BankAccount> {
* @return * @return
*/ */
String selectMaxBankAccount(); String selectMaxBankAccount();
/**
* 根据卡号获取银行账号信息
* @param bankAccount
* @return
*/
BankAccountDTO selectByBankAccount(@Param("bankAccount") String bankAccount);
} }

View File

@ -40,4 +40,10 @@ public interface CommentMapper extends Mapper<Comment> {
* @return * @return
*/ */
Integer updateCommentSharpUrl(@Param("idComment") Integer idComment, @Param("commentSharpUrl") String commentSharpUrl); Integer updateCommentSharpUrl(@Param("idComment") Integer idComment, @Param("commentSharpUrl") String commentSharpUrl);
/**
* 获取评论列表数据
* @return
*/
List<CommentDTO> selectComments();
} }

View File

@ -31,11 +31,18 @@ public interface BankAccountService extends Service<BankAccount> {
* @param bankAccount * @param bankAccount
* @return * @return
*/ */
BankAccount findByBankAccount(String bankAccount); BankAccountDTO findByBankAccount(String bankAccount);
/** /**
* 查询系统社区银行 * 查询系统社区银行
* @return * @return
*/ */
BankAccount findSystemBankAccount(); BankAccount findSystemBankAccount();
/**
* 查询账号信息
* @param formBankAccount
* @return
*/
BankAccount findInfoByBankAccount(String formBankAccount);
} }

View File

@ -13,7 +13,24 @@ import java.util.Map;
*/ */
public interface CommentService extends Service<Comment> { public interface CommentService extends Service<Comment> {
/**
* 获取文章评论数据
* @param idArticle
* @return
*/
List<CommentDTO> getArticleComments(Integer idArticle); List<CommentDTO> getArticleComments(Integer idArticle);
/**
* 评论
* @param comment
* @param request
* @return
*/
Map postComment(Comment comment, HttpServletRequest request); Map postComment(Comment comment, HttpServletRequest request);
/**
* 获取评论列表数据
* @return
*/
List<CommentDTO> findComments();
} }

View File

@ -11,12 +11,10 @@ import com.rymcu.forest.entity.User;
import com.rymcu.forest.lucene.service.LuceneService; import com.rymcu.forest.lucene.service.LuceneService;
import com.rymcu.forest.mapper.ArticleMapper; import com.rymcu.forest.mapper.ArticleMapper;
import com.rymcu.forest.service.ArticleService; import com.rymcu.forest.service.ArticleService;
import com.rymcu.forest.service.CommentService;
import com.rymcu.forest.service.TagService; import com.rymcu.forest.service.TagService;
import com.rymcu.forest.service.UserService; import com.rymcu.forest.service.UserService;
import com.rymcu.forest.util.*; import com.rymcu.forest.util.*;
import com.rymcu.forest.web.api.exception.BaseApiException; import com.rymcu.forest.web.api.exception.BaseApiException;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.text.StringEscapeUtils; import org.apache.commons.text.StringEscapeUtils;
@ -44,8 +42,6 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
@Resource @Resource
private UserService userService; private UserService userService;
@Resource @Resource
private CommentService commentService;
@Resource
private LuceneService luceneService; private LuceneService luceneService;
@Value("${resource.domain}") @Value("${resource.domain}")

View File

@ -61,10 +61,8 @@ public class BankAccountServiceImpl extends AbstractService<BankAccount> impleme
} }
@Override @Override
public BankAccount findByBankAccount(String bankAccount) { public BankAccountDTO findByBankAccount(String bankAccount) {
BankAccount searchBankAccount = new BankAccount(); return bankAccountMapper.selectByBankAccount(bankAccount);
searchBankAccount.setBankAccount(bankAccount);
return bankAccountMapper.selectOne(searchBankAccount);
} }
@Override @Override
@ -76,6 +74,13 @@ public class BankAccountServiceImpl extends AbstractService<BankAccount> impleme
return bankAccountMapper.selectOne(bankAccount); return bankAccountMapper.selectOne(bankAccount);
} }
@Override
public BankAccount findInfoByBankAccount(String bankAccount) {
BankAccount searchBankAccount = new BankAccount();
searchBankAccount.setBankAccount(bankAccount);
return bankAccountMapper.selectOne(searchBankAccount);
}
private String nextBankAccount() { private String nextBankAccount() {
String bankAccount = "600000001"; String bankAccount = "600000001";
String maxBankAccount = bankAccountMapper.selectMaxBankAccount(); String maxBankAccount = bankAccountMapper.selectMaxBankAccount();

View File

@ -36,6 +36,10 @@ public class CommentServiceImpl extends AbstractService<Comment> implements Comm
@Override @Override
public List<CommentDTO> getArticleComments(Integer idArticle) { public List<CommentDTO> getArticleComments(Integer idArticle) {
List<CommentDTO> commentDTOList = commentMapper.selectArticleComments(idArticle); List<CommentDTO> commentDTOList = commentMapper.selectArticleComments(idArticle);
return genComments(commentDTOList);
}
private List<CommentDTO> genComments(List<CommentDTO> commentDTOList) {
commentDTOList.forEach(commentDTO -> { commentDTOList.forEach(commentDTO -> {
commentDTO.setTimeAgo(Utils.getTimeAgo(commentDTO.getCreatedTime())); commentDTO.setTimeAgo(Utils.getTimeAgo(commentDTO.getCreatedTime()));
if (commentDTO.getCommentAuthorId() != null) { if (commentDTO.getCommentAuthorId() != null) {
@ -113,4 +117,10 @@ public class CommentServiceImpl extends AbstractService<Comment> implements Comm
return map; return map;
} }
@Override
public List<CommentDTO> findComments() {
List<CommentDTO> commentDTOList = commentMapper.selectComments();
return genComments(commentDTOList);
}
} }

View File

@ -4,15 +4,19 @@ import com.rymcu.forest.core.exception.TransactionException;
import com.rymcu.forest.core.service.AbstractService; import com.rymcu.forest.core.service.AbstractService;
import com.rymcu.forest.core.service.redis.RedisService; import com.rymcu.forest.core.service.redis.RedisService;
import com.rymcu.forest.dto.BankAccountDTO; import com.rymcu.forest.dto.BankAccountDTO;
import com.rymcu.forest.dto.BankAccountSearchDTO;
import com.rymcu.forest.dto.TransactionRecordDTO; import com.rymcu.forest.dto.TransactionRecordDTO;
import com.rymcu.forest.entity.BankAccount; import com.rymcu.forest.entity.BankAccount;
import com.rymcu.forest.entity.TransactionRecord; import com.rymcu.forest.entity.TransactionRecord;
import com.rymcu.forest.entity.User;
import com.rymcu.forest.enumerate.TransactionCode; import com.rymcu.forest.enumerate.TransactionCode;
import com.rymcu.forest.enumerate.TransactionEnum; import com.rymcu.forest.enumerate.TransactionEnum;
import com.rymcu.forest.mapper.TransactionRecordMapper; import com.rymcu.forest.mapper.TransactionRecordMapper;
import com.rymcu.forest.service.BankAccountService; import com.rymcu.forest.service.BankAccountService;
import com.rymcu.forest.service.TransactionRecordService; import com.rymcu.forest.service.TransactionRecordService;
import com.rymcu.forest.util.DateUtil; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -56,7 +60,17 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
@Override @Override
public List<TransactionRecordDTO> findTransactionRecords(String bankAccount) { 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 @Override
@ -122,7 +136,7 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
} }
private boolean checkFormAccountStatus(String formBankAccount, BigDecimal money) { private boolean checkFormAccountStatus(String formBankAccount, BigDecimal money) {
BankAccount bankAccount = bankAccountService.findByBankAccount(formBankAccount); BankAccount bankAccount = bankAccountService.findInfoByBankAccount(formBankAccount);
if (Objects.nonNull(bankAccount)) { if (Objects.nonNull(bankAccount)) {
if (bankAccount.getAccountBalance().compareTo(money) > 0) { if (bankAccount.getAccountBalance().compareTo(money) > 0) {
return true; return true;

View File

@ -4,6 +4,9 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.rymcu.forest.core.result.GlobalResult; import com.rymcu.forest.core.result.GlobalResult;
import com.rymcu.forest.core.result.GlobalResultGenerator; 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.UserSearchDTO;
import com.rymcu.forest.dto.admin.TopicTagDTO; import com.rymcu.forest.dto.admin.TopicTagDTO;
import com.rymcu.forest.dto.admin.UserRoleDTO; import com.rymcu.forest.dto.admin.UserRoleDTO;
@ -36,6 +39,10 @@ public class AdminController {
private TagService tagService; private TagService tagService;
@Resource @Resource
private SpecialDayService specialDayService; private SpecialDayService specialDayService;
@Resource
private ArticleService articleService;
@Resource
private CommentService commentService;
@GetMapping("/users") @GetMapping("/users")
public GlobalResult<Map<String, Object>> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, UserSearchDTO searchDTO){ 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); 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);
}
} }

View File

@ -7,6 +7,7 @@ import com.rymcu.forest.core.result.GlobalResultGenerator;
import com.rymcu.forest.core.result.GlobalResultMessage; import com.rymcu.forest.core.result.GlobalResultMessage;
import com.rymcu.forest.core.service.log.annotation.VisitLogger; import com.rymcu.forest.core.service.log.annotation.VisitLogger;
import com.rymcu.forest.dto.*; import com.rymcu.forest.dto.*;
import com.rymcu.forest.entity.Portfolio;
import com.rymcu.forest.entity.User; import com.rymcu.forest.entity.User;
import com.rymcu.forest.service.*; import com.rymcu.forest.service.*;
import com.rymcu.forest.util.UserUtils; import com.rymcu.forest.util.UserUtils;
@ -142,4 +143,16 @@ public class CommonApiController {
Map map = Utils.getArticlesGlobalResult(pageInfo); Map map = Utils.getArticlesGlobalResult(pageInfo);
return GlobalResultGenerator.genSuccessResult(map); 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);
}
} }

View File

@ -12,24 +12,30 @@
<result column="created_time" property="createdTime"></result> <result column="created_time" property="createdTime"></result>
</resultMap> </resultMap>
<select id="selectBankAccounts" resultMap="DTOResultMap"> <select id="selectBankAccounts" resultMap="DTOResultMap">
select vb.bank_name, vu.nickname as account_owner_name, vba.* from forest_bank_account vba select fb.bank_name, ifnull(fu.nickname, '系统') as account_owner_name, fba.* from forest_bank_account fba
join forest_bank vb on vba.id_bank = vb.id join forest_bank fb on fba.id_bank = fb.id
join forest_user vu on vba.account_owner = vu.id where vba.account_type = 0 left join forest_user fu on fba.account_owner = fu.id where fba.account_type = 0
<if test="bankName != null and bankName != ''"> <if test="bankName != null and bankName != ''">
and vb.bank_name = #{bankName} and fb.bank_name = #{bankName}
</if> </if>
<if test="accountOwnerName != null and accountOwnerName != ''"> <if test="accountOwnerName != null and accountOwnerName != ''">
and vu.nickname = #{accountOwnerName} and fu.nickname = #{accountOwnerName}
</if> </if>
<if test="bankAccount != null and bankAccount != ''"> <if test="bankAccount != null and bankAccount != ''">
and vba.bank_account = #{bankAccount} and fba.bank_account = #{bankAccount}
</if> </if>
</select> </select>
<select id="selectBankAccount" resultMap="DTOResultMap"> <select id="selectBankAccount" resultMap="DTOResultMap">
select vb.bank_name, vba.* from forest_bank_account vba select fb.bank_name, fu.nickname as account_owner_name, fba.* from forest_bank_account fba
join forest_bank vb on vba.id_bank = vb.id where vba.id = #{idBank} 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>
<select id="selectMaxBankAccount" resultType="java.lang.String"> <select id="selectMaxBankAccount" resultType="java.lang.String">
select max(bank_account) as max_bank_account from forest_bank_account where account_type = 0 select max(bank_account) as max_bank_account from forest_bank_account where account_type = 0
</select> </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> </mapper>

View File

@ -28,6 +28,7 @@
<result column="comment_reply_count" property="commentReplyCount"></result> <result column="comment_reply_count" property="commentReplyCount"></result>
<result column="comment_visible" property="commentVisible"></result> <result column="comment_visible" property="commentVisible"></result>
<result column="created_time" property="createdTime"></result> <result column="created_time" property="createdTime"></result>
<result column="article_title" property="articleTitle"></result>
</resultMap> </resultMap>
<resultMap id="AuthorResultMap" type="com.rymcu.forest.dto.Author"> <resultMap id="AuthorResultMap" type="com.rymcu.forest.dto.Author">
<result column="id" property="idUser"/> <result column="id" property="idUser"/>
@ -39,7 +40,7 @@
update forest_comment set comment_sharp_url = #{commentSharpUrl} where id = #{idComment} update forest_comment set comment_sharp_url = #{commentSharpUrl} where id = #{idComment}
</update> </update>
<select id="selectArticleComments" resultMap="DTOResultMap"> <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>
<select id="selectAuthor" resultMap="AuthorResultMap"> <select id="selectAuthor" resultMap="AuthorResultMap">
select id,nickname,avatar_url,account from forest_user where id = #{commentAuthorId} select id,nickname,avatar_url,account from forest_user where id = #{commentAuthorId}
@ -47,4 +48,7 @@
<select id="selectCommentOriginalAuthor" resultMap="AuthorResultMap"> <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 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>
<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> </mapper>

View File

@ -52,6 +52,7 @@
select ifnull(max(sort_no),0) + 1 from forest_portfolio_article where id_portfolio = #{idPortfolio} select ifnull(max(sort_no),0) + 1 from forest_portfolio_article where id_portfolio = #{idPortfolio}
</select> </select>
<select id="selectPortfolios" resultMap="BaseResultMap"> <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> </select>
</mapper> </mapper>

View File

@ -16,7 +16,7 @@
update forest_bank_account set account_balance = account_balance + #{money} where bank_account = #{toBankAccount}; update forest_bank_account set account_balance = account_balance + #{money} where bank_account = #{toBankAccount};
</update> </update>
<select id="selectTransactionRecords" resultMap="DTOResultMap"> <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>
<select id="existsWithBankAccountAndFunds" resultType="java.lang.Boolean"> <select id="existsWithBankAccountAndFunds" resultType="java.lang.Boolean">
select ifnull((select false from forest_transaction_record where to_bank_account = #{bankAccount} select ifnull((select false from forest_transaction_record where to_bank_account = #{bankAccount}

View File

@ -32,7 +32,7 @@
<result column="article_sponsor_count" property="articleSponsorCount"></result> <result column="article_sponsor_count" property="articleSponsorCount"></result>
</resultMap> </resultMap>
<select id="getAllArticleLucene" resultMap="ResultMapWithBLOBs"> <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 from forest_article art
join forest_article_content content on art.id = content.id_article join forest_article_content content on art.id = content.id_article
where article_status = 0; where article_status = 0;