🐛 修复了一些 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;
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;

View File

@ -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;
}

View File

@ -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;
/** 交易类型 */

View File

@ -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,7 +50,12 @@ 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;
/**
* 将文章的数据解析为一个个关键字词存储到索引文件中
@ -187,11 +201,36 @@ public class LuceneServiceImpl implements LuceneService {
@Override
public List<ArticleLucene> getAllArticleLucene() {
return luceneMapper.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) {
return luceneMapper.getArticlesByIds(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
*/
String selectMaxBankAccount();
/**
* 根据卡号获取银行账号信息
* @param bankAccount
* @return
*/
BankAccountDTO selectByBankAccount(@Param("bankAccount") String bankAccount);
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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}")

View File

@ -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();

View File

@ -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);
}
}

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.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;

View File

@ -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);
}
}

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.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);
}
}

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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}

View File

@ -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;