|
@@ -19,16 +19,17 @@
|
|
|
|
|
|
<!-- 根据主键查询一条记录 -->
|
|
<!-- 根据主键查询一条记录 -->
|
|
<select id="get" resultMap="Subject">
|
|
<select id="get" resultMap="Subject">
|
|
- SELECT * FROM subject WHERE id_ = #{id}
|
|
|
|
|
|
+ SELECT * FROM subject WHERE del_flag_ = 0 and id_ = #{id}
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<!-- 全查询 -->
|
|
<!-- 全查询 -->
|
|
<select id="findAll" resultMap="Subject">
|
|
<select id="findAll" resultMap="Subject">
|
|
- SELECT * FROM subject ORDER BY id_
|
|
|
|
|
|
+ SELECT * FROM subject where del_flag_ = 0 ORDER BY id_
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<!-- 向数据库增加一条记录 -->
|
|
<!-- 向数据库增加一条记录 -->
|
|
- <insert id="insert" parameterType="com.yonge.cooleshow.biz.dal.entity.Subject" useGeneratedKeys="true" keyColumn="id"
|
|
|
|
|
|
+ <insert id="insert" parameterType="com.yonge.cooleshow.biz.dal.entity.Subject" useGeneratedKeys="true"
|
|
|
|
+ keyColumn="id"
|
|
keyProperty="id">
|
|
keyProperty="id">
|
|
INSERT INTO subject (id_,name_,code_,parent_subject_id_,img_,create_time_,update_time_,desc_)
|
|
INSERT INTO subject (id_,name_,code_,parent_subject_id_,img_,create_time_,update_time_,desc_)
|
|
VALUES(#{id},#{name},#{code},#{parentSubjectId},#{img},now(),now(),#{desc})
|
|
VALUES(#{id},#{name},#{code},#{parentSubjectId},#{img},now(),now(),#{desc})
|
|
@@ -68,6 +69,10 @@
|
|
UPDATE `subject` SET del_flag_ = 1 WHERE id_ = #{id} OR parent_subject_id_ = #{id}
|
|
UPDATE `subject` SET del_flag_ = 1 WHERE id_ = #{id} OR parent_subject_id_ = #{id}
|
|
</update>
|
|
</update>
|
|
|
|
|
|
|
|
+ <delete id="deleteById">
|
|
|
|
+ update subject set del_flag_ = 1 where id_ = #{id} or parent_subject_id_ = #{id}
|
|
|
|
+ </delete>
|
|
|
|
+
|
|
<!-- 分页查询 -->
|
|
<!-- 分页查询 -->
|
|
<select id="queryPage" resultMap="Subject" parameterType="map">
|
|
<select id="queryPage" resultMap="Subject" parameterType="map">
|
|
SELECT * FROM subject
|
|
SELECT * FROM subject
|
|
@@ -78,39 +83,35 @@
|
|
|
|
|
|
<!-- 查询当前表的总记录数 -->
|
|
<!-- 查询当前表的总记录数 -->
|
|
<select id="queryCount" resultType="int">
|
|
<select id="queryCount" resultType="int">
|
|
- SELECT COUNT(*) FROM subject <include refid="querySubPageSql"/>
|
|
|
|
- </select>
|
|
|
|
|
|
+ SELECT COUNT(*) FROM subject
|
|
|
|
+ <include refid="querySubPageSql"/>
|
|
|
|
+ </select>
|
|
|
|
|
|
<select id="findByParentId" resultMap="Subject">
|
|
<select id="findByParentId" resultMap="Subject">
|
|
SELECT * FROM subject
|
|
SELECT * FROM subject
|
|
- <where>
|
|
|
|
- <if test="parentId != null">
|
|
|
|
- AND parent_subject_id_ = #{parentId}
|
|
|
|
- </if>
|
|
|
|
- <if test="delFlag != null">
|
|
|
|
- AND del_flag_ = #{delFlag}
|
|
|
|
- </if>
|
|
|
|
- </where>
|
|
|
|
|
|
+ where del_flag_ = 0
|
|
|
|
+ <if test="parentId != null">
|
|
|
|
+ AND parent_subject_id_ = #{parentId}
|
|
|
|
+ </if>
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<sql id="querySubPageSql">
|
|
<sql id="querySubPageSql">
|
|
- <where>
|
|
|
|
- <if test="parentId != null">
|
|
|
|
- AND parent_subject_id_ = #{parentId}
|
|
|
|
- </if>
|
|
|
|
- <if test="delFlag != null">
|
|
|
|
- AND del_flag_ = #{delFlag}
|
|
|
|
- </if>
|
|
|
|
- <if test="search != null and search != ''">
|
|
|
|
- AND (id_ like concat('%',#{search},'%') or name_ like concat('%',#{search},'%'))
|
|
|
|
- </if>
|
|
|
|
- <if test="queryType != null and queryType == 'category'">
|
|
|
|
- and (parent_subject_id_ = 0 or parent_subject_id_ is null)
|
|
|
|
- </if>
|
|
|
|
- <if test="queryType != null and queryType == 'list'">
|
|
|
|
- and parent_subject_id_ > 0
|
|
|
|
- </if>
|
|
|
|
- </where>
|
|
|
|
|
|
+ where del_flag_ = 0
|
|
|
|
+ <if test="parentId != null">
|
|
|
|
+ AND parent_subject_id_ = #{parentId}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="delFlag != null">
|
|
|
|
+ AND del_flag_ = #{delFlag}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="search != null and search != ''">
|
|
|
|
+ AND (id_ like concat('%',#{search},'%') or name_ like concat('%',#{search},'%'))
|
|
|
|
+ </if>
|
|
|
|
+ <if test="queryType != null and queryType == 'category'">
|
|
|
|
+ and (parent_subject_id_ = 0 or parent_subject_id_ is null)
|
|
|
|
+ </if>
|
|
|
|
+ <if test="queryType != null and queryType == 'list'">
|
|
|
|
+ and parent_subject_id_ > 0
|
|
|
|
+ </if>
|
|
</sql>
|
|
</sql>
|
|
|
|
|
|
<select id="findBySubjectByIdList" resultMap="Subject">
|
|
<select id="findBySubjectByIdList" resultMap="Subject">
|
|
@@ -118,17 +119,14 @@
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="findBySubjectIds" resultMap="Subject">
|
|
<select id="findBySubjectIds" resultMap="Subject">
|
|
- SELECT * FROM subject WHERE id_ IN
|
|
|
|
- <foreach collection="subjectIds" item="subjectId" separator="," open="(" close=")">
|
|
|
|
- #{subjectId}
|
|
|
|
- </foreach>
|
|
|
|
|
|
+ SELECT * FROM subject WHERE del_flag_ = 0 and id_ IN
|
|
|
|
+ <foreach collection="subjectIds" item="subjectId" separator="," open="(" close=")">
|
|
|
|
+ #{subjectId}
|
|
|
|
+ </foreach>
|
|
</select>
|
|
</select>
|
|
<select id="selectSubjectById" resultType="com.yonge.cooleshow.biz.dal.entity.Subject"
|
|
<select id="selectSubjectById" resultType="com.yonge.cooleshow.biz.dal.entity.Subject"
|
|
parameterType="java.lang.String">
|
|
parameterType="java.lang.String">
|
|
- SELECT * FROM subject WHERE id_=#{lessonSubject}
|
|
|
|
|
|
+ SELECT * FROM subject WHERE del_flag_ = 0 and id_=#{lessonSubject}
|
|
</select>
|
|
</select>
|
|
|
|
|
|
- <delete id="deleteById">
|
|
|
|
- update subject set del_flag_ = 1 where id_ = #{id} or parent_subject_id_ = #{id}
|
|
|
|
- </delete>
|
|
|
|
</mapper>
|
|
</mapper>
|