Commit 0e76d24b authored by 以墨为白's avatar 以墨为白 🎧

分组校验

parent 189f62d7
package com.zksy.szpt.controller; package com.zksy.szpt.controller;
import com.zksy.szpt.domain.ValidationGroups;
import com.zksy.szpt.domain.dto.AppStoreDTO; import com.zksy.szpt.domain.dto.AppStoreDTO;
import com.zksy.szpt.service.AppStoreService; import com.zksy.szpt.service.AppStoreService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
@Api(tags = "appKey管理") @Api(tags = "appKey管理")
@RequestMapping("/rest/appStore") @RequestMapping("/rest/appStore")
@RestController @RestController
...@@ -29,13 +29,13 @@ public class AppStoreController { ...@@ -29,13 +29,13 @@ public class AppStoreController {
@ApiOperation(value = "新增appKey", notes = "新增appKey") @ApiOperation(value = "新增appKey", notes = "新增appKey")
@PostMapping("/insertAppStore") @PostMapping("/insertAppStore")
public Integer insertAppStore(@RequestBody @Valid AppStoreDTO appStoreDTO) { public Integer insertAppStore(@RequestBody @Validated({ValidationGroups.Create.class}) AppStoreDTO appStoreDTO) {
return appStoreService.insertAppStore(appStoreDTO); return appStoreService.insertAppStore(appStoreDTO);
} }
@ApiOperation(value = "更新appKey", notes = "更新appKey") @ApiOperation(value = "更新appKey", notes = "更新appKey")
@PostMapping("/updateAppIdSecret") @PostMapping("/updateAppIdSecret")
public Integer updateAppStore(@RequestBody @Valid AppStoreDTO appStoreDTO) { public Integer updateAppStore(@RequestBody @Validated({ValidationGroups.Update.class}) AppStoreDTO appStoreDTO) {
return appStoreService.updateAppStore(appStoreDTO); return appStoreService.updateAppStore(appStoreDTO);
} }
} }
package com.zksy.szpt.domain;
public interface ValidationGroups {
interface Create {
}
interface Update {
}
interface Query {
}
}
package com.zksy.szpt.domain.dto; package com.zksy.szpt.domain.dto;
import com.zksy.szpt.domain.ValidationGroups;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -8,16 +9,15 @@ import javax.validation.constraints.NotBlank; ...@@ -8,16 +9,15 @@ import javax.validation.constraints.NotBlank;
@ApiModel(value = "AppStoreDTO", description = "应用商店信息") @ApiModel(value = "AppStoreDTO", description = "应用商店信息")
public class AppStoreDTO { public class AppStoreDTO {
private Long id;
@ApiModelProperty(value = "应用Key", required = true) @ApiModelProperty(value = "应用Key", required = true)
@NotBlank @NotBlank(groups = {ValidationGroups.Update.class}, message = "应用Key不能为空")
private String appKey; private String appKey;
@NotBlank
@NotBlank(message = "密钥不能为空")
@ApiModelProperty(value = "密钥", required = true) @ApiModelProperty(value = "密钥", required = true)
private String appSecret; private String appSecret;
@ApiModelProperty(value = "单位", required = true) @ApiModelProperty(value = "单位", required = false)
private String deptCode; private String deptCode;
public String getDeptCode() { public String getDeptCode() {
...@@ -28,13 +28,6 @@ public class AppStoreDTO { ...@@ -28,13 +28,6 @@ public class AppStoreDTO {
this.deptCode = deptCode; this.deptCode = deptCode;
} }
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAppKey() { public String getAppKey() {
return appKey; return appKey;
......
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