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