feat:新增接口InsertGroup,UpdateGroup区分新增和修改,Controller增加新增与修改时的判断

This commit is contained in:
qiaoqinzheng 2023-05-12 15:03:14 +08:00
parent 1561b06977
commit 4db2a9df4b
10 changed files with 54 additions and 12 deletions

View File

@ -0,0 +1,5 @@
package org.jeecg.config.valid;
public interface InsertGroup {
}

View File

@ -0,0 +1,5 @@
package org.jeecg.config.valid;
public interface UpdateGroup {
}

View File

@ -5,6 +5,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.config.valid.InsertGroup;
import org.jeecg.config.valid.UpdateGroup;
import org.jeecg.modules.system.entity.GardsDetectors;
import org.jeecg.modules.system.service.IGardsDetectorsService;
import org.springframework.beans.factory.annotation.Autowired;
@ -35,14 +37,14 @@ public class GardsDetectorsController {
@PostMapping("create")
@ApiOperation(value = "新增监测器信息", notes = "新增监测器信息")
public Result create(@RequestBody @Validated GardsDetectors gardsDetectors){
public Result create(@RequestBody @Validated(value = InsertGroup.class) GardsDetectors gardsDetectors){
Result result = gardsDetectorsService.create(gardsDetectors);
return result;
}
@PutMapping("update")
@ApiOperation(value = "修改监测器信息", notes = "修改监测器信息")
public Result update(@RequestBody @Validated GardsDetectors gardsDetectors){
public Result update(@RequestBody @Validated(value = UpdateGroup.class) GardsDetectors gardsDetectors){
Result result = gardsDetectorsService.update(gardsDetectors);
return result;
}

View File

@ -5,6 +5,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.config.valid.InsertGroup;
import org.jeecg.config.valid.UpdateGroup;
import org.jeecg.modules.system.entity.GardsNuclearfacility;
import org.jeecg.modules.system.service.IGardsNuclearfacilityService;
import org.springframework.beans.factory.annotation.Autowired;
@ -35,14 +37,14 @@ public class GardsNuclearfacilityController {
@PostMapping("create")
@ApiOperation(value = "新增核设施信息", notes = "新增核设施信息")
public Result create(@RequestBody @Validated GardsNuclearfacility gardsNuclearfacility){
public Result create(@RequestBody @Validated(value = InsertGroup.class) GardsNuclearfacility gardsNuclearfacility){
Result result = gardsNuclearfacilityService.create(gardsNuclearfacility);
return result;
}
@PutMapping("update")
@ApiOperation(value = "修改核设施信息", notes = "修改核设施信息")
public Result update(@RequestBody @Validated GardsNuclearfacility gardsNuclearfacility){
public Result update(@RequestBody @Validated(value = UpdateGroup.class) GardsNuclearfacility gardsNuclearfacility){
Result result = gardsNuclearfacilityService.update(gardsNuclearfacility);
return result;
}

View File

@ -5,6 +5,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.config.valid.InsertGroup;
import org.jeecg.config.valid.UpdateGroup;
import org.jeecg.modules.system.entity.GardsSelfbuiltStations;
import org.jeecg.modules.system.service.IGardsSelfbuiltService;
import org.springframework.beans.factory.annotation.Autowired;
@ -35,14 +37,14 @@ public class GardsSelfbuiltController {
@PostMapping("create")
@ApiOperation(value = "新增自建台站信息", notes = "新增自建台站信息")
public Result create(@RequestBody @Validated GardsSelfbuiltStations gardsSelfbuiltStations){
public Result create(@RequestBody @Validated(value = InsertGroup.class) GardsSelfbuiltStations gardsSelfbuiltStations){
Result result = gardsSelfbuiltService.create(gardsSelfbuiltStations);
return result;
}
@PutMapping("update")
@ApiOperation(value = "修改自建台站信息", notes = "修改自建台站信息")
public Result update(@RequestBody @Validated GardsSelfbuiltStations gardsSelfbuiltStations){
public Result update(@RequestBody @Validated(value = UpdateGroup.class) GardsSelfbuiltStations gardsSelfbuiltStations){
Result result = gardsSelfbuiltService.update(gardsSelfbuiltStations);
return result;
}

View File

@ -5,6 +5,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.config.valid.InsertGroup;
import org.jeecg.config.valid.UpdateGroup;
import org.jeecg.modules.system.entity.GardsStations;
import org.jeecg.modules.system.service.IGardsStationsService;
import org.springframework.beans.factory.annotation.Autowired;
@ -49,7 +51,7 @@ public class GardsStationsController {
*/
@PostMapping("create")
@ApiOperation(value = "新增台站管理信息", notes = "新增台站管理信息")
public Result create(@RequestBody @Validated GardsStations gardsStations){
public Result create(@RequestBody @Validated(value = InsertGroup.class) GardsStations gardsStations){
Result result = gardsStationsService.create(gardsStations);
return result;
}
@ -59,7 +61,7 @@ public class GardsStationsController {
*/
@PutMapping("update")
@ApiOperation(value = "修改台站管理信息", notes = "修改台站管理信息")
public Result update(@RequestBody @Validated GardsStations gardsStations){
public Result update(@RequestBody @Validated(value = UpdateGroup.class) GardsStations gardsStations){
Result result = gardsStationsService.update(gardsStations);
return result;
}

View File

@ -4,9 +4,13 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.jeecg.config.valid.InsertGroup;
import org.jeecg.config.valid.UpdateGroup;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.util.Date;
@ -15,10 +19,12 @@ import java.util.Date;
public class GardsDetectors implements Serializable {
@TableField(value = "DETECTOR_ID")
@Null(message = "必须为空", groups = InsertGroup.class)
@NotNull(message = "不能为空", groups = UpdateGroup.class)
private Integer detectorId;
@TableField(value = "DETECTOR_CODE")
@NotBlank(message = "不能为空")
@NotBlank(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
private String detectorCode;
@TableField(value = "LON")

View File

@ -4,9 +4,13 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.jeecg.config.valid.InsertGroup;
import org.jeecg.config.valid.UpdateGroup;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.util.Date;
@ -15,10 +19,12 @@ import java.util.Date;
public class GardsNuclearfacility implements Serializable {
@TableField(value = "FACILITY_ID")
@Null(message = "必须为空", groups = InsertGroup.class)
@NotNull(message = "不能为空", groups = UpdateGroup.class)
private Integer facilityId;
@TableField(value = "FACILITY_NAME")
@NotBlank(message = "不能为空")
@NotBlank(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
private String facilityName;
@TableField(value = "TYPE")

View File

@ -6,9 +6,13 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.jeecg.config.valid.InsertGroup;
import org.jeecg.config.valid.UpdateGroup;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.util.Date;
@ -17,10 +21,12 @@ import java.util.Date;
public class GardsSelfbuiltStations implements Serializable {
@TableId(value = "ID", type = IdType.ASSIGN_ID)
@Null(message = "必须为空", groups = InsertGroup.class)
@NotNull(message = "不能为空", groups = UpdateGroup.class)
private Integer id;
@TableField(value = "CODE")
@NotBlank(message = "不能为空")
@NotBlank(message = "不能为空" , groups = {InsertGroup.class, UpdateGroup.class})
private String code;
@TableField(value = "NAME")

View File

@ -5,9 +5,13 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.jeecg.config.valid.InsertGroup;
import org.jeecg.config.valid.UpdateGroup;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
@ -17,10 +21,12 @@ import java.util.Date;
public class GardsStations implements Serializable {
@TableField(value = "STATION_ID")
@Null(message = "必须为空", groups = InsertGroup.class)
@NotNull(message = "不能为空", groups = UpdateGroup.class)
private Integer stationId;
@TableField(value = "STATION_CODE")
@NotBlank(message = "不能为空")
@NotBlank(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
private String stationCode;
@TableField(value = "COUNTRY_CODE")