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,127 +1,115 @@
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;
/** /**
* 交换机模板 信息操作处理 * 交换机模板 信息操作处理
* *
* @author TP * @author TP
* @date 2019-06-12 * @date 2019-06-12
*/ */
@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
private ITmplSwitchService tmplSwitchService; private ITmplSwitchService tmplSwitchService;
@RequiresPermissions("template:tmplSwitch:view") @RequiresPermissions("template:tmplSwitch:view")
@GetMapping() @GetMapping()
public String tmplSwitch() public String tmplSwitch() {
{ return prefix + "/tmplSwitch";
return prefix + "/tmplSwitch"; }
}
/**
/** * 查询交换机模板列表
* 查询交换机模板列表 */
*/ @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);
} }
/** /**
* 导出交换机模板列表 * 导出交换机模板列表
*/ */
@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");
} }
/**
* 新增交换机模板
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存交换机模板
*/
@RequiresPermissions("template:tmplSwitch:add")
@Log(title = "交换机模板", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(TmplSwitch tmplSwitch)
{
return toAjax(tmplSwitchService.insertTmplSwitch(tmplSwitch));
}
/** /**
* 修改交换机模板 * 新增交换机模板
*/ */
@GetMapping("/edit/{switchId}") @GetMapping("/add")
public String edit(@PathVariable("switchId") Integer switchId, ModelMap mmap) public String add() {
{ return prefix + "/add";
TmplSwitch tmplSwitch = tmplSwitchService.selectTmplSwitchById(switchId); }
mmap.put("tmplSwitch", tmplSwitch);
return prefix + "/edit"; /**
} * 新增保存交换机模板
*/
/** @RequiresPermissions("template:tmplSwitch:add")
* 修改保存交换机模板 @Log(title = "交换机模板", businessType = BusinessType.INSERT)
*/ @PostMapping("/add")
@RequiresPermissions("template:tmplSwitch:edit") @ResponseBody
@Log(title = "交换机模板", businessType = BusinessType.UPDATE) public AjaxResult addSave(TmplSwitch tmplSwitch) {
@PostMapping("/edit") return toAjax(tmplSwitchService.insertTmplSwitch(tmplSwitch));
@ResponseBody }
public AjaxResult editSave(TmplSwitch tmplSwitch)
{ /**
return toAjax(tmplSwitchService.updateTmplSwitch(tmplSwitch)); * 修改交换机模板
} */
@GetMapping("/edit/{switchId}")
/** public String edit(@PathVariable("switchId") Integer switchId, ModelMap mmap) {
* 删除交换机模板 TmplSwitch tmplSwitch = tmplSwitchService.selectTmplSwitchById(switchId);
*/ mmap.put("tmplSwitch", tmplSwitch);
@RequiresPermissions("template:tmplSwitch:remove") return prefix + "/edit";
@Log(title = "交换机模板", businessType = BusinessType.DELETE) }
@PostMapping( "/remove")
@ResponseBody /**
public AjaxResult remove(String ids) * 修改保存交换机模板
{ */
return toAjax(tmplSwitchService.deleteTmplSwitchByIds(ids)); @RequiresPermissions("template:tmplSwitch:edit")
} @Log(title = "交换机模板", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(TmplSwitch tmplSwitch) {
return toAjax(tmplSwitchService.updateTmplSwitch(tmplSwitch));
}
/**
* 删除交换机模板
*/
@RequiresPermissions("template:tmplSwitch:remove")
@Log(title = "交换机模板", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids) {
return toAjax(tmplSwitchService.deleteTmplSwitchByIds(ids));
}
} }

View File

