master
ck 5 years ago
parent a5fa31117c
commit 76c9208f6b

@ -120,4 +120,22 @@ public class ArticleController {
file.transferTo(dest);
}
}
/**
* id
* @param jsonObject
* @return
*/
@RequestMapping("/article-detail-by-id")
public AjaxResult getArticleDetail(@RequestBody JSONObject jsonObject) {
AjaxResult ajaxResult = new AjaxResult();
Long id = jsonObject.getLong("id");
if (null == id){
ajaxResult.setRetcode(AjaxResult.FAILED);
ajaxResult.setRetmsg("id不可为空");
return ajaxResult;
}
ajaxResult= articleSerive.getArticleDetail(id);
return ajaxResult;
}
}

@ -2,6 +2,7 @@ package com.jingcheng.cms.service;
import com.alibaba.fastjson.JSONObject;
import com.jingcheng.cms.util.AjaxResult;
import com.jingcheng.cms.vo.ArticleVo;
import java.util.List;
@ -44,4 +45,10 @@ public interface ArticleSerive {
*/
AjaxResult delArticleList(JSONObject jsonObject);
/**
* id
* @param id
* @return
*/
AjaxResult getArticleDetail(Long id);
}

@ -2,9 +2,12 @@ package com.jingcheng.cms.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.generator.config.IFileCreate;
import com.jingcheng.cms.constants.Constants;
import com.jingcheng.cms.mapper.ArticleMapper;
import com.jingcheng.cms.mapper.CategoryMapper;
import com.jingcheng.cms.model.Article;
import com.jingcheng.cms.model.Category;
import com.jingcheng.cms.model.Users;
import com.jingcheng.cms.service.ArticleSerive;
import com.jingcheng.cms.util.AjaxResult;
@ -24,6 +27,8 @@ public class ArticleSerivceImpl implements ArticleSerive {
@Resource
private ArticleMapper articleMapper;
@Resource
private CategoryMapper categoryMapper;
@Override
@ -177,5 +182,42 @@ public class ArticleSerivceImpl implements ArticleSerive {
return ajaxResult;
}
@Override
public AjaxResult getArticleDetail(Long id) {
AjaxResult ajaxResult = new AjaxResult();
Article article = articleMapper.selectByPrimaryKey(id);
if (null == article){
ajaxResult.setRetcode(AjaxResult.FAILED);
ajaxResult.setRetmsg("未找到该文章");
return ajaxResult;
}else {
Long firstCategoryId = article.getFirstCategory();
Long secondCategoryId = article.getSecondCategory();
Category firstCategory = categoryMapper.selectByPrimaryKey(firstCategoryId);
Category secondCategory = categoryMapper.selectByPrimaryKey(secondCategoryId);
ArticleVo articleVo = new ArticleVo();
articleVo.setTitle(article.getTitle());
articleVo.setFirstCategory(firstCategoryId);
articleVo.setSecondCategory(secondCategoryId);
articleVo.setContent(article.getContent());
articleVo.setFileType(article.getFileType());
articleVo.setKeyword(article.getKeyword());
articleVo.setDescribe(article.getDescribe());
articleVo.setCreateDateTime(article.getCreateDateTime());
if (null != firstCategory ){
articleVo.setFirstCategoryName(firstCategory.getName());
articleVo.setFirstLevel(firstCategory.getLevel());
articleVo.setFirstSortNum(firstCategory.getSortNum());
}
if (null != secondCategory ){
articleVo.setSecondCategoryName(secondCategory.getName());
articleVo.setSecondLevel(secondCategory.getLevel());
articleVo.setFirstSortNum(secondCategory.getSortNum());
}
ajaxResult.setData(articleVo);
}
return ajaxResult;
}
}

Loading…
Cancel
Save