后台搜索文章

master
ck 5 years ago
parent 2c3c94cf5b
commit 090da963a0

@ -138,4 +138,35 @@ public class CaseContentController {
}
return ajaxResult;
}
/**
*
* @param jsonObject
* @return
*/
@RequestMapping("/search-bak-content")
public AjaxResult searchBakContent(@RequestBody JSONObject jsonObject) {
AjaxResult ajaxResult = new AjaxResult();
try {
String name = jsonObject.getString("name");
Long level1Id = jsonObject.getLong("level1Id");
Long level2Id = jsonObject.getLong("level2Id");
Long level3Id = jsonObject.getLong("level3Id");
Integer pageNum = jsonObject.getInteger("pageNum");
if (null == pageNum){
ajaxResult.setRetmsg("分页参数不可为空");
ajaxResult.setRetcode(AjaxResult.FAILED);
}else {
ajaxResult.setData(caseContentService.searchBakContentByParam(name,level1Id,level2Id,level3Id,pageNum));
ajaxResult.setRetmsg("操作成功");
ajaxResult.setRetcode(AjaxResult.SUCCESS);
}
} catch (Exception e) {
e.printStackTrace();
ajaxResult.setRetmsg("操作失败:" + e.getMessage());
ajaxResult.setRetcode(AjaxResult.FAILED);
}
return ajaxResult;
}
}

@ -2,6 +2,7 @@ package com.bsd.cases.mapper;
import com.bsd.cases.model.CaseCategory;
import com.bsd.cases.util.CommonMapper;
import com.bsd.cases.vo.CaseContentBakVo;
import com.bsd.cases.vo.CaseSearchVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

@ -2,8 +2,16 @@ package com.bsd.cases.mapper;
import com.bsd.cases.model.CaseContent;
import com.bsd.cases.util.CommonMapper;
import com.bsd.cases.vo.CaseContentBakVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface CaseContentMapper extends CommonMapper<CaseContent> {
List<CaseContentBakVo> searchBak(@Param("name") String name
, @Param("level1Id") Long level1Id
, @Param("level2Id") Long level2Id
, @Param("level3Id") Long level3Id);
}

@ -1,11 +1,9 @@
package com.bsd.cases.service;
import com.alibaba.fastjson.JSONObject;
import com.bsd.cases.model.CaseCategory;
import com.bsd.cases.util.AjaxRequest;
import com.bsd.cases.util.AjaxResult;
import com.bsd.cases.util.PageAjax;
import com.bsd.cases.vo.CaseSearchVo;
import com.bsd.cases.vo.CaseContentBakVo;
import java.util.List;

@ -3,6 +3,8 @@ package com.bsd.cases.service;
import com.alibaba.fastjson.JSONObject;
import com.bsd.cases.util.AjaxRequest;
import com.bsd.cases.util.AjaxResult;
import com.bsd.cases.util.PageAjax;
import com.bsd.cases.vo.CaseContentBakVo;
import com.bsd.cases.vo.CaseContentDetailVo;
import com.bsd.cases.vo.CaseContentVo;
@ -16,4 +18,14 @@ public interface CaseContentService<CaseContent> extends BaseService<CaseContent
AjaxResult saveContent(JSONObject jsonObject);
AjaxResult delContent(Long contentId);
/**
*
* @param name
* @param level1
* @param level2
* @param level3
* @return
*/
PageAjax<CaseContentBakVo> searchBakContentByParam(String name, Long level1, Long level2, Long level3, Integer pageNum);
}

@ -9,9 +9,12 @@ import com.bsd.cases.service.CaseContentService;
import com.bsd.cases.service.CaseUsersService;
import com.bsd.cases.util.AjaxRequest;
import com.bsd.cases.util.AjaxResult;
import com.bsd.cases.util.PageAjax;
import com.bsd.cases.util.PageUtils;
import com.bsd.cases.vo.CaseContentBakVo;
import com.bsd.cases.vo.CaseContentDetailVo;
import com.bsd.cases.vo.CaseContentVo;
import com.github.pagehelper.PageHelper;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -261,4 +264,12 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
}
return ajaxResult;
}
@Override
public PageAjax<CaseContentBakVo> searchBakContentByParam(String name, Long level1, Long level2, Long level3,Integer pageNum) {
PageHelper.startPage(pageNum, Constants.PAGE_SIZE);
List<CaseContentBakVo> caseContentBakVoList = caseContentMapper.searchBak(name,level1,level2,level3);
PageAjax<CaseContentBakVo> pageAjax = new PageAjax<>(caseContentBakVoList);
return pageAjax;
}
}

@ -0,0 +1,13 @@
package com.bsd.cases.vo;
import com.bsd.cases.model.CaseCategory;
import com.bsd.cases.model.CaseContent;
import lombok.Data;
@Data
public class CaseContentBakVo extends CaseContent {
private Long level2Id;
private Long level1Id;
}

@ -1,5 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bsd.cases.mapper.CaseContentMapper">
<select id="searchBak" resultType="com.bsd.cases.vo.CaseContentBakVo">
SELECT a.id,a.content_title,a.url,a.content,a.category_id,a.create_date_time,a.update_date_time,a.create_by,a.update_by,
a.state,a.`level2_id`,ccy.parent_id as `level1_id`
FROM (select cc.`id`,cc.`content_title`,cc.`url`,cc.`content`,cc.`category_id`,ccy.`name` as level3_name,
cc.`create_date_time`,cc.`update_date_time`,cc.`create_by`,cc.`update_by`,cc.`state`,ccy.parent_id as level2_id
FROM case_content cc
left join case_category ccy
on ccy.id = cc.category_id) a
left join case_category ccy
on a.level2_id = ccy.id
WHERE
1 = 1
<if test="level1Id != null">
AND ccy.parent_id = #{level1Id}
</if>
<if test="level2Id != null">
AND a.`level2_id` = #{level2Id}
</if>
<if test="level3Id != null">
and a.category_id = #{level3Id}
</if>
<if test="name != null and name != ''">
a.`content_title` LIKE CONCAT('%',#{name},'%')
</if>
</select>
</mapper>

Loading…
Cancel
Save