You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.6 KiB
XML
91 lines
3.6 KiB
XML
<?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.jingcheng.cms.mapper.ArticleMapper">
|
|
|
|
<insert id="addArticle" parameterType="com.jingcheng.cms.model.Article">
|
|
INSERT INTO article(`title`,`first_category_name`,`second_category_name`,`keyword`,`file_type`,`content`,`state`)
|
|
values (#{title},#{firstCategoryName},#{secondCategoryName},#{keyword},#{fileType},#{content},#{state})
|
|
</insert>
|
|
|
|
<select id="getArticleListByCondition" resultType="com.jingcheng.cms.vo.ArticleVo">
|
|
select ar.`id`,ar.`title`,c1.`name` as `first_category_name`,c2.`name` as `second_category_name`,
|
|
ar.`keyword`,ar.`file_type`,ar.`content`,ar.`create_date_time`,ar.`update_date_time`,ar.`state`,
|
|
c1.level as `first_level`,c2.level as `second_level`,c1.`sort_num` as `first_sort_num`,c2.`sort_num` as `second_sort_num`,
|
|
ar.`keyword`,ar.`file_type`
|
|
FROM article ar
|
|
left join category c1
|
|
on
|
|
ar.first_category = c1.id and c1.level = 1
|
|
left join category c2
|
|
on
|
|
ar.second_category = c2.id and c2.level = 2
|
|
where
|
|
1 = 1
|
|
<if test="title != null and title != ''">
|
|
and ar.title like #{title}
|
|
</if>
|
|
<if test="firstCategory != null ">
|
|
and ar.first_category = #{firstCategory}
|
|
</if>
|
|
<if test="secondCategory != null ">
|
|
and ar.second_category = #{secondCategory}
|
|
</if>
|
|
<if test="fileType != null ">
|
|
and file_type = #{fileType}
|
|
</if>
|
|
<if test="state != null ">
|
|
and state = #{state}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getFirstCategory" resultType="String">
|
|
select c.`name`
|
|
from article ar
|
|
left join category c
|
|
on c.id = ar.`first_category`
|
|
where c.level = 1 and ar.state = 1
|
|
group by c.name
|
|
order by c.sort_num ASC
|
|
</select>
|
|
|
|
<select id="getSecondCategory" resultType="String" parameterType="Long">
|
|
select c.`name`
|
|
from article ar
|
|
left join category c
|
|
on ar.`second_category` = c.`id`
|
|
where
|
|
1=1
|
|
<if test="firstCategory != null ">
|
|
and ar.first_category = #{firstCategory}
|
|
</if>
|
|
and c.level = 2 and ar.state = 1
|
|
group by c.name
|
|
order by c.sort_num ASC
|
|
</select>
|
|
|
|
<select id="searchArticleListByCondition" resultType="com.jingcheng.cms.vo.ArticleVo">
|
|
select ar.`id`,ar.`title`,c1.`name` as `first_category_name`,c2.`name` as `second_category_name`,
|
|
ar.`keyword`,ar.`file_type`,ar.`content`,ar.`create_date_time`,ar.`update_date_time`,ar.`state`,
|
|
c1.level as `first_level`,c2.level as `second_level`,c1.`sort_num` as `first_sort_num`,c2.`sort_num` as `second_sort_num`,
|
|
ar.`keyword`,ar.`file_type`
|
|
FROM article ar
|
|
left join category c1
|
|
on
|
|
ar.first_category = c1.id and c1.level = 1
|
|
left join category c2
|
|
on
|
|
ar.second_category = c2.id and c2.level = 2
|
|
where
|
|
1 = 1
|
|
<if test="param != null and param != ''">
|
|
and (ar.title like #{param} OR ar.keyword like #{param} or c1.name like #{param} or c2.name like #{param} )
|
|
</if>
|
|
<if test="firstCategory != null ">
|
|
and ar.first_category = #{firstCategory}
|
|
</if>
|
|
<if test="secondCategory != null ">
|
|
and ar.second_category = #{secondCategory}
|
|
</if>
|
|
and ar.state = 1
|
|
</select>
|
|
</mapper> |