Mr.Wang
7 months ago
6 changed files with 277 additions and 0 deletions
@ -0,0 +1,46 @@ |
|||||
|
package com.zc.business.controller; |
||||
|
|
||||
|
import com.ruoyi.common.core.controller.BaseController; |
||||
|
import com.ruoyi.common.core.domain.AjaxResult; |
||||
|
import com.zc.business.domain.DcSwitch; |
||||
|
import com.zc.business.service.DcSwitchService; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
|
||||
|
/** |
||||
|
* 交换机Controller |
||||
|
* |
||||
|
* @author wangjiabao |
||||
|
*/ |
||||
|
@Api(tags = {"交换机"}) |
||||
|
@RestController |
||||
|
@RequestMapping("/business/switch") |
||||
|
public class DcSwitchController extends BaseController { |
||||
|
|
||||
|
@Resource |
||||
|
private DcSwitchService dcSwitchService; |
||||
|
|
||||
|
/** |
||||
|
* 查询交换机 |
||||
|
*/ |
||||
|
@ApiOperation("查询交换机") |
||||
|
@GetMapping("/query") |
||||
|
public AjaxResult getSwitchList(DcSwitch dcSwitch) { |
||||
|
return AjaxResult.success(dcSwitchService.getSwitchList(dcSwitch)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据设备列表查询设备 |
||||
|
*/ |
||||
|
@ApiOperation("根据设备列表查询设备") |
||||
|
@GetMapping("/deviceList/{deviceList}") |
||||
|
public AjaxResult getDeviceList(@PathVariable String deviceList) { |
||||
|
return AjaxResult.success(dcSwitchService.getDeviceList(deviceList)); |
||||
|
} |
||||
|
} |
@ -0,0 +1,98 @@ |
|||||
|
package com.zc.business.domain; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.ruoyi.common.annotation.Excel; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 交换机对象 dc_switch |
||||
|
* |
||||
|
* @author wangjiabao |
||||
|
* @date 2024-04-19 |
||||
|
*/ |
||||
|
|
||||
|
@ApiModel("交换机实体") |
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
@NoArgsConstructor |
||||
|
public class DcSwitch { |
||||
|
|
||||
|
/** |
||||
|
* 交换机编号 |
||||
|
*/ |
||||
|
@Excel(name = "交换机编号") |
||||
|
@ApiModelProperty("交换机编号") |
||||
|
private Integer switchId; |
||||
|
|
||||
|
/** |
||||
|
* 父交换机编号 |
||||
|
*/ |
||||
|
@Excel(name = "父交换机编号") |
||||
|
@ApiModelProperty("父交换机编号") |
||||
|
private Integer parentId; |
||||
|
|
||||
|
/** |
||||
|
* 祖级列表 |
||||
|
*/ |
||||
|
@Excel(name = "祖级列表") |
||||
|
@ApiModelProperty("祖级列表") |
||||
|
private String ancestors; |
||||
|
|
||||
|
/** |
||||
|
* 交换机名称 |
||||
|
*/ |
||||
|
@Excel(name = "交换机名称") |
||||
|
@ApiModelProperty("交换机名称") |
||||
|
private String switchName; |
||||
|
|
||||
|
/** |
||||
|
* 所在桩号 |
||||
|
*/ |
||||
|
@Excel(name = "所在桩号") |
||||
|
@ApiModelProperty("所在桩号") |
||||
|
private String stakeMark; |
||||
|
|
||||
|
/** |
||||
|
* 设备列表 |
||||
|
*/ |
||||
|
@Excel(name = "设备列表") |
||||
|
@ApiModelProperty("设备列表") |
||||
|
private String deviceList; |
||||
|
/** |
||||
|
* 交换机ip |
||||
|
*/ |
||||
|
@Excel(name = "交换机ip") |
||||
|
@ApiModelProperty("交换机ip") |
||||
|
private String switchIp; |
||||
|
|
||||
|
/** |
||||
|
* 使用状态 |
||||
|
*/ |
||||
|
@Excel(name = "使用状态") |
||||
|
@ApiModelProperty("使用状态") |
||||
|
private Integer userState; |
||||
|
|
||||
|
/** |
||||
|
* 创建时间 |
||||
|
*/ |
||||
|
@Excel(name = "创建时间") |
||||
|
@ApiModelProperty("创建时间") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") |
||||
|
private Date createTime; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
@Excel(name = "更新时间") |
||||
|
@ApiModelProperty("更新时间") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") |
||||
|
private Date updateTime; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package com.zc.business.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.zc.business.domain.DcSwitch; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 交换机Mapper接口 |
||||
|
* |
||||
|
* @author wangjiabao |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface DcSwitchMapper extends BaseMapper<DcSwitch> { |
||||
|
List<DcSwitch> getSwitchList(DcSwitch dcSwitch); |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package com.zc.business.service; |
||||
|
|
||||
|
import com.zc.business.domain.DcDevice; |
||||
|
import com.zc.business.domain.DcSwitch; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 交换机Service接口 |
||||
|
* |
||||
|
* @author wangjiabao |
||||
|
* @date 2024-04-19 |
||||
|
*/ |
||||
|
public interface DcSwitchService { |
||||
|
|
||||
|
/** |
||||
|
* 查询交换机 |
||||
|
*/ |
||||
|
List<DcSwitch> getSwitchList(DcSwitch dcSwitch); |
||||
|
|
||||
|
/** |
||||
|
* 根据设备列表查询设备 |
||||
|
*/ |
||||
|
List<DcDevice> getDeviceList(String deviceList); |
||||
|
} |
@ -0,0 +1,48 @@ |
|||||
|
package com.zc.business.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.zc.business.domain.DcDevice; |
||||
|
import com.zc.business.domain.DcSwitch; |
||||
|
import com.zc.business.mapper.DcDeviceMapper; |
||||
|
import com.zc.business.mapper.DcSwitchMapper; |
||||
|
import com.zc.business.service.DcSwitchService; |
||||
|
import com.zc.business.service.IDcDeviceService; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 交换机Service实现类 |
||||
|
* |
||||
|
* @author wangjiabao |
||||
|
* @date 2024-04-19 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class DcSwitchServiceImpl extends ServiceImpl<DcSwitchMapper, DcSwitch> implements DcSwitchService { |
||||
|
|
||||
|
@Resource |
||||
|
private DcSwitchMapper dcSwitchMapper; |
||||
|
|
||||
|
@Resource |
||||
|
private DcDeviceMapper dcDeviceMapper; |
||||
|
|
||||
|
/** |
||||
|
* 查询交换机 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<DcSwitch> getSwitchList(DcSwitch dcSwitch) { |
||||
|
return dcSwitchMapper.getSwitchList(dcSwitch); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据设备列表查询设备 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<DcDevice> getDeviceList(String deviceList) { |
||||
|
List<String> devices = Arrays.stream(deviceList.split(",")).collect(Collectors.toList()); |
||||
|
return dcDeviceMapper.selectBatchIds(devices); |
||||
|
} |
||||
|
} |
@ -0,0 +1,43 @@ |
|||||
|
<?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.zc.business.mapper.DcSwitchMapper"> |
||||
|
|
||||
|
<resultMap type="DcSwitch" id="DcSwitch"> |
||||
|
<result property="switchId" column="switch_id"/> |
||||
|
<result property="parentId" column="parent_id"/> |
||||
|
<result property="ancestors" column="ancestors"/> |
||||
|
<result property="switchName" column="switch_name"/> |
||||
|
<result property="stakeMark" column="stake_mark"/> |
||||
|
<result property="deviceList" column="device_list"/> |
||||
|
<result property="switchIp" column="switch_ip"/> |
||||
|
<result property="userState" column="user_state"/> |
||||
|
<result property="stakeMark" column="stake_mark"/> |
||||
|
<result property="createTime" column="create_time"/> |
||||
|
<result property="updateTime" column="update_time"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
<sql id="selectDcSwitchVo"> |
||||
|
select switch_id, |
||||
|
parent_id, |
||||
|
ancestors, |
||||
|
switch_name, |
||||
|
stake_mark, |
||||
|
device_list, |
||||
|
switch_ip, |
||||
|
user_state, |
||||
|
create_time, |
||||
|
update_time |
||||
|
from dc_switch |
||||
|
</sql> |
||||
|
|
||||
|
<select id="getSwitchList" parameterType="DcSwitch" resultType="DcSwitch"> |
||||
|
<include refid="selectDcSwitchVo"/> |
||||
|
<where> |
||||
|
<if test="parentId != null ">and parent_id = #{parentId}</if> |
||||
|
</where> |
||||
|
and user_state = 1 |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue