<?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.ym.mec.biz.dal.dao.SysManualDao">
  <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.SysManual">
                       <id column="id_" jdbcType="INTEGER" property="id"/>
                                  <result column="menu_id_" jdbcType="INTEGER" property="menuId"/>
                                  <result column="name_" jdbcType="VARCHAR" property="name"/>
                                  <result column="op_flow_" jdbcType="VARCHAR" property="opFlow"/>
                                  <result column="fun_rule_" jdbcType="VARCHAR" property="funRule"/>
                                  <result column="video_url_" jdbcType="VARCHAR" property="videoUrl"/>
                                  <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
                                  <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
                                  <result column="operator_id_" jdbcType="INTEGER" property="operatorId"/>
                </resultMap>
  
  <sql id="Base_Column_List">    
                                                id_, menu_id_, name_, op_flow_, fun_rule_, video_url_, create_time_, update_time_, operator_id_
  </sql>
  
   <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
            parameterType="com.ym.mec.biz.dal.entity.SysManual">
       insert into sys_manual(menu_id_, name_, op_flow_, fun_rule_, video_url_, create_time_, update_time_, operator_id_)
       values
       <foreach collection="entities" item="entity" separator=",">
       (#{entity.menuId}, #{entity.name}, #{entity.opFlow}, #{entity.funRule}, #{entity.videoUrl}, #{entity.createTime}, #{entity.updateTime}, #{entity.operatorId})
       </foreach>
   </insert>
    <select id="findRecordCount" resultType="java.lang.Integer">
        select count(1) from sys_manual sm
        left join sys_user u on sm.operator_id_ = u.id_
        left join sys_menu m on sm.menu_id_ = m.id_
        <where>
            1 = 1
            <if test="menuId != null and menuId != '' ">
                AND menu_id_ = #{menuId}
            </if>
            <if test="search != null and search != '' ">
                AND (sm.name_ like concat('%', #{search} '%') )
            </if>
        </where>
        <include refid="global.limit"/>
    </select>

    <select id="queryRecord" resultType="com.ym.mec.biz.dal.entity.SysManual">
        select sm.*
             , u.username_ as operatorName
             , m.name_ as menuName
        from sys_manual sm
        left join sys_user u on sm.operator_id_ = u.id_
        left join sys_menu m on sm.menu_id_ = m.id_
        <where>
            1 = 1
            <if test="menuId != null and menuId != '' ">
                AND sm.menu_id_ = #{menuId}
            </if>
            <if test="search != null and search != '' ">
                AND (sm.name_ like concat('%', #{search} '%') )
            </if>
        </where>
        <include refid="global.limit"/>
    </select>
    <select id="listMenuIds" resultType="java.lang.String">
        select menu_id_ from sys_manual
    </select>

</mapper>
