devicesmgt/sgzb-modules/sgzb-machine/src/main/resources/mapper.machine/MaLabelBindMapper.xml

94 lines
3.5 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.bonus.sgzb.machine.mapper.MaLabelBindMapper">
<sql id="selectMaLabelVo">
select mml.label_id, mml.label_type, mml.label_code, mml.bind_time, mml.binder, mml.is_bind, mt.type_name
from ma_machine_label mml
left join ma_type mt on mml.type_id = mt.type_id
</sql>
<insert id="insertLabel">
insert into ma_machine_label(
<if test="labelId != null and labelId != 0">label_id,</if>
<if test="labelType != null and labelType != ''">label_type,</if>
<if test="labelCode != null and labelCode != 0">label_code,</if>
<if test="binder != null and binder != ''">binder,</if>
<if test="isBind != null and isBind != ''">is_bind,</if>
)values(
<if test="labelId != null and labelId != 0">#{labelId},</if>
<if test="labelType != null and labelType != ''">#{labelType},</if>
<if test="labelCode != null and labelCode != 0">#{labelCode},</if>
<if test="binder != null and binder != ''">#{binder},</if>
<if test="isBind != null and isBind != ''">#{isBind},</if>
)
</insert>
<insert id="insertType">
insert into ma_type(
<if test="typeName != null and typeName != ''">type_name,</if>
)values(
<if test="typeName != null and typeName != ''">#{typeName},</if>
)
</insert>
<update id="updateBind">
update ma_machine_label
set is_bind = '0'
where label_id in
<foreach collection="labelIds" item="labelId" open="(" separator="," close=")">
#{labelId}
</foreach>
</update>
<update id="updateNoBind">
update ma_machine_label set is_bind = '1' where label_id = #{labelId}
</update>
<update id="updateMaLabel">
update ma_machine_label
<set>
<if test="labelType != null and labelType != ''">label_type = #{labelType},</if>
<if test="labelCode != null and labelCode != ''">label_code = #{labelCode},</if>
<if test="binder != null and binder != ''">binder = #{binder},</if>
<if test="isBind != null and isBind != ''">is_bind = #{isBind},</if>
<if test="companyId != null and companyId != ''">company_id = #{companyId},</if>
</set>
where label_id = #{labelId}
</update>
<update id="updateMaType">
update ma_type
<set>
<if test="typeName != null and typeName != ''">type_name = #{typeName},</if>
</set>
where type_id = #{typeId}
</update>
<select id="selectUserList" resultType="com.bonus.sgzb.machine.vo.DeptUser">
select sd.dept_name, su.user_name from sys_user su
left join sys_dept sd on su.dept_id = sd.dept_id
<where>
<if test="userName != null and userName != ''">
AND user_name like concat('%', #{userName}, '%')
</if>
</where>
</select>
<select id="selectMaLabelList" resultType="com.bonus.sgzb.machine.vo.MaLabelBindVO">
<include refid="selectMaLabelVo"/>
<where>
<if test="typeName != null and typeName != ''">
AND mt.type_name = #{typeName}
</if>
</where>
</select>
<select id="checkLabelNameUnique" resultType="com.bonus.sgzb.machine.vo.MaLabelBindVO">
<include refid="selectMaLabelVo"/> where mt.type_name = #{typeName}
</select>
</mapper>