gz_digital_signage/src/main/resources/mappers/basic/TbProjectMapper.xml

89 lines
4.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.bonus.digitalSignage.basic.dao.TbProjectMapper">
<insert id="addTbProject">
insert into tb_project
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="departId != null ">depart_id,</if>
<if test="proName != null ">pro_name,</if>
<if test="voltageLevel != null ">voltage_level,</if>
<if test="lineLength != null ">line_length,</if>
<if test="planStartTime != null">plan_start_time,</if>
<if test="planEndTime != null ">plan_end_time,</if>
<if test="lon != null ">lon,</if>
<if test="lat != null ">lat,</if>
<if test="address != null ">address,</if>
<if test="proStatus != null ">pro_status,</if>
<if test="createTime != null">create_time,</if>
<if test="createUser != null ">create_user,</if>
is_active
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="departId != null ">#{departId},</if>
<if test="proName != null ">#{proName},</if>
<if test="voltageLevel != null ">#{voltageLevel},</if>
<if test="lineLength != null ">#{lineLength},</if>
<if test="planStartTime != null ">#{planStartTime},</if>
<if test="planEndTime != null ">#{planEndTime},</if>
<if test="lon != null ">#{lon},</if>
<if test="lat != null ">#{lat},</if>
<if test="address != null ">#{address},</if>
<if test="proStatus != null ">#{proStatus},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="createUser != null ">#{createUser},</if>
1
</trim>
</insert>
<update id="UpdateTbProject">
update tb_project
<trim prefix="SET" suffixOverrides=",">
<if test="departId != null">depart_id = #{departId},</if>
<if test="proName != null">pro_name = #{proName},</if>
<if test="voltageLevel != null">voltage_level = #{voltageLevel},</if>
<if test="lineLength != null">line_length = #{lineLength},</if>
<if test="planStartTime != null">plan_start_time = #{planStartTime},</if>
<if test="planEndTime != null">plan_end_time = #{planEndTime},</if>
<if test="lon != null">lon = #{lon},</if>
<if test="lat != null">lat = #{lat},</if>
<if test="address != null">address = #{address},</if>
<if test="proStatus != null">pro_status = #{proStatus},</if>
<if test="updateUserId != null">update_user_id = #{updateUserId},</if>
update_time = now()
</trim>
where id = #{id}
</update>
<select id="getTbProjectList" resultType="com.bonus.digitalSignage.basic.vo.TbProjectVo">
select tp.id as id,tp.pro_name as proName,A.dict_name as voltageLevel,tp.line_length as lineLength,
tp.plan_start_time as planStartTime,tp.plan_end_time as planEndTime,tp.lon as lon,tp.lat as lat,
tp.address as address,B.dict_name as pro_status
from tb_project tp
LEFT JOIN (
SELECT sd.dict_value,sd.dict_name
FROM sys_distinct sd
LEFT JOIN sys_distinct sd2 ON sd.p_id = sd2.id
WHERE sd2.dict_code = 'voltage_level' AND sd.del_flag = 0
) A ON A.dict_value = tp.voltage_level
LEFT JOIN (
SELECT sd.dict_value,sd.dict_name
FROM sys_distinct sd
LEFT JOIN sys_distinct sd2 ON sd.p_id = sd2.id
WHERE sd2.dict_code = 'pro_status' AND sd.del_flag = 0
) B ON B.dict_value = tp.voltage_level
where tp.is_active = '1'
</select>
<select id="getTbProjectById" resultType="com.bonus.digitalSignage.basic.vo.TbProjectVo">
select tp.id as id,tp.pro_name as proName,tp.voltage_level as voltageLevel,tp.line_length as lineLength,
tp.plan_start_time as planStartTime,tp.plan_end_time as planEndTime,tp.lon as lon,tp.lat as lat,
tp.address as address,B.pro_status as pro_status
from tb_project tp where id = #{id}
</select>
<select id="getTbProjectByProName" resultType="com.bonus.digitalSignage.basic.vo.TbProjectVo">
select tp.id as id,tp.pro_name as proName,tp.voltage_level as voltageLevel,tp.line_length as lineLength,
tp.plan_start_time as planStartTime,tp.plan_end_time as planEndTime,tp.lon as lon,tp.lat as lat,
tp.address as address,B.pro_status as pro_status
from tb_project tp where pro_name = #{proName} and is_active ='1'
</select>
</mapper>