<?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="MdeExperienceShareMapper">
    <resultMap type="com.wechat.model.dbEntity.MdeExperienceShare" id="MdeExperienceShare">
    	<id column="exps_id" property="expsId"/>
		<result column="user_code" property="userCode"/>
		<result column="cv_title" property="cvTitle"/>
		<result column="cv_url" property="cvUrl"/>
		<result column="version_no" property="versionNo"/>
		<result column="remarks" property="remarks"/>
		<result column="del_flag" property="delFlag"/>
		<result column="create_by" property="createBy"/>
		<result column="create_date" property="createDate"/>
		<result column="update_by" property="updateBy"/>
		<result column="update_date" property="updateDate"/>
    </resultMap>
	<sql id="mdeExperienceShareColumns">
		a.exps_id AS "expsId",
		a.user_code AS "userCode",
		a.cv_title AS "cvTitle",
		a.cv_url AS "cvUrl",
		a.version_no AS "versionNo",
		a.remarks AS "remarks",
		a.del_flag AS "delFlag",
		a.create_by AS "createBy",
		a.create_date AS "createDate",
		a.update_by AS "updateBy",
		a.update_date AS "updateDate"
	</sql>
	
	<sql id="mdeExperienceShareJoins">
	</sql>
    
	<select id="get" resultMap="MdeExperienceShare">
		SELECT 
			<include refid="mdeExperienceShareColumns"/>
		FROM mde_experience_share a
		<include refid="mdeExperienceShareJoins"/>
		WHERE a.exps_id = #{id}
	</select>
	
	<select id="findList" resultMap="MdeExperienceShare">
		SELECT 
			<include refid="mdeExperienceShareColumns"/>
		FROM mde_experience_share a
		<include refid="mdeExperienceShareJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY #{page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>
	
	<select id="findAllList" resultMap="MdeExperienceShare">
		SELECT 
			<include refid="mdeExperienceShareColumns"/>
		FROM mde_experience_share a
		<include refid="mdeExperienceShareJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
		</where>		
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY #{page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>
	
	<insert id="insert">
		INSERT INTO mde_experience_share(
			exps_id,
			user_code,
			cv_title,
			cv_url,
			version_no,
			remarks,
			del_flag,
			create_by,
			create_date,
			update_by,
			update_date
		) VALUES (
			#{expsId},
			#{userCode},
			#{cvTitle},
			#{cvUrl},
			#{versionNo},
			#{remarks},
			#{delFlag},
			#{createBy},
			#{createDate},
			#{updateBy},
			#{updateDate}
		)
	</insert>
	
	<update id="update">
		UPDATE mde_experience_share SET 	
			exps_id = #{expsId},
			user_code = #{userCode},
			cv_title = #{cvTitle},
			cv_url = #{cvUrl},
			version_no = version_no + 1,
			remarks = #{remarks},
			update_by = #{updateBy},
			update_date = #{updateDate}
		WHERE exps_id = #{id} and version_no = #{versionNo}
	</update>
	
	<update id="delete">
		UPDATE mde_experience_share SET 
			version_no = version_no + 1,
			del_flag = #{DEL_FLAG_DELETE}
		WHERE exps_id = #{id} and and version_no = #{versionNo}
	</update>
	
</mapper>