BizChannelMapper.xml 5.91 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.BizChannelMapper">
	<resultMap id="BaseResultMap" type="cn.runsa.portal.base.entity.BizChannel">
		<id column="becId" property="id" jdbcType="INTEGER" />
		<result column="beId" property="beid" jdbcType="INTEGER" />
		<result column="chId" property="chid" jdbcType="INTEGER" />
		<result column="becLimit" property="limit" jdbcType="BIT" />
		<result column="beParent" property="beparent" jdbcType="INTEGER" />
		<result column="ptValid" property="valid" jdbcType="SMALLINT" />
		<!-- 添加属性 -->
		<result column="chName" property="chname" jdbcType="VARCHAR" />
		<result column="chDesc" property="chdesc" jdbcType="VARCHAR" />
		<result column="brName" property="brname" jdbcType="VARCHAR" />
		<result column="brId" property="brid" jdbcType="VARCHAR" />
		<result column="beName" property="bename" jdbcType="VARCHAR" />
		<collection property="brandList" ofType="cn.runsa.portal.base.entity.Brand" column="brandList">
			<id column="brId" jdbcType="INTEGER" property="id" />
			<result column="brName" jdbcType="VARCHAR" property="name" />
			<!-- 后续需要在增加 -->
		</collection>
	</resultMap>

	<resultMap id="BizBrandResultMap" type="cn.runsa.portal.base.entity.BizBrand">
		<id column="becId" property="becid" jdbcType="INTEGER" />
		<result column="brId" property="brid" jdbcType="INTEGER" />
	</resultMap>

	<sql id="Base_Column_List">
		bec.becId, bec.beId, bec.chId, bec.becLimit, bec.beParent, bec.ptValid
	</sql>
	<select id="findById" resultMap="BaseResultMap" parameterType="cn.runsa.portal.base.entity.BizChannel">
		select
		<include refid="Base_Column_List" />
		from mtBizChannel bec
		where becId = #{id,jdbcType=INTEGER}
	</select>
	<select id="findByBecId" resultMap="BaseResultMap" parameterType="java.lang.Integer">
		SELECT
		t1.becId,
		t1.beId,
		t1.beParent,
		t1.ptValid,
		t1.chId,
		GROUP_CONCAT(DISTINCT t2.brId) brId,
		t3.chName,
		t3.chDesc,
		GROUP_CONCAT(DISTINCT t4.brName) brName,
		t5.beName
		FROM
		mtBizChannel t1
		LEFT JOIN mtBizBrand t2 ON t1.becId = t2.becId
		LEFT JOIN mtchannel t3 ON t3.chId=t1.chId
		LEFT JOIN mtbrand t4 on t4.brId=t2.brId
		LEFT JOIN mtbizentity t5 on t5.beId=t1.beParent
		where t1.becId=#{becid,jdbcType=INTEGER}
		GROUP BY t1.becId
	</select>
	<select id="findBecId" parameterType="java.lang.Integer" resultType="java.lang.Integer">
		select becId from mtBizChannel where beId = #{beid,jdbcType=INTEGER}
	</select>
	<select id="findList" resultMap="BaseResultMap" parameterType="cn.runsa.portal.base.entity.BizChannel">
		select
		<include refid="Base_Column_List" />
		,
		br.brId,
		br.brName
		FROM
		mtBizChannel bec,
		mtBizBrand bb,
		mtBrand br
		WHERE
		bec.becId=bb.becId
		AND bb.brId = br.brId
		AND bec.beId = #{beid,jdbcType=INTEGER}
	</select>
	<delete id="delete" parameterType="java.lang.Integer">
		delete from mtBizChannel
		where becId = #{id,jdbcType=INTEGER}
	</delete>
	<delete id="deleteBybeId" parameterType="java.lang.Integer">
		delete from mtBizChannel
		where beId = #{beid,jdbcType=INTEGER}
	</delete>
	<insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="cn.runsa.portal.base.entity.BizChannel">
		insert into mtBizChannel (beId, chId, becLimit,
		beParent, ptValid)
		values (#{beid,jdbcType=INTEGER}, #{chid,jdbcType=INTEGER}, #{limit,jdbcType=BIT},
		#{beparent,jdbcType=INTEGER}, #{valid,jdbcType=SMALLINT})
	</insert>
	<insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="cn.runsa.portal.base.entity.BizChannel">
		insert into mtBizChannel
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="beid != null">
				beId,
			</if>
			<if test="chid != null">
				chId,
			</if>
			<if test="limit != null">
				becLimit,
			</if>
			<if test="beparent != null">
				beParent,
			</if>
			<if test="valid != null">
				ptValid,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="beid != null">
				#{beid,jdbcType=INTEGER},
			</if>
			<if test="chid != null">
				#{chid,jdbcType=INTEGER},
			</if>
			<if test="limit != null">
				#{limit,jdbcType=BIT},
			</if>
			<if test="beparent != null">
				#{beparent,jdbcType=INTEGER},
			</if>
			<if test="valid != null">
				#{valid,jdbcType=SMALLINT},
			</if>
		</trim>
	</insert>
	<update id="updateBrank" parameterType="java.util.Map">
		update mtBizBrand set becId=#{becId,jdbcType=INTEGER} where becId=#{be,jdbcType=INTEGER}
	</update>
	<update id="updateSelective" parameterType="cn.runsa.portal.base.entity.BizChannel">
		update mtBizChannel
		<set>
			<if test="beid != null">
				beId = #{beid,jdbcType=INTEGER},
			</if>
			<if test="chid != null">
				chId = #{chid,jdbcType=INTEGER},
			</if>
			<if test="limit != null">
				becLimit = #{limit,jdbcType=BIT},
			</if>
			<if test="beparent != null">
				beParent = #{beparent,jdbcType=INTEGER},
			</if>
			<if test="valid != null">
				ptValid = #{valid,jdbcType=SMALLINT},
			</if>
		</set>
		where becId = #{id,jdbcType=INTEGER}
	</update>
	<update id="update" parameterType="cn.runsa.portal.base.entity.BizChannel">
		update mtBizChannel
		set beId = #{beid,jdbcType=INTEGER},
		chId = #{chid,jdbcType=INTEGER},
		becLimit = #{limit,jdbcType=BIT},
		beParent = #{beparent,jdbcType=INTEGER},
		ptValid = #{valid,jdbcType=SMALLINT}
		where becId = #{id,jdbcType=INTEGER}
	</update>
	<insert id="insertBizBr" parameterType="java.util.Map">
		insert into mtBizBrand (becId,brId) values (#{id,jdbcType=INTEGER},#{brId,jdbcType=INTEGER})
	</insert>
	<delete id="deleteBizBr" parameterType="java.lang.Integer">
		delete from mtBizBrand
		where becId = #{id,jdbcType=INTEGER}
	</delete>

	<select id="findBizBrandByBeid" parameterType="java.lang.Integer" resultMap="BizBrandResultMap">
		select t1.becId from mtBizBrand t1 left join mtBizChannel t2 on t1.becId=t2.becId where t2.beId = #{beid,jdbcType=INTEGER}
	</select>
</mapper>