| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?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.yonge.cooleshow.biz.dal.dao.SubjectDao">
- <resultMap type="com.yonge.cooleshow.biz.dal.entity.Subject" id="Subject">
- <result column="id_" property="id"/>
- <result column="name_" property="name"/>
- <result column="code_" property="code"/>
- <result column="parent_subject_id_" property="parentSubjectId"/>
- <result column="img_" property="img"/>
- <result column="desc_" property="desc"/>
- <result column="create_time_" property="createTime"/>
- <result column="update_time_" property="updateTime"/>
- <result column="del_flag_" property="delFlag"/>
- </resultMap>
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="Subject">
- SELECT * FROM subject WHERE del_flag_ = 0 and id_ = #{id}
- </select>
- <!-- 全查询 -->
- <select id="findAll" resultMap="Subject">
- SELECT * FROM subject where del_flag_ = 0 ORDER BY id_
- </select>
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.yonge.cooleshow.biz.dal.entity.Subject" useGeneratedKeys="true"
- keyColumn="id"
- keyProperty="id">
- INSERT INTO subject (id_,name_,code_,parent_subject_id_,img_,create_time_,update_time_,desc_)
- VALUES(#{id},#{name},#{code},#{parentSubjectId},#{img},now(),now(),#{desc})
- </insert>
- <!-- 根据主键查询一条记录 -->
- <update id="update" parameterType="com.yonge.cooleshow.biz.dal.entity.Subject">
- UPDATE subject
- <set>
- <if test="delFlag != null">
- del_flag_ = #{delFlag},
- </if>
- <if test="parentSubjectId != null">
- parent_subject_id_ = #{parentSubjectId},
- </if>
- <if test="code != null">
- code_ = #{code},
- </if>
- <if test="img != null">
- img_ = #{img},
- </if>
- <if test="updateTime != null">
- update_time_ = NOW(),
- </if>
- <if test="name != null">
- name_ = #{name},
- </if>
- <if test="desc != null">
- desc_ = #{desc},
- </if>
- </set>
- WHERE id_ = #{id}
- </update>
- <!-- 根据主键删除一条记录 -->
- <update id="delete">
- UPDATE `subject` SET del_flag_ = 1 WHERE id_ = #{id} OR parent_subject_id_ = #{id}
- </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 * FROM subject
- <include refid="querySubPageSql"/>
- ORDER BY id_
- <include refid="global.limit"/>
- </select>
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(*) FROM subject
- <include refid="querySubPageSql"/>
- </select>
- <select id="findByParentId" resultMap="Subject">
- SELECT * FROM subject
- where del_flag_ = 0
- <if test="parentId != null">
- AND parent_subject_id_ = #{parentId}
- </if>
- </select>
- <sql id="querySubPageSql">
- 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>
- <select id="findBySubjectByIdList" resultMap="Subject">
- SELECT * FROM `subject` WHERE del_flag_ = 0 AND FIND_IN_SET(id_,#{subjectIdList})
- </select>
- <select id="findBySubjectIds" resultMap="Subject">
- SELECT * FROM subject WHERE del_flag_ = 0 and id_ IN
- <foreach collection="subjectIds" item="subjectId" separator="," open="(" close=")">
- #{subjectId}
- </foreach>
- </select>
- <select id="selectSubjectById" resultType="com.yonge.cooleshow.biz.dal.entity.Subject"
- parameterType="java.lang.String">
- SELECT * FROM subject WHERE del_flag_ = 0 and id_=#{lessonSubject}
- </select>
- </mapper>
|