Skip to content

Commit

Permalink
修复目前已发现BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
sunkaifei committed Jan 24, 2019
1 parent d339b6c commit ca2eaae
Show file tree
Hide file tree
Showing 45 changed files with 208 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- ###### 增加 ###### -->
<!-- ############################## -->
<!-- 添加文章分类 -->
<insert id="addArticleCategory">
<insert id="addArticleCategory" useGeneratedKeys="true" keyProperty="id">
insert into fly_article_category
<!-- 添加表字段 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
Expand Down Expand Up @@ -40,7 +40,7 @@
<!-- ###### 删除 ###### -->
<!-- ############################## -->
<!-- 按分类id删除该分类信息 -->
<delete id="deleteArticleCategoryById">
<delete id="deleteArticleCategoryById" parameterType="Integer">
delete from fly_article_category where id=#{id}
</delete>

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/flycms/module/article/dao/ArticleDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public interface ArticleDao {
public int addArticle(Article article);

//添加文章统计关联数据
public int addArticleCount(@Param("articleId") long articleId);
public int addArticleCount(@Param("articleId") Long articleId);

//按id查询文章信息
public int addArticleAndCategory(@Param("articleId") long articleId,@Param("categoryId") String categoryId,@Param("typeId") Integer typeId);
public int addArticleAndCategory(@Param("articleId") Long articleId,@Param("categoryId") String categoryId,@Param("typeId") Long typeId);

//添加文章评论内容
public int addArticleComment(ArticleComment articleComment);
Expand All @@ -40,19 +40,19 @@ public interface ArticleDao {
// ///// 刪除 ////////
// ///////////////////////////////
//按id删除文章信息
public Long deleteArticleById(@Param("id") long id);
public Long deleteArticleById(@Param("id") Long id);

//按id删除文章统计关联
public Long deleteArticleCountById(@Param("articleId") long articleId);
public Long deleteArticleCountById(@Param("articleId") Long articleId);

//按id删除文章评论内容
public Long deleteArticleCommentById(@Param("articleId") long articleId);
public Long deleteArticleCommentById(@Param("articleId") Long articleId);

//按id删除文章和分类关联
public Long deleteArticleAndCcategoryById(@Param("articleId") long articleId);
public Long deleteArticleAndCcategoryById(@Param("articleId") Long articleId);

//按文章id删除用户顶或者踩记录
public Long deleteAllArticleVotesById(@Param("articleId") long articleId);
public Long deleteAllArticleVotesById(@Param("articleId") Long articleId);

/**
* 按信息类型id、文章id、用户id删除用户顶或者踩记录
Expand Down Expand Up @@ -87,7 +87,7 @@ public Long deleteArticleVotesById(@Param("infoType") Integer infoType,
public int updateArticleStatusById(@Param("id") Long id,@Param("status") Integer status,@Param("recommend") Integer recommend);

//按id更新文章分类
public int editArticleAndCcategoryById(@Param("categoryId") String categoryId,@Param("typeId") Integer typeId,@Param("articleId") long articleId);
public int editArticleAndCcategoryById(@Param("categoryId") String categoryId,@Param("typeId") Integer typeId,@Param("articleId") Long articleId);

/**
* 更新文章被评论的数量
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/com/flycms/module/article/dao/ArticleDao.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- ###### 增加 ###### -->
<!-- ############################## -->
<!-- 添加文章 -->
<insert id="addArticle">
<insert id="addArticle" useGeneratedKeys="true" keyProperty="id">
insert into fly_article
<!-- 添加表字段 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
Expand Down Expand Up @@ -73,7 +73,7 @@
</insert>

<!-- 添加文章评论内容-->
<insert id="addArticleComment">
<insert id="addArticleComment" useGeneratedKeys="true" keyProperty="id">
insert into fly_article_comment
<!-- 添加表字段 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
Expand Down Expand Up @@ -117,32 +117,32 @@
<!-- ###### 删除 ###### -->
<!-- ############################## -->
<!-- 按id删除文章信息 -->
<delete id="deleteArticleById">
<delete id="deleteArticleById" parameterType="java.lang.Long">
delete from fly_article where id=#{id}
</delete>

<!-- 按id删除文章统计关联 -->
<delete id="deleteArticleCountById">
<delete id="deleteArticleCountById" parameterType="java.lang.Long">
delete from fly_article_count where article_id=#{articleId}
</delete>

<!-- 按id删除文章评论内容 -->
<delete id="deleteArticleCommentById">
<delete id="deleteArticleCommentById" parameterType="java.lang.Long">
delete from fly_article_comment where article_id=#{articleId}
</delete>

<!-- 按id删除文章和分类关联 -->
<delete id="deleteArticleAndCcategoryById">
<delete id="deleteArticleAndCcategoryById" parameterType="java.lang.Long">
delete from fly_article_category_merge where article_id=#{articleId}
</delete>

<!-- 按文章id删除用户顶或者踩记录 -->
<delete id="deleteAllArticleVotesById">
delete from fly_article_votes where info_id=#{articleId}
<delete id="deleteAllArticleVotesById" parameterType="java.lang.Long">
delete from fly_article_votes where article_id=#{articleId}
</delete>

<!-- 按信息类型id、文章id、用户id删除用户顶或者踩记录 -->
<delete id="deleteArticleVotesById">
<delete id="deleteArticleVotesById" parameterType="java.lang.Long">
delete from fly_article_votes where info_type= #{infoType} and info_id=#{infoId} and user_id = #{userId}
</delete>
<!-- ############################## -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ public DataVo addArticle(Article article) throws Exception {
if(StringUtils.isBlank(article.getContent())){
return data=DataVo.failure("内容不能为空!");
}
if(StringUtils.isBlank(article.getCategoryId())){
if(StringUtils.isBlank(article.getCategoryId()) || article.getCategoryId().length() < 2){
return data=DataVo.failure("必须选择文章分类!");
}
//转换为数组
String[] str = article.getCategoryId().split(",");
if((new Long(0)).equals(Long.parseLong(str[str.length - 1]))){
return data=DataVo.failure("必须选择文章分类!");
}
if(this.checkArticleByTitle(article.getTitle(),article.getUserId(),0L)){
Expand Down Expand Up @@ -106,10 +111,10 @@ public Article addArticle(Article article,String[] tags) throws Exception {
article.setTitle(StringEscapeUtils.escapeHtml4(article.getTitle()));
article.setCreateTime(new Date());
article.setStatus(Integer.parseInt(configService.getStringByKey("user_article_verify")));
article.setContent(imagesService.replaceContent(1,article.getId(),article.getUserId(),article.getContent()));
article.setContent(imagesService.replaceContent(2,article.getId(),article.getUserId(),article.getContent()));
int totalCount=articleDao.addArticle(article);
if(totalCount > 0) {
articleDao.addArticleAndCategory(article.getId(), article.getCategoryId(), Integer.valueOf(str[str.length - 1]));
articleDao.addArticleAndCategory(article.getId(), article.getCategoryId(), Long.parseLong(str[str.length - 1]));
//添加用户feed信息
feedService.addUserFeed(article.getUserId(), 1, article.getId());
//添加文章统计关联数据
Expand Down Expand Up @@ -173,6 +178,7 @@ public DataVo deleteArticleById(Long id) {
//按id删除文章统计关联
articleDao.deleteArticleAndCcategoryById(id);
feedService.deleteUserFeed(article.getUserId(),1,article.getId());
topicService.deleteTopicAndInfoUpCount(1,article.getId());
solrService.indexDeleteInfo(1,article.getId());
userService.updateArticleCount(article.getUserId());
data = DataVo.jump("删除成功!","/admin/article/article_list");
Expand All @@ -192,7 +198,12 @@ public DataVo editArticleById(Article article) throws Exception {
if(StringUtils.isBlank(article.getContent())){
return data=DataVo.failure("内容不能为空!");
}
if(StringUtils.isBlank(article.getCategoryId())){
if(StringUtils.isBlank(article.getCategoryId()) || article.getCategoryId().length() < 2){
return data=DataVo.failure("必须选择文章分类!");
}
//转换为数组
String[] str = article.getCategoryId().split(",");
if((new Long(0)).equals(Long.parseLong(str[str.length - 1]))){
return data=DataVo.failure("必须选择文章分类!");
}
if(this.checkArticleByTitle(article.getTitle(),article.getUserId(),article.getId())){
Expand All @@ -205,11 +216,9 @@ public DataVo editArticleById(Article article) throws Exception {
if (tags.length>5) {
return DataVo.failure("话题数不能大于5个");
}
//转换为数组
String[] str = article.getCategoryId().split(",");
article.setUpdateTime(new Date());
article.setStatus(Integer.parseInt(configService.getStringByKey("user_article_verify")));
article.setContent(imagesService.replaceContent(article.getContent(),article.getUserId()));
article.setContent(imagesService.replaceContent(2,article.getId(),article.getUserId(),article.getContent()));
int totalCount=articleDao.editArticleById(article);
if(totalCount > 0){
//修改分类信息
Expand Down Expand Up @@ -272,7 +281,7 @@ public DataVo updateArticleStatusById(Long id, Integer status, Integer recommend
feedService.updateuUserFeedById(1,article.getId(),1);
}
userService.updateArticleCount(article.getUserId());
solrService.indexQuestionId(article.getId());
solrService.indexArticleId(article.getId());
//更新权重
//this.weight(article,null);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<!-- ###### 删除 ###### -->
<!-- ############################## -->
<!-- 按id删除收藏信息 -->
<delete id="deleteFavoriteById">
<delete id="deleteFavoriteById" parameterType="Integer">
delete from fly_favorite where user_id= #{userId} and info_type= #{infoType} and info_id= #{infoId}
</delete>

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/flycms/module/links/dao/LinksDao.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- ############################## -->
<!-- ###### 增加 ###### -->
<!-- ############################## -->
<insert id="addLinks">
<insert id="addLinks" parameterType="com.flycms.module.links.model.Links">
insert into fly_links
<!-- 添加表字段 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/flycms/module/question/dao/AnswerDao.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- ###### 增加 ###### -->
<!-- ############################## -->
<!-- 增加答案信息-->
<insert id="addAnswer">
<insert id="addAnswer" useGeneratedKeys="true" keyProperty="id">
insert into fly_answer
<!-- 添加表字段 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/flycms/module/question/dao/ImagesDao.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- ############################## -->
<!-- ###### 增加 ###### -->
<!-- ############################## -->
<insert id="addImages">
<insert id="addImages" useGeneratedKeys="true" keyProperty="id">
insert into fly_images
<!-- 添加表字段 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
Expand Down Expand Up @@ -67,22 +67,22 @@
<!-- ###### 删除 ###### -->
<!-- ############################## -->
<!-- 按图片id删除图片信息 -->
<delete id="deleteImagesById">
<delete id="deleteImagesById" parameterType="Integer">
delete from fly_images where id=#{id}
</delete>

<!-- 按图片地址删除图片信息 -->
<delete id="deleteImagesByimgurl">
<delete id="deleteImagesByimgurl" parameterType="Integer">
delete from fly_images where imgurl=#{imgurl}
</delete>

<!-- 按信息分类和内容id删除图片信息 -->
<delete id="deleteImagesByTid">
<delete id="deleteImagesByTid" parameterType="Integer">
delete from fly_images where channel_id = #{channelId} and tid=#{tid}
</delete>

<!-- 按图片路径删除数据-->
<delete id="deleteImagesByTidAndImgurl">
<delete id="deleteImagesByTidAndImgurl" parameterType="Integer">
delete from fly_images where tid=#{tid} and imgurl=#{imgurl}
</delete>

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/flycms/module/question/dao/QuestionDao.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- ###### 增加 ###### -->
<!-- ############################## -->
<!-- 增加问题信息-->
<insert id="addQuestion">
<insert id="addQuestion" useGeneratedKeys="true" keyProperty="id">
insert into fly_question
<!-- 添加表字段 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
Expand Down Expand Up @@ -48,7 +48,7 @@
</insert>

<!-- 添加关注问题关联-->
<insert id="addQuestionFollow">
<insert id="addQuestionFollow" useGeneratedKeys="true" keyProperty="id">
insert into fly_question_follow_merge
<!-- 添加表字段 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/flycms/module/question/model/Attribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
@Setter
@Getter
public class Attribute implements Serializable {
private Integer id;
private Long id;

private Integer modelId;
private Long modelId;

private Integer type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class QuestionCount implements Serializable {
private static final long serialVersionUID = 1L;
//问题id
private Integer questionId;
private Long questionId;
//回答数量
private Integer countAnswer;
//关注人数
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ public DataVo addAnswer(Long questionId,Long userId,String content) throws Excep
if(checkAnswerByContent(userId,content)){
return data= DataVo.failure("请勿重复发表相同内容");
}
content=imagesService.replaceContent(content,userId);
Answer answer=new Answer();
SnowFlake snowFlake = new SnowFlake(2, 3);
answer.setId(snowFlake.nextId());
answer.setQuestionId(questionId);
answer.setUserId(userId);
answer.setContent(content);
answer.setContent(imagesService.replaceContent(1,answer.getId(),answer.getUserId(),content));
answer.setCreateTime(new Date());
answer.setStatus(Integer.parseInt(configService.getStringByKey("user_answer_verify")));
int totalCount=answerDao.addAnswer(answer);
Expand Down Expand Up @@ -178,7 +177,7 @@ public DataVo updateAnswerById(Long id,Long userId, String content) throws Excep
if(answer==null){
return data = DataVo.failure("该答案不存在或已删除");
}
answer.setContent(imagesService.replaceContent(content,answer.getUserId()));
answer.setContent(imagesService.replaceContent(1,answer.getId(),answer.getUserId(),answer.getContent()));
answer.setLastTime(new Date());
Question question=questionService.findQuestionById(answer.getQuestionId(),0);
if(question.getStatus()!=1){
Expand Down
Loading

0 comments on commit ca2eaae

Please sign in to comment.