Commit b50c0c2d authored by duanruiming's avatar duanruiming

[update] 优化持久层

parent 778fdec2
......@@ -15,7 +15,7 @@ import java.util.List;
* @desc CrossInfoMapper
*/
@Repository
public interface CrossInfoMapper extends BaseMapper<TBaseCrossInfo> {
public interface BaseCrossInfoMapper extends BaseMapper<TBaseCrossInfo> {
/**
* 查询路口列表信息
......
package net.wanji.databus.dao.mapper;
import net.wanji.databus.po.BaseCrossLightsPO;
import org.apache.ibatis.annotations.Param;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
/**
* 灯组基础信息;(t_base_cross_lights)表数据库访问层
* @author : hanbing
* @date : 2023-1-3
*/
@Repository
@Primary
public interface BaseCrossLightsMapper {
void deleteByCrossId(@Param("crossId") String crossId);
void insertBatch(@Param("entities") Collection<BaseCrossLightsPO> entities);
BaseCrossLightsPO selectByCrossIdAndLedNum(@Param("crossId") String crossId, @Param("ledNum") String ledNum);
List<BaseCrossLightsPO> selectByCrossId(@Param("crossId") String crossId);
List<BaseCrossLightsPO> selectByCrossIdAndDir(@Param("crossId") String crossId, @Param("dir") Integer dir);
BaseCrossLightsPO selectById(@Param("id") Integer id);
List<BaseCrossLightsPO> selectByLightsIdsAndDir(@Param("lightsIds") List<Integer> lightsIds,
@Param("dir") Integer dir);
void update(BaseCrossLightsPO baseCrossLightsPO);
void insertOne(BaseCrossLightsPO baseCrossLightsPO);
List<BaseCrossLightsPO> listCrossLightsPO(@Param("entity") BaseCrossLightsPO entity);
List<BaseCrossLightsPO> listCrossLights();
void deleteOne(@Param("crossId") String crossId,
@Param("elementId") String elementId);
}
package net.wanji.databus.dao.mapper;
import net.wanji.databus.po.CrossLightsPO;
import net.wanji.databus.dao.entity.CrossLightsPO;
import org.apache.ibatis.annotations.Param;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
/**
* 灯组基础信息;(t_base_cross_lights)表数据库访问层
* @author : hanbing
* @date : 2023-1-3
* @author Kent HAN
* @date 2022/11/18 14:10
*/
@Repository
@Primary
public interface CrossLightsMapper {
void deleteByCrossId(@Param("crossId") String crossId);
void insertBatch(@Param("entities") Collection<CrossLightsPO> entities);
CrossLightsPO selectByCrossIdAndLedNum(@Param("crossId") String crossId, @Param("ledNum") String ledNum);
List<CrossLightsPO> selectByCrossId(@Param("crossId") String crossId);
List<CrossLightsPO> selectByCrossIdAndDir(@Param("crossId") String crossId, @Param("dir") Integer dir);
CrossLightsPO selectById(@Param("id") Integer id);
List<CrossLightsPO> selectByLightsIdsAndDir(@Param("lightsIds") List<Integer> lightsIds,
@Param("dir") Integer dir);
void update(CrossLightsPO crossLightsPO);
void deleteOne(@Param("crossId") String crossId,
@Param("elementId") String elementId);
void insertOne(CrossLightsPO crossLightsPO);
List<CrossLightsPO> listCrossLightsPO(@Param("entity") CrossLightsPO entity);
List<CrossLightsPO> listCrossLights();
List<CrossLightsPO> selectByCrossId(@Param("crossId") String crossId);
void deleteOne(@Param("crossId") String crossId,
@Param("elementId") String elementId);
void deleteByCrossId(String crossId);
}
......@@ -10,7 +10,7 @@ import java.util.Date;
* @date 2023/1/3 9:40
*/
@Data
public class CrossLightsPO {
public class BaseCrossLightsPO {
/** 灯组ID */
@ApiModelProperty(name = "灯组ID",notes = "")
private Integer id ;
......
<?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="net.wanji.databus.dao.mapper.CrossInfoMapper">
<mapper namespace="net.wanji.databus.dao.mapper.BaseCrossInfoMapper">
<resultMap id="BaseResultMap" type="net.wanji.databus.po.TBaseCrossInfo">
<id column="id" property="id" jdbcType="CHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
......
<?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="net.wanji.databus.dao.mapper.BaseCrossLightsMapper">
<!-- 通用查询映射结果 -->
<resultMap type="net.wanji.databus.po.BaseCrossLightsPO" id="BaseResultMap">
<result property="id" column="id"/>
<result property="lightsNo" column="lights_no"/>
<result property="type" column="type"/>
<result property="dir" column="dir"/>
<result property="sort" column="sort"/>
<result property="crossId" column="cross_id"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<sql id="Base_Column_List">
id, lights_no,type, dir, sort, cross_id, gmt_create, gmt_modified
</sql>
<select id="listCrossLightsPO" parameterType="net.wanji.databus.po.BaseCrossLightsPO" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"></include>
from t_base_cross_lights
<where>
<if test="entity.crossId != null and entity.crossId != ''">
cross_id = #{entity.crossId}
</if>
</where>
</select>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into t_base_cross_lights(lights_no,type,dir,sort,cross_id)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.lightsNo},#{entity.type},#{entity.dir},#{entity.sort},#{entity.crossId})
</foreach>
</insert>
<insert id="insertOne" keyProperty="id" useGeneratedKeys="true">
insert into t_base_cross_lights(lights_no, type, dir, sort, cross_id)
values (#{lightsNo}, #{type}, #{dir}, #{sort}, #{crossId})
</insert>
<update id="update">
update t_base_cross_lights
<set>
<if test="type != null and type != ''">
type = #{type},
</if>
<if test="dir != null and dir != ''">
dir = #{dir},
</if>
<if test="sort != null and sort != ''">
sort = #{sort},
</if>
</set>
where cross_id = #{crossId} and lights_no=#{lightsNo}
</update>
<delete id="deleteByCrossId">
delete
from t_base_cross_lights
where cross_id = #{crossId}
</delete>
<delete id="deleteOne">
delete from t_cross_lights
where cross_id = #{crossId} and name = #{elementId}
</delete>
<select id="selectByCrossIdAndLedNum" resultMap="BaseResultMap">
select id,
lights_no,
type,
dir,
sort,
cross_id,
gmt_create,
gmt_modified
from t_base_cross_lights
where cross_id = #{crossId}
and lights_no = #{ledNum}
</select>
<select id="selectByCrossId" resultMap="BaseResultMap">
select id,
lights_no,
type,
dir,
sort,
cross_id,
gmt_create,
gmt_modified
from t_base_cross_lights
where cross_id = #{crossId}
</select>
<select id="selectByCrossIdAndDir" resultMap="BaseResultMap">
select id,
lights_no,
type,
dir,
sort,
cross_id,
gmt_create,
gmt_modified
from t_base_cross_lights
where cross_id = #{crossId}
and dir = #{dir}
</select>
<select id="selectById" resultMap="BaseResultMap">
select id,
lights_no,
type,
dir,
sort,
cross_id,
gmt_create,
gmt_modified
from t_base_cross_lights
where id = #{id}
</select>
<select id="selectByLightsIdsAndDir" resultMap="BaseResultMap">
select
id,lights_no,type,dir,sort,cross_id,gmt_create,gmt_modified
from t_base_cross_lights
where dir = #{dir} and id in
<foreach collection="lightsIds" item="lightsId" separator="," open="(" close=")">
#{lightsId}
</foreach>
</select>
<select id="listCrossLights" resultType="net.wanji.databus.po.BaseCrossLightsPO">
select
id
,lights_no
,type
,dir
,sort
,cross_id
from
t_base_cross_lights
where 1=1
<if test="crossId != null and crossId != ''">
and cross_id = #{crossId}
</if>
</select>
</mapper>
<?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="net.wanji.databus.dao.mapper.CrossLightsMapper">
<!-- 通用查询映射结果 -->
<resultMap type="net.wanji.databus.po.CrossLightsPO" id="BaseResultMap">
<resultMap type="net.wanji.databus.dao.entity.CrossLightsPO" id="BaseResultMap">
<result property="id" column="id"/>
<result property="lightsNo" column="lights_no"/>
<result property="name" column="name"/>
<result property="type" column="type"/>
<result property="dir" column="dir"/>
<result property="sort" column="sort"/>
<result property="turn" column="turn"/>
<result property="crossId" column="cross_id"/>
<result property="inOutType" column="in_out_type"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<sql id="Base_Column_List">
id, lights_no,type, dir, sort, cross_id, gmt_create, gmt_modified
</sql>
<select id="listCrossLightsPO" parameterType="net.wanji.databus.po.CrossLightsPO" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"></include>
from t_base_cross_lights
<where>
<if test="entity.crossId != null and entity.crossId != ''">
cross_id = #{entity.crossId}
</if>
</where>
</select>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into t_base_cross_lights(lights_no,type,dir,sort,cross_id)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.lightsNo},#{entity.type},#{entity.dir},#{entity.sort},#{entity.crossId})
</foreach>
</insert>
<insert id="insertOne" keyProperty="id" useGeneratedKeys="true">
insert into t_base_cross_lights(lights_no, type, dir, sort, cross_id)
values (#{lightsNo}, #{type}, #{dir}, #{sort}, #{crossId})
insert into t_cross_lights(lights_no,name,type,dir,turn,cross_id,in_out_type)
values (#{lightsNo},#{name},#{type},#{dir},#{turn},#{crossId},#{inOutType})
</insert>
<update id="update">
update t_base_cross_lights
<set>
<if test="type != null and type != ''">
type = #{type},
</if>
<if test="dir != null and dir != ''">
dir = #{dir},
</if>
<if test="sort != null and sort != ''">
sort = #{sort},
</if>
</set>
where cross_id = #{crossId} and lights_no=#{lightsNo}
</update>
<delete id="deleteByCrossId">
delete
from t_base_cross_lights
where cross_id = #{crossId}
</delete>
<delete id="deleteOne">
delete from t_cross_lights
where cross_id = #{crossId} and name = #{elementId}
</delete>
<select id="selectByCrossIdAndLedNum" resultMap="BaseResultMap">
select id,
lights_no,
type,
dir,
sort,
cross_id,
gmt_create,
gmt_modified
from t_base_cross_lights
<delete id="deleteByCrossId">
delete from t_cross_lights
where cross_id = #{crossId}
and lights_no = #{ledNum}
</select>
</delete>
<select id="selectByCrossId" resultMap="BaseResultMap">
select id,
lights_no,
type,
dir,
sort,
cross_id,
gmt_create,
gmt_modified
from t_base_cross_lights
where cross_id = #{crossId}
</select>
<select id="selectByCrossIdAndDir" resultMap="BaseResultMap">
select id,
lights_no,
type,
dir,
sort,
cross_id,
gmt_create,
gmt_modified
from t_base_cross_lights
where cross_id = #{crossId}
and dir = #{dir}
</select>
<select id="selectById" resultMap="BaseResultMap">
select id,
lights_no,
type,
dir,
sort,
cross_id,
gmt_create,
gmt_modified
from t_base_cross_lights
where id = #{id}
</select>
<select id="selectByLightsIdsAndDir" resultMap="BaseResultMap">
select
id,lights_no,type,dir,sort,cross_id,gmt_create,gmt_modified
from t_base_cross_lights
where dir = #{dir} and id in
<foreach collection="lightsIds" item="lightsId" separator="," open="(" close=")">
#{lightsId}
</foreach>
id,lights_no,name,type,dir,turn,cross_id,in_out_type,gmt_create,gmt_modified
from t_cross_lights
where cross_id = #{crossId}
</select>
<select id="listCrossLights" resultType="net.wanji.databus.po.CrossLightsPO">
select
id
,lights_no
,type
,dir
,sort
,cross_id
from
t_base_cross_lights
where 1=1
<if test="crossId != null and crossId != ''">
and cross_id = #{crossId}
</if>
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment