diff --git a/src/main/java/com/rymcu/forest/dto/ArticleDTO.java b/src/main/java/com/rymcu/forest/dto/ArticleDTO.java index 43a84b4..530998c 100644 --- a/src/main/java/com/rymcu/forest/dto/ArticleDTO.java +++ b/src/main/java/com/rymcu/forest/dto/ArticleDTO.java @@ -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; diff --git a/src/main/java/com/rymcu/forest/dto/CommentDTO.java b/src/main/java/com/rymcu/forest/dto/CommentDTO.java index 1f93a53..8920b41 100644 --- a/src/main/java/com/rymcu/forest/dto/CommentDTO.java +++ b/src/main/java/com/rymcu/forest/dto/CommentDTO.java @@ -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; } diff --git a/src/main/java/com/rymcu/forest/dto/TransactionRecordDTO.java b/src/main/java/com/rymcu/forest/dto/TransactionRecordDTO.java index 14148d8..349dbb9 100644 --- a/src/main/java/com/rymcu/forest/dto/TransactionRecordDTO.java +++ b/src/main/java/com/rymcu/forest/dto/TransactionRecordDTO.java @@ -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; /** 交易类型 */ diff --git a/src/main/java/com/rymcu/forest/lucene/service/impl/LuceneServiceImpl.java b/src/main/java/com/rymcu/forest/lucene/service/impl/LuceneServiceImpl.java index 412c865..ed6cbc2 100644 --- a/src/main/java/com/rymcu/forest/lucene/service/impl/LuceneServiceImpl.java +++ b/src/main/java/com/rymcu/forest/lucene/service/impl/LuceneServiceImpl.java @@ -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 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 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 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 searchArticle(String value) { - List 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); - // 最终被分词后添加的前缀和后缀处理器,默认是粗体 - SimpleHTMLFormatter htmlFormatter = - new SimpleHTMLFormatter("", ""); - // 高亮搜索的词添加到高亮处理器中 - 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 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 getAllArticleLucene() { - return luceneMapper.getAllArticleLucene(); - } + @Override + public void writeArticle(String id) { + writeArticle(luceneMapper.getById(id)); + } - @Override - public List 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 searchArticle(String value) { + List 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); + // 最终被分词后添加的前缀和后缀处理器,默认是粗体 + SimpleHTMLFormatter htmlFormatter = + new SimpleHTMLFormatter("", ""); + // 高亮搜索的词添加到高亮处理器中 + 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 getAllArticleLucene() { + List list = luceneMapper.getAllArticleLucene(); + for (ArticleLucene articleLucene : list) { + articleLucene.setArticleContent(Html2TextUtil.getContent(articleLucene.getArticleContent())); + } + return list; + } + + @Override + public List getArticlesByIds(String[] ids) { + List 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 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; + } } diff --git a/src/main/java/com/rymcu/forest/mapper/BankAccountMapper.java b/src/main/java/com/rymcu/forest/mapper/BankAccountMapper.java index a71f580..a067c76 100644 --- a/src/main/java/com/rymcu/forest/mapper/BankAccountMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/BankAccountMapper.java @@ -32,4 +32,11 @@ public interface BankAccountMapper extends Mapper { * @return */ String selectMaxBankAccount(); + + /** + * 根据卡号获取银行账号信息 + * @param bankAccount + * @return + */ + BankAccountDTO selectByBankAccount(@Param("bankAccount") String bankAccount); } diff --git a/src/main/java/com/rymcu/forest/mapper/CommentMapper.java b/src/main/java/com/rymcu/forest/mapper/CommentMapper.java index aa369ac..4969ece 100644 --- a/src/main/java/com/rymcu/forest/mapper/CommentMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/CommentMapper.java @@ -40,4 +40,10 @@ public interface CommentMapper extends Mapper { * @return */ Integer updateCommentSharpUrl(@Param("idComment") Integer idComment, @Param("commentSharpUrl") String commentSharpUrl); + + /** + * 获取评论列表数据 + * @return + */ + List selectComments(); } diff --git a/src/main/java/com/rymcu/forest/service/BankAccountService.java b/src/main/java/com/rymcu/forest/service/BankAccountService.java index fa355e7..d7e2d10 100644 --- a/src/main/java/com/rymcu/forest/service/BankAccountService.java +++ b/src/main/java/com/rymcu/forest/service/BankAccountService.java @@ -31,11 +31,18 @@ public interface BankAccountService extends Service { * @param bankAccount * @return */ - BankAccount findByBankAccount(String bankAccount); + BankAccountDTO findByBankAccount(String bankAccount); /** * 查询系统社区银行 * @return */ BankAccount findSystemBankAccount(); + + /** + * 查询账号信息 + * @param formBankAccount + * @return + */ + BankAccount findInfoByBankAccount(String formBankAccount); } diff --git a/src/main/java/com/rymcu/forest/service/CommentService.java b/src/main/java/com/rymcu/forest/service/CommentService.java index 9199b90..92b2b9d 100644 --- a/src/main/java/com/rymcu/forest/service/CommentService.java +++ b/src/main/java/com/rymcu/forest/service/CommentService.java @@ -13,7 +13,24 @@ import java.util.Map; */ public interface CommentService extends Service { + /** + * 获取文章评论数据 + * @param idArticle + * @return + */ List getArticleComments(Integer idArticle); + /** + * 评论 + * @param comment + * @param request + * @return + */ Map postComment(Comment comment, HttpServletRequest request); + + /** + * 获取评论列表数据 + * @return + */ + List findComments(); } diff --git a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java index dbcf9a5..7db94a9 100644 --- a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java @@ -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
implements Arti @Resource private UserService userService; @Resource - private CommentService commentService; - @Resource private LuceneService luceneService; @Value("${resource.domain}") diff --git a/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java index 5721464..da34cca 100644 --- a/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java @@ -61,10 +61,8 @@ public class BankAccountServiceImpl extends AbstractService 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 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(); diff --git a/src/main/java/com/rymcu/forest/service/impl/CommentServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/CommentServiceImpl.java index 174e66e..0602e87 100644 --- a/src/main/java/com/rymcu/forest/service/impl/CommentServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/CommentServiceImpl.java @@ -36,6 +36,10 @@ public class CommentServiceImpl extends AbstractService implements Comm @Override public List getArticleComments(Integer idArticle) { List commentDTOList = commentMapper.selectArticleComments(idArticle); + return genComments(commentDTOList); + } + + private List genComments(List commentDTOList) { commentDTOList.forEach(commentDTO -> { commentDTO.setTimeAgo(Utils.getTimeAgo(commentDTO.getCreatedTime())); if (commentDTO.getCommentAuthorId() != null) { @@ -113,4 +117,10 @@ public class CommentServiceImpl extends AbstractService implements Comm return map; } + + @Override + public List findComments() { + List commentDTOList = commentMapper.selectComments(); + return genComments(commentDTOList); + } } diff --git a/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java index a832bf3..c0a2167 100644 --- a/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java @@ -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 findTransactionRecords(String bankAccount) { - return transactionRecordMapper.selectTransactionRecords(bankAccount); + List 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 0) { return true; diff --git a/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java b/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java index f39b423..216ea56 100644 --- a/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java +++ b/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java @@ -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> 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 articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO articleSearchDTO) { + PageHelper.startPage(page, rows); + List list = articleService.findArticles(articleSearchDTO); + PageInfo pageInfo = new PageInfo<>(list); + Map 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 comments(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { + PageHelper.startPage(page, rows); + List list = commentService.findComments(); + PageInfo pageInfo = new PageInfo<>(list); + Map map = new HashMap<>(2); + map.put("comments", pageInfo.getList()); + Map pagination = Utils.getPagination(pageInfo); + map.put("pagination", pagination); + return GlobalResultGenerator.genSuccessResult(map); + } + + + } diff --git a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java index ec2d5a7..27980fa 100644 --- a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java +++ b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java @@ -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 list = portfolioService.findPortfolios(); + PageInfo 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); + } } diff --git a/src/main/java/mapper/BankAccountMapper.xml b/src/main/java/mapper/BankAccountMapper.xml index 2cc2765..ff935f7 100644 --- a/src/main/java/mapper/BankAccountMapper.xml +++ b/src/main/java/mapper/BankAccountMapper.xml @@ -12,24 +12,30 @@ + \ No newline at end of file diff --git a/src/main/java/mapper/CommentMapper.xml b/src/main/java/mapper/CommentMapper.xml index 646abb2..5d73f0f 100644 --- a/src/main/java/mapper/CommentMapper.xml +++ b/src/main/java/mapper/CommentMapper.xml @@ -28,6 +28,7 @@ + @@ -39,7 +40,7 @@ update forest_comment set comment_sharp_url = #{commentSharpUrl} where id = #{idComment} 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} + \ No newline at end of file diff --git a/src/main/java/mapper/PortfolioMapper.xml b/src/main/java/mapper/PortfolioMapper.xml index ac07b15..ad1ebbc 100644 --- a/src/main/java/mapper/PortfolioMapper.xml +++ b/src/main/java/mapper/PortfolioMapper.xml @@ -52,6 +52,7 @@ select ifnull(max(sort_no),0) + 1 from forest_portfolio_article where id_portfolio = #{idPortfolio} \ No newline at end of file diff --git a/src/main/java/mapper/TransactionRecordMapper.xml b/src/main/java/mapper/TransactionRecordMapper.xml index effeafe..0ae14b6 100644 --- a/src/main/java/mapper/TransactionRecordMapper.xml +++ b/src/main/java/mapper/TransactionRecordMapper.xml @@ -16,7 +16,7 @@ update forest_bank_account set account_balance = account_balance + #{money} where bank_account = #{toBankAccount}; - 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;