Merge remote-tracking branch 'origin/master'

master
ck 5 years ago
commit d103b52d47

@ -5,8 +5,10 @@ import com.alibaba.fastjson.JSONObject;
import com.bsd.cases.constants.Constants;
import com.bsd.cases.mapper.CaseCategoryMapper;
import com.bsd.cases.mapper.CaseContentMapper;
import com.bsd.cases.mapper.CaseContentStaticalMapper;
import com.bsd.cases.model.CaseCategory;
import com.bsd.cases.model.CaseContent;
import com.bsd.cases.model.CaseContentStatical;
import com.bsd.cases.model.CaseUsers;
import com.bsd.cases.service.CaseCategoryService;
import com.bsd.cases.util.AjaxRequest;
@ -34,6 +36,8 @@ public class CaseCategoryServiceImpl extends BaseServiceImpl<CaseCategoryMapper,
private CaseCategoryMapper caseCategoryMapper;
@Resource
private CaseContentMapper caseContentMapper;
@Resource
private CaseContentStaticalMapper caseContentStaticalMapper;
/**
* 12
@ -111,6 +115,23 @@ public class CaseCategoryServiceImpl extends BaseServiceImpl<CaseCategoryMapper,
@Override
public JSONObject search(String name, Integer pageNum, Integer pageSize) {
List<CaseSearchVo> caseSearchVoList = caseCategoryMapper.search(name);
for (CaseSearchVo caseSearchVo:caseSearchVoList){
Integer type = caseSearchVo.getType();
if (0 == type){
CaseCategory caseCategory = caseCategoryMapper.selectByPrimaryKey(caseSearchVo.getId());
CaseCategory parentCategory = caseCategoryMapper.selectByPrimaryKey(caseCategory.getParentId());
caseSearchVo.setParentName(parentCategory.getName());
}else {
CaseContentStatical findCaseContentStatical = new CaseContentStatical();
findCaseContentStatical.setState(Constants.STATE_VALID);
findCaseContentStatical.setContentId(caseSearchVo.getId());
CaseContentStatical caseContentStatical = caseContentStaticalMapper.selectOne(findCaseContentStatical);
caseSearchVo.setCommentsNum(caseContentStatical.getCommentsNum());
caseSearchVo.setLikeNum(caseContentStatical.getLikeNum());
caseSearchVo.setViewNum(caseContentStatical.getViewNum());
caseSearchVo.setScore(caseContentStatical.getScore());
}
}
JSONObject data = PageUtils.page(caseSearchVoList,pageNum,pageSize);
return data;
}

@ -131,7 +131,10 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
CaseContent caseContent = caseContentMapper.selectByPrimaryKey(contentId);
CaseContentDetailVo caseContentDetailVo = new CaseContentDetailVo();
caseContentDetailVo.setId(contentId);
String content = new String(caseContent.getContent(), "utf8");
String content = null;
if (null != caseContent.getContent()){
content = new String(caseContent.getContent(), "utf8");
}
caseContentDetailVo.setContent(content);
caseContentDetailVo.setCategoryId(caseContent.getCategoryId());
CaseCategory caseCategory = caseCategoryMapper.selectByPrimaryKey(caseContent.getCategoryId());

@ -14,4 +14,14 @@ public class CaseSearchVo {
* type 0 category type 1 content
*/
private Integer type;
private String parentName;
private Integer viewNum;
private Integer likeNum;
private Integer commentsNum;
private Double score;
}

@ -17,7 +17,7 @@
AND ccy.parent_id = #{level1Id}
</if>
<if test="level2Id != null">
AND a.`level2_id` = #{level2Id}
AND a.`level_id2` = #{level2Id}
</if>
<if test="level3Id != null">
and a.category_id = #{level3Id}

Loading…
Cancel
Save