UsDataItemMapper.xml 3.06 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.UsDataItemMapper">
	<resultMap id="BaseResultMap" type="cn.runsa.portal.base.entity.UsDataItem">
		<id column="usdId" property="usdId" jdbcType="INTEGER" />
		<result column="usId" property="usId" jdbcType="INTEGER" />
		<result column="usdType" property="usdType" jdbcType="INTEGER" />
		<result column="usdStatus" property="usdStatus" jdbcType="INTEGER" />
		<result column="extId" property="extId" jdbcType="INTEGER" />
		<result column="extLongId" property="extLongId" jdbcType="BIGINT" />
		<result column="extStringId" property="extStringId" jdbcType="VARCHAR" />
		<result column="usdText" property="usdText" jdbcType="VARCHAR" />
		<result column="viewName" property="viewName" jdbcType="VARCHAR" />
		<result column="editName" property="editName" jdbcType="VARCHAR" />
	</resultMap>

	<sql id="Base_Column_List">
		usdId, usId, usdType, usdStatus, extId, extLongId, extStringId, usdText
	</sql>

	<select id="selectById" resultMap="BaseResultMap" parameterType="java.lang.Integer">
		select
		<include refid="Base_Column_List" />
		from smUsDataItem
		where usdId = #{usdId,jdbcType=INTEGER}
	</select>

	<delete id="deleteById" parameterType="java.lang.Integer">
		delete from smUsDataItem
		where usdId = #{usdId,jdbcType=INTEGER}
	</delete>

	<insert id="insert" parameterType="cn.runsa.portal.base.entity.UsDataItem">
		insert into smUsDataItem (usId, usdType,
		usdStatus, extId, extLongId,extStringId,
		usdText)
		values (#{usId,jdbcType=INTEGER},
		#{usdType,jdbcType=INTEGER},
		#{usdStatus,jdbcType=INTEGER}, #{extId,jdbcType=INTEGER},
		#{extLongId,jdbcType=BIGINT},#{extStringId,jdbcType=VARCHAR},
		#{usdText,jdbcType=VARCHAR})
	</insert>

	<delete id="deleteUsDataByUsId" parameterType="java.lang.Integer">
		delete from smUsDataItem
		where usId = #{usId,jdbcType=INTEGER}
	</delete>
	
	<select id="selectDataItemsByUsId" resultMap="BaseResultMap" parameterType="java.lang.Integer">
		SELECT g1.viewName,g2.editName,1 AS usdId,1 AS usdType FROM (
			SELECT GROUP_CONCAT(DISTINCT t2.ACT_NAME) viewName FROM smUsDataItem t1 LEFT JOIN crm_account_set t2 ON t1.extId = t2.ACT_ID WHERE t1.usdType = 1 AND t1.usdStatus = 1 AND t1.usId = #{usId,jdbcType=INTEGER}
		) g1,
		(
			SELECT GROUP_CONCAT(DISTINCT t2.ACT_NAME) editName FROM smUsDataItem t1 LEFT JOIN crm_account_set t2 ON t1.extId = t2.ACT_ID WHERE t1.usdType = 1 AND t1.usdStatus = 2 AND t1.usId = #{usId,jdbcType=INTEGER}
		) g2
		UNION
		SELECT g3.viewName,g4.editName,2 AS usdId,2 AS usdType FROM (
			SELECT GROUP_CONCAT(DISTINCT t2.NICK_NAME) viewName FROM smUsDataItem t1 LEFT JOIN crm_wxgzh t2 ON t1.extStringId = t2.GZH_ID WHERE t1.usdType = 2 AND t1.usdStatus = 1 AND t1.usId = #{usId,jdbcType=INTEGER}
		) g3,
		(
			SELECT GROUP_CONCAT(DISTINCT t2.NICK_NAME) editName FROM smUsDataItem t1 LEFT JOIN crm_wxgzh t2 ON t1.extStringId = t2.GZH_ID WHERE t1.usdType = 2 AND t1.usdStatus = 2 AND t1.usId = #{usId,jdbcType=INTEGER}
		) g4
	</select>
</mapper>