2023-08-10 21:09:49 +08:00
<?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.yanzhu.jh.project.mapper.SurProjectUnitInfoMapper" >
<resultMap type= "SurProjectUnitInfo" id= "SurProjectUnitInfoResult" >
<result property= "id" column= "id" />
<result property= "projectId" column= "projectId" />
<result property= "unitId" column= "unitId" />
2023-08-11 22:15:06 +08:00
<result property= "deptId" column= "deptId" />
2023-08-10 21:09:49 +08:00
<result property= "unitType" column= "unitType" />
2023-08-20 15:46:23 +08:00
<result property= "unitTypeName" column= "unitTypeName" />
2023-08-10 21:09:49 +08:00
<result property= "unitName" column= "unitName" />
2023-08-11 22:15:06 +08:00
<result property= "deptName" column= "deptName" />
2023-08-10 21:09:49 +08:00
<result property= "unitPersonName" column= "unitPersonName" />
<result property= "unitPersonPhone" column= "unitPersonPhone" />
<result property= "createUser" column= "createUser" />
<result property= "createTime" column= "createTime" />
<result property= "delFlag" column= "del_flag" />
</resultMap>
<sql id= "selectSurProjectUnitInfoVo" >
2023-08-11 22:15:06 +08:00
select id, projectId, unitId, unitId as deptId, unitType, unitName, unitName as deptName,unitPersonName, unitPersonPhone, createUser, createTime, del_flag from sur_project_unit_info
2023-08-10 21:09:49 +08:00
</sql>
<select id= "selectSurProjectUnitInfoList" parameterType= "SurProjectUnitInfo" resultMap= "SurProjectUnitInfoResult" >
2023-08-20 15:46:23 +08:00
select spui.id, spui.projectId, spui.unitId, spui.unitId as deptId, spui.unitType, sdd.dict_label as unitTypeName, spui.unitName, spui.unitName as deptName, spui.unitPersonName, spui.unitPersonPhone, spui.createUser, spui.createTime, spui.del_flag from sur_project_unit_info spui
left join sys_dict_data sdd on sdd.dict_type='sys_dept_type' and dict_value=spui.unitType
2023-08-17 19:39:25 +08:00
<where >
and del_flag=0
2023-08-20 15:46:23 +08:00
<if test= "projectId != null " > and spui.projectId = #{projectId}</if>
<if test= "unitId != null " > and spui.unitId = #{unitId}</if>
<if test= "unitType != null " > and spui.unitType = #{unitType}</if>
<if test= "unitName != null and unitName != ''" > and spui.unitName like concat('%', #{unitName}, '%')</if>
<if test= "unitPersonName != null and unitPersonName != ''" > and spui.unitPersonName like concat('%', #{unitPersonName}, '%')</if>
<if test= "unitPersonPhone != null and unitPersonPhone != ''" > and spui.unitPersonPhone = #{unitPersonPhone}</if>
<if test= "createUser != null and createUser != ''" > and spui.createUser = #{createUser}</if>
<if test= "createTime != null " > and spui.createTime = #{createTime}</if>
<if test= "nowDept != null and nowDept != ''" > and spui.unitId != #{nowDept}</if>
2023-08-22 18:09:42 +08:00
<if test= "unitTypes != null " >
and spui.unitType in
<foreach item= "type" collection= "unitTypes" open= "(" separator= "," close= ")" >
#{type}
</foreach>
</if>
2023-08-10 21:09:49 +08:00
</where>
2023-08-24 18:42:44 +08:00
order by sdd.dict_sort
2023-08-10 21:09:49 +08:00
</select>
<select id= "selectSurProjectUnitInfoById" parameterType= "Long" resultMap= "SurProjectUnitInfoResult" >
<include refid= "selectSurProjectUnitInfoVo" />
where id = #{id}
</select>
<insert id= "insertSurProjectUnitInfo" parameterType= "SurProjectUnitInfo" useGeneratedKeys= "true" keyProperty= "id" >
insert into sur_project_unit_info
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "projectId != null" > projectId,</if>
<if test= "unitId != null" > unitId,</if>
<if test= "unitType != null" > unitType,</if>
<if test= "unitName != null" > unitName,</if>
<if test= "unitPersonName != null" > unitPersonName,</if>
<if test= "unitPersonPhone != null" > unitPersonPhone,</if>
<if test= "createUser != null" > createUser,</if>
<if test= "createTime != null" > createTime,</if>
<if test= "delFlag != null" > del_flag,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "projectId != null" > #{projectId},</if>
<if test= "unitId != null" > #{unitId},</if>
<if test= "unitType != null" > #{unitType},</if>
<if test= "unitName != null" > #{unitName},</if>
<if test= "unitPersonName != null" > #{unitPersonName},</if>
<if test= "unitPersonPhone != null" > #{unitPersonPhone},</if>
<if test= "createUser != null" > #{createUser},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "delFlag != null" > #{delFlag},</if>
</trim>
</insert>
<update id= "updateSurProjectUnitInfo" parameterType= "SurProjectUnitInfo" >
update sur_project_unit_info
<trim prefix= "SET" suffixOverrides= "," >
<if test= "projectId != null" > projectId = #{projectId},</if>
<if test= "unitId != null" > unitId = #{unitId},</if>
<if test= "unitType != null" > unitType = #{unitType},</if>
<if test= "unitName != null" > unitName = #{unitName},</if>
<if test= "unitPersonName != null" > unitPersonName = #{unitPersonName},</if>
<if test= "unitPersonPhone != null" > unitPersonPhone = #{unitPersonPhone},</if>
<if test= "createUser != null" > createUser = #{createUser},</if>
<if test= "createTime != null" > createTime = #{createTime},</if>
<if test= "delFlag != null" > del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<delete id= "deleteSurProjectUnitInfoById" parameterType= "Long" >
delete from sur_project_unit_info where id = #{id}
</delete>
<delete id= "deleteSurProjectUnitInfoByProjectId" parameterType= "Long" >
delete from sur_project_unit_info where projectId = #{projectId} and unitId not in (select dept_id from sur_project_userinfo where project_id = #{projectId} and is_del=0)
</delete>
<delete id= "deleteSurProjectUnitInfoByIds" parameterType= "String" >
delete from sur_project_unit_info where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
</mapper>