@ -1,48 +1,72 @@
<!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>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="switchBrand" name="switchBrand" class="form-control" type="text"> <input id="switchBrand" name="switchBrand" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">交换机型号:</label> <label class="col-sm-3 control-label">交换机型号:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="switchType" name="switchType" class="form-control" type="text"> <input id="switchType" name="switchType" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">交换机电源数量:</label> <label class="col-sm-3 control-label">交换机电源数量:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<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> <div class="form-group" th:with="type=${@dict.getType('dict_port_type')}">
<div th:include="include::footer"></div> <div class="col-sm-6" th:each="dict : ${type}">
<script type="text/javascript"> <div class="col-md-12">
var prefix = ctx + "template/tmplSwitch" <div class="form-group">
$("#form-tmplSwitch-add").validate({ <label class="col-sm-3 control-label" th:text="${dict.dictLabel}"></label>
rules:{ <div class="col-sm-9">
xxxx:{ <input type="text" value="" th:name="${dict.dictCode}" class="form-control switchPort"
required:true, placeholder="单位(个)">
}, </div>
}, </div>
focusCleanup: true </div>
}); </div>
</div>
function submitHandler() { </form>
if ($.validate.form()) { </div>
$.operate.save(prefix + "/add", $('#form-tmplSwitch-add').serialize()); <div th:include="include::footer"></div>
} <script type="text/javascript">
} var prefix = ctx + "template/tmplSwitch"
</script> $("#form-tmplSwitch-add").validate({
rules: {
xxxx: {
required: true,
},
},
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
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>
</body> </body>
</html> </html>

View File

@ -11,104 +11,100 @@ 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;
/** 搜索值 */ /** 搜索值 */
private String searchValue; private String searchValue;
/** 创建者 */ /** 创建者 */
private String createBy; private String createBy;
/** 创建时间 */ /** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime; private Date createTime;
/** 更新者 */ /** 更新者 */
private String updateBy; private String updateBy;
/** 更新时间 */ /** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime; private Date updateTime;
/** 备注 */ /** 备注 */
private String remark; private String remark;
/** 请求参数 */ /** 请求参数 */
private Map<String, Object> params; private Map<String, Object> params;
public String getSearchValue() /** 外键关联额外信息 */
{ private String foreignKeyInfo;
return searchValue;
}
public void setSearchValue(String searchValue) public String getSearchValue() {
{ return searchValue;
this.searchValue = searchValue; }
}
public String getCreateBy() public void setSearchValue(String searchValue) {
{ this.searchValue = searchValue;
return createBy; }
}
public void setCreateBy(String createBy) public String getCreateBy() {
{ return createBy;
this.createBy = createBy; }
}
public Date getCreateTime() public void setCreateBy(String createBy) {
{ this.createBy = createBy;
return createTime; }
}
public void setCreateTime(Date createTime) public Date getCreateTime() {
{ return createTime;
this.createTime = createTime; }
}
public String getUpdateBy() public void setCreateTime(Date createTime) {
{ this.createTime = createTime;
return updateBy; }
}
public void setUpdateBy(String updateBy) public String getUpdateBy() {
{ return updateBy;
this.updateBy = updateBy; }
}
public Date getUpdateTime() public void setUpdateBy(String updateBy) {
{ this.updateBy = updateBy;
return updateTime; }
}
public void setUpdateTime(Date updateTime) public Date getUpdateTime() {
{ return updateTime;
this.updateTime = updateTime; }
}
public String getRemark() public void setUpdateTime(Date updateTime) {
{ this.updateTime = updateTime;
return remark; }
}
public void setRemark(String remark) public String getRemark() {
{ return remark;
this.remark = remark; }
}
public Map<String, Object> getParams() public void setRemark(String remark) {
{ this.remark = remark;
if (params == null) }
{
params = new HashMap<>(); public Map<String, Object> getParams() {
} if (params == null) {
return params; params = new HashMap<>();
} }
return params;
}
public void setParams(Map<String, Object> params) {
this.params = params;
}
public String getForeignKeyInfo() {
return foreignKeyInfo;
}
public void setForeignKeyInfo(String foreignKeyInfo) {
this.foreignKeyInfo = foreignKeyInfo;
}
public void setParams(Map<String, Object> params)
{
this.params = params;
}
} }

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

@ -6,114 +6,121 @@ import com.ruoyi.common.core.domain.BaseEntity;
/** /**
* 服务器模板表 tmpl_server * 服务器模板表 tmpl_server
* *
* @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 String serverBrand;
/** 服务器型号 */
private String serverType;
/** CPU主频 */
private String cpuFreq;
/** CPU数量 */
private Integer cpuNum;
/** IPMI端口 */
private Integer ipmiPort;
/** 服务器电源数量 */
private Integer powerNum;
/** 服务器raid卡 */
private String raidCard;
public void setServerId(Integer serverId) /**
{ * 服务器模板编号
this.serverId = serverId; */
} private Integer serverId;
/**
* 服务器品牌
*/
private String serverBrand;
/**
* 服务器型号
*/
private String serverType;
/**
* CPU主频
*/
private String cpuFreq;
/**
* CPU数量
*/
private Integer cpuNum;
/**
* IPMI端口
*/
private Integer ipmiPort;
/**
* 服务器电源数量
*/
private Integer powerNum;
/**
* 服务器raid卡
*/
private String raidCard;
public Integer getServerId() public void setServerId(Integer serverId) {
{ this.serverId = serverId;
return serverId; }
}
public void setServerBrand(String serverBrand)
{
this.serverBrand = serverBrand;
}
public String getServerBrand() public Integer getServerId() {
{ return serverId;
return serverBrand; }
}
public void setServerType(String serverType)
{
this.serverType = serverType;
}
public String getServerType() public void setServerBrand(String serverBrand) {
{ this.serverBrand = serverBrand;
return serverType; }
}
public void setCpuFreq(String cpuFreq)
{
this.cpuFreq = cpuFreq;
}
public String getCpuFreq() public String getServerBrand() {
{ return serverBrand;
return cpuFreq; }
}
public void setCpuNum(Integer cpuNum)
{
this.cpuNum = cpuNum;
}
public Integer getCpuNum() public void setServerType(String serverType) {
{ this.serverType = serverType;
return cpuNum; }
}
public void setIpmiPort(Integer ipmiPort)
{
this.ipmiPort = ipmiPort;
}
public Integer getIpmiPort() public String getServerType() {
{ return serverType;
return ipmiPort; }
}
public void setPowerNum(Integer powerNum)
{
this.powerNum = powerNum;
}
public Integer getPowerNum() public void setCpuFreq(String cpuFreq) {
{ this.cpuFreq = cpuFreq;
return powerNum; }
}
public void setRaidCard(String raidCard)
{
this.raidCard = raidCard;
}
public String getRaidCard() public String getCpuFreq() {
{ return cpuFreq;
return raidCard; }
}
public void setCpuNum(Integer cpuNum) {
this.cpuNum = cpuNum;
}
public Integer getCpuNum() {
return cpuNum;
}
public void setIpmiPort(Integer ipmiPort) {
this.ipmiPort = ipmiPort;
}
public Integer getIpmiPort() {
return ipmiPort;
}
public void setPowerNum(Integer powerNum) {
this.powerNum = powerNum;
}
public Integer getPowerNum() {
return powerNum;
}
public void setRaidCard(String raidCard) {
this.raidCard = raidCard;
}
public String getRaidCard() {
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())
.append("cpuFreq", getCpuFreq()) .append("cpuFreq", getCpuFreq())
.append("cpuNum", getCpuNum()) .append("cpuNum", getCpuNum())
.append("ipmiPort", getIpmiPort()) .append("ipmiPort", getIpmiPort())
.append("powerNum", getPowerNum()) .append("powerNum", getPowerNum())
.append("raidCard", getRaidCard()) .append("raidCard", getRaidCard())
.toString(); .toString();
} }
} }

View File

@ -1,71 +1,89 @@
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
* *
* @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 String switchBrand;
/** 交换机型号 */
private String switchType;
/** 交换机电源数量 */
private Integer powerNum;
public void setSwitchId(Integer switchId) /**
{ * 交换机模板编号
this.switchId = switchId; */
} private Integer switchId;
/**
* 交换机品牌
*/
private String switchBrand;
/**
* 交换机型号
*/
private String switchType;
/**
* 交换机电源数量
*/
private Integer powerNum;
/**
* 交换机端口类型
*/
private List<TmplSwitchPort> switchPorts;
public Integer getSwitchId() public void setSwitchId(Integer switchId) {
{ this.switchId = switchId;
return switchId; }
}
public void setSwitchBrand(String switchBrand)
{
this.switchBrand = switchBrand;
}
public String getSwitchBrand() public Integer getSwitchId() {
{ return switchId;
return switchBrand; }
}
public void setSwitchType(String switchType)
{
this.switchType = switchType;
}
public String getSwitchType() public void setSwitchBrand(String switchBrand) {
{ this.switchBrand = switchBrand;
return switchType; }
}
public void setPowerNum(Integer powerNum)
{
this.powerNum = powerNum;
}
public Integer getPowerNum() public String getSwitchBrand() {
{ return switchBrand;
return powerNum; }
}
public void setSwitchType(String switchType) {
this.switchType = switchType;
}
public String getSwitchType() {
return switchType;
}
public void setPowerNum(Integer powerNum) {
this.powerNum = powerNum;
}
public Integer getPowerNum() {
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())
.toString(); .append("switchPorts", getSwitchPorts())
.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,49 +1,71 @@
<?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"> <!-- <sql id="selectTmplSwitchVo">-->
select switch_id, switch_brand, switch_type, power_num from tmpl_switch <!-- 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> </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">
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>
<if test="switchType != null and switchType != '' ">switch_type,</if> <if test="switchType != null and switchType != '' ">switch_type,</if>
<if test="powerNum != null ">power_num,</if> <if test="powerNum != null ">power_num,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="switchBrand != null and switchBrand != '' ">#{switchBrand},</if> <if test="switchBrand != null and switchBrand != '' ">#{switchBrand},</if>
<if test="switchType != null and switchType != '' ">#{switchType},</if> <if test="switchType != null and switchType != '' ">#{switchType},</if>
<if test="powerNum != null ">#{powerNum},</if> <if test="powerNum != null ">#{powerNum},</if>
</trim> </trim>
</insert> </insert>
<update id="updateTmplSwitch" parameterType="TmplSwitch"> <update id="updateTmplSwitch" parameterType="TmplSwitch">
update tmpl_switch update tmpl_switch
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
@ -54,15 +76,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where switch_id = #{switchId} where switch_id = #{switchId}
</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>
</mapper> </mapper>

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>