master
ck 5 years ago
parent 233dd24060
commit fe74b9759a

@ -1,6 +1,7 @@
package com.jingcheng.cms.controller;
import com.alibaba.fastjson.JSONObject;
import com.jingcheng.cms.model.Category;
import com.jingcheng.cms.service.ArticleSerive;
import com.jingcheng.cms.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
@ -53,7 +54,7 @@ public class ArticleController {
@RequestMapping("/article-first-category")
public AjaxResult getFirstCategory() {
AjaxResult ajaxResult = new AjaxResult();
List<String> articleSeriveFirstCategory= articleSerive.getFirstCategory();
List<Category> articleSeriveFirstCategory= articleSerive.getFirstCategory();
ajaxResult.setData(articleSeriveFirstCategory);
return ajaxResult;
}
@ -65,7 +66,7 @@ public class ArticleController {
@RequestMapping("/article-second-category")
public AjaxResult getSecondCategory(@RequestBody JSONObject jsonObject) {
AjaxResult ajaxResult = new AjaxResult();
List<String> articleSeriveFirstCategory= articleSerive.getSecondCategory(jsonObject);
List<Category> articleSeriveFirstCategory= articleSerive.getSecondCategory(jsonObject);
ajaxResult.setData(articleSeriveFirstCategory);
return ajaxResult;
}

@ -1,6 +1,7 @@
package com.jingcheng.cms.mapper;
import com.jingcheng.cms.model.Article;
import com.jingcheng.cms.model.Category;
import com.jingcheng.cms.util.CommonMapper;
import com.jingcheng.cms.vo.ArticleVo;
import org.apache.ibatis.annotations.Param;
@ -17,9 +18,9 @@ public interface ArticleMapper extends CommonMapper<Article> {
@Param("secondCategory") Long secondCategory,
@Param("fileType") Integer fileType,
@Param("state") Integer state);
List<String> getFirstCategory();
List<Category> getFirstCategory();
List<String> getSecondCategory(@Param("firstCategory") Long firstCategory);
List<Category> getSecondCategory(@Param("firstCategory") Long firstCategory);
List<ArticleVo> searchArticleListByCondition(@Param("param") String param,
@Param("firstCategory") Long firstCategory,

@ -1,6 +1,7 @@
package com.jingcheng.cms.service;
import com.alibaba.fastjson.JSONObject;
import com.jingcheng.cms.model.Category;
import com.jingcheng.cms.util.AjaxResult;
import com.jingcheng.cms.vo.ArticleVo;
@ -24,12 +25,12 @@ public interface ArticleSerive {
/**
* 1
*/
List<String> getFirstCategory();
List<Category> getFirstCategory();
/**
* 2
*/
List<String> getSecondCategory(JSONObject jsonObject);
List<Category> getSecondCategory(JSONObject jsonObject);
/**
*

@ -130,16 +130,16 @@ public class ArticleSerivceImpl implements ArticleSerive {
}
@Override
public List<String> getFirstCategory() {
List<String> categoryName = articleMapper.getFirstCategory();
return categoryName;
public List<Category> getFirstCategory() {
List<Category> categoryList = articleMapper.getFirstCategory();
return categoryList;
}
@Override
public List<String> getSecondCategory(JSONObject jsonObject) {
public List<Category> getSecondCategory(JSONObject jsonObject) {
Long firstCategory = jsonObject.getLong("firstCategory");
List<String> categoryName = articleMapper.getSecondCategory(firstCategory);
return categoryName;
List<Category> categoryList = articleMapper.getSecondCategory(firstCategory);
return categoryList;
}
@Override

@ -38,8 +38,8 @@
</if>
</select>
<select id="getFirstCategory" resultType="String">
select c.`name`
<select id="getFirstCategory" resultType="com.jingcheng.cms.model.Category">
select c.`id`,c.`name`,c.`level`,c.`type_name`,c.`sort_num`
from article ar
left join category c
on c.id = ar.`first_category`
@ -48,8 +48,8 @@
order by c.sort_num ASC
</select>
<select id="getSecondCategory" resultType="String" parameterType="Long">
select c.`name`
<select id="getSecondCategory" resultType="com.jingcheng.cms.model.Category" parameterType="Long">
select c.`id`,c.`name`,c.`level`,c.`type_name`,c.`sort_num`
from article ar
left join category c
on ar.`second_category` = c.`id`

Loading…
Cancel
Save