master
ck 5 years ago
parent d71765cdda
commit 9b4160f6d9

@ -2,6 +2,7 @@ package com.jingcheng.cms.mapper;
import com.jingcheng.cms.model.Article;
import com.jingcheng.cms.util.CommonMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -10,5 +11,8 @@ import java.util.List;
public interface ArticleMapper extends CommonMapper<Article> {
int addArticle(Article article);
List<Article> getArticleListByCondition(Article article);
List<Article> getArticleListByCondition(@Param("title") String title,
@Param("categoryName") String categoryName,
@Param("fileType") Integer fileType,
@Param("state") Integer state);
}

@ -36,5 +36,5 @@ public class Article extends BaseEntity{
/**
*
*/
private byte[] content;
private String content;
}

@ -68,7 +68,7 @@ public class ArticleSerivceImpl implements ArticleSerive {
article.setKeyword(keyword);
article.setFileType(fileType);
article.setState(state);
article.setContent(content.getBytes());
article.setContent(content);
articleMapper.addArticle(article);
ajaxResult.setRetmsg("成功新增文章");
}else {
@ -85,7 +85,7 @@ public class ArticleSerivceImpl implements ArticleSerive {
article.setKeyword(keyword);
article.setFileType(fileType);
article.setState(state);
article.setContent(content.getBytes());
article.setContent(content);
articleMapper.updateByPrimaryKeySelective(article);
ajaxResult.setRetmsg("成功修改文章");
}
@ -101,12 +101,7 @@ public class ArticleSerivceImpl implements ArticleSerive {
String categoryName = jsonObject.getString("categoryName");
Integer fileType = jsonObject.getInteger("fileType");
Integer state = jsonObject.getInteger("state");
Article article = new Article();
article.setTitle(title);
article.setFirstCategoryName(categoryName);
article.setFileType(fileType);
article.setState(state);
List<Article> CategoryList = articleMapper.getArticleListByCondition(article);
List<Article> CategoryList = articleMapper.getArticleListByCondition(title,categoryName,fileType,state);
JSONObject pageJson = PageUtils.page(CategoryList,pageNum,pageSize);
return pageJson;
}

@ -7,16 +7,16 @@
values (#{title},#{firstCategoryName},#{secondCategoryName},#{keyword},#{fileType},#{content},#{state})
</insert>
<select id="getArticleListByCondition" parameterType="com.jingcheng.cms.model.Article" resultType="com.jingcheng.cms.model.Article">
<select id="getArticleListByCondition" resultType="com.jingcheng.cms.model.Article">
select `id`,`title`,`first_category_name`,`second_category_name`,`keyword`,`file_type`,`content`,`create_date_time`,
`update_date_time`,`state` FROM article
where
1 = 1
<if test="title != null and title != ''">
and title LIKE CONCAT('%',#{title},'%')
and title like #{title}
</if>
<if test="firstCategoryName != null and firstCategoryName != ''">
and (first_category_name LIKE CONCAT('%',#{firstCategoryName},'%') or second_category_name LIKE CONCAT('%',#{firstCategoryName},'%'))
<if test="categoryName != null and categoryName != ''">
and (first_category_name like #{categoryName} or second_category_name like #{categoryName})
</if>
<if test="fileType != null ">
and file_type = #{fileType}

Loading…
Cancel
Save