diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/ChannelController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/ChannelController.java index 90ecd3c24..1f8eeca24 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/ChannelController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/ChannelController.java @@ -22,6 +22,7 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanWrapperImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.http.HttpHeaders; @@ -33,6 +34,7 @@ import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.async.DeferredResult; +import java.beans.PropertyDescriptor; import java.net.MalformedURLException; import java.net.URL; import java.util.List; @@ -86,13 +88,26 @@ public class ChannelController { @Operation(summary = "更新通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) @PostMapping("/update") public void update(@RequestBody CommonGBChannel channel){ + BeanWrapperImpl wrapper = new BeanWrapperImpl(channel); + int count = 0; + for (PropertyDescriptor pd : wrapper.getPropertyDescriptors()) { + String name = pd.getName(); + if ("class".equals(name)) continue; + if (pd.getReadMethod() == null) continue; + Object val = wrapper.getPropertyValue(name); + if (val != null) count++; + } + Assert.isTrue(count > 1, "未进行任何修改"); channelService.update(channel); } + @Operation(summary = "重置国标通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) @PostMapping("/reset") - public void reset(Integer id){ - channelService.reset(id); + public void reset(ResetParam param){ + Assert.notNull(param.getId(), "通道ID不能为空"); + Assert.notEmpty(param.getChanelFields(), "待重置字段不可以空"); + channelService.reset(param.getId(), param.getChanelFields()); } @Operation(summary = "增加通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/bean/ResetParam.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/bean/ResetParam.java new file mode 100644 index 000000000..bcb144be5 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/bean/ResetParam.java @@ -0,0 +1,15 @@ +package com.genersoft.iot.vmp.gb28181.controller.bean; + +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Getter +@Setter +public class ResetParam { + + private Integer id; + private List chanelFields; + +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index 37e19617e..1a25105b7 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -117,40 +117,40 @@ public interface CommonGBChannelMapper { @Update(value = {" "}) int update(CommonGBChannel commonGBChannel); @@ -236,17 +236,13 @@ public interface CommonGBChannelMapper { @Update(value = {" "}) - void reset(@Param("id") int id, @Param("dataType") Integer dataType, @Param("dataDeviceId") int dataDeviceId, @Param("updateTime") String updateTime); + void reset(@Param("id") int id, List fields, @Param("updateTime") String updateTime); @SelectProvider(type = ChannelProvider.class, method = "queryByIds") @@ -421,7 +417,7 @@ public interface CommonGBChannelMapper { ", gb_ip_address=#{item.gbIpAddress}" + ", gb_port=#{item.gbPort}" + ", gb_password=#{item.gbPassword}" + - ", gb_status=#{item.gbStatus}" + + " , gb_status=#{item.gbStatus} " + ", gb_longitude=#{item.gbLongitude}" + ", gb_latitude=#{item.gbLatitude}" + ", gb_ptz_type=#{item.gbPtzType}" + diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java index 3571dadfa..1edee0166 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java @@ -309,12 +309,12 @@ public interface GroupMapper { @Select("