<?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.lyms.platform.permission.dao.ChildrenPersonMapper">
<resultMap id="ChildrenPersonResultMap" type="com.lyms.platform.permission.model.ChildrenPerson">
<result column="ID" property="id" jdbcType="VARCHAR"/>
<result column="MOTHER_ID" property="motherId" jdbcType="VARCHAR"/>
<result column="NAME" property="name" jdbcType="VARCHAR"/>
<result column="GENDER" property="gender" jdbcType="INTEGER"/>
<result column="PAPERS_NUM" property="papersNum" jdbcType="VARCHAR"/>
<result column="BIRTHDAY" property="birthday" jdbcType="TIMESTAMP"/>
<result column="ADDRESS_PROVINCE" property="addressProvince" jdbcType="VARCHAR"/>
<result column="ADDRESS_CITY" property="addressCity" jdbcType="VARCHAR"/>
<result column="ADDRESS_AREA" property="addressArea" jdbcType="VARCHAR"/>
<result column="ADDRESS_STREET" property="addressStreet" jdbcType="VARCHAR"/>
<result column="ADDRESS_DETAIL" property="addressDetail" jdbcType="VARCHAR"/>
<result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP"/>
<result column="DOCTOR_ID" property="doctorId" jdbcType="INTEGER"/>
<result column="IF_DEL" property="ifDel" jdbcType="INTEGER"/>
<result column="BASE_WOMAN_NAME" property="baseWomanName" jdbcType="VARCHAR"/>
<result column="BASE_PAPERS_TYPE" property="basePapersType" jdbcType="INTEGER"/>
<result column="BASE_PAPERS_NUMBER" property="basePapersNumber" jdbcType="VARCHAR"/>
<result column="BASE_WOMAN_BIRTH" property="baseWomanBirth" jdbcType="TIMESTAMP"/>
<result column="CONTACT_WOMAN_WAY" property="contactWomanWay" jdbcType="VARCHAR"/>
<result column="DEGREE" property="degree" jdbcType="INTEGER"/>
<result column="OCCUPATION" property="occupation" jdbcType="INTEGER"/>
</resultMap>
<insert id="addChildrenPerson" parameterType="com.lyms.platform.permission.model.ChildrenPerson">
insert into CHILDREN_PERSON (ID,MOTHER_ID,NAME,GENDER,PAPERS_NUM,BIRTHDAY,ADDRESS_PROVINCE,ADDRESS_CITY,ADDRESS_AREA,ADDRESS_STREET,ADDRESS_DETAIL,CREATE_TIME,DOCTOR_ID,IF_DEL,BASE_WOMAN_NAME,BASE_PAPERS_TYPE,BASE_PAPERS_NUMBER,BASE_WOMAN_BIRTH,CONTACT_WOMAN_WAY,DEGREE,OCCUPATION) values (#{id},#{motherId},#{name},#{gender},#{papersNum},#{birthday},#{addressProvince},#{addressCity},#{addressArea},#{addressStreet},#{addressDetail},#{createTime},#{doctorId},#{ifDel},#{baseWomanName},#{basePapersType},#{basePapersNumber},#{baseWomanBirth},#{contactWomanWay},#{degree},#{occupation})
</insert>
<update id="updateChildrenPerson" parameterType="com.lyms.platform.permission.model.ChildrenPerson">
update CHILDREN_PERSON
<set>
<if test="id != null and id != ''">
ID = #{id,jdbcType=VARCHAR},
</if>
<if test="motherId != null and motherId != ''">
MOTHER_ID = #{motherId,jdbcType=VARCHAR},
</if>
<if test="name != null and name != ''">
NAME = #{name,jdbcType=VARCHAR},
</if>
<if test="gender != null and gender >= 0">
GENDER = #{gender,jdbcType=INTEGER},
</if>
<if test="papersNum != null and papersNum != ''">
PAPERS_NUM = #{papersNum,jdbcType=VARCHAR},
</if>
<if test="birthday != null">
BIRTHDAY = #{birthday,jdbcType=TIMESTAMP},
</if>
<if test="addressProvince != null and addressProvince != ''">
ADDRESS_PROVINCE = #{addressProvince,jdbcType=VARCHAR},
</if>
<if test="addressCity != null and addressCity != ''">
ADDRESS_CITY = #{addressCity,jdbcType=VARCHAR},
</if>
<if test="addressArea != null and addressArea != ''">
ADDRESS_AREA = #{addressArea,jdbcType=VARCHAR},
</if>
<if test="addressStreet != null and addressStreet != ''">
ADDRESS_STREET = #{addressStreet,jdbcType=VARCHAR},
</if>
<if test="addressDetail != null and addressDetail != ''">
ADDRESS_DETAIL = #{addressDetail,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="doctorId != null and doctorId >= 0">
DOCTOR_ID = #{doctorId,jdbcType=INTEGER},
</if>
<if test="ifDel != null and ifDel >= 0">
IF_DEL = #{ifDel,jdbcType=INTEGER},
</if>
<if test="baseWomanName != null and baseWomanName != ''">
BASE_WOMAN_NAME = #{baseWomanName,jdbcType=VARCHAR},
</if>
<if test="basePapersType != null and basePapersType >= 0">
BASE_PAPERS_TYPE = #{basePapersType,jdbcType=INTEGER},
</if>
<if test="basePapersNumber != null and basePapersNumber != ''">
BASE_PAPERS_NUMBER = #{basePapersNumber,jdbcType=VARCHAR},
</if>
<if test="baseWomanBirth != null">
BASE_WOMAN_BIRTH = #{baseWomanBirth,jdbcType=TIMESTAMP},
</if>
<if test="contactWomanWay != null and contactWomanWay != ''">
CONTACT_WOMAN_WAY = #{contactWomanWay,jdbcType=VARCHAR},
</if>
<if test="degree != null and degree >= 0">
DEGREE = #{degree,jdbcType=INTEGER},
</if>
<if test="occupation != null and occupation >= 0">
OCCUPATION = #{occupation,jdbcType=INTEGER},
</if>
</set>
</update>
<delete id="deleteChildrenPerson" parameterType="java.lang.String">
</delete>
<select id="getChildrenPerson" resultMap="ChildrenPersonResultMap" parameterType="java.lang.String">
select ID,MOTHER_ID,NAME,GENDER,PAPERS_NUM,BIRTHDAY,ADDRESS_PROVINCE,ADDRESS_CITY,ADDRESS_AREA,ADDRESS_STREET,ADDRESS_DETAIL,CREATE_TIME,DOCTOR_ID,IF_DEL,BASE_WOMAN_NAME,BASE_PAPERS_TYPE,BASE_PAPERS_NUMBER,BASE_WOMAN_BIRTH,CONTACT_WOMAN_WAY,DEGREE,OCCUPATION
</select>
<sql id="orderAndLimit">
<if test="sort != null and sort != '' ">
order by ${sort}
<if test="need != null">
limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
</if>
</if>
</sql>
<sql id="ChildrenPersonCondition">
<where>
1 = 1
<if test="id != null and id != ''">
and ID = #{id,jdbcType=VARCHAR}
</if>
<if test="motherId != null and motherId != ''">
and MOTHER_ID = #{motherId,jdbcType=VARCHAR}
</if>
<if test="name != null and name != ''">
and NAME = #{name,jdbcType=VARCHAR}
</if>
<if test="gender != null and gender >= 0">
and GENDER = #{gender,jdbcType=INTEGER}
</if>
<if test="papersNum != null and papersNum != ''">
and PAPERS_NUM = #{papersNum,jdbcType=VARCHAR}
</if>
<if test="birthday != null">
and BIRTHDAY = #{birthday,jdbcType=TIMESTAMP}
</if>
<if test="startBirthday != null">
and
<![CDATA[
DATEDIFF(#{startBirthday},BIRTHDAY)<=0
]]>
</if>
<if test="endBirthday != null">
AND
<![CDATA[
DATEDIFF(#{endBirthday},BIRTHDAY) >=0
]]>
</if>
<if test="addressProvince != null and addressProvince != ''">
and ADDRESS_PROVINCE = #{addressProvince,jdbcType=VARCHAR}
</if>
<if test="addressCity != null and addressCity != ''">
and ADDRESS_CITY = #{addressCity,jdbcType=VARCHAR}
</if>
<if test="addressArea != null and addressArea != ''">
and ADDRESS_AREA = #{addressArea,jdbcType=VARCHAR}
</if>
<if test="addressStreet != null and addressStreet != ''">
and ADDRESS_STREET = #{addressStreet,jdbcType=VARCHAR}
</if>
<if test="addressDetail != null and addressDetail != ''">
and ADDRESS_DETAIL = #{addressDetail,jdbcType=VARCHAR}
</if>
<if test="createTime != null">
and CREATE_TIME = #{createTime,jdbcType=TIMESTAMP}
</if>
<if test="doctorId != null and doctorId >= 0">
and DOCTOR_ID = #{doctorId,jdbcType=INTEGER}
</if>
<if test="ifDel != null and ifDel >= 0">
and IF_DEL = #{ifDel,jdbcType=INTEGER}
</if>
<if test="baseWomanName != null and baseWomanName != ''">
and BASE_WOMAN_NAME = #{baseWomanName,jdbcType=VARCHAR}
</if>
<if test="basePapersType != null and basePapersType >= 0">
and BASE_PAPERS_TYPE = #{basePapersType,jdbcType=INTEGER}
</if>
<if test="basePapersNumber != null and basePapersNumber != ''">
and BASE_PAPERS_NUMBER = #{basePapersNumber,jdbcType=VARCHAR}
</if>
<if test="baseWomanBirth != null">
and BASE_WOMAN_BIRTH = #{baseWomanBirth,jdbcType=TIMESTAMP}
</if>
<if test="contactWomanWay != null and contactWomanWay != ''">
and CONTACT_WOMAN_WAY = #{contactWomanWay,jdbcType=VARCHAR}
</if>
<if test="degree != null and degree >= 0">
and DEGREE = #{degree,jdbcType=INTEGER}
</if>
<if test="occupation != null and occupation >= 0">
and OCCUPATION = #{occupation,jdbcType=INTEGER}
</if>
<if test="keyWord != null and keyWord >= 0">
and (
NAME like concat('%',#{name},'%')
or CONTACT_WOMAN_WAY LIKE concat('%',#{name},'%')
)
</if>
</where>
</sql>
<select id="queryChildrenPerson" resultMap="ChildrenPersonResultMap"
parameterType="com.lyms.platform.permission.model.ChildrenPersonQuery">
select
ID,MOTHER_ID,NAME,GENDER,PAPERS_NUM,BIRTHDAY,ADDRESS_PROVINCE,ADDRESS_CITY,ADDRESS_AREA,ADDRESS_STREET,ADDRESS_DETAIL,CREATE_TIME,DOCTOR_ID,IF_DEL,BASE_WOMAN_NAME,BASE_PAPERS_TYPE,BASE_PAPERS_NUMBER,BASE_WOMAN_BIRTH,CONTACT_WOMAN_WAY,DEGREE,OCCUPATION
from CHILDREN_PERSON
<include refid="ChildrenPersonCondition"/>
<include refid="orderAndLimit"/>
</select>
<select id="queryChildrenPersonCount" resultType="int"
parameterType="com.lyms.platform.permission.model.ChildrenPersonQuery">
select count(1) from CHILDREN_PERSON
<include refid="ChildrenPersonCondition"/>
</select>
</mapper>