<?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.lymsh.yimiao.main.data.dao.MedVaccineNameMapper">
<resultMap id="MedVaccineNameResultMap" type="com.lymsh.yimiao.main.data.model.MedVaccineName">
<result column="vn_id" property="vnId" jdbcType="VARCHAR" />
<result column="vn_name" property="vnName" jdbcType="VARCHAR" />
<result column="vn_preventDisease" property="vnPreventDisease" jdbcType="VARCHAR" />
<result column="vn_monthAge" property="vnMonthAge" jdbcType="VARCHAR" />
<result column="vn_position" property="vnPosition" jdbcType="VARCHAR" />
<result column="vn_taboo" property="vnTaboo" jdbcType="VARCHAR" />
<result column="vn_description" property="vnDescription" jdbcType="VARCHAR" />
<result column="vn_isValid" property="vnIsValid" jdbcType="VARCHAR" />
<result column="vn_vaccineType" property="vnVaccineType" jdbcType="INTEGER" />
<result column="isDelete" property="isDelete" jdbcType="INTEGER" />
<result column="MONTH_AGE" property="mouthAge" jdbcType="INTEGER" />
</resultMap>
<select id="getMedVaccineName" resultMap="MedVaccineNameResultMap" parameterType="java.lang.String">
select vn_id,vn_name,vn_preventDisease,vn_monthAge,vn_position,vn_taboo,vn_description,vn_isValid,vn_vaccineType,isDelete
from med_vaccinename
WHERE vn_id = #{vnId,jdbcType=VARCHAR}
</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="MedVaccineNameCondition">
<where>
1 = 1 and VN_ISINPLAN = 1
<if test="vnId != null and vnId != ''">
and vn_id = #{vnId,jdbcType=VARCHAR}
</if>
<if test="vnName != null and vnName != ''">
and vn_name = #{vnName,jdbcType=VARCHAR}
</if>
<if test="vnPreventDisease != null and vnPreventDisease != ''">
and vn_preventDisease = #{vnPreventDisease,jdbcType=VARCHAR}
</if>
<if test="vnMonthAge != null and vnMonthAge != ''">
and (vn_monthAge = #{vnMonthAge,jdbcType=VARCHAR}
OR vn_monthAge like CONCAT(#{vnMonthAge,jdbcType=VARCHAR}, ',%')
OR vn_monthAge LIKE CONCAT('%,',#{vnMonthAge,jdbcType=VARCHAR})
OR vn_monthAge LIKE '%,'||#{vnMonthAge,jdbcType=VARCHAR}||',%'
)
</if>
<if test="vnPosition != null and vnPosition != ''">
and vn_position = #{vnPosition,jdbcType=VARCHAR}
</if>
<if test="vnTaboo != null and vnTaboo != ''">
and vn_taboo = #{vnTaboo,jdbcType=VARCHAR}
</if>
<if test="vnDescription != null and vnDescription != ''">
and vn_description = #{vnDescription,jdbcType=VARCHAR}
</if>
<if test="vnIsValid != null and vnIsValid != ''">
and vn_isValid = #{vnIsValid,jdbcType=VARCHAR}
</if>
<if test="vnVaccineType != null and vnVaccineType != ''">
and vn_vaccineType = #{vnVaccineType,jdbcType=INTEGER}
</if>
<if test="isDelete != null and isDelete != ''">
and isDelete = #{isDelete,jdbcType=INTEGER}
</if>
<if test="mouthAge != null and mouthAge != ''">
and MONTH_AGE = #{mouthAge,jdbcType=INTEGER}
</if>
</where>
</sql>
<select id="queryMedVaccineName" resultMap="MedVaccineNameResultMap" parameterType="com.lymsh.yimiao.main.data.model.MedVaccineNameQuery">
select vn_id,vn_name,vn_preventDisease,vn_monthAge,vn_position,vn_taboo,vn_description,vn_isValid,isDelete,vn_vaccineType
from med_vaccinename
<include refid="MedVaccineNameCondition" />
<include refid="orderAndLimit" />
</select>
<select id="queryMedVaccineNameCount" resultType="int" parameterType="com.lymsh.yimiao.main.data.model.MedVaccineNameQuery">
select count(1) from med_vaccinename
<include refid="MedVaccineNameCondition" />
</select>
<select id="queryVaccineNameList" resultMap="MedVaccineNameResultMap" >
SELECT VN_ID, VN_NAME, b.column_value AS MONTH_AGE,VN_VACCINETYPE,VN_MONTHAGE
FROM med_VaccineName , table(splitstr(VN_MONTHAGE, ',')) b
WHERE VN_MONTHAGE IS NOT NULL
AND ISDELETE = 1
AND VN_ISINPLAN = 1
ORDER BY MONTH_AGE,VN_VACCINETYPE
</select>
</mapper>