交换机级联添加端口
This commit is contained in:
parent
aa98683b11
commit
defc83aedb
1
pom.xml
1
pom.xml
|
|
@ -30,6 +30,7 @@
|
|||
<jsoup.version>1.11.3</jsoup.version>
|
||||
<poi.version>3.17</poi.version>
|
||||
<velocity.version>1.7</velocity.version>
|
||||
<fastjson.version>1.2.16</fastjson.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
<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"
|
||||
<input type="number" value="" th:name="${dict.dictCode}" class="form-control switchPort"
|
||||
placeholder="单位(个)">
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -52,6 +52,12 @@
|
|||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<!-- fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- io常用工具类 -->
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
/**
|
||||
* Entity基类
|
||||
|
|
@ -38,6 +41,7 @@ public class BaseEntity implements Serializable {
|
|||
private Map<String, Object> params;
|
||||
|
||||
/** 外键关联额外信息 */
|
||||
@JsonIgnore
|
||||
private String foreignKeyInfo;
|
||||
|
||||
public String getSearchValue() {
|
||||
|
|
|
|||
|
|
@ -1,39 +1,31 @@
|
|||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.exception.BusinessException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.security.Md5Utils;
|
||||
import com.ruoyi.system.domain.SysPost;
|
||||
import com.ruoyi.system.domain.SysRole;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
import com.ruoyi.system.domain.SysUserPost;
|
||||
import com.ruoyi.system.domain.SysUserRole;
|
||||
import com.ruoyi.system.mapper.SysPostMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import com.ruoyi.system.mapper.SysUserPostMapper;
|
||||
import com.ruoyi.system.mapper.SysUserRoleMapper;
|
||||
import com.ruoyi.system.domain.*;
|
||||
import com.ruoyi.system.mapper.*;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户 业务层处理
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysUserServiceImpl implements ISysUserService
|
||||
{
|
||||
public class SysUserServiceImpl implements ISysUserService {
|
||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
|
|
@ -56,98 +48,90 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
@DataScope(tableAlias = "u")
|
||||
public List<SysUser> selectUserList(SysUser user)
|
||||
{
|
||||
public List<SysUser> selectUserList(SysUser user) {
|
||||
return userMapper.selectUserList(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已分配用户角色列表
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@DataScope(tableAlias = "u")
|
||||
public List<SysUser> selectAllocatedList(SysUser user)
|
||||
{
|
||||
public List<SysUser> selectAllocatedList(SysUser user) {
|
||||
return userMapper.selectAllocatedList(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询未分配用户角色列表
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@DataScope(tableAlias = "u")
|
||||
public List<SysUser> selectUnallocatedList(SysUser user)
|
||||
{
|
||||
public List<SysUser> selectUnallocatedList(SysUser user) {
|
||||
return userMapper.selectUnallocatedList(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserByLoginName(String userName)
|
||||
{
|
||||
public SysUser selectUserByLoginName(String userName) {
|
||||
return userMapper.selectUserByLoginName(userName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过手机号码查询用户
|
||||
*
|
||||
*
|
||||
* @param phoneNumber 手机号码
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserByPhoneNumber(String phoneNumber)
|
||||
{
|
||||
public SysUser selectUserByPhoneNumber(String phoneNumber) {
|
||||
return userMapper.selectUserByPhoneNumber(phoneNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过邮箱查询用户
|
||||
*
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserByEmail(String email)
|
||||
{
|
||||
public SysUser selectUserByEmail(String email) {
|
||||
return userMapper.selectUserByEmail(email);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserById(Long userId)
|
||||
{
|
||||
public SysUser selectUserById(Long userId) {
|
||||
return userMapper.selectUserById(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID删除用户
|
||||
*
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteUserById(Long userId)
|
||||
{
|
||||
public int deleteUserById(Long userId) {
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// 删除用户与岗位表
|
||||
|
|
@ -157,18 +141,15 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
/**
|
||||
* 批量删除用户信息
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteUserByIds(String ids) throws BusinessException
|
||||
{
|
||||
public int deleteUserByIds(String ids) throws BusinessException {
|
||||
Long[] userIds = Convert.toLongArray(ids);
|
||||
for (Long userId : userIds)
|
||||
{
|
||||
if (SysUser.isAdmin(userId))
|
||||
{
|
||||
for (Long userId : userIds) {
|
||||
if (SysUser.isAdmin(userId)) {
|
||||
throw new BusinessException("不允许删除超级管理员用户");
|
||||
}
|
||||
}
|
||||
|
|
@ -177,14 +158,13 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
/**
|
||||
* 新增保存用户信息
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertUser(SysUser user)
|
||||
{
|
||||
public int insertUser(SysUser user) {
|
||||
// 新增用户信息
|
||||
int rows = userMapper.insertUser(user);
|
||||
// 新增用户岗位关联
|
||||
|
|
@ -196,14 +176,13 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
/**
|
||||
* 修改保存用户信息
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateUser(SysUser user)
|
||||
{
|
||||
public int updateUser(SysUser user) {
|
||||
Long userId = user.getUserId();
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
|
|
@ -218,49 +197,43 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
/**
|
||||
* 修改用户个人详细信息
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserInfo(SysUser user)
|
||||
{
|
||||
public int updateUserInfo(SysUser user) {
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户密码
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int resetUserPwd(SysUser user)
|
||||
{
|
||||
public int resetUserPwd(SysUser user) {
|
||||
return updateUserInfo(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户角色信息
|
||||
*
|
||||
*
|
||||
* @param user 用户对象
|
||||
*/
|
||||
public void insertUserRole(SysUser user)
|
||||
{
|
||||
public void insertUserRole(SysUser user) {
|
||||
Long[] roles = user.getRoleIds();
|
||||
if (StringUtils.isNotNull(roles))
|
||||
{
|
||||
if (StringUtils.isNotNull(roles)) {
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
||||
for (Long roleId : roles)
|
||||
{
|
||||
for (Long roleId : roles) {
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(user.getUserId());
|
||||
ur.setRoleId(roleId);
|
||||
list.add(ur);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
if (list.size() > 0) {
|
||||
userRoleMapper.batchUserRole(list);
|
||||
}
|
||||
}
|
||||
|
|
@ -268,25 +241,21 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
/**
|
||||
* 新增用户岗位信息
|
||||
*
|
||||
*
|
||||
* @param user 用户对象
|
||||
*/
|
||||
public void insertUserPost(SysUser user)
|
||||
{
|
||||
public void insertUserPost(SysUser user) {
|
||||
Long[] posts = user.getPostIds();
|
||||
if (StringUtils.isNotNull(posts))
|
||||
{
|
||||
if (StringUtils.isNotNull(posts)) {
|
||||
// 新增用户与岗位管理
|
||||
List<SysUserPost> list = new ArrayList<SysUserPost>();
|
||||
for (Long postId : posts)
|
||||
{
|
||||
for (Long postId : posts) {
|
||||
SysUserPost up = new SysUserPost();
|
||||
up.setUserId(user.getUserId());
|
||||
up.setPostId(postId);
|
||||
list.add(up);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
if (list.size() > 0) {
|
||||
userPostMapper.batchUserPost(list);
|
||||
}
|
||||
}
|
||||
|
|
@ -294,16 +263,14 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
/**
|
||||
* 校验登录名称是否唯一
|
||||
*
|
||||
*
|
||||
* @param loginName 用户名
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String checkLoginNameUnique(String loginName)
|
||||
{
|
||||
public String checkLoginNameUnique(String loginName) {
|
||||
int count = userMapper.checkLoginNameUnique(loginName);
|
||||
if (count > 0)
|
||||
{
|
||||
if (count > 0) {
|
||||
return UserConstants.USER_NAME_NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.USER_NAME_UNIQUE;
|
||||
|
|
@ -316,12 +283,10 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String checkPhoneUnique(SysUser user)
|
||||
{
|
||||
public String checkPhoneUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||
return UserConstants.USER_PHONE_NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.USER_PHONE_UNIQUE;
|
||||
|
|
@ -334,12 +299,10 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String checkEmailUnique(SysUser user)
|
||||
{
|
||||
public String checkEmailUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkEmailUnique(user.getEmail());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||
return UserConstants.USER_EMAIL_NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.USER_EMAIL_UNIQUE;
|
||||
|
|
@ -347,21 +310,18 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
/**
|
||||
* 查询用户所属角色组
|
||||
*
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String selectUserRoleGroup(Long userId)
|
||||
{
|
||||
public String selectUserRoleGroup(Long userId) {
|
||||
List<SysRole> list = roleMapper.selectRolesByUserId(userId);
|
||||
StringBuffer idsStr = new StringBuffer();
|
||||
for (SysRole role : list)
|
||||
{
|
||||
for (SysRole role : list) {
|
||||
idsStr.append(role.getRoleName()).append(",");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(idsStr.toString()))
|
||||
{
|
||||
if (StringUtils.isNotEmpty(idsStr.toString())) {
|
||||
return idsStr.substring(0, idsStr.length() - 1);
|
||||
}
|
||||
return idsStr.toString();
|
||||
|
|
@ -369,21 +329,18 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
/**
|
||||
* 查询用户所属岗位组
|
||||
*
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String selectUserPostGroup(Long userId)
|
||||
{
|
||||
public String selectUserPostGroup(Long userId) {
|
||||
List<SysPost> list = postMapper.selectPostsByUserId(userId);
|
||||
StringBuffer idsStr = new StringBuffer();
|
||||
for (SysPost post : list)
|
||||
{
|
||||
for (SysPost post : list) {
|
||||
idsStr.append(post.getPostName()).append(",");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(idsStr.toString()))
|
||||
{
|
||||
if (StringUtils.isNotEmpty(idsStr.toString())) {
|
||||
return idsStr.substring(0, idsStr.length() - 1);
|
||||
}
|
||||
return idsStr.toString();
|
||||
|
|
@ -391,17 +348,15 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
/**
|
||||
* 导入用户数据
|
||||
*
|
||||
* @param userList 用户数据列表
|
||||
*
|
||||
* @param userList 用户数据列表
|
||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
||||
* @param operName 操作用户
|
||||
* @param operName 操作用户
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName)
|
||||
{
|
||||
if (StringUtils.isNull(userList) || userList.size() == 0)
|
||||
{
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) {
|
||||
if (StringUtils.isNull(userList) || userList.size() == 0) {
|
||||
throw new BusinessException("导入用户数据不能为空!");
|
||||
}
|
||||
int successNum = 0;
|
||||
|
|
@ -409,48 +364,36 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
String password = configService.selectConfigByKey("sys.user.initPassword");
|
||||
for (SysUser user : userList)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (SysUser user : userList) {
|
||||
try {
|
||||
// 验证是否存在这个用户
|
||||
SysUser u = userMapper.selectUserByLoginName(user.getLoginName());
|
||||
if (StringUtils.isNull(u))
|
||||
{
|
||||
if (StringUtils.isNull(u)) {
|
||||
user.setPassword(Md5Utils.hash(user.getLoginName() + password));
|
||||
user.setCreateBy(operName);
|
||||
this.insertUser(user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getLoginName() + " 导入成功");
|
||||
}
|
||||
else if (isUpdateSupport)
|
||||
{
|
||||
} else if (isUpdateSupport) {
|
||||
user.setUpdateBy(operName);
|
||||
this.updateUser(user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getLoginName() + " 更新成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>" + failureNum + "、账号 " + user.getLoginName() + " 已存在");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、账号 " + user.getLoginName() + " 导入失败:";
|
||||
failureMsg.append(msg + e.getMessage());
|
||||
log.error(msg, e);
|
||||
}
|
||||
}
|
||||
if (failureNum > 0)
|
||||
{
|
||||
if (failureNum > 0) {
|
||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||
throw new BusinessException(failureMsg.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||
}
|
||||
return successMsg.toString();
|
||||
|
|
@ -458,15 +401,13 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
/**
|
||||
* 用户状态修改
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int changeStatus(SysUser user)
|
||||
{
|
||||
if (SysUser.isAdmin(user.getUserId()))
|
||||
{
|
||||
public int changeStatus(SysUser user) {
|
||||
if (SysUser.isAdmin(user.getUserId())) {
|
||||
throw new BusinessException("不允许修改超级管理员用户");
|
||||
}
|
||||
return userMapper.updateUser(user);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 交换机端口类型(不用代码生成工具)表 tmpl_switch_port
|
||||
* 交换机端口类型表 tmpl_switch_port
|
||||
*
|
||||
* @author TP
|
||||
* @date 2019-06-12
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
package com.ruoyi.template.mapper;
|
||||
|
||||
import com.ruoyi.template.domain.TmplSwitchPort;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交换机端口类型 数据层
|
||||
*
|
||||
* @author TP
|
||||
* @date 2019-06-12
|
||||
*/
|
||||
public interface TmplSwitchPortMapper
|
||||
{
|
||||
/**
|
||||
* 查询交换机端口类型信息
|
||||
*
|
||||
* @param switchPortId 交换机端口类型ID
|
||||
* @return 交换机端口类型信息
|
||||
*/
|
||||
public TmplSwitchPort selectTmplSwitchPortById(Integer switchPortId);
|
||||
|
||||
/**
|
||||
* 查询交换机端口类型列表
|
||||
*
|
||||
* @param tmplSwitchPort 交换机端口类型信息
|
||||
* @return 交换机端口类型集合
|
||||
*/
|
||||
public List<TmplSwitchPort> selectTmplSwitchPortList(TmplSwitchPort tmplSwitchPort);
|
||||
|
||||
/**
|
||||
* 新增交换机端口类型
|
||||
*
|
||||
* @param tmplSwitchPort 交换机端口类型信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertTmplSwitchPort(TmplSwitchPort tmplSwitchPort);
|
||||
|
||||
/**
|
||||
* 修改交换机端口类型
|
||||
*
|
||||
* @param tmplSwitchPort 交换机端口类型信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateTmplSwitchPort(TmplSwitchPort tmplSwitchPort);
|
||||
|
||||
/**
|
||||
* 删除交换机端口类型
|
||||
*
|
||||
* @param switchPortId 交换机端口类型ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTmplSwitchPortById(Integer switchPortId);
|
||||
|
||||
/**
|
||||
* 批量删除交换机端口类型
|
||||
*
|
||||
* @param switchPortIds 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTmplSwitchPortByIds(String[] switchPortIds);
|
||||
|
||||
/**
|
||||
* 批量新增交换机端口信息
|
||||
*
|
||||
* @param tmplSwitchPortList 交换机端口列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchTmplSwitchPort(List<TmplSwitchPort> tmplSwitchPortList);
|
||||
|
||||
}
|
||||
|
|
@ -6,79 +6,75 @@ import com.ruoyi.template.mapper.TmplServerMapper;
|
|||
import com.ruoyi.template.service.ITmplServerService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务器模板 服务层实现
|
||||
*
|
||||
*
|
||||
* @author TP
|
||||
* @date 2019-06-12
|
||||
*/
|
||||
@Service
|
||||
public class TmplServerServiceImpl implements ITmplServerService
|
||||
{
|
||||
@Autowired
|
||||
private TmplServerMapper tmplServerMapper;
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class TmplServerServiceImpl implements ITmplServerService {
|
||||
@Autowired
|
||||
private TmplServerMapper tmplServerMapper;
|
||||
|
||||
/**
|
||||
/**
|
||||
* 查询服务器模板信息
|
||||
*
|
||||
*
|
||||
* @param serverId 服务器模板ID
|
||||
* @return 服务器模板信息
|
||||
*/
|
||||
@Override
|
||||
public TmplServer selectTmplServerById(Integer serverId)
|
||||
{
|
||||
return tmplServerMapper.selectTmplServerById(serverId);
|
||||
}
|
||||
|
||||
/**
|
||||
public TmplServer selectTmplServerById(Integer serverId) {
|
||||
return tmplServerMapper.selectTmplServerById(serverId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询服务器模板列表
|
||||
*
|
||||
*
|
||||
* @param tmplServer 服务器模板信息
|
||||
* @return 服务器模板集合
|
||||
*/
|
||||
@Override
|
||||
public List<TmplServer> selectTmplServerList(TmplServer tmplServer)
|
||||
{
|
||||
return tmplServerMapper.selectTmplServerList(tmplServer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TmplServer> selectTmplServerList(TmplServer tmplServer) {
|
||||
return tmplServerMapper.selectTmplServerList(tmplServer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增服务器模板
|
||||
*
|
||||
*
|
||||
* @param tmplServer 服务器模板信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertTmplServer(TmplServer tmplServer)
|
||||
{
|
||||
return tmplServerMapper.insertTmplServer(tmplServer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改服务器模板
|
||||
*
|
||||
* @param tmplServer 服务器模板信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateTmplServer(TmplServer tmplServer)
|
||||
{
|
||||
return tmplServerMapper.updateTmplServer(tmplServer);
|
||||
}
|
||||
@Override
|
||||
public int insertTmplServer(TmplServer tmplServer) {
|
||||
return tmplServerMapper.insertTmplServer(tmplServer);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 修改服务器模板
|
||||
*
|
||||
* @param tmplServer 服务器模板信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateTmplServer(TmplServer tmplServer) {
|
||||
return tmplServerMapper.updateTmplServer(tmplServer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除服务器模板对象
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTmplServerByIds(String ids)
|
||||
{
|
||||
return tmplServerMapper.deleteTmplServerByIds(Convert.toStrArray(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteTmplServerByIds(String ids) {
|
||||
return tmplServerMapper.deleteTmplServerByIds(Convert.toStrArray(ids));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,83 +1,116 @@
|
|||
package com.ruoyi.template.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.exception.BusinessException;
|
||||
import com.ruoyi.system.domain.SysDictData;
|
||||
import com.ruoyi.system.mapper.SysDictDataMapper;
|
||||
import com.ruoyi.template.domain.TmplSwitch;
|
||||
import com.ruoyi.template.domain.TmplSwitchPort;
|
||||
import com.ruoyi.template.mapper.TmplSwitchMapper;
|
||||
import com.ruoyi.template.mapper.TmplSwitchPortMapper;
|
||||
import com.ruoyi.template.service.ITmplSwitchService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.template.mapper.TmplSwitchMapper;
|
||||
import com.ruoyi.template.domain.TmplSwitch;
|
||||
import com.ruoyi.template.service.ITmplSwitchService;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交换机模板 服务层实现
|
||||
*
|
||||
*
|
||||
* @author TP
|
||||
* @date 2019-06-12
|
||||
*/
|
||||
@Service
|
||||
public class TmplSwitchServiceImpl implements ITmplSwitchService
|
||||
{
|
||||
@Autowired
|
||||
private TmplSwitchMapper tmplSwitchMapper;
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class TmplSwitchServiceImpl implements ITmplSwitchService {
|
||||
@Autowired
|
||||
private TmplSwitchMapper tmplSwitchMapper;
|
||||
@Autowired
|
||||
private TmplSwitchPortMapper tmplSwitchPortMapper;
|
||||
@Autowired
|
||||
private SysDictDataMapper sysDictDataMapper;
|
||||
|
||||
/**
|
||||
/**
|
||||
* 查询交换机模板信息
|
||||
*
|
||||
*
|
||||
* @param switchId 交换机模板ID
|
||||
* @return 交换机模板信息
|
||||
*/
|
||||
@Override
|
||||
public TmplSwitch selectTmplSwitchById(Integer switchId)
|
||||
{
|
||||
return tmplSwitchMapper.selectTmplSwitchById(switchId);
|
||||
}
|
||||
|
||||
/**
|
||||
public TmplSwitch selectTmplSwitchById(Integer switchId) {
|
||||
return tmplSwitchMapper.selectTmplSwitchById(switchId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询交换机模板列表
|
||||
*
|
||||
*
|
||||
* @param tmplSwitch 交换机模板信息
|
||||
* @return 交换机模板集合
|
||||
*/
|
||||
@Override
|
||||
public List<TmplSwitch> selectTmplSwitchList(TmplSwitch tmplSwitch)
|
||||
{
|
||||
return tmplSwitchMapper.selectTmplSwitchList(tmplSwitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TmplSwitch> selectTmplSwitchList(TmplSwitch tmplSwitch) {
|
||||
return tmplSwitchMapper.selectTmplSwitchList(tmplSwitch);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增交换机模板
|
||||
*
|
||||
*
|
||||
* @param tmplSwitch 交换机模板信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertTmplSwitch(TmplSwitch tmplSwitch)
|
||||
{
|
||||
return tmplSwitchMapper.insertTmplSwitch(tmplSwitch);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改交换机模板
|
||||
*
|
||||
* @param tmplSwitch 交换机模板信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateTmplSwitch(TmplSwitch tmplSwitch)
|
||||
{
|
||||
return tmplSwitchMapper.updateTmplSwitch(tmplSwitch);
|
||||
}
|
||||
@Override
|
||||
public int insertTmplSwitch(TmplSwitch tmplSwitch) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(tmplSwitch.getForeignKeyInfo());
|
||||
int affectRow = tmplSwitchMapper.insertTmplSwitch(tmplSwitch);
|
||||
if (affectRow > 0) {
|
||||
List<TmplSwitchPort> list = new ArrayList<>();
|
||||
jsonArray.forEach((i) -> {
|
||||
JSONObject jsonObject = (JSONObject) i;
|
||||
String valueStr = jsonObject.getString("value");
|
||||
int num = 0;
|
||||
if (StringUtils.isNotBlank(valueStr) && (num = Convert.toInt(valueStr)) > 0) {
|
||||
SysDictData dictData = sysDictDataMapper
|
||||
.selectDictDataById(Convert.toLong(jsonObject.getString("id")));
|
||||
TmplSwitchPort tmplSwitchPort = new TmplSwitchPort();
|
||||
tmplSwitchPort.setSwitchId(tmplSwitch.getSwitchId());
|
||||
tmplSwitchPort.setSwitchPortType(Convert.toInt(dictData.getDictCode()));
|
||||
tmplSwitchPort.setSwitchPortNum(num);
|
||||
list.add(tmplSwitchPort);
|
||||
}
|
||||
});
|
||||
int switchPorts = list.size() > 0 ? tmplSwitchPortMapper.batchTmplSwitchPort(list) : 0;
|
||||
if (switchPorts == 0) {
|
||||
throw new BusinessException("至少输入一个端口数量");
|
||||
}
|
||||
}
|
||||
return affectRow;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 修改交换机模板
|
||||
*
|
||||
* @param tmplSwitch 交换机模板信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateTmplSwitch(TmplSwitch tmplSwitch) {
|
||||
return tmplSwitchMapper.updateTmplSwitch(tmplSwitch);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除交换机模板对象
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTmplSwitchByIds(String ids)
|
||||
{
|
||||
return tmplSwitchMapper.deleteTmplSwitchByIds(Convert.toStrArray(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteTmplSwitchByIds(String ids) {
|
||||
return tmplSwitchMapper.deleteTmplSwitchByIds(Convert.toStrArray(ids));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,4 +67,11 @@
|
|||
</foreach>
|
||||
</delete>
|
||||
|
||||
<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>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue