BaseEntity添加ForeignKeyInfo参数供请求手动解析外键

This commit is contained in:
tangpeng 2019-06-12 21:13:56 +08:00
parent 46c36f2aaf
commit acdf998880
9 changed files with 605 additions and 478 deletions

View File

@ -1,23 +1,20 @@
package com.ruoyi.web.controller.template; package com.ruoyi.web.controller.template;
import java.util.List; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.template.domain.TmplSwitch;
import com.ruoyi.template.service.ITmplSwitchService;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import java.util.List;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.template.domain.TmplSwitch;
import com.ruoyi.template.service.ITmplSwitchService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
/** /**
* 交换机模板 信息操作处理 * 交换机模板 信息操作处理
@ -27,8 +24,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
*/ */
@Controller @Controller
@RequestMapping("/template/tmplSwitch") @RequestMapping("/template/tmplSwitch")
public class TmplSwitchController extends BaseController public class TmplSwitchController extends BaseController {
{
private String prefix = "template/tmplSwitch"; private String prefix = "template/tmplSwitch";
@Autowired @Autowired
@ -36,8 +32,7 @@ public class TmplSwitchController extends BaseController
@RequiresPermissions("template:tmplSwitch:view") @RequiresPermissions("template:tmplSwitch:view")
@GetMapping() @GetMapping()
public String tmplSwitch() public String tmplSwitch() {
{
return prefix + "/tmplSwitch"; return prefix + "/tmplSwitch";
} }
@ -47,8 +42,7 @@ public class TmplSwitchController extends BaseController
@RequiresPermissions("template:tmplSwitch:list") @RequiresPermissions("template:tmplSwitch:list")
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public TableDataInfo list(TmplSwitch tmplSwitch) public TableDataInfo list(TmplSwitch tmplSwitch) {
{
startPage(); startPage();
List<TmplSwitch> list = tmplSwitchService.selectTmplSwitchList(tmplSwitch); List<TmplSwitch> list = tmplSwitchService.selectTmplSwitchList(tmplSwitch);
return getDataTable(list); return getDataTable(list);
@ -61,8 +55,7 @@ public class TmplSwitchController extends BaseController
@RequiresPermissions("template:tmplSwitch:export") @RequiresPermissions("template:tmplSwitch:export")
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public AjaxResult export(TmplSwitch tmplSwitch) public AjaxResult export(TmplSwitch tmplSwitch) {
{
List<TmplSwitch> list = tmplSwitchService.selectTmplSwitchList(tmplSwitch); List<TmplSwitch> list = tmplSwitchService.selectTmplSwitchList(tmplSwitch);
ExcelUtil<TmplSwitch> util = new ExcelUtil<TmplSwitch>(TmplSwitch.class); ExcelUtil<TmplSwitch> util = new ExcelUtil<TmplSwitch>(TmplSwitch.class);
return util.exportExcel(list, "tmplSwitch"); return util.exportExcel(list, "tmplSwitch");
@ -72,8 +65,7 @@ public class TmplSwitchController extends BaseController
* 新增交换机模板 * 新增交换机模板
*/ */
@GetMapping("/add") @GetMapping("/add")
public String add() public String add() {
{
return prefix + "/add"; return prefix + "/add";
} }
@ -84,8 +76,7 @@ public class TmplSwitchController extends BaseController
@Log(title = "交换机模板", businessType = BusinessType.INSERT) @Log(title = "交换机模板", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(TmplSwitch tmplSwitch) public AjaxResult addSave(TmplSwitch tmplSwitch) {
{
return toAjax(tmplSwitchService.insertTmplSwitch(tmplSwitch)); return toAjax(tmplSwitchService.insertTmplSwitch(tmplSwitch));
} }
@ -93,8 +84,7 @@ public class TmplSwitchController extends BaseController
* 修改交换机模板 * 修改交换机模板
*/ */
@GetMapping("/edit/{switchId}") @GetMapping("/edit/{switchId}")
public String edit(@PathVariable("switchId") Integer switchId, ModelMap mmap) public String edit(@PathVariable("switchId") Integer switchId, ModelMap mmap) {
{
TmplSwitch tmplSwitch = tmplSwitchService.selectTmplSwitchById(switchId); TmplSwitch tmplSwitch = tmplSwitchService.selectTmplSwitchById(switchId);
mmap.put("tmplSwitch", tmplSwitch); mmap.put("tmplSwitch", tmplSwitch);
return prefix + "/edit"; return prefix + "/edit";
@ -107,8 +97,7 @@ public class TmplSwitchController extends BaseController
@Log(title = "交换机模板", businessType = BusinessType.UPDATE) @Log(title = "交换机模板", businessType = BusinessType.UPDATE)
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(TmplSwitch tmplSwitch) public AjaxResult editSave(TmplSwitch tmplSwitch) {
{
return toAjax(tmplSwitchService.updateTmplSwitch(tmplSwitch)); return toAjax(tmplSwitchService.updateTmplSwitch(tmplSwitch));
} }
@ -117,10 +106,9 @@ public class TmplSwitchController extends BaseController
*/ */
@RequiresPermissions("template:tmplSwitch:remove") @RequiresPermissions("template:tmplSwitch:remove")
@Log(title = "交换机模板", businessType = BusinessType.DELETE) @Log(title = "交换机模板", businessType = BusinessType.DELETE)
@PostMapping( "/remove") @PostMapping("/remove")
@ResponseBody @ResponseBody
public AjaxResult remove(String ids) public AjaxResult remove(String ids) {
{
return toAjax(tmplSwitchService.deleteTmplSwitchByIds(ids)); return toAjax(tmplSwitchService.deleteTmplSwitchByIds(ids));
} }

View File

@ -1,10 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > <html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head> <head>
<th:block th:include="include :: header('新增交换机模板')" /> <th:block th:include="include :: header('新增交换机模板')"/>
</head> </head>
<body class="white-bg"> <body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> <div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-tmplSwitch-add"> <form class="form-horizontal m" id="form-tmplSwitch-add">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">交换机品牌:</label> <label class="col-sm-3 control-label">交换机品牌:</label>
@ -24,15 +24,29 @@
<input id="powerNum" name="powerNum" class="form-control" type="text"> <input id="powerNum" name="powerNum" class="form-control" type="text">
</div> </div>
</div> </div>
</form>
<div class="form-group" th:with="type=${@dict.getType('dict_port_type')}">
<div class="col-sm-6" th:each="dict : ${type}">
<div class="col-md-12">
<div class="form-group">
<label class="col-sm-3 control-label" th:text="${dict.dictLabel}"></label>
<div class="col-sm-9">
<input type="text" value="" th:name="${dict.dictCode}" class="form-control switchPort"
placeholder="单位(个)">
</div> </div>
<div th:include="include::footer"></div> </div>
<script type="text/javascript"> </div>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
var prefix = ctx + "template/tmplSwitch" var prefix = ctx + "template/tmplSwitch"
$("#form-tmplSwitch-add").validate({ $("#form-tmplSwitch-add").validate({
rules:{ rules: {
xxxx:{ xxxx: {
required:true, required: true,
}, },
}, },
focusCleanup: true focusCleanup: true
@ -40,9 +54,19 @@
function submitHandler() { function submitHandler() {
if ($.validate.form()) { if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-tmplSwitch-add').serialize()); var data = $('#form-tmplSwitch-add').serializeArray();
var params = [];
$(".switchPort").each(function () {
params.push({"id": $(this).attr("name"), "value": $(this).val()});
});
var obj = {
"name": "foreignKeyInfo",
"value": JSON.stringify(params)
};
data.push(obj);
$.operate.save(prefix + "/add", data);
} }
} }
</script> </script>
</body> </body>
</html> </html>

View File

@ -11,8 +11,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
* *
* @author ruoyi * @author ruoyi
*/ */
public class BaseEntity implements Serializable public class BaseEntity implements Serializable {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 搜索值 */ /** 搜索值 */
@ -38,77 +37,74 @@ public class BaseEntity implements Serializable
/** 请求参数 */ /** 请求参数 */
private Map<String, Object> params; private Map<String, Object> params;
public String getSearchValue() /** 外键关联额外信息 */
{ private String foreignKeyInfo;
public String getSearchValue() {
return searchValue; return searchValue;
} }
public void setSearchValue(String searchValue) public void setSearchValue(String searchValue) {
{
this.searchValue = searchValue; this.searchValue = searchValue;
} }
public String getCreateBy() public String getCreateBy() {
{
return createBy; return createBy;
} }
public void setCreateBy(String createBy) public void setCreateBy(String createBy) {
{
this.createBy = createBy; this.createBy = createBy;
} }
public Date getCreateTime() public Date getCreateTime() {
{
return createTime; return createTime;
} }
public void setCreateTime(Date createTime) public void setCreateTime(Date createTime) {
{
this.createTime = createTime; this.createTime = createTime;
} }
public String getUpdateBy() public String getUpdateBy() {
{
return updateBy; return updateBy;
} }
public void setUpdateBy(String updateBy) public void setUpdateBy(String updateBy) {
{
this.updateBy = updateBy; this.updateBy = updateBy;
} }
public Date getUpdateTime() public Date getUpdateTime() {
{
return updateTime; return updateTime;
} }
public void setUpdateTime(Date updateTime) public void setUpdateTime(Date updateTime) {
{
this.updateTime = updateTime; this.updateTime = updateTime;
} }
public String getRemark() public String getRemark() {
{
return remark; return remark;
} }
public void setRemark(String remark) public void setRemark(String remark) {
{
this.remark = remark; this.remark = remark;
} }
public Map<String, Object> getParams() public Map<String, Object> getParams() {
{ if (params == null) {
if (params == null)
{
params = new HashMap<>(); params = new HashMap<>();
} }
return params; return params;
} }
public void setParams(Map<String, Object> params) public void setParams(Map<String, Object> params) {
{
this.params = params; this.params = params;
} }
public String getForeignKeyInfo() {
return foreignKeyInfo;
}
public void setForeignKeyInfo(String foreignKeyInfo) {
this.foreignKeyInfo = foreignKeyInfo;
}
} }

View File

@ -1,72 +0,0 @@
package com.ruoyi.template.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 交换机端口类型(不用代码生成工具) tmpl_switch_port
*
* @author TP
* @date 2019-06-12
*/
public class SwitchPort extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 交换机端口编号 */
private Integer switchPortId;
/** 交换机模板编号 */
private Integer switchId;
/** 交换机端口类型 */
private Integer switchPortType;
/** 交换机端口数量 */
private Integer switchPortNum;
public void setSwitchPortId(Integer switchPortId)
{
this.switchPortId = switchPortId;
}
public Integer getSwitchPortId()
{
return switchPortId;
}
public void setSwitchId(Integer switchId)
{
this.switchId = switchId;
}
public Integer getSwitchId()
{
return switchId;
}
public void setSwitchPortType(Integer switchPortType)
{
this.switchPortType = switchPortType;
}
public Integer getSwitchPortType()
{
return switchPortType;
}
public void setSwitchPortNum(Integer switchPortNum)
{
this.switchPortNum = switchPortNum;
}
public Integer getSwitchPortNum()
{
return switchPortNum;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("switchPortId", getSwitchPortId())
.append("switchId", getSwitchId())
.append("switchPortType", getSwitchPortType())
.append("switchPortNum", getSwitchPortNum())
.toString();
}
}

View File

@ -10,102 +10,109 @@ import com.ruoyi.common.core.domain.BaseEntity;
* @author TP * @author TP
* @date 2019-06-12 * @date 2019-06-12
*/ */
public class TmplServer extends BaseEntity public class TmplServer extends BaseEntity {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 服务器模板编号 */ /**
* 服务器模板编号
*/
private Integer serverId; private Integer serverId;
/** 服务器品牌 */ /**
* 服务器品牌
*/
private String serverBrand; private String serverBrand;
/** 服务器型号 */ /**
* 服务器型号
*/
private String serverType; private String serverType;
/** CPU主频 */ /**
* CPU主频
*/
private String cpuFreq; private String cpuFreq;
/** CPU数量 */ /**
* CPU数量
*/
private Integer cpuNum; private Integer cpuNum;
/** IPMI端口 */ /**
* IPMI端口
*/
private Integer ipmiPort; private Integer ipmiPort;
/** 服务器电源数量 */ /**
* 服务器电源数量
*/
private Integer powerNum; private Integer powerNum;
/** 服务器raid卡 */ /**
* 服务器raid卡
*/
private String raidCard; private String raidCard;
public void setServerId(Integer serverId) public void setServerId(Integer serverId) {
{
this.serverId = serverId; this.serverId = serverId;
} }
public Integer getServerId() public Integer getServerId() {
{
return serverId; return serverId;
} }
public void setServerBrand(String serverBrand)
{ public void setServerBrand(String serverBrand) {
this.serverBrand = serverBrand; this.serverBrand = serverBrand;
} }
public String getServerBrand() public String getServerBrand() {
{
return serverBrand; return serverBrand;
} }
public void setServerType(String serverType)
{ public void setServerType(String serverType) {
this.serverType = serverType; this.serverType = serverType;
} }
public String getServerType() public String getServerType() {
{
return serverType; return serverType;
} }
public void setCpuFreq(String cpuFreq)
{ public void setCpuFreq(String cpuFreq) {
this.cpuFreq = cpuFreq; this.cpuFreq = cpuFreq;
} }
public String getCpuFreq() public String getCpuFreq() {
{
return cpuFreq; return cpuFreq;
} }
public void setCpuNum(Integer cpuNum)
{ public void setCpuNum(Integer cpuNum) {
this.cpuNum = cpuNum; this.cpuNum = cpuNum;
} }
public Integer getCpuNum() public Integer getCpuNum() {
{
return cpuNum; return cpuNum;
} }
public void setIpmiPort(Integer ipmiPort)
{ public void setIpmiPort(Integer ipmiPort) {
this.ipmiPort = ipmiPort; this.ipmiPort = ipmiPort;
} }
public Integer getIpmiPort() public Integer getIpmiPort() {
{
return ipmiPort; return ipmiPort;
} }
public void setPowerNum(Integer powerNum)
{ public void setPowerNum(Integer powerNum) {
this.powerNum = powerNum; this.powerNum = powerNum;
} }
public Integer getPowerNum() public Integer getPowerNum() {
{
return powerNum; return powerNum;
} }
public void setRaidCard(String raidCard)
{ public void setRaidCard(String raidCard) {
this.raidCard = raidCard; this.raidCard = raidCard;
} }
public String getRaidCard() public String getRaidCard() {
{
return raidCard; return raidCard;
} }
@Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("serverId", getServerId()) .append("serverId", getServerId())
.append("serverBrand", getServerBrand()) .append("serverBrand", getServerBrand())
.append("serverType", getServerType()) .append("serverType", getServerType())

View File

@ -1,8 +1,10 @@
package com.ruoyi.template.domain; package com.ruoyi.template.domain;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.List;
/** /**
* 交换机模板表 tmpl_switch * 交换机模板表 tmpl_switch
@ -10,62 +12,78 @@ import com.ruoyi.common.core.domain.BaseEntity;
* @author TP * @author TP
* @date 2019-06-12 * @date 2019-06-12
*/ */
public class TmplSwitch extends BaseEntity public class TmplSwitch extends BaseEntity {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 交换机模板编号 */ /**
* 交换机模板编号
*/
private Integer switchId; private Integer switchId;
/** 交换机品牌 */ /**
* 交换机品牌
*/
private String switchBrand; private String switchBrand;
/** 交换机型号 */ /**
* 交换机型号
*/
private String switchType; private String switchType;
/** 交换机电源数量 */ /**
* 交换机电源数量
*/
private Integer powerNum; private Integer powerNum;
/**
* 交换机端口类型
*/
private List<TmplSwitchPort> switchPorts;
public void setSwitchId(Integer switchId) public void setSwitchId(Integer switchId) {
{
this.switchId = switchId; this.switchId = switchId;
} }
public Integer getSwitchId() public Integer getSwitchId() {
{
return switchId; return switchId;
} }
public void setSwitchBrand(String switchBrand)
{ public void setSwitchBrand(String switchBrand) {
this.switchBrand = switchBrand; this.switchBrand = switchBrand;
} }
public String getSwitchBrand() public String getSwitchBrand() {
{
return switchBrand; return switchBrand;
} }
public void setSwitchType(String switchType)
{ public void setSwitchType(String switchType) {
this.switchType = switchType; this.switchType = switchType;
} }
public String getSwitchType() public String getSwitchType() {
{
return switchType; return switchType;
} }
public void setPowerNum(Integer powerNum)
{ public void setPowerNum(Integer powerNum) {
this.powerNum = powerNum; this.powerNum = powerNum;
} }
public Integer getPowerNum() public Integer getPowerNum() {
{
return powerNum; return powerNum;
} }
public List<TmplSwitchPort> getSwitchPorts() {
return switchPorts;
}
public void setSwitchPorts(List<TmplSwitchPort> switchPorts) {
this.switchPorts = switchPorts;
}
@Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("switchId", getSwitchId()) .append("switchId", getSwitchId())
.append("switchBrand", getSwitchBrand()) .append("switchBrand", getSwitchBrand())
.append("switchType", getSwitchType()) .append("switchType", getSwitchType())
.append("powerNum", getPowerNum()) .append("powerNum", getPowerNum())
.append("switchPorts", getSwitchPorts())
.toString(); .toString();
} }
} }

View File

@ -0,0 +1,74 @@
package com.ruoyi.template.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 交换机端口类型(不用代码生成工具) tmpl_switch_port
*
* @author TP
* @date 2019-06-12
*/
public class TmplSwitchPort extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 交换机端口编号
*/
private Integer switchPortId;
/**
* 交换机模板编号
*/
private Integer switchId;
/**
* 交换机端口类型
*/
private Integer switchPortType;
/**
* 交换机端口数量
*/
private Integer switchPortNum;
public void setSwitchPortId(Integer switchPortId) {
this.switchPortId = switchPortId;
}
public Integer getSwitchPortId() {
return switchPortId;
}
public void setSwitchId(Integer switchId) {
this.switchId = switchId;
}
public Integer getSwitchId() {
return switchId;
}
public void setSwitchPortType(Integer switchPortType) {
this.switchPortType = switchPortType;
}
public Integer getSwitchPortType() {
return switchPortType;
}
public void setSwitchPortNum(Integer switchPortNum) {
this.switchPortNum = switchPortNum;
}
public Integer getSwitchPortNum() {
return switchPortNum;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("switchPortId", getSwitchPortId())
.append("switchId", getSwitchId())
.append("switchPortType", getSwitchPortType())
.append("switchPortNum", getSwitchPortNum())
.toString();
}
}

View File

@ -1,33 +1,55 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!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.TmplSwitchMapper"> <mapper namespace="com.ruoyi.template.mapper.TmplSwitchMapper">
<resultMap type="TmplSwitch" id="TmplSwitchResult"> <resultMap type="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="TmplSwitchPort" column="switch_id">
<id column="pid" property="switchPortId"/><!-- 这里的column对应的是下面查询的别名而不是表字段名 -->
<result column="ptype" property="switchPortType"/><!-- property对应JavaBean中的属性名 -->
<result column="pnum" property="switchPortNum"/>
</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 switch_id, switch_brand, switch_type, power_num from tmpl_switch 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> </sql>
<select id="selectTmplSwitchList" parameterType="TmplSwitch" resultMap="TmplSwitchResult"> <select id="selectTmplSwitchList" parameterType="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>
<if test="switchBrand != null and switchBrand != '' "> and switch_brand = #{switchBrand}</if> <if test="switchBrand != null and switchBrand != '' ">and switch_brand = #{switchBrand}</if>
<if test="switchType != null and switchType != '' "> and switch_type = #{switchType}</if> <if test="switchType != null and switchType != '' ">and switch_type = #{switchType}</if>
<if test="powerNum != null "> and power_num = #{powerNum}</if> <if test="powerNum != null ">and power_num = #{powerNum}</if>
</where> </where>
</select> </select>
<select id="selectTmplSwitchById" parameterType="Integer" resultMap="TmplSwitchResult"> <select id="selectTmplSwitchById" parameterType="Integer" resultMap="TmplSwitchResult">
<include refid="selectTmplSwitchVo"/> <include refid="selectTmplSwitchVo"/>
where switch_id = #{switchId} where s.switch_id = #{switchId}
</select> </select>
<insert id="insertTmplSwitch" parameterType="TmplSwitch" useGeneratedKeys="true" keyProperty="switchId"> <insert id="insertTmplSwitch" parameterType="TmplSwitch" useGeneratedKeys="true" keyProperty="switchId">

View File

@ -0,0 +1,70 @@
<?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.ruoyi.template.mapper.TmplSwitchPortMapper">
<resultMap type="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>
<select id="selectTmplSwitchPortList" parameterType="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="selectTmplSwitchPortById" parameterType="Integer" resultMap="TmplSwitchPortResult">
<include refid="selectTmplSwitchPortVo"/>
where switch_port_id = #{switchPortId}
</select>
<insert id="insertTmplSwitchPort" parameterType="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>
<update id="updateTmplSwitchPort" parameterType="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="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>