master
ck 5 years ago
parent 233dd24060
commit fe74b9759a

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

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

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

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

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

Loading…
Cancel
Save