SensFieldMapper.xml 2.12 KB
<?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="cn.runsa.portal.base.dao.SensFieldMapper" >
<resultMap id="BaseResultMap" type="cn.runsa.portal.base.entity.SensField" >
    <id column="sfId" property="id" />
    <result column="sfName" property="name" />
    <result column="sfTable" property="table" />
    <result column="sfField" property="field" />
    <result column="sfType" property="type" />
    <result column="ptRemark" property="remark" />
    <result column="sfiId" property="sfiId" />
    <result column="sfiName" property="sfiName" />
    <result column="roId" property="roId" />
    <result column="ptUpTime" property="uptime" />
    <result column="ptUpdater" property="updater" />
  </resultMap>
 <select id="selectList" resultMap="BaseResultMap">
		select t1.sfId,t1.sfName,t1.sfTable,t1.sfField,t1.sfType,t1.ptRemark,t1.ptUpTime,t1.ptUpdater,
		       t3.sfiId,t3.sfiName
		 from smSensField t1 
		       left join smSensFieldValue t2 on t1.sfId=t2.sfId and t2.sfvDef=1
		       left join smSensFieldItem t3 on t2.sfiId=t2.sfiId
 </select>
 <select id="selectCountByRid" parameterType="java.lang.Integer" resultType="java.lang.Integer">
		select count(*)
		 from smRoleSensField where roId=#{roleId}
 </select>
 <select id="selectListByRid" parameterType="java.lang.Integer" resultMap="BaseResultMap">
		select t1.sfId,t1.sfName,t1.sfTable,t1.sfField,t1.sfType,t1.ptRemark,t1.ptUpTime,t1.ptUpdater,
		       t3.sfiId,t3.sfiName,t0.roId
		 from smRoleSensField t0
		       left join smSensField t1  on t0.sfId = t1.sfId
		       left join smSensFieldItem t3 on t0.sfiId=t2.sfiId
		 where t0.roId=#{roleId}     
 </select>
 
 <insert id="insert" parameterType="List" useGeneratedKeys="true" keyProperty="id">
    insert into smRoleSensField(roId,sfId,sfiId)
	values
	<foreach collection="sensField" item="item" separator=",">
         (#{item.roId},#{item.id},#{item.sfId})
    </foreach>
 </insert>
 <delete id="deleteByRoleId" parameterType="java.lang.Integer">
   delete from smRoleSensField where roId=#{roId}
 </delete>
</mapper>