Commit b7e1729d by tutingyin

feat: 内外网隔离策略

parent 23967958
package com.skr.mdm.bean.qo.strategy;
import com.skr.mdm.bean.qo.BaseStrategyQO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
/**
* 网络隔离策略
* strategy_network_isolation
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class StrategyNetworkIsolationQO extends BaseStrategyQO {
private Integer id;
@NotBlank(message = "策略名称不能为空")
@ApiModelProperty(value = "策略名称")
private String strategyName;
@ApiModelProperty(value = "作用域 (1:个人域 2:工作域 3:个人域和工作域)")
private Integer actionScope;
@ApiModelProperty(value = "1: 有围栏策略 0:无围栏策略")
private Integer rail;
@ApiModelProperty(value = "经度")
private String longitude;
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "半径")
private String radius;
@ApiModelProperty(value = "自定义范围")
private String locs;
@ApiModelProperty(value = "url")
private String url;
@ApiModelProperty(value = "ip")
private String ip;
@ApiModelProperty(value = "dns")
private String dns;
}
\ No newline at end of file
package com.skr.mdm.bean.so.strategy;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author tty
* @date 2024/9/12 15:30
*/
@Data
@ApiModel(value = "内外网隔离策略策略下发对象")
public class NetworkIsoStrategySO {
private Integer id;
@ApiModelProperty(value = "策略名称")
private String strategyName;
@ApiModelProperty(value = "作用域 (1:个人域 2:工作域 3:个人域和工作域)")
private Integer actionScope;
@ApiModelProperty(value = "1: 有围栏策略 0:无围栏策略")
private Integer rail;
@ApiModelProperty(value = "经度")
private String longitude;
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "半径")
private String radius;
@ApiModelProperty(value = "自定义范围")
private String locs;
@ApiModelProperty(value = "url")
private String url;
@ApiModelProperty(value = "ip")
private String ip;
@ApiModelProperty(value = "dns")
private String dns;
@ApiModelProperty(value = "下发时间")
private Long sendTime;
@ApiModelProperty(value = "操作时间")
private Long operateTime;
@ApiModelProperty(value = "策略全局类型(1:公司全局 2:部门全局 3:个人)")
private Integer globalType;
}
\ No newline at end of file
package com.skr.mdm.bean.vo.strategy;
import com.skr.mdm.bean.qo.BaseStrategyQO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
/**
* 网络隔离策略
* strategy_network_isolation
*/
@Data
public class StrategyNetworkIsolationVO {
@ApiModelProperty(value = "策略ID")
private Integer id;
@ApiModelProperty(value = "策略名称")
private String strategyName;
@ApiModelProperty(value = "作用域 (1:个人域 2:工作域 3:个人域和工作域)")
private Integer actionScope;
@ApiModelProperty(value = "1: 有围栏策略 0:无围栏策略")
private Integer rail;
@ApiModelProperty(value = "经度")
private String longitude;
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "半径")
private String radius;
@ApiModelProperty(value = "自定义范围")
private String locs;
@ApiModelProperty(value = "url")
private String url;
@ApiModelProperty(value = "ip")
private String ip;
@ApiModelProperty(value = "dns")
private String dns;
@ApiModelProperty(value = "策略全局类型(1:公司全局 2:部门全局 3:个人)")
private Integer globalType;
}
\ No newline at end of file
package com.skr.mdm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.skr.mdm.bean.bo.StrategyIssuedBO;
import com.skr.mdm.bean.qo.StrategyQueryQO;
import com.skr.mdm.bean.vo.strategy.StrategyVO;
import com.skr.mdm.entity.StrategyNetworkIsolationDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface StrategyNetworkIsolationDao extends BaseMapper<StrategyNetworkIsolationDO> {
int deleteByPrimaryKey(Integer id);
int insert(StrategyNetworkIsolationDO record);
int insertSelective(StrategyNetworkIsolationDO record);
StrategyNetworkIsolationDO selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(StrategyNetworkIsolationDO record);
int updateByPrimaryKey(StrategyNetworkIsolationDO record);
/**
* 策略列表
* @param strategyQueryQO
* @return
*/
List<StrategyVO> listStrategy(StrategyQueryQO strategyQueryQO);
/**
* 根据公司ID删除
* @param companyId 公司ID
*/
void deleteByCompanyId(@Param("companyId") Integer companyId);
/**
* 获取未禁用配置策略
* @param equipmentId
* @param state
* @return
*/
List<StrategyIssuedBO> listStrategyIdByEquipmentId(@Param("equipmentId") Integer equipmentId, @Param("state") Integer state, @Param("issuedState") Integer issuedState);
}
\ No newline at end of file
package com.skr.mdm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.skr.mdm.bean.qo.controller.LargeScreenQO;
import com.skr.mdm.bean.vo.strategy.StrategyUserVO;
import com.skr.mdm.entity.StrategyConfigUserDO;
import com.skr.mdm.entity.StrategyNetworkIsolationUserDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
@Repository
public interface StrategyNetworkIsolationUserDao extends BaseMapper<StrategyNetworkIsolationUserDO>{
/**
* 根据设备ID删除
* @param equipmentIdList 设备ID集合
*/
void deleteByEquipmentIdList(@Param("equipmentIdList") List<Integer> equipmentIdList);
/**
* 批量添加
* @param list
*/
void insertBatch(@Param("list") List<StrategyNetworkIsolationUserDO> list);
/**
* 配置策略作用人列表
* @param strategyId
* @return
*/
List<StrategyUserVO> listStrategyUser(@Param("strategyId") Integer strategyId,
@Param("searchType") Integer searchType,
@Param("searchValue") String searchValue);
/**
* 批量更新
* @param list
*/
void updateBatch(@Param("list") List<StrategyConfigUserDO> list);
/**
* 批量更新设备状态
* @param strategyId
* @param equipmentIdList
* @param issuedTime
* @param state
* @return
*/
int updateStateByStrategyId(@Param("strategyId") Integer strategyId, @Param("equipmentIdList") List<Integer> equipmentIdList, @Param("issuedTime") Date issuedTime, @Param("state") Integer state);
/**
* 获取策略设备id
* @param list
* @return
*/
List<Integer> listEquipmentIdByStrategyIds(@Param("list") List<Integer> list);
List<Integer> queryConfigStrategyStatistics(LargeScreenQO largeScreenQO);
void insertStrategyConfigUser(@Param("deviceIdList") List<Integer> deviceIdList, @Param("id") Integer id);
List<Integer> listStrategyIdListByEquipmentId(@Param("deviceIdList") List<Integer> deviceIdList);
}
\ No newline at end of file
package com.skr.mdm.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Builder;
import lombok.Data;
/**
* 网络隔离策略
* strategy_network_isolation
*/
@Data
@TableName("strategy_network_isolation")
@Builder
public class StrategyNetworkIsolationDO implements Serializable {
private Integer id;
/**
* 策略名称
*/
private String strategyName;
private Object url;
private Object dns;
private Object ip;
/**
* 策略状态(1:保存未下发 2:已下发(启用)3:禁用)
*/
private Integer state;
/**
* 操作人
*/
private String operator;
private Date operateTime;
/**
* 全局类型( 1:公司全局 2:部门全局 3:用户)
*/
private Integer globalType;
/**
* 部门全局ID数组
*/
private String departmentIds;
/**
* 公司id
*/
private Integer companyId;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.skr.mdm.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Builder;
import lombok.Data;
/**
* 策略作用人
* strategy_network_isolation_user
*/
@Data
@Builder
@TableName("strategy_network_isolation_user")
public class StrategyNetworkIsolationUserDO implements Serializable {
private Integer id;
private Integer strategyId;
/**
* 设备id
*/
private Integer equipmentId;
/**
* 状态 1:下发中 2:下发成功 3:执行中 4:执行成功
*/
private Integer state;
/**
* 1:管控中 2:未管控
*/
private Integer mdmStatus;
/**
* 下发时间
*/
private Date issuedTime;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
<?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.skr.mdm.dao.StrategyNetworkIsolationDao">
<resultMap id="BaseResultMap" type="com.skr.mdm.entity.StrategyNetworkIsolationDO">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="strategy_name" jdbcType="VARCHAR" property="strategyName" />
<result column="url" jdbcType="OTHER" property="url" />
<result column="dns" jdbcType="OTHER" property="dns" />
<result column="ip" jdbcType="OTHER" property="ip" />
<result column="state" jdbcType="TINYINT" property="state" />
<result column="operator" jdbcType="VARCHAR" property="operator" />
<result column="operate_time" jdbcType="TIMESTAMP" property="operateTime" />
<result column="global_type" jdbcType="TINYINT" property="globalType" />
<result column="department_ids" jdbcType="VARCHAR" property="departmentIds" />
<result column="company_id" jdbcType="INTEGER" property="companyId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
id, strategy_name, url, dns, ip, `state`, `operator`, operate_time, global_type,
department_ids, company_id, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from strategy_network_isolation
where id = #{id,jdbcType=INTEGER}
</select>
<select id="listStrategy" resultType="com.skr.mdm.bean.vo.strategy.StrategyVO">
select t1.id, t1.global_type, t1.strategy_name, t1.state, t1.operate_time, t1.operator, 2 as strategyType,
t1.department_ids from strategy_network_isolation t1
left join strategy_network_isolation_user t2 on t1.id = t2.strategy_id
left join device_equipment t3 on t2.equipment_id = t3.id
where t1.company_id = #{companyId}
<if test="searchType == 1">
and t1.strategy_name like concat(concat('%', #{searchValue}), '%')
</if>
<if test="searchType == 2">
and date_format(t1.create_time, '%Y-%m-%d') = #{searchValue}
</if>
<if test="searchType == 3">
and t3.user_name like concat(concat('%', #{searchValue}), '%')
</if>
group by t1.id
order by t1.operate_time desc
</select>
<select id="listStrategyIdByEquipmentId" resultType="com.skr.mdm.bean.bo.StrategyIssuedBO">
select t2.strategy_id, t2.issued_time as sendTime, t1.operate_time
from strategy_network_isolation t1 join strategy_network_isolation_user t2 on t1.id = t2.strategy_id
where t2.equipment_id = #{equipmentId} and t1.state != #{state} and t2.state != #{issuedState}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from strategy_network_isolation
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByCompanyId">
delete
from strategy_network_isolation
where company_id = #{companyId}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.skr.mdm.entity.StrategyNetworkIsolationDO" useGeneratedKeys="true">
insert into strategy_network_isolation (strategy_name, url, dns,
ip, `state`, `operator`,
operate_time, global_type, department_ids,
company_id, create_time, update_time
)
values (#{strategyName,jdbcType=VARCHAR}, #{url,jdbcType=OTHER}, #{dns,jdbcType=OTHER},
#{ip,jdbcType=OTHER}, #{state,jdbcType=TINYINT}, #{operator,jdbcType=VARCHAR},
#{operateTime,jdbcType=TIMESTAMP}, #{globalType,jdbcType=TINYINT}, #{departmentIds,jdbcType=VARCHAR},
#{companyId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.skr.mdm.entity.StrategyNetworkIsolationDO" useGeneratedKeys="true">
insert into strategy_network_isolation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="strategyName != null">
strategy_name,
</if>
<if test="url != null">
url,
</if>
<if test="dns != null">
dns,
</if>
<if test="ip != null">
ip,
</if>
<if test="state != null">
`state`,
</if>
<if test="operator != null">
`operator`,
</if>
<if test="operateTime != null">
operate_time,
</if>
<if test="globalType != null">
global_type,
</if>
<if test="departmentIds != null">
department_ids,
</if>
<if test="companyId != null">
company_id,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="strategyName != null">
#{strategyName,jdbcType=VARCHAR},
</if>
<if test="url != null">
#{url,jdbcType=OTHER},
</if>
<if test="dns != null">
#{dns,jdbcType=OTHER},
</if>
<if test="ip != null">
#{ip,jdbcType=OTHER},
</if>
<if test="state != null">
#{state,jdbcType=TINYINT},
</if>
<if test="operator != null">
#{operator,jdbcType=VARCHAR},
</if>
<if test="operateTime != null">
#{operateTime,jdbcType=TIMESTAMP},
</if>
<if test="globalType != null">
#{globalType,jdbcType=TINYINT},
</if>
<if test="departmentIds != null">
#{departmentIds,jdbcType=VARCHAR},
</if>
<if test="companyId != null">
#{companyId,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.skr.mdm.entity.StrategyNetworkIsolationDO">
update strategy_network_isolation
<set>
<if test="strategyName != null">
strategy_name = #{strategyName,jdbcType=VARCHAR},
</if>
<if test="url != null">
url = #{url,jdbcType=OTHER},
</if>
<if test="dns != null">
dns = #{dns,jdbcType=OTHER},
</if>
<if test="ip != null">
ip = #{ip,jdbcType=OTHER},
</if>
<if test="state != null">
`state` = #{state,jdbcType=TINYINT},
</if>
<if test="operator != null">
`operator` = #{operator,jdbcType=VARCHAR},
</if>
<if test="operateTime != null">
operate_time = #{operateTime,jdbcType=TIMESTAMP},
</if>
<if test="globalType != null">
global_type = #{globalType,jdbcType=TINYINT},
</if>
<if test="departmentIds != null">
department_ids = #{departmentIds,jdbcType=VARCHAR},
</if>
<if test="companyId != null">
company_id = #{companyId,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.skr.mdm.entity.StrategyNetworkIsolationDO">
update strategy_network_isolation
set strategy_name = #{strategyName,jdbcType=VARCHAR},
url = #{url,jdbcType=OTHER},
dns = #{dns,jdbcType=OTHER},
ip = #{ip,jdbcType=OTHER},
`state` = #{state,jdbcType=TINYINT},
`operator` = #{operator,jdbcType=VARCHAR},
operate_time = #{operateTime,jdbcType=TIMESTAMP},
global_type = #{globalType,jdbcType=TINYINT},
department_ids = #{departmentIds,jdbcType=VARCHAR},
company_id = #{companyId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
<?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.skr.mdm.dao.StrategyNetworkIsolationUserDao">
<resultMap id="BaseResultMap" type="com.skr.mdm.entity.StrategyNetworkIsolationUserDO">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="strategy_id" jdbcType="INTEGER" property="strategyId" />
<result column="equipment_id" jdbcType="INTEGER" property="equipmentId" />
<result column="state" jdbcType="TINYINT" property="state" />
<result column="mdm_status" jdbcType="TINYINT" property="mdmStatus" />
<result column="issued_time" jdbcType="TIMESTAMP" property="issuedTime" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
id, strategy_id, equipment_id, `state`, mdm_status, issued_time, create_time, update_time
</sql>
<delete id="deleteByEquipmentIdList">
delete from strategy_network_isolation_user where equipment_id in
<foreach collection="equipmentIdList" open="(" close=")" separator="," item="equipmentId">
#{equipmentId}
</foreach>
</delete>
<insert id="insertBatch">
insert into strategy_network_isolation_user(strategy_id, equipment_id, state, issued_time) VALUES
<foreach collection="list" separator="," item="item">
(#{item.strategyId}, #{item.equipmentId}, #{item.state}, #{item.issuedTime})
</foreach>
</insert>
<insert id="insertStrategyConfigUser">
insert into strategy_network_isolation_user(strategy_id, equipment_id, state, issued_time) VALUES
<foreach collection="deviceIdList" separator="," item="equipmentId">
(#{id}, #{equipmentId}, 1, now())
</foreach>
</insert>
<select id="listStrategyUser" resultType="com.skr.mdm.bean.vo.strategy.StrategyUserVO">
select t1.id, t2.user_name, t1.equipment_id, t2.equipment_name, t2.equipment_model, t2.department_name, t1.state, t1.issued_time
from strategy_network_isolation_user t1
join device_equipment t2 on t1.equipment_id = t2.id
where t1.strategy_id = #{strategyId}
<if test="searchType == 1">
and t2.user_name like concat(concat('%', #{searchValue}), '%')
</if>
<if test="searchType == 2">
and t2.equipment_name like concat(concat('%', #{searchValue}), '%')
</if>
<if test="searchType == 3">
and t2.department_name like concat(concat('%', #{searchValue}), '%')
</if>
<if test="searchType == 4">
and t2.imei like concat(concat('%', #{searchValue}), '%')
</if>
<if test="searchType == 5">
and t1.state = #{searchValue}
</if>
order by t1.issued_time desc, t1.id
</select>
<update id="updateBatch">
<foreach collection="list" separator=";" item="item">
update strategy_network_isolation_user set
state = #{item.state},
issued_time = #{item.issuedTime}
where strategy_id = #{item.strategyId} and equipment_id = #{item.equipmentId}
</foreach>
</update>
<update id="updateStateByStrategyId">
update strategy_network_isolation_user
set state = #{state},
issued_time = #{issuedTime}
where strategy_id = #{strategyId}
and equipment_id in
<foreach collection="equipmentIdList" open="(" close=")" item="equipmentId" separator=",">
#{equipmentId}
</foreach>
</update>
<select id="listEquipmentIdByStrategyIds" resultType="java.lang.Integer">
select equipment_id from strategy_network_isolation_user where strategy_id in
<foreach collection="list" open="(" close=")" separator="," item="strategyId">
#{strategyId}
</foreach>
</select>
<select id="queryConfigStrategyStatistics" resultType="integer">
SELECT scu.state
FROM strategy_config sc
JOIN strategy_network_isolation_user scu ON sc.id = scu.strategy_id
WHERE sc.company_id = #{companyId}
<if test="startTime != null and startTime != '' ">
AND scu.update_time &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != '' ">
AND scu.update_time &lt;= #{endTime}
</if>
</select>
<select id="listStrategyIdListByEquipmentId" resultType="java.lang.Integer">
SELECT strategy_id FROM strategy_network_isolation_user
WHERE equipment_id IN
<foreach collection="deviceIdList" item="deviceId" open="(" close=")" separator=",">
#{deviceId}
</foreach>
</select>
</mapper>
\ No newline at end of file
package com.skr.mdm.manager;
import com.skr.mdm.bean.so.strategy.*;
import com.skr.mdm.dao.*;
import com.skr.mdm.entity.*;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* 内外网隔离策略通用处理
* @author tty
* @date 2024-09-12 15:45
*/
@Component
public class NetworkIsoStrategyManager {
@Autowired
private StrategyNetworkIsolationDao networkIsolationDao;
/**
* 获取内外网隔离策略下发数据
*
* @param strategyIdList
* @param currentTime
* @return
*/
public List<NetworkIsoStrategySO> getStrategySO(List<Integer> strategyIdList, Long currentTime) {
List<StrategyNetworkIsolationDO> strategyConfigDOList = networkIsolationDao.selectBatchIds(strategyIdList);
List<NetworkIsoStrategySO> networkIsolationSOList = new ArrayList<>(strategyConfigDOList.size());
if (CollectionUtils.isEmpty(strategyConfigDOList)) {
return networkIsolationSOList;
}
strategyConfigDOList.forEach(strategyConfigDO -> {
NetworkIsoStrategySO networkIsoStrategySO = new NetworkIsoStrategySO();
BeanUtils.copyProperties(strategyConfigDO, networkIsoStrategySO);
networkIsoStrategySO.setOperateTime(strategyConfigDO.getOperateTime().getTime());
networkIsoStrategySO.setSendTime(currentTime);
networkIsolationSOList.add(networkIsoStrategySO);
});
return networkIsolationSOList;
}
}
\ No newline at end of file
package com.skr.mdm.api.strategy.controller;
import com.skr.mdm.api.strategy.service.ConfigStrategyService;
import com.skr.mdm.api.strategy.service.NetworkIsolationStrategyService;
import com.skr.mdm.bean.qo.StrategyUserQO;
import com.skr.mdm.bean.qo.strategy.ConfigStrategyQO;
import com.skr.mdm.dto.LoginAdminDTO;
import com.skr.mdm.result.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @Author tty
* @Date 2024/9/12 9:22
* @Description 内外网隔离策略
*/
@Validated
@RestController
@RequestMapping("strategy/network")
@Api(tags = "内外网隔离策略")
public class NetworkIsolationStrategyController {
@Autowired
private NetworkIsolationStrategyService networkIsolationStrategyService;
@PostMapping("add")
@ApiOperation(value = "创建")
@PreAuthorize("hasAnyAuthority('sys:strategy:config:add')")
public ResponseResult addStrategy(@RequestBody @Valid ConfigStrategyQO configStrategyQO,
@ApiIgnore Authentication authentication) {
LoginAdminDTO loginAdminDTO = (LoginAdminDTO) authentication.getPrincipal();
return networkIsolationStrategyService.addStrategy(configStrategyQO, loginAdminDTO);
}
@PostMapping("update")
@ApiOperation(value = "编辑")
@PreAuthorize("hasAnyAuthority('sys:strategy:update')")
public ResponseResult updateStrategy(@RequestBody @Valid ConfigStrategyQO configStrategyQO,
@ApiIgnore Authentication authentication) {
LoginAdminDTO loginAdminDTO = (LoginAdminDTO) authentication.getPrincipal();
return networkIsolationStrategyService.updateStrategy(configStrategyQO, loginAdminDTO);
}
@PostMapping("user/list")
@ApiOperation(value = "作用人列表")
@PreAuthorize("hasAnyAuthority('sys:strategy:user:list')")
public ResponseResult listStrategyUser(@RequestBody @Valid StrategyUserQO strategyUserQO) {
return networkIsolationStrategyService.listStrategyUser(strategyUserQO);
}
@PostMapping("user/delete")
@ApiOperation(value = "作用人删除")
@PreAuthorize("hasAnyAuthority('sys:strategy:user:delete')")
public ResponseResult deleteStrategyUser(@RequestParam @NotNull(message = "策略ID不能为空") Integer strategyId,
@RequestParam @NotEmpty(message = "设备ID不能为空") List<Integer> equipmentIdList,
@ApiIgnore Authentication authentication) {
LoginAdminDTO loginAdminDTO = (LoginAdminDTO) authentication.getPrincipal();
return networkIsolationStrategyService.deleteStrategyUser(strategyId, equipmentIdList, loginAdminDTO);
}
@PostMapping("state/change")
@ApiOperation(value = "启用禁用")
@PreAuthorize("hasAnyAuthority('sys:strategy:able')")
public ResponseResult updateStrategyState(@RequestParam @NotNull(message = "策略ID不能为空") Integer strategyId,
@RequestParam @NotNull(message = "策略状态不能为空") Integer state,
@ApiIgnore Authentication authentication) {
LoginAdminDTO loginAdminDTO = (LoginAdminDTO) authentication.getPrincipal();
return networkIsolationStrategyService.updateStrategyState(strategyId, state, loginAdminDTO);
}
@PostMapping("info")
@ApiOperation(value = "详细信息")
@PreAuthorize("hasAnyAuthority('sys:strategy:list')")
public ResponseResult strategyInfo(@RequestParam @NotNull(message = "策略ID不能为空") Integer strategyId) {
return networkIsolationStrategyService.strategyInfo(strategyId);
}
}
\ No newline at end of file
package com.skr.mdm.api.strategy.service;
import com.skr.mdm.api.template.DefaultStrategyService;
import com.skr.mdm.bean.qo.StrategyQueryQO;
import com.skr.mdm.bean.vo.strategy.StrategyVO;
import java.util.List;
public interface NetworkIsolationStrategyService extends DefaultStrategyService {
List<StrategyVO> listStrategy(StrategyQueryQO strategyQueryQO);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment