Bonus-Cloud-Material/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmUnitMapper.xml

110 lines
5.4 KiB
XML
Raw Normal View History

2024-09-26 16:15:51 +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.bonus.material.basic.mapper.BmUnitMapper">
<resultMap type="com.bonus.material.basic.domain.BmUnit" id="BmUnitResult">
<result property="unitId" column="unit_id" />
<result property="unitName" column="unit_name" />
<result property="status" column="status" />
<result property="typeId" column="type_id" />
<result property="linkMan" column="link_man" />
<result property="telphone" column="telphone" />
<result property="deptId" column="dept_id" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectBmUnitVo">
select unit_id, unit_name, status, type_id, link_man, telphone, dept_id, del_flag, create_by, create_time, update_by, update_time, remark from bm_unit
</sql>
<select id="selectBmUnitList" parameterType="com.bonus.material.basic.domain.BmUnit" resultMap="BmUnitResult">
<include refid="selectBmUnitVo"/>
2024-10-14 13:52:48 +08:00
<where>
del_flag = 0
2024-09-26 16:15:51 +08:00
<if test="unitName != null and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="typeId != null "> and type_id = #{typeId}</if>
<if test="linkMan != null and linkMan != ''"> and link_man = #{linkMan}</if>
<if test="telphone != null and telphone != ''"> and telphone = #{telphone}</if>
<if test="deptId != null "> and dept_id = #{deptId}</if>
</where>
</select>
<select id="selectBmUnitByUnitId" parameterType="Long" resultMap="BmUnitResult">
<include refid="selectBmUnitVo"/>
2024-10-14 13:52:48 +08:00
where del_flag = 0 and unit_id = #{unitId}
</select>
2024-10-15 10:21:17 +08:00
2024-10-14 13:52:48 +08:00
<select id="selectBmUnitByProName" resultType="com.bonus.material.basic.domain.BmUnit">
select unit_id as unitId, unit_name as unitName from bm_unit where del_flag = 0 and unit_name = #{unitName}
2024-09-26 16:15:51 +08:00
</select>
2024-10-14 13:52:48 +08:00
2024-10-15 10:21:17 +08:00
<select id="selectBmUnitPersonByUnitId" resultType="java.lang.Integer">
select count(1) from bm_unit_person where unit_id = #{unitId}
</select>
2024-09-26 16:15:51 +08:00
<insert id="insertBmUnit" parameterType="com.bonus.material.basic.domain.BmUnit" useGeneratedKeys="true" keyProperty="unitId">
insert into bm_unit
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="unitName != null and unitName != ''">unit_name,</if>
<if test="status != null">status,</if>
<if test="typeId != null">type_id,</if>
<if test="linkMan != null">link_man,</if>
<if test="telphone != null">telphone,</if>
<if test="deptId != null">dept_id,</if>
2024-10-14 13:52:48 +08:00
del_flag,
2024-09-26 16:15:51 +08:00
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="unitName != null and unitName != ''">#{unitName},</if>
<if test="status != null">#{status},</if>
<if test="typeId != null">#{typeId},</if>
<if test="linkMan != null">#{linkMan},</if>
<if test="telphone != null">#{telphone},</if>
<if test="deptId != null">#{deptId},</if>
2024-10-14 13:52:48 +08:00
0,
2024-09-26 16:15:51 +08:00
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateBmUnit" parameterType="com.bonus.material.basic.domain.BmUnit">
update bm_unit
<trim prefix="SET" suffixOverrides=",">
<if test="unitName != null and unitName != ''">unit_name = #{unitName},</if>
<if test="status != null">status = #{status},</if>
<if test="typeId != null">type_id = #{typeId},</if>
<if test="linkMan != null">link_man = #{linkMan},</if>
<if test="telphone != null">telphone = #{telphone},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where unit_id = #{unitId}
</update>
<delete id="deleteBmUnitByUnitId" parameterType="Long">
2024-10-14 13:52:48 +08:00
update bm_unit set del_flag = 2 where unit_id = #{unitId}
2024-09-26 16:15:51 +08:00
</delete>
<delete id="deleteBmUnitByUnitIds" parameterType="String">
2024-10-14 13:52:48 +08:00
update bm_unit set del_flag = 2 where unit_id in
2024-09-26 16:15:51 +08:00
<foreach item="unitId" collection="array" open="(" separator="," close=")">
#{unitId}
</foreach>
</delete>
</mapper>