123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <?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.hcloud.microserver.bank.dao.ProductBelongMapper">
- <resultMap id="BaseResultMap" type="com.hcloud.microserver.facade.carbon.entity.ProductBelong">
- <id column="guid" jdbcType="CHAR" property="guid"/>
- <result column="fk_product_guid" jdbcType="CHAR" property="fkProductGuid"/>
- <result column="fk_farmer_guid" jdbcType="CHAR" property="fkFarmerGuid"/>
- <result column="fk_collective_guid" jdbcType="CHAR" property="fkCollectiveGuid"/>
- <result column="farmer_name" jdbcType="VARCHAR" property="farmerName"/>
- <result column="farmer_village" jdbcType="VARCHAR" property="farmerVillage"/>
- <result column="farmer_num" jdbcType="INTEGER" property="farmerNum"/>
- <result column="state" jdbcType="INTEGER" property="state"/>
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="modified_time" jdbcType="TIMESTAMP" property="modifiedTime"/>
- <result column="belong_type" jdbcType="INTEGER" property="belongType"/>
- <discriminator javaType="int" column="belong_type">
- <case value="1" resultMap="farmerMap"></case>
- <case value="2" resultMap="collectiveMap"></case>
- </discriminator>
- </resultMap>
- <resultMap id="collectiveMap" type="com.hcloud.microserver.facade.carbon.entity.CollectiveProductBelong" extends="BaseResultMap">
- <association property="collectiveFarmer" select="com.hcloud.microserver.bank.dao.CollectiveFarmerMapper.selectByPrimaryKey" column="fk_farmer_guid"/>
- </resultMap>
- <resultMap id="farmerMap" type="com.hcloud.microserver.facade.carbon.entity.FarmerProductBelong" extends="BaseResultMap">
- <association property="farmerInfo" select="com.hcloud.microserver.bank.dao.FarmerInfoMapper.selectByPrimaryKey" column="fk_farmer_guid"/>
- </resultMap>
- <sql id="Base_Column_List">
- guid, fk_product_guid, fk_farmer_guid, fk_collective_guid, farmer_name, farmer_village, farmer_num, state,
- create_time, modified_time, belong_type
- </sql>
- <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List"/>
- from t_product_belong
- where guid = #{guid,jdbcType=CHAR}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
- delete from t_product_belong
- where guid = #{guid,jdbcType=CHAR}
- </delete>
- <insert id="insert" parameterType="com.hcloud.microserver.facade.carbon.entity.ProductBelong">
- insert into t_product_belong (guid, fk_product_guid, fk_farmer_guid, fk_collective_guid
- farmer_name, farmer_village, farmer_num,
- state, create_time, modified_time, belong_type
- )
- values (#{guid,jdbcType=CHAR}, #{fkProductGuid,jdbcType=CHAR}, #{fkFarmerGuid,jdbcType=CHAR}, #{fkCollectiveGuid,jdbcType=VARCHAR},
- #{farmerName,jdbcType=VARCHAR}, #{farmerVillage,jdbcType=VARCHAR}, #{farmerNum,jdbcType=INTEGER},
- #{state,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{modifiedTime,jdbcType=TIMESTAMP}, #{belongType,jdbcType=INTEGER}
- )
- </insert>
- <insert id="insertSelective" parameterType="com.hcloud.microserver.facade.carbon.entity.ProductBelong">
- insert into t_product_belong
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="guid != null">
- guid,
- </if>
- <if test="fkProductGuid != null">
- fk_product_guid,
- </if>
- <if test="fkFarmerGuid != null">
- fk_farmer_guid,
- </if>
- <if test="fkCollectiveGuid != null and fkCollectiveGuid != ''">
- fk_collective_guid,
- </if>
- <if test="farmerName != null">
- farmer_name,
- </if>
- <if test="farmerVillage != null">
- farmer_village,
- </if>
- <if test="farmerNum != null">
- farmer_num,
- </if>
- <if test="state != null">
- state,
- </if>
- <if test="createTime != null">
- create_time,
- </if>
- <if test="modifiedTime != null">
- modified_time,
- </if>
- <if test="belongType != null">
- belong_type,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="guid != null">
- #{guid,jdbcType=CHAR},
- </if>
- <if test="fkProductGuid != null">
- #{fkProductGuid,jdbcType=CHAR},
- </if>
- <if test="fkFarmerGuid != null">
- #{fkFarmerGuid,jdbcType=CHAR},
- </if>
- <if test="fkCollectiveGuid != null and fkCollectiveGuid != ''">
- #{fkCollectiveGuid,jdbcType=VARCHAR},
- </if>
- <if test="farmerName != null">
- #{farmerName,jdbcType=VARCHAR},
- </if>
- <if test="farmerVillage != null">
- #{farmerVillage,jdbcType=VARCHAR},
- </if>
- <if test="farmerNum != null">
- #{farmerNum,jdbcType=INTEGER},
- </if>
- <if test="state != null">
- #{state,jdbcType=INTEGER},
- </if>
- <if test="createTime != null">
- #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="modifiedTime != null">
- #{modifiedTime,jdbcType=TIMESTAMP},
- </if>
- <if test="belongType != null">
- #{belongType,jdbcType=INTEGER},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.hcloud.microserver.facade.carbon.entity.ProductBelong">
- update t_product_belong
- <set>
- <if test="fkProductGuid != null">
- fk_product_guid = #{fkProductGuid,jdbcType=CHAR},
- </if>
- <if test="fkFarmerGuid != null">
- fk_farmer_guid = #{fkFarmerGuid,jdbcType=CHAR},
- </if>
- <if test="fkCollectiveGuid != null and fkCollectiveGuid != ''">
- fk_collective_guid = #{fkCollectiveGuid,jdbcType=VARCHAR},
- </if>
- <if test="farmerName != null">
- farmer_name = #{farmerName,jdbcType=VARCHAR},
- </if>
- <if test="farmerVillage != null">
- farmer_village = #{farmerVillage,jdbcType=VARCHAR},
- </if>
- <if test="farmerNum != null">
- farmer_num = #{farmerNum,jdbcType=INTEGER},
- </if>
- <if test="state != null">
- state = #{state,jdbcType=INTEGER},
- </if>
- <if test="createTime != null">
- create_time = #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="modifiedTime != null">
- modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
- </if>
- <if test="belongType != null">
- belong_type = #{belongType,jdbcType=INTEGER},
- </if>
- </set>
- where guid = #{guid,jdbcType=CHAR}
- </update>
- <update id="updateByPrimaryKey" parameterType="com.hcloud.microserver.facade.carbon.entity.ProductBelong">
- update t_product_belong
- set fk_product_guid = #{fkProductGuid,jdbcType=CHAR},
- fk_farmer_guid = #{fkFarmerGuid,jdbcType=CHAR},
- fk_collective_guid = #{fkCollectiveGuid,jdbcType=VARCHAR},
- farmer_name = #{farmerName,jdbcType=VARCHAR},
- farmer_village = #{farmerVillage,jdbcType=VARCHAR},
- farmer_num = #{farmerNum,jdbcType=INTEGER},
- state = #{state,jdbcType=INTEGER},
- create_time = #{createTime,jdbcType=TIMESTAMP},
- modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
- belong_type = #{belongType,jdbcType=INTEGER}
- where guid = #{guid,jdbcType=CHAR}
- </update>
- <insert id="batchInsert" parameterType="java.util.List">
- insert into t_product_belong (<include refid="Base_Column_List"/>)
- values
- <foreach collection="list" item="item" index="index" separator=",">
- (
- #{item.guid,jdbcType=VARCHAR},
- #{item.fkProductGuid,jdbcType=VARCHAR},
- #{item.fkFarmerGuid,jdbcType=VARCHAR},
- #{item.fkCollectiveGuid,jdbcType=VARCHAR},
- #{item.farmerName,jdbcType=VARCHAR},
- #{item.farmerVillage,jdbcType=VARCHAR},
- #{item.farmerNum,jdbcType=INTEGER},
- #{item.state,jdbcType=INTEGER},
- #{item.createTime,jdbcType=TIMESTAMP},
- #{item.modifiedTime,jdbcType=TIMESTAMP},
- #{item.belongType,jdbcType=INTEGER}
- )
- </foreach>
- </insert>
- <delete id="deleteByProductInfoGuid" parameterType="string">
- delete from t_product_belong where fk_product_guid = #{productInfoGuid,jdbcType=VARCHAR}
- </delete>
- <select id="selectByProductGuid" parameterType="string" resultMap="BaseResultMap">
- select guid, fk_product_guid, fk_farmer_guid, fk_collective_guid,
- (CASE belong_type WHEN 1 THEN farmer_name ELSE farmer_village END ) AS farmer_name,
- farmer_village, farmer_num, state, create_time, modified_time, belong_type
- from t_product_belong
- where fk_product_guid = #{productInfoGuid,jdbcType=CHAR}
- </select>
- <delete id="deleteByProductInfoGuids" parameterType="list">
- delete from t_product_belong where fk_product_guid in
- <foreach collection="list" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </delete>
- </mapper>
|