2f27549ac85b7d8c620f6a0128d2913254a93f8e.svn-base 3.4 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="com.thinkgem.jeesite.modules.ycsl.dao.YcslSjclDao">
    
	<sql id="ycslSjclColumns">
		a.id AS "id",
		a.proid AS "proid",
		a.sjr AS "sjr",
		a.sjrq AS "sjrq",
		a.cllx AS "cllx",
		a.clmc AS "clmc",
		a.fs AS "fs",
		a.ys AS "ys",
		a.sjcllj AS "sjcllj",
		a.sjid AS "sjId.id",
		a.del_flag AS "delFlag",
		a.create_by AS "createBy.id",
		a.create_date AS "createDate",
		a.update_by AS "updateBy.id",
		a.update_date AS "updateDate"
	</sql>
	
	<sql id="ycslSjclJoins">
	
		LEFT JOIN ycsl_sj b ON b.id = a.sjid and b.proid = a.proid
	
	</sql>
    
	<select id="get" resultType="YcslSjcl">
		SELECT 
			<include refid="ycslSjclColumns"/>
		FROM ycsl_sjcl a
		<include refid="ycslSjclJoins"/>
		WHERE a.id = #{id}
	</select>
	
	<select id="findList" resultType="YcslSjcl">
		SELECT 
			<include refid="ycslSjclColumns"/>
		FROM ycsl_sjcl a
		<include refid="ycslSjclJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="sjId.id != null and sjId.id != ''">
				AND a.sjid = #{sjId.id}
			</if>
			<if test="proid != null and proid != ''">
				AND a.proid = #{proid}
			</if>
			<if test="cllx != null and cllx != ''">
				AND a.cllx = #{cllx}
			</if>
			<if test="clmc != null and clmc != ''">
				AND a.clmc = #{clmc}
			</if>
			
		</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" resultType="YcslSjcl">
		SELECT 
			<include refid="ycslSjclColumns"/>
		FROM ycsl_sjcl a
		<include refid="ycslSjclJoins"/>
		<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 ycsl_sjcl(
			id,
			proid,
			sjr,
			sjrq,
			cllx,
			clmc,
			fs,
			ys,
			sjcllj,
			sjid,
			del_flag,
			create_by,
			create_date,
			update_by,
			update_date
		) VALUES (
			#{id},
			#{proid},
			#{createBy.name},
			#{createDate},
			#{cllx},
			#{clmc},
			#{fs},
			#{ys},
			#{sjcllj},
			#{sjId.id},
			#{delFlag},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate}
		)
	</insert>
	
	<insert id="insertsjcl">
		INSERT INTO ycsl_sjcl(
			id,
			proid,
			sjr,
			sjrq,
			cllx,
			clmc,
			fs,
			ys,
			sjcllj,
			sjid,
			del_flag,
			create_by,
			create_date,
			update_by,
			update_date
		) VALUES (
			#{id},
			#{proid},
			#{sjr},
			#{sjrq},
			#{cllx},
			#{clmc},
			#{fs},
			#{ys},
			#{sjcllj},
			#{sjid},
			#{delFlag},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate}
		)
	</insert>
	
	<update id="update">
		UPDATE ycsl_sjcl SET 	
			proid = #{proid},
			sjr = #{sjr},
			sjrq = #{sjrq},
			cllx = #{cllx},
			clmc = #{clmc},
			fs = #{fs},
			ys = #{ys},
			sjcllj = #{sjcllj},
		
			update_by = #{updateBy.id},
			update_date = #{updateDate}
		WHERE id = #{id}
	</update>
	
	<update id="delete">
		UPDATE ycsl_sjcl SET 
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>
	<update id="deleteByproid">
		UPDATE ycsl_sjcl SET 
			del_flag = '1'
		WHERE proid = #{proid}
	</update>
</mapper>