修复PageHelper分页问题,Mapper连接查询改为子查询
This commit is contained in:
parent
d1a07af916
commit
c147cfd71a
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.template.mapper;
|
||||
|
||||
import com.ruoyi.template.domain.TmplSwitchPort;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -28,6 +29,8 @@ public interface TmplSwitchPortMapper {
|
|||
*/
|
||||
public TmplSwitchPort selectBySwitchIdAndPortType(Integer switchId, Integer switchPortType);
|
||||
|
||||
public TmplSwitchPort selectBySwitchId(@Param("switchId") Integer switchId);
|
||||
|
||||
/**
|
||||
* 查询交换机端口类型列表
|
||||
*
|
||||
|
|
|
|||
|
|
@ -4,40 +4,26 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.template.mapper.TmplSwitchMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.template.domain.TmplSwitch" id="TmplSwitchResult">
|
||||
<resultMap type="com.ruoyi.template.domain.TmplSwitch"
|
||||
id="TmplSwitchResult">
|
||||
<result property="switchId" column="switch_id"/>
|
||||
<result property="switchBrand" column="switch_brand"/>
|
||||
<result property="switchType" column="switch_type"/>
|
||||
<result property="powerNum" column="power_num"/>
|
||||
|
||||
<collection property="switchPorts" ofType="com.ruoyi.template.domain.TmplSwitchPort" column="switch_id">
|
||||
<id column="pid" property="switchPortId"/><!-- 这里的column对应的是下面查询的别名,而不是表字段名 -->
|
||||
<result column="ptype" property="switchPortType"/><!-- property对应JavaBean中的属性名 -->
|
||||
<result column="pnum" property="switchPortNum"/>
|
||||
<collection property="switchPorts" column="switch_id"
|
||||
select="com.ruoyi.template.mapper.TmplSwitchPortMapper.selectBySwitchId">
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<!-- <sql id="selectTmplSwitchVo">-->
|
||||
<!-- select switch_id, switch_brand, switch_type, power_num from tmpl_switch-->
|
||||
<!-- </sql>-->
|
||||
<sql id="selectTmplSwitchVo">
|
||||
select
|
||||
s.switch_id,
|
||||
s.switch_brand,
|
||||
s.switch_type,
|
||||
s.power_num,
|
||||
p.switch_port_id as pid,
|
||||
p.switch_port_type as ptype,
|
||||
p.switch_port_num as pnum
|
||||
from
|
||||
tmpl_switch s
|
||||
left join
|
||||
tmpl_switch_port p
|
||||
on
|
||||
s.switch_id = p.switch_id
|
||||
</sql>
|
||||
select switch_id, switch_brand, switch_type, power_num from
|
||||
tmpl_switch
|
||||
</sql>
|
||||
|
||||
<select id="selectTmplSwitchList" parameterType="com.ruoyi.template.domain.TmplSwitch" resultMap="TmplSwitchResult">
|
||||
<select id="selectTmplSwitchList"
|
||||
parameterType="com.ruoyi.template.domain.TmplSwitch"
|
||||
resultMap="TmplSwitchResult">
|
||||
<include refid="selectTmplSwitchVo"/>
|
||||
<where>
|
||||
<if test="switchId != null ">and switch_id = #{switchId}</if>
|
||||
|
|
@ -46,18 +32,16 @@
|
|||
<if test="powerNum != null ">and power_num = #{powerNum}</if>
|
||||
</where>
|
||||
</select>
|
||||
<!-- <select id="selectTmplSwitchList_COUNT" resultType="Long">-->
|
||||
<!-- select count(0) from tmpl_switch-->
|
||||
<!-- </select>-->
|
||||
|
||||
|
||||
<select id="selectTmplSwitchById" parameterType="Integer" resultMap="TmplSwitchResult">
|
||||
<select id="selectTmplSwitchById" parameterType="Integer"
|
||||
resultMap="TmplSwitchResult">
|
||||
<include refid="selectTmplSwitchVo"/>
|
||||
where s.switch_id = #{switchId}
|
||||
where switch_id = #{switchId}
|
||||
</select>
|
||||
|
||||
<insert id="insertTmplSwitch" parameterType="com.ruoyi.template.domain.TmplSwitch" useGeneratedKeys="true"
|
||||
keyProperty="switchId">
|
||||
<insert id="insertTmplSwitch"
|
||||
parameterType="com.ruoyi.template.domain.TmplSwitch"
|
||||
useGeneratedKeys="true" keyProperty="switchId">
|
||||
insert into tmpl_switch
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="switchBrand != null and switchBrand != '' ">switch_brand,</if>
|
||||
|
|
@ -71,7 +55,8 @@
|
|||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateTmplSwitch" parameterType="com.ruoyi.template.domain.TmplSwitch">
|
||||
<update id="updateTmplSwitch"
|
||||
parameterType="com.ruoyi.template.domain.TmplSwitch">
|
||||
update tmpl_switch
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="switchBrand != null and switchBrand != '' ">switch_brand = #{switchBrand},</if>
|
||||
|
|
@ -82,12 +67,14 @@
|
|||
</update>
|
||||
|
||||
<delete id="deleteTmplSwitchById" parameterType="Integer">
|
||||
delete from tmpl_switch where switch_id = #{switchId}
|
||||
</delete>
|
||||
delete from
|
||||
tmpl_switch where switch_id = #{switchId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteTmplSwitchByIds" parameterType="String">
|
||||
delete from tmpl_switch where switch_id in
|
||||
<foreach item="switchId" collection="array" open="(" separator="," close=")">
|
||||
<foreach item="switchId" collection="array" open="("
|
||||
separator="," close=")">
|
||||
#{switchId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
|
|
|||
|
|
@ -2,88 +2,113 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.template.mapper.TmplSwitchPortMapper">
|
||||
<mapper
|
||||
namespace="com.ruoyi.template.mapper.TmplSwitchPortMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.template.domain.TmplSwitchPort" id="TmplSwitchPortResult">
|
||||
<result property="switchPortId" column="switch_port_id"/>
|
||||
<result property="switchId" column="switch_id"/>
|
||||
<result property="switchPortType" column="switch_port_type"/>
|
||||
<result property="switchPortNum" column="switch_port_num"/>
|
||||
</resultMap>
|
||||
<resultMap type="com.ruoyi.template.domain.TmplSwitchPort"
|
||||
id="TmplSwitchPortResult">
|
||||
<result property="switchPortId" column="switch_port_id" />
|
||||
<result property="switchId" column="switch_id" />
|
||||
<result property="switchPortType" column="switch_port_type" />
|
||||
<result property="switchPortNum" column="switch_port_num" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectTmplSwitchPortVo">
|
||||
select switch_port_id, switch_id, switch_port_type, switch_port_num from tmpl_switch_port
|
||||
</sql>
|
||||
<sql id="selectTmplSwitchPortVo">
|
||||
select switch_port_id, switch_id, switch_port_type,
|
||||
switch_port_num from
|
||||
tmpl_switch_port
|
||||
</sql>
|
||||
|
||||
<select id="selectTmplSwitchPortList" parameterType="com.ruoyi.template.domain.TmplSwitchPort"
|
||||
resultMap="TmplSwitchPortResult">
|
||||
<include refid="selectTmplSwitchPortVo"/>
|
||||
<where>
|
||||
<if test="switchPortId != null ">and switch_port_id = #{switchPortId}</if>
|
||||
<if test="switchId != null ">and switch_id = #{switchId}</if>
|
||||
<if test="switchPortType != null ">and switch_port_type = #{switchPortType}</if>
|
||||
<if test="switchPortNum != null ">and switch_port_num = #{switchPortNum}</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectBySwitchId" parameterType="java.lang.Integer"
|
||||
resultMap="TmplSwitchPortResult">
|
||||
<include refid="selectTmplSwitchPortVo" />
|
||||
where switch_id=#{switchId};
|
||||
</select>
|
||||
|
||||
<select id="selectTmplSwitchPortById" parameterType="Integer" resultMap="TmplSwitchPortResult">
|
||||
<include refid="selectTmplSwitchPortVo"/>
|
||||
where switch_port_id = #{switchPortId}
|
||||
</select>
|
||||
<select id="selectTmplSwitchPortList"
|
||||
parameterType="com.ruoyi.template.domain.TmplSwitchPort"
|
||||
resultMap="TmplSwitchPortResult">
|
||||
<include refid="selectTmplSwitchPortVo" />
|
||||
<where>
|
||||
<if test="switchPortId != null ">and switch_port_id = #{switchPortId}</if>
|
||||
<if test="switchId != null ">and switch_id = #{switchId}</if>
|
||||
<if test="switchPortType != null ">and switch_port_type = #{switchPortType}</if>
|
||||
<if test="switchPortNum != null ">and switch_port_num = #{switchPortNum}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectBySwitchIdAndPortType" parameterType="Integer" resultMap="TmplSwitchPortResult">
|
||||
<include refid="selectTmplSwitchPortVo"/>
|
||||
where switch_id = #{switchPortId}
|
||||
and switch_port_type = #{switchPortType}
|
||||
</select>
|
||||
<select id="selectTmplSwitchPortById" parameterType="Integer"
|
||||
resultMap="TmplSwitchPortResult">
|
||||
<include refid="selectTmplSwitchPortVo" />
|
||||
-- where switch_port_id = #{switchPortId}
|
||||
<where>
|
||||
<if test="switchPortId != null ">and switch_port_id = #{switchPortId}</if>
|
||||
<if test="switchId != null ">and switch_id = #{switchId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectBySwitchIdAndPortType" parameterType="Integer"
|
||||
resultMap="TmplSwitchPortResult">
|
||||
<include refid="selectTmplSwitchPortVo" />
|
||||
<if test="switchId != null ">and switch_id = #{switchId}</if>
|
||||
<if test="switchPortType != null ">and switch_port_type = #{switchPortType}</if>
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertTmplSwitchPort" parameterType="com.ruoyi.template.domain.TmplSwitchPort">
|
||||
insert into tmpl_switch_port
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="switchPortId != null ">switch_port_id,</if>
|
||||
<if test="switchId != null ">switch_id,</if>
|
||||
<if test="switchPortType != null ">switch_port_type,</if>
|
||||
<if test="switchPortNum != null ">switch_port_num,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="switchPortId != null ">#{switchPortId},</if>
|
||||
<if test="switchId != null ">#{switchId},</if>
|
||||
<if test="switchPortType != null ">#{switchPortType},</if>
|
||||
<if test="switchPortNum != null ">#{switchPortNum},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<insert id="insertTmplSwitchPort"
|
||||
parameterType="com.ruoyi.template.domain.TmplSwitchPort">
|
||||
insert into tmpl_switch_port
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="switchPortId != null ">switch_port_id,</if>
|
||||
<if test="switchId != null ">switch_id,</if>
|
||||
<if test="switchPortType != null ">switch_port_type,</if>
|
||||
<if test="switchPortNum != null ">switch_port_num,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="switchPortId != null ">#{switchPortId},</if>
|
||||
<if test="switchId != null ">#{switchId},</if>
|
||||
<if test="switchPortType != null ">#{switchPortType},</if>
|
||||
<if test="switchPortNum != null ">#{switchPortNum},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="batchTmplSwitchPort">
|
||||
insert into tmpl_switch_port(switch_id, switch_port_type,switch_port_num) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.switchId},#{item.switchPortType},#{item.switchPortNum})
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="batchTmplSwitchPort">
|
||||
insert into tmpl_switch_port(switch_id,
|
||||
switch_port_type,switch_port_num) values
|
||||
<foreach item="item" index="index" collection="list"
|
||||
separator=",">
|
||||
(#{item.switchId},#{item.switchPortType},#{item.switchPortNum})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateTmplSwitchPort" parameterType="com.ruoyi.template.domain.TmplSwitchPort">
|
||||
update tmpl_switch_port
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="switchId != null ">switch_id = #{switchId},</if>
|
||||
<if test="switchPortType != null ">switch_port_type = #{switchPortType},</if>
|
||||
<if test="switchPortNum != null ">switch_port_num = #{switchPortNum},</if>
|
||||
</trim>
|
||||
where switch_port_id = #{switchPortId}
|
||||
</update>
|
||||
<update id="updateTmplSwitchPort"
|
||||
parameterType="com.ruoyi.template.domain.TmplSwitchPort">
|
||||
update tmpl_switch_port
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="switchId != null ">switch_id = #{switchId},</if>
|
||||
<if test="switchPortType != null ">switch_port_type = #{switchPortType},</if>
|
||||
<if test="switchPortNum != null ">switch_port_num = #{switchPortNum},</if>
|
||||
</trim>
|
||||
where switch_port_id = #{switchPortId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteTmplSwitchPortById" parameterType="Integer">
|
||||
delete from tmpl_switch_port where switch_port_id = #{switchPortId}
|
||||
</delete>
|
||||
<delete id="deleteTmplSwitchPortById" parameterType="Integer">
|
||||
delete from
|
||||
tmpl_switch_port where switch_port_id = #{switchPortId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteTmplSwitchPortBySwitchId" parameterType="Integer">
|
||||
delete from tmpl_switch_port where switch_id = #{switchId}
|
||||
</delete>
|
||||
<delete id="deleteTmplSwitchPortBySwitchId"
|
||||
parameterType="Integer">
|
||||
delete from tmpl_switch_port where switch_id =
|
||||
#{switchId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteTmplSwitchPortByIds" parameterType="String">
|
||||
delete from tmpl_switch_port where switch_port_id in
|
||||
<foreach item="switchPortId" collection="array" open="(" separator="," close=")">
|
||||
#{switchPortId}
|
||||
</foreach>
|
||||
</delete>
|
||||
<delete id="deleteTmplSwitchPortByIds" parameterType="String">
|
||||
delete from tmpl_switch_port where switch_port_id in
|
||||
<foreach item="switchPortId" collection="array" open="("
|
||||
separator="," close=")">
|
||||
#{switchPortId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue