|
|
|
@ -7,6 +7,7 @@ import com.jingcheng.cms.model.Article;
|
|
|
|
|
import com.jingcheng.cms.service.ArticleSerive;
|
|
|
|
|
import com.jingcheng.cms.util.AjaxResult;
|
|
|
|
|
import com.jingcheng.cms.util.PageUtils;
|
|
|
|
|
import com.jingcheng.cms.vo.ArticleVo;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@ -28,28 +29,32 @@ public class ArticleSerivceImpl implements ArticleSerive {
|
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
|
Long id = jsonObject.getLong("id");
|
|
|
|
|
String title = jsonObject.getString("title");
|
|
|
|
|
String firstCategoryName = jsonObject.getString("firstCategoryName");
|
|
|
|
|
String secondCategoryName = jsonObject.getString("secondCategoryName");
|
|
|
|
|
Long firstCategory = jsonObject.getLong("firstCategory");
|
|
|
|
|
Long secondCategory = jsonObject.getLong("secondCategory");
|
|
|
|
|
String keyword = jsonObject.getString("keyword");
|
|
|
|
|
Integer fileType = jsonObject.getInteger("fileType");
|
|
|
|
|
String content = jsonObject.getString("content");
|
|
|
|
|
Integer state = jsonObject.getInteger("state");
|
|
|
|
|
if (null == state){
|
|
|
|
|
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
ajaxResult.setRetmsg("是否启用不可为空");
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(title)){
|
|
|
|
|
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
ajaxResult.setRetmsg("文章标题不可为空");
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(firstCategoryName)||StringUtils.isBlank(secondCategoryName)){
|
|
|
|
|
if (null == firstCategory||null == secondCategory){
|
|
|
|
|
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
ajaxResult.setRetmsg("文章分类不可为空");
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
if (null == fileType){
|
|
|
|
|
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
ajaxResult.setRetmsg("文章形式不可为空");
|
|
|
|
|
return ajaxResult;
|
|
|
|
@ -63,8 +68,8 @@ public class ArticleSerivceImpl implements ArticleSerive {
|
|
|
|
|
//新增
|
|
|
|
|
Article article = new Article();
|
|
|
|
|
article.setTitle(title);
|
|
|
|
|
article.setFirstCategoryName(firstCategoryName);
|
|
|
|
|
article.setSecondCategoryName(secondCategoryName);
|
|
|
|
|
article.setFirstCategory(firstCategory);
|
|
|
|
|
article.setSecondCategory(secondCategory);
|
|
|
|
|
article.setKeyword(keyword);
|
|
|
|
|
article.setFileType(fileType);
|
|
|
|
|
article.setState(state);
|
|
|
|
@ -80,8 +85,8 @@ public class ArticleSerivceImpl implements ArticleSerive {
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
article.setTitle(title);
|
|
|
|
|
article.setFirstCategoryName(firstCategoryName);
|
|
|
|
|
article.setSecondCategoryName(secondCategoryName);
|
|
|
|
|
article.setFirstCategory(firstCategory);
|
|
|
|
|
article.setSecondCategory(secondCategory);
|
|
|
|
|
article.setKeyword(keyword);
|
|
|
|
|
article.setFileType(fileType);
|
|
|
|
|
article.setState(state);
|
|
|
|
@ -98,10 +103,39 @@ public class ArticleSerivceImpl implements ArticleSerive {
|
|
|
|
|
Integer pageNum = jsonObject.getInteger("pageNum") == null ? 1 : jsonObject.getInteger("pageNum");
|
|
|
|
|
Integer pageSize = jsonObject.getInteger("pageSize") == null ? 5 : jsonObject.getInteger("pageSize");
|
|
|
|
|
String title = jsonObject.getString("title");
|
|
|
|
|
String categoryName = jsonObject.getString("categoryName");
|
|
|
|
|
if (StringUtils.isNotEmpty(title)){
|
|
|
|
|
title = "%" + title + "%" ;
|
|
|
|
|
}
|
|
|
|
|
Long firstCategory = jsonObject.getLong("firstCategory");
|
|
|
|
|
Long secondCategory = jsonObject.getLong("secondCategory");
|
|
|
|
|
Integer fileType = jsonObject.getInteger("fileType");
|
|
|
|
|
Integer state = jsonObject.getInteger("state");
|
|
|
|
|
List<Article> CategoryList = articleMapper.getArticleListByCondition(title,categoryName,fileType,state);
|
|
|
|
|
List<ArticleVo> CategoryList = articleMapper.getArticleListByCondition(title,firstCategory,secondCategory,fileType,state);
|
|
|
|
|
JSONObject pageJson = PageUtils.page(CategoryList,pageNum,pageSize);
|
|
|
|
|
return pageJson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<String> getFirstCategory() {
|
|
|
|
|
List<String> categoryName = articleMapper.getFirstCategory();
|
|
|
|
|
return categoryName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<String> getSecondCategory(JSONObject jsonObject) {
|
|
|
|
|
Long firstCategory = jsonObject.getLong("firstCategory");
|
|
|
|
|
List<String> categoryName = articleMapper.getSecondCategory(firstCategory);
|
|
|
|
|
return categoryName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject searchArticleListByPage(JSONObject jsonObject) {
|
|
|
|
|
Integer pageNum = jsonObject.getInteger("pageNum") == null ? 1 : jsonObject.getInteger("pageNum");
|
|
|
|
|
Integer pageSize = jsonObject.getInteger("pageSize") == null ? 5 : jsonObject.getInteger("pageSize");
|
|
|
|
|
String param = jsonObject.getString("param");
|
|
|
|
|
Long firstCategory = jsonObject.getLong("firstCategory");
|
|
|
|
|
Long secondCategory = jsonObject.getLong("secondCategory");
|
|
|
|
|
List<ArticleVo> CategoryList = articleMapper.searchArticleListByCondition(param,firstCategory,secondCategory);
|
|
|
|
|
JSONObject pageJson = PageUtils.page(CategoryList,pageNum,pageSize);
|
|
|
|
|
return pageJson;
|
|
|
|
|
}
|
|
|
|
|