Selaa lähdekoodia

Merge remote-tracking branch 'origin/20210716' into 20210716

hym 3 vuotta sitten
vanhempi
commit
b0b4eccd38

+ 7 - 0
zoniot-rmcp/zoniot-rmcp-api/src/main/java/com/zcxk/rmcp/api/dto/device/DeviceInputDto.java

@@ -4,6 +4,9 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
@@ -18,18 +21,22 @@ public class DeviceInputDto {
     @ApiModelProperty(value="编号")
     private Long id;
 
+    @NotNull(message = "companyOrgId cannot be empty")
     @ApiModelProperty(value="公司")
     private Integer companyOrgId;
 
     @ApiModelProperty(value="部门")
     private Integer deptOrgId;
 
+    @NotNull(message = "productId cannot be empty")
     @ApiModelProperty(value="产品")
     private Integer productId;
 
+    @NotBlank(message = "deviceNo cannot be empty")
     @ApiModelProperty(value="设备编号")
     private String deviceNo;
 
+    @NotBlank(message = "meterNo cannot be empty")
     @ApiModelProperty(value="电子号")
     private String meterNo;
 

+ 1 - 1
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/config/ResourceServerConfig.java

@@ -24,7 +24,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
                     "/file/**","/test/test",
                    "/v2/**")
             .permitAll() //配置不需要身份认证的请求路径
-           // .anyRequest().authenticated() //其他所有访问路径都需要身份认证
+            .anyRequest().authenticated() //其他所有访问路径都需要身份认证
             .and()
             .httpBasic();
     }

+ 2 - 2
zoniot-rmcp/zoniot-rmcp-web/src/main/java/com/zcxk/rmcp/web/controller/DeviceController.java

@@ -76,7 +76,7 @@ public class DeviceController {
     @PostMapping("add")
     @ApiOperation(value = "添加设备")
     public AjaxMessage<Void> add(
-            @ApiParam(value = "设备", required = true) @RequestBody(required = true) DeviceInputDto device
+            @ApiParam(value = "设备", required = true) @RequestBody(required = true) @Valid DeviceInputDto device
     ) {
         deviceService.add(device);
         return AjaxMessage.success();
@@ -87,7 +87,7 @@ public class DeviceController {
     @PostMapping("edit")
     @ApiOperation(value = "编辑设备")
     public AjaxMessage<Void> edit(
-            @ApiParam(value = "设备", required = true) @RequestBody(required = true) DeviceInputDto device
+            @ApiParam(value = "设备", required = true) @RequestBody(required = true) @Valid DeviceInputDto device
     ) {
         deviceService.edit(device);
         return AjaxMessage.success();