Files
zhyc-sheep/zhyc-module/src/main/resources/mapper/produce/breed/ScBreedPlanMapper.xml
2026-03-05 14:58:15 +08:00

74 lines
3.1 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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.produce.breed.mapper.ScBreedPlanMapper">
<resultMap type="ScBreedPlan" id="ScBreedPlanResult">
<result property="id" column="id" />
<result property="ramId" column="ram_id" />
<result property="eweId" column="ewe_id" />
<result property="breedType" column="breed_type" />
</resultMap>
<sql id="selectScBreedPlanVo">
select s.id, s.ram_id, s.ewe_id, s.breed_type, s.user_id, s.dept_id
from sc_breed_plan s
</sql>
<!-- 修改为:条件里加别名前缀,末尾加 ${params.dataScope} -->
<select id="selectScBreedPlanList" parameterType="ScBreedPlan" resultMap="ScBreedPlanResult">
<include refid="selectScBreedPlanVo"/>
<where>
<if test="ramId != null and ramId != ''"> and s.ram_id = #{ramId}</if>
<if test="eweId != null and eweId != ''"> and s.ewe_id = #{eweId}</if>
<if test="breedType != null "> and s.breed_type = #{breedType}</if>
<!-- 数据权限控制必须加在where末尾 -->
${params.dataScope}
</where>
</select>
<select id="selectScBreedPlanById" parameterType="Long" resultMap="ScBreedPlanResult">
<include refid="selectScBreedPlanVo"/>
where id = #{id}
</select>
<insert id="insertScBreedPlan" parameterType="ScBreedPlan" useGeneratedKeys="true" keyProperty="id">
insert into sc_breed_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="ramId != null">ram_id,</if>
<if test="eweId != null">ewe_id,</if>
<if test="breedType != null">breed_type,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ramId != null">#{ramId},</if>
<if test="eweId != null">#{eweId},</if>
<if test="breedType != null">#{breedType},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
<update id="updateScBreedPlan" parameterType="ScBreedPlan">
update sc_breed_plan
<trim prefix="SET" suffixOverrides=",">
<if test="ramId != null">ram_id = #{ramId},</if>
<if test="eweId != null">ewe_id = #{eweId},</if>
<if test="breedType != null">breed_type = #{breedType},</if>
<!-- 通常不更新 user_id 和 dept_id保持创建时的值 -->
</trim>
where id = #{id}
</update>
<delete id="deleteScBreedPlanById" parameterType="Long">
delete from sc_breed_plan where id = #{id}
</delete>
<delete id="deleteScBreedPlanByIds" parameterType="String">
delete from sc_breed_plan where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>