105 lines
3.7 KiB
XML
105 lines
3.7 KiB
XML
<?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.zhyc.module.base.mapper.BasSheepGroupMappingMapper">
|
|
|
|
<resultMap type="BasSheepGroupMapping" id="BasSheepGroupMappingResult">
|
|
<result property="id" column="id" />
|
|
<result property="sheepId" column="sheep_id" />
|
|
<result property="groupId" column="group_id" />
|
|
</resultMap>
|
|
|
|
<sql id="selectBasSheepGroupMappingVo">
|
|
select id, sheep_id, group_id from bas_sheep_group_mapping
|
|
</sql>
|
|
|
|
<!-- <select id="selectBasSheepGroupMappingList" parameterType="BasSheepGroupMapping" resultMap="BasSheepGroupMappingResult">-->
|
|
<!-- <include refid="selectBasSheepGroupMappingVo"/>-->
|
|
<!-- <where> -->
|
|
<!-- <if test="sheepId != null "> and sheep_id = #{sheepId}</if>-->
|
|
<!-- <if test="groupId != null "> and group_id = #{groupId}</if>-->
|
|
<!-- </where>-->
|
|
<!-- </select>-->
|
|
|
|
<select id="selectBasSheepGroupMappingList"
|
|
parameterType="map"
|
|
resultType="map"> <!-- 1. 返回 map 方便前端直接取值 -->
|
|
|
|
SELECT
|
|
m.id,
|
|
m.sheep_id,
|
|
m.group_id,
|
|
s.id AS bs_sheep_id,
|
|
s.bs_manage_tags,
|
|
s.variety,
|
|
s.gender,
|
|
s.name,
|
|
s.birthday,
|
|
s.parity,
|
|
s.month_age,
|
|
s.breed,
|
|
s.birth_weight,
|
|
s.weaning_weight,
|
|
s.current_weight,
|
|
s.father_manage_tags,
|
|
s.mother_manage_tags,
|
|
s.family
|
|
FROM bas_sheep_group_mapping m
|
|
JOIN sheep_file s ON s.id = m.sheep_id
|
|
<where>
|
|
<if test="sheepId != null"> AND m.sheep_id = #{sheepId}</if>
|
|
<if test="groupId != null"> AND m.group_id = #{groupId}</if>
|
|
<if test="bsManageTags != null and bsManageTags.size > 0">
|
|
AND s.bs_manage_tags IN
|
|
<foreach collection="bsManageTags" item="bsManageTag " open="(" separator="," close=")">
|
|
#{bsManageTag}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
ORDER BY m.id
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectBasSheepGroupMappingById" parameterType="Long" resultMap="BasSheepGroupMappingResult">
|
|
<include refid="selectBasSheepGroupMappingVo"/>
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertBasSheepGroupMapping" parameterType="BasSheepGroupMapping" useGeneratedKeys="true" keyProperty="id">
|
|
insert into bas_sheep_group_mapping
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="sheepId != null">sheep_id,</if>
|
|
<if test="groupId != null">group_id,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="sheepId != null">#{sheepId},</if>
|
|
<if test="groupId != null">#{groupId},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateBasSheepGroupMapping" parameterType="BasSheepGroupMapping">
|
|
update bas_sheep_group_mapping
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="sheepId != null">sheep_id = #{sheepId},</if>
|
|
<if test="groupId != null">group_id = #{groupId},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteBasSheepGroupMappingById" parameterType="Long">
|
|
delete from bas_sheep_group_mapping where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteBasSheepGroupMappingByIds" parameterType="String">
|
|
delete from bas_sheep_group_mapping where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
</mapper> |