FactorProjectMapper.xml 6.77 KB
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
<?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.master.FactorProjectMapper">

<resultMap id="FactorProjectMap" type="com.lyms.platform.permission.model.FactorProject">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="risk_factor_ids" property="riskFactorIds" jdbcType="VARCHAR"/>
<result column="risk_factor_name" property="riskFactorName" jdbcType="VARCHAR"/>
<result column="hospital_id" property="hospitalId" jdbcType="INTEGER"/>
<result column="week" property="week" jdbcType="VARCHAR"/>
<result column="type" property="type" jdbcType="INTEGER"></result>
<result column="tips" property="tips" jdbcType="VARCHAR"/>
<result column="created" property="created" jdbcType="TIMESTAMP"/>
</resultMap>
<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>
<select id="getList" resultMap="FactorProjectMap"
parameterType="com.lyms.platform.permission.model.FactorProjectQuery">
SELECT id,
risk_factor_name,risk_factor_ids,
week,hospital_id,created,type,tips
FROM lyms_factor_project
where
hospital_id = #{hospitalId,jdbcType=INTEGER}
<if test="type!=null">
and type=#{type,jdbcType=INTEGER}
</if>
<if test="week !=null and week !='' ">
and week=#{week,jdbcType=VARCHAR}
</if>
<if test="riskFactorIds!=null and riskFactorIds.size() > 0">
and risk_factor_ids in
<foreach collection="riskFactorIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<include refid="orderAndLimit"/>
</select>

<insert id="add" parameterType="com.lyms.platform.permission.model.FactorProject" useGeneratedKeys="true" keyProperty="id">
INSERT INTO lyms_factor_project(risk_factor_ids,risk_factor_name,week,hospital_id,created,type,tips)
VALUES (#{riskFactorIds},#{riskFactorName},#{week},#{hospitalId},#{created},#{type},#{tips})
</insert>


<update id="update" parameterType="com.lyms.platform.permission.model.FactorProject">
update lyms_factor_project
<set>
<if test="riskFactorIds != null and riskFactorIds != ''">
risk_factor_ids = #{riskFactorIds,jdbcType=VARCHAR},
</if>
<if test="riskFactorName != null and riskFactorName != ''">
risk_factor_name = #{riskFactorName,jdbcType=VARCHAR},
</if>
<if test="hospitalId != null">
hospital_id = #{hospitalId,jdbcType=INTEGER},
</if>
<if test="week != null and week != ''">
week = #{week,jdbcType=VARCHAR},
</if>
<if test="type!=null">
type=#{type,jdbcType=INTEGER},
</if>
<if test="tips !=null">
tips = #{tips,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>

<delete id="del" parameterType="java.lang.Integer">
delete from lyms_factor_project where id = #{id,jdbcType=INTEGER}
</delete>
<select id="queryFactorProjectCount" resultType="int"
parameterType="com.lyms.platform.permission.model.FactorProjectQuery">
SELECT count(id) from lyms_factor_project where
<if test="hospitalId!=null">
hospital_id = #{hospitalId,jdbcType=INTEGER}
</if>
<if test="type!=null">
and type=#{type,jdbcType=INTEGER}
</if>
<if test="week !=null and week!='' ">
and week=#{week,jdbcType=VARCHAR}
</if>
</select>
<select id="selectById" resultMap="FactorProjectMap" parameterType="java.lang.Integer">
SELECT id,risk_factor_ids,
risk_factor_name,
week,hospital_id,created,type,tips
FROM lyms_factor_project
where
id = #{id,jdbcType=INTEGER}
</select>

<resultMap id="FactorProjectResultMap" type="com.lyms.platform.permission.model.FactorProject">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="hospital_id" property="hospitalId" jdbcType="INTEGER"/>
<result column="risk_factor_ids" property="riskFactorIds" jdbcType="VARCHAR"/>
<result column="risk_factor_name" property="riskFactorName" jdbcType="VARCHAR"/>
<result column="week" property="week" jdbcType="VARCHAR"/>
<result column="tips" property="tips" jdbcType="VARCHAR"/>
<result column="type" property="type" jdbcType="INTEGER"></result>
<result column="created" property="created" jdbcType="TIMESTAMP"/>
<collection property="wayList" ofType="com.lyms.platform.permission.model.ProjectWay">
<id column="projectWay.id" property="id"/>
<result column="projectWay.week_project_id" property="weekProjectId"/>
<result column="projectWay.way" property="way"/>
<result column="projectWay.week_project_name" property="weekProjectName"/>
<result column="projectWay.factor_id" property="factorId"/>
<result column="projectWay.sort" property="sort"/>
</collection>
</resultMap>
<select id="selectInfo" resultMap="FactorProjectResultMap" parameterType="java.lang.Integer">
SELECT
fp.id,
fp.hospital_id,
fp.type,
fp.tips,
fp.risk_factor_ids,
fp.risk_factor_name,
fp.`week`,
pw.id AS `projectWay.id`,
pw.way AS `projectWay.way`,
pw.factor_id AS `projectWay.factor_id`,
pw.week_project_id AS `projectWay.week_project_id`,
pw.week_project_name AS `projectWay.week_project_name`,
pw.sort AS `projectWay.sort`
FROM
`lyms_factor_project` fp
INNER JOIN lyms_project_way pw ON pw.factor_id = fp.id
where
fp.id = #{id,jdbcType=INTEGER}
</select>

<select id="selectList" resultMap="FactorProjectResultMap">
SELECT
fp.id,
fp.risk_factor_ids,
fp.risk_factor_name,
fp.`week`,
fp.tips,
fp.type,
pw.id AS `projectWay.id`,
pw.way AS `projectWay.way`,
pw.factor_id AS `projectWay.factor_id`,
pw.week_project_id AS `projectWay.week_project_id`,
pw.week_project_name AS `projectWay.week_project_name`,
pw.sort AS `projectWay.sort`
FROM
`lyms_factor_project` fp
INNER JOIN lyms_project_way pw ON pw.factor_id = fp.id
where
fp.hospital_id = #{hospitalId}
and fp.type=#{type}
and fp.week = #{week}
</select>

</mapper>