SwitchTemplate生成

This commit is contained in:
tangpeng 2019-06-11 23:37:55 +08:00
parent 31d3a6a6d5
commit 62205847ec
9 changed files with 661 additions and 0 deletions

View File

@ -0,0 +1,115 @@
package com.ruoyi.web.controller.template;
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.Switch;
import com.ruoyi.template.service.ISwitchService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 交换机模板 信息操作处理
*
* @author TP
* @date 2019-06-11
*/
@Controller
@RequestMapping("/template/switch")
public class SwitchController extends BaseController {
private String prefix = "template/switch" ;
@Autowired
private ISwitchService switchService;
@RequiresPermissions("template:switch:view")
@GetMapping()
public String switchTemplate() {
return prefix + "/switch" ;
}
/**
* 查询交换机模板列表
*/
@RequiresPermissions("template:switch:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(Switch switchTemplate) {
startPage();
List<Switch> list = switchService.selectSwitchList(switchTemplate);
return getDataTable(list);
}
/**
* 导出交换机模板列表
*/
@RequiresPermissions("template:switch:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(Switch switchTemplate) {
List<Switch> list = switchService.selectSwitchList(switchTemplate);
ExcelUtil<Switch> util = new ExcelUtil<Switch>(Switch.class);
return util.exportExcel(list, "switch");
}
/**
* 新增交换机模板
*/
@GetMapping("/add")
public String add() {
return prefix + "/add" ;
}
/**
* 新增保存交换机模板
*/
@RequiresPermissions("template:switch:add")
@Log(title = "交换机模板", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(Switch switchTemplate) {
return toAjax(switchService.insertSwitch(switchTemplate));
}
/**
* 修改交换机模板
*/
@GetMapping("/edit/{serverId}")
public String edit(@PathVariable("serverId") Integer serverId, ModelMap mmap) {
Switch switchTemplate = switchService.selectSwitchById(serverId);
mmap.put("switch", switchTemplate);
return prefix + "/edit" ;
}
/**
* 修改保存交换机模板
*/
@RequiresPermissions("template:switch:edit")
@Log(title = "交换机模板", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(Switch switchTemplate) {
return toAjax(switchService.updateSwitch(switchTemplate));
}
/**
* 删除交换机模板
*/
@RequiresPermissions("template:switch:remove")
@Log(title = "交换机模板", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids) {
return toAjax(switchService.deleteSwitchByIds(ids));
}
}

View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增交换机模板')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-switch-add">
<div class="form-group">
<label class="col-sm-3 control-label">交换机品牌:</label>
<div class="col-sm-8">
<input id="serverBrand" name="serverBrand" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">交换机型号:</label>
<div class="col-sm-8">
<input id="serverType" name="serverType" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">交换机电源数量:</label>
<div class="col-sm-8">
<input id="powerNum" name="powerNum" class="form-control" type="text">
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
var prefix = ctx + "template/switch"
$("#form-switch-add").validate({
rules:{
xxxx:{
required:true,
},
},
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-switch-add').serialize());
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改交换机模板')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-switch-edit" th:object="${switch}">
<input id="serverId" name="serverId" th:field="*{serverId}" type="hidden">
<div class="form-group">
<label class="col-sm-3 control-label">交换机品牌:</label>
<div class="col-sm-8">
<input id="serverBrand" name="serverBrand" th:field="*{serverBrand}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">交换机型号:</label>
<div class="col-sm-8">
<input id="serverType" name="serverType" th:field="*{serverType}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">交换机电源数量:</label>
<div class="col-sm-8">
<input id="powerNum" name="powerNum" th:field="*{powerNum}" class="form-control" type="text">
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
var prefix = ctx + "template/switch";
$("#form-switch-edit").validate({
rules:{
xxxx:{
required:true,
},
},
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-switch-edit').serialize());
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,106 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('交换机模板列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
交换机品牌:<input type="text" name="serverBrand"/>
</li>
<li>
交换机型号:<input type="text" name="serverType"/>
</li>
<li>
交换机电源数量:<input type="text" name="powerNum"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="template:switch:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="template:switch:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="template:switch:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="template:switch:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table" data-mobile-responsive="true"></table>
</div>
</div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('template:switch:edit')}]];
var removeFlag = [[${@permission.hasPermi('template:switch:remove')}]];
var prefix = ctx + "template/switch";
$(function() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "交换机模板",
showExport: true,
columns: [{
checkbox: true
},
{
field : 'serverId',
title : '交换机模板编号',
visible: false
},
{
field : 'serverBrand',
title : '交换机品牌',
sortable: true
},
{
field : 'serverType',
title : '交换机型号',
sortable: true
},
{
field : 'powerNum',
title : '交换机电源数量',
sortable: true
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.serverId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.serverId + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});
</script>
</body>
</html>

View File

@ -0,0 +1,72 @@
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
*
* @author TP
* @date 2019-06-11
*/
public class Switch extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 交换机模板编号 */
private Integer serverId;
/** 交换机品牌 */
private String serverBrand;
/** 交换机型号 */
private String serverType;
/** 交换机电源数量 */
private Integer powerNum;
public void setServerId(Integer serverId)
{
this.serverId = serverId;
}
public Integer getServerId()
{
return serverId;
}
public void setServerBrand(String serverBrand)
{
this.serverBrand = serverBrand;
}
public String getServerBrand()
{
return serverBrand;
}
public void setServerType(String serverType)
{
this.serverType = serverType;
}
public String getServerType()
{
return serverType;
}
public void setPowerNum(Integer powerNum)
{
this.powerNum = powerNum;
}
public Integer getPowerNum()
{
return powerNum;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("serverId", getServerId())
.append("serverBrand", getServerBrand())
.append("serverType", getServerType())
.append("powerNum", getPowerNum())
.toString();
}
}

View File

@ -0,0 +1,63 @@
package com.ruoyi.template.mapper;
import java.util.List;
import com.ruoyi.template.domain.Switch;
/**
* 交换机模板 数据层
*
* @author TP
* @date 2019-06-11
*/
public interface SwitchMapper
{
/**
* 查询交换机模板信息
*
* @param serverId 交换机模板ID
* @return 交换机模板信息
*/
public Switch selectSwitchById(Integer serverId);
/**
* 查询交换机模板列表
*
* @param switchTmpl 交换机模板信息
* @return 交换机模板集合
*/
public List<Switch> selectSwitchList(Switch s);
/**
* 新增交换机模板
*
* @param switchTmpl 交换机模板信息
* @return 结果
*/
public int insertSwitch(Switch switchTmpl);
/**
* 修改交换机模板
*
* @param switchTmpl 交换机模板信息
* @return 结果
*/
public int updateSwitch(Switch switchTmpl);
/**
* 删除交换机模板
*
* @param serverId 交换机模板ID
* @return 结果
*/
public int deleteSwitchById(Integer serverId);
/**
* 批量删除交换机模板
*
* @param serverIds 需要删除的数据ID
* @return 结果
*/
public int deleteSwitchByIds(String[] serverIds);
}

View File

@ -0,0 +1,55 @@
package com.ruoyi.template.service;
import java.util.List;
import com.ruoyi.template.domain.Switch;
/**
* 交换机模板 服务层
*
* @author TP
* @date 2019-06-11
*/
public interface ISwitchService
{
/**
* 查询交换机模板信息
*
* @param serverId 交换机模板ID
* @return 交换机模板信息
*/
public Switch selectSwitchById(Integer serverId);
/**
* 查询交换机模板列表
*
* @param switchTmpl 交换机模板信息
* @return 交换机模板集合
*/
public List<Switch> selectSwitchList(Switch switchTmpl);
/**
* 新增交换机模板
*
* @param switchTmpl 交换机模板信息
* @return 结果
*/
public int insertSwitch(Switch switchTmpl);
/**
* 修改交换机模板
*
* @param switchTmpl 交换机模板信息
* @return 结果
*/
public int updateSwitch(Switch switchTmpl);
/**
* 删除交换机模板信息
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteSwitchByIds(String ids);
}

View File

@ -0,0 +1,85 @@
package com.ruoyi.template.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.template.domain.Switch;
import com.ruoyi.template.mapper.SwitchMapper;
import com.ruoyi.template.service.ISwitchService;
/**
* 交换机模板 服务层实现
*
* @author TP
* @date 2019-06-11
*/
@Service
public class SwitchServiceImpl implements ISwitchService
{
@Autowired
private SwitchMapper switchMapper;
/**
* 查询交换机模板信息
*
* @param serverId 交换机模板ID
* @return 交换机模板信息
*/
@Override
public Switch selectSwitchById(Integer serverId)
{
return switchMapper.selectSwitchById(serverId);
}
/**
* 查询交换机模板列表
*
* @param switchTempalte 交换机模板信息
* @return 交换机模板集合
*/
@Override
public List<Switch> selectSwitchList(Switch switchTempalte)
{
return switchMapper.selectSwitchList(switchTempalte);
}
/**
* 新增交换机模板
*
* @param switchTempalte 交换机模板信息
* @return 结果
*/
@Override
public int insertSwitch(Switch switchTempalte)
{
return switchMapper.insertSwitch(switchTempalte);
}
/**
* 修改交换机模板
*
* @param switchTempalte 交换机模板信息
* @return 结果
*/
@Override
public int updateSwitch(Switch switchTempalte)
{
return switchMapper.updateSwitch(switchTempalte);
}
/**
* 删除交换机模板对象
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteSwitchByIds(String ids)
{
return switchMapper.deleteSwitchByIds(Convert.toStrArray(ids));
}
}

View File

@ -0,0 +1,68 @@
<?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.SwitchMapper">
<resultMap type="Switch" id="SwitchResult">
<result property="serverId" column="server_id" />
<result property="serverBrand" column="server_brand" />
<result property="serverType" column="server_type" />
<result property="powerNum" column="power_num" />
</resultMap>
<sql id="selectSwitchVo">
select server_id, server_brand, server_type, power_num from tmpl_switch
</sql>
<select id="selectSwitchList" parameterType="Switch" resultMap="SwitchResult">
<include refid="selectSwitchVo"/>
<where>
<if test="serverId != null "> and server_id = #{serverId}</if>
<if test="serverBrand != null and serverBrand != '' "> and server_brand = #{serverBrand}</if>
<if test="serverType != null and serverType != '' "> and server_type = #{serverType}</if>
<if test="powerNum != null "> and power_num = #{powerNum}</if>
</where>
</select>
<select id="selectSwitchById" parameterType="Integer" resultMap="SwitchResult">
<include refid="selectSwitchVo"/>
where server_id = #{serverId}
</select>
<insert id="insertSwitch" parameterType="Switch" useGeneratedKeys="true" keyProperty="serverId">
insert into tmpl_switch
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="serverBrand != null and serverBrand != '' ">server_brand,</if>
<if test="serverType != null and serverType != '' ">server_type,</if>
<if test="powerNum != null ">power_num,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="serverBrand != null and serverBrand != '' ">#{serverBrand},</if>
<if test="serverType != null and serverType != '' ">#{serverType},</if>
<if test="powerNum != null ">#{powerNum},</if>
</trim>
</insert>
<update id="updateSwitch" parameterType="Switch">
update tmpl_switch
<trim prefix="SET" suffixOverrides=",">
<if test="serverBrand != null and serverBrand != '' ">server_brand = #{serverBrand},</if>
<if test="serverType != null and serverType != '' ">server_type = #{serverType},</if>
<if test="powerNum != null ">power_num = #{powerNum},</if>
</trim>
where server_id = #{serverId}
</update>
<delete id="deleteSwitchById" parameterType="Integer">
delete from tmpl_switch where server_id = #{serverId}
</delete>
<delete id="deleteSwitchByIds" parameterType="String">
delete from tmpl_switch where server_id in
<foreach item="serverId" collection="array" open="(" separator="," close=")">
#{serverId}
</foreach>
</delete>
</mapper>