feat:Api注解内容修改,新增唯一标识符非空判断,修改moddate字段日期格式化问题

This commit is contained in:
qiaoqinzheng 2023-05-12 11:49:26 +08:00
parent b0cd23fe06
commit 1561b06977
12 changed files with 113 additions and 71 deletions

View File

@ -8,6 +8,7 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.system.entity.GardsDetectors;
import org.jeecg.modules.system.service.IGardsDetectorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@RestController
@ -19,35 +20,35 @@ public class GardsDetectorsController {
private IGardsDetectorsService gardsDetectorsService;
@GetMapping("findPage")
@ApiOperation(value = "分页查询监测器", tags = "分页查询监测器")
@ApiOperation(value = "分页查询监测器", notes = "分页查询监测器")
public Result<IPage<GardsDetectors>> findPage(QueryRequest queryRequest, GardsDetectors gardsDetectors){
Result<IPage<GardsDetectors>> result = gardsDetectorsService.findPage(queryRequest, gardsDetectors);
return result;
}
@GetMapping("findInfo")
@ApiOperation(value = "查询监测器详情信息", tags = "查询监测器详情信息")
@ApiOperation(value = "查询监测器详情信息", notes = "查询监测器详情信息")
public GardsDetectors findInfo(Integer id){
GardsDetectors result = gardsDetectorsService.findInfo(id);
return result;
}
@PostMapping("create")
@ApiOperation(value = "新增监测器信息", tags = "新增监测器信息")
public Result create(@RequestBody GardsDetectors gardsDetectors){
@ApiOperation(value = "新增监测器信息", notes = "新增监测器信息")
public Result create(@RequestBody @Validated GardsDetectors gardsDetectors){
Result result = gardsDetectorsService.create(gardsDetectors);
return result;
}
@PutMapping("update")
@ApiOperation(value = "修改监测器信息", tags = "修改监测器信息")
public Result update(@RequestBody GardsDetectors gardsDetectors){
@ApiOperation(value = "修改监测器信息", notes = "修改监测器信息")
public Result update(@RequestBody @Validated GardsDetectors gardsDetectors){
Result result = gardsDetectorsService.update(gardsDetectors);
return result;
}
@DeleteMapping("deleteById")
@ApiOperation(value = "删除监测器信息", tags = "删除监测器信息")
@ApiOperation(value = "删除监测器信息", notes = "删除监测器信息")
public Result deleteById(Integer id){
Result result = gardsDetectorsService.deleteById(id);
return result;

View File

@ -8,6 +8,7 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.system.entity.GardsNuclearfacility;
import org.jeecg.modules.system.service.IGardsNuclearfacilityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@RestController
@ -19,35 +20,35 @@ public class GardsNuclearfacilityController {
private IGardsNuclearfacilityService gardsNuclearfacilityService;
@GetMapping("findPage")
@ApiOperation(value = "分页查询核设施信息", tags = "分页查询核设施信息")
@ApiOperation(value = "分页查询核设施信息", notes = "分页查询核设施信息")
public Result<IPage<GardsNuclearfacility>> findPage(QueryRequest queryRequest, GardsNuclearfacility gardsNuclearfacility){
Result<IPage<GardsNuclearfacility>> result = gardsNuclearfacilityService.findPage(queryRequest, gardsNuclearfacility);
return result;
}
@GetMapping("findInfo")
@ApiOperation(value = "查询核设施详情信息", tags = "查询核设施详情信息")
@ApiOperation(value = "查询核设施详情信息", notes = "查询核设施详情信息")
public GardsNuclearfacility findInfo(Integer id){
GardsNuclearfacility result = gardsNuclearfacilityService.findInfo(id);
return result;
}
@PostMapping("create")
@ApiOperation(value = "新增核设施信息", tags = "新增核设施信息")
public Result create(@RequestBody GardsNuclearfacility gardsNuclearfacility){
@ApiOperation(value = "新增核设施信息", notes = "新增核设施信息")
public Result create(@RequestBody @Validated GardsNuclearfacility gardsNuclearfacility){
Result result = gardsNuclearfacilityService.create(gardsNuclearfacility);
return result;
}
@PutMapping("update")
@ApiOperation(value = "修改核设施信息", tags = "修改核设施信息")
public Result update(@RequestBody GardsNuclearfacility gardsNuclearfacility){
@ApiOperation(value = "修改核设施信息", notes = "修改核设施信息")
public Result update(@RequestBody @Validated GardsNuclearfacility gardsNuclearfacility){
Result result = gardsNuclearfacilityService.update(gardsNuclearfacility);
return result;
}
@DeleteMapping("deleteById")
@ApiOperation(value = "删除核设施信息", tags = "删除核设施信息")
@ApiOperation(value = "删除核设施信息", notes = "删除核设施信息")
public Result deleteById(Integer id){
Result result = gardsNuclearfacilityService.deleteById(id);
return result;

View File

@ -8,6 +8,7 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.system.entity.GardsSelfbuiltStations;
import org.jeecg.modules.system.service.IGardsSelfbuiltService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@RestController
@ -19,35 +20,35 @@ public class GardsSelfbuiltController {
private IGardsSelfbuiltService gardsSelfbuiltService;
@GetMapping("findPage")
@ApiOperation(value = "分页查询自建台站信息", tags = "分页查询自建台站信息")
@ApiOperation(value = "分页查询自建台站信息", notes = "分页查询自建台站信息")
public Result<IPage<GardsSelfbuiltStations>> findPage(QueryRequest queryRequest, GardsSelfbuiltStations gardsSelfbuiltStations){
Result<IPage<GardsSelfbuiltStations>> result = gardsSelfbuiltService.findPage(queryRequest, gardsSelfbuiltStations);
return result;
}
@GetMapping("findInfo")
@ApiOperation(value = "查询自建台站详情信息", tags = "查询自建台站详情信息")
@ApiOperation(value = "查询自建台站详情信息", notes = "查询自建台站详情信息")
public GardsSelfbuiltStations findInfo(Integer id){
GardsSelfbuiltStations info = gardsSelfbuiltService.findInfo(id);
return info;
}
@PostMapping("create")
@ApiOperation(value = "新增自建台站信息", tags = "新增自建台站信息")
public Result create(@RequestBody GardsSelfbuiltStations gardsSelfbuiltStations){
@ApiOperation(value = "新增自建台站信息", notes = "新增自建台站信息")
public Result create(@RequestBody @Validated GardsSelfbuiltStations gardsSelfbuiltStations){
Result result = gardsSelfbuiltService.create(gardsSelfbuiltStations);
return result;
}
@PutMapping("update")
@ApiOperation(value = "修改自建台站信息", tags = "修改自建台站信息")
public Result update(@RequestBody GardsSelfbuiltStations gardsSelfbuiltStations){
@ApiOperation(value = "修改自建台站信息", notes = "修改自建台站信息")
public Result update(@RequestBody @Validated GardsSelfbuiltStations gardsSelfbuiltStations){
Result result = gardsSelfbuiltService.update(gardsSelfbuiltStations);
return result;
}
@DeleteMapping("deleteById")
@ApiOperation(value = "删除自建台站信息", tags = "删除自建台站信息")
@ApiOperation(value = "删除自建台站信息", notes = "删除自建台站信息")
public Result deleteById(Integer id){
Result result = gardsSelfbuiltService.deleteById(id);
return result;

View File

@ -8,6 +8,7 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.system.entity.GardsStations;
import org.jeecg.modules.system.service.IGardsStationsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@RestController
@ -25,7 +26,7 @@ public class GardsStationsController {
* @return
*/
@GetMapping("findPage")
@ApiOperation(value = "分页查询台站管理信息", tags = "分页查询台站管理信息")
@ApiOperation(value = "分页查询台站管理信息", notes = "分页查询台站管理信息")
public Result<IPage<GardsStations>> findPage(QueryRequest queryRequest, GardsStations gardsStations){
Result<IPage<GardsStations>> result = gardsStationsService.findPage(queryRequest, gardsStations);
return result;
@ -37,7 +38,7 @@ public class GardsStationsController {
* @return
*/
@GetMapping("findInfo")
@ApiOperation(value = "查询台站管理详情信息", tags = "查询台站管理详情信息")
@ApiOperation(value = "查询台站管理详情信息", notes = "查询台站管理详情信息")
public GardsStations findInfo(Integer stationId){
GardsStations result = gardsStationsService.findInfo(stationId);
return result;
@ -47,8 +48,8 @@ public class GardsStationsController {
* 新增台站信息接口
*/
@PostMapping("create")
@ApiOperation(value = "新增台站管理信息", tags = "新增台站管理信息")
public Result create(@RequestBody GardsStations gardsStations){
@ApiOperation(value = "新增台站管理信息", notes = "新增台站管理信息")
public Result create(@RequestBody @Validated GardsStations gardsStations){
Result result = gardsStationsService.create(gardsStations);
return result;
}
@ -57,8 +58,8 @@ public class GardsStationsController {
* 修改台站信息接口
*/
@PutMapping("update")
@ApiOperation(value = "修改台站管理信息", tags = "修改台站管理信息")
public Result update(@RequestBody GardsStations gardsStations){
@ApiOperation(value = "修改台站管理信息", notes = "修改台站管理信息")
public Result update(@RequestBody @Validated GardsStations gardsStations){
Result result = gardsStationsService.update(gardsStations);
return result;
}
@ -68,7 +69,7 @@ public class GardsStationsController {
* @param stationId
*/
@DeleteMapping("deleteById")
@ApiOperation(value = "删除台站管理信息", tags = "删除台站管理信息")
@ApiOperation(value = "删除台站管理信息", notes = "删除台站管理信息")
public Result deleteById(Integer stationId){
Result result = gardsStationsService.deleteById(stationId);
return result;

View File

@ -2,8 +2,11 @@ package org.jeecg.modules.system.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
@ -15,6 +18,7 @@ public class GardsDetectors implements Serializable {
private Integer detectorId;
@TableField(value = "DETECTOR_CODE")
@NotBlank(message = "不能为空")
private String detectorCode;
@TableField(value = "LON")
@ -39,9 +43,13 @@ public class GardsDetectors implements Serializable {
private Double ecalRangeMax;
@TableField(value = "DATE_BEGIN")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date dateBegin;
@TableField(value = "DATE_END")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date dateEnd;
@TableField(value = "STATUS")
@ -51,6 +59,7 @@ public class GardsDetectors implements Serializable {
private String description;
@TableField(value = "MODDATE")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date moddate;
@TableField(value = "STATION_ID")

View File

@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
@ -17,6 +18,7 @@ public class GardsNuclearfacility implements Serializable {
private Integer facilityId;
@TableField(value = "FACILITY_NAME")
@NotBlank(message = "不能为空")
private String facilityName;
@TableField(value = "TYPE")

View File

@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
@ -19,6 +20,7 @@ public class GardsSelfbuiltStations implements Serializable {
private Integer id;
@TableField(value = "CODE")
@NotBlank(message = "不能为空")
private String code;
@TableField(value = "NAME")

View File

@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
@ -19,6 +20,7 @@ public class GardsStations implements Serializable {
private Integer stationId;
@TableField(value = "STATION_CODE")
@NotBlank(message = "不能为空")
private String stationCode;
@TableField(value = "COUNTRY_CODE")
@ -54,7 +56,6 @@ public class GardsStations implements Serializable {
@TableField(value = "MODDATE")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date moddate;
}

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.api.QueryRequest;
@ -17,6 +18,10 @@ import org.jeecg.modules.system.service.IGardsStationsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@ -73,11 +78,13 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
@Override
public Result create(GardsDetectors gardsDetectors) {
Result result = new Result();
LambdaQueryWrapper<GardsDetectors> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsDetectors::getDetectorCode, gardsDetectors.getDetectorCode());
GardsDetectors detectors = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(detectors)) {
throw new RuntimeException("当前数据已存在,新增失败!");
if (StringUtils.isNotBlank(gardsDetectors.getDetectorCode())){
LambdaQueryWrapper<GardsDetectors> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsDetectors::getDetectorCode, gardsDetectors.getDetectorCode());
GardsDetectors detectors = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(detectors)) {
throw new RuntimeException("当前数据已存在,新增失败!");
}
}
Long id = IdWorker.getId();
gardsDetectors.setDetectorId(id.intValue());
@ -95,11 +102,13 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
if (Objects.isNull(stations)) {
throw new RuntimeException("当前数据不存在,修改失败");
}
LambdaQueryWrapper<GardsDetectors> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsDetectors::getDetectorCode, gardsDetectors.getDetectorCode());
GardsDetectors detectors = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(detectors) && !detectors.getDetectorId().equals(gardsDetectors.getDetectorId())) {
throw new RuntimeException("当前数据已存在,修改失败!");
if (StringUtils.isNotBlank(gardsDetectors.getDetectorCode())){
LambdaQueryWrapper<GardsDetectors> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsDetectors::getDetectorCode, gardsDetectors.getDetectorCode());
GardsDetectors detectors = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(detectors) && !detectors.getDetectorId().equals(gardsDetectors.getDetectorId())) {
throw new RuntimeException("当前数据已存在,修改失败!");
}
}
LambdaQueryWrapper<GardsDetectors> detectorsQueryWrapper = new LambdaQueryWrapper<>();
detectorsQueryWrapper.eq(GardsDetectors::getDetectorId, gardsDetectors.getDetectorId());

View File

@ -4,6 +4,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.api.QueryRequest;
@ -46,11 +47,13 @@ public class GardsNuclearfacilityServiceImpl extends ServiceImpl<GardsNuclearfac
@Transactional
public Result create(GardsNuclearfacility gardsNuclearfacility) {
Result result = new Result();
LambdaQueryWrapper<GardsNuclearfacility> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsNuclearfacility::getFacilityName, gardsNuclearfacility.getFacilityName());
GardsNuclearfacility nuclearfacility = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(nuclearfacility)){
throw new RuntimeException("当前同名称的核设施已存在,新增失败");
if (StringUtils.isNotBlank(gardsNuclearfacility.getFacilityName())){
LambdaQueryWrapper<GardsNuclearfacility> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsNuclearfacility::getFacilityName, gardsNuclearfacility.getFacilityName());
GardsNuclearfacility nuclearfacility = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(nuclearfacility)){
throw new RuntimeException("当前同名称的核设施已存在,新增失败");
}
}
Long id = IdWorker.getId();
gardsNuclearfacility.setFacilityId(id.intValue());
@ -69,11 +72,13 @@ public class GardsNuclearfacilityServiceImpl extends ServiceImpl<GardsNuclearfac
if (Objects.isNull(stations)){
throw new RuntimeException("修改失败,当前数据不存在!");
}
LambdaQueryWrapper<GardsNuclearfacility> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsNuclearfacility::getFacilityName, gardsNuclearfacility.getFacilityName());
GardsNuclearfacility nuclearfacility = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(nuclearfacility) && !nuclearfacility.getFacilityId().equals(gardsNuclearfacility.getFacilityId())){
throw new RuntimeException("当前同名称的核设施已存在,修改失败");
if (StringUtils.isNotBlank(gardsNuclearfacility.getFacilityName())){
LambdaQueryWrapper<GardsNuclearfacility> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsNuclearfacility::getFacilityName, gardsNuclearfacility.getFacilityName());
GardsNuclearfacility nuclearfacility = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(nuclearfacility) && !nuclearfacility.getFacilityId().equals(gardsNuclearfacility.getFacilityId())){
throw new RuntimeException("当前同名称的核设施已存在,修改失败");
}
}
LambdaQueryWrapper<GardsNuclearfacility> nuclearfacilityQueryWrapper = new LambdaQueryWrapper<>();
nuclearfacilityQueryWrapper.eq(GardsNuclearfacility::getFacilityId, gardsNuclearfacility.getFacilityId());

View File

@ -4,6 +4,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.api.QueryRequest;
@ -49,11 +50,13 @@ public class GardsSelfbuiltServiceImpl extends ServiceImpl<GardsSelfbuiltStation
@Transactional
public Result create(GardsSelfbuiltStations gardsSelfbuiltStations) {
Result result = new Result();
LambdaQueryWrapper<GardsSelfbuiltStations> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsSelfbuiltStations::getCode, gardsSelfbuiltStations.getCode());
GardsSelfbuiltStations selfbuiltStations = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(selfbuiltStations)) {
throw new RuntimeException("当前数据已存在,新增失败!");
if (StringUtils.isNotBlank(gardsSelfbuiltStations.getCode())){
LambdaQueryWrapper<GardsSelfbuiltStations> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsSelfbuiltStations::getCode, gardsSelfbuiltStations.getCode());
GardsSelfbuiltStations selfbuiltStations = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(selfbuiltStations)) {
throw new RuntimeException("当前数据已存在,新增失败!");
}
}
//获取request
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
@ -82,11 +85,13 @@ public class GardsSelfbuiltServiceImpl extends ServiceImpl<GardsSelfbuiltStation
if (Objects.isNull(stations)){
throw new RuntimeException("修改失败,当前数据不存在!");
}
LambdaQueryWrapper<GardsSelfbuiltStations> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsSelfbuiltStations::getCode, gardsSelfbuiltStations.getCode());
GardsSelfbuiltStations selfbuiltStations = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(selfbuiltStations) && !selfbuiltStations.getId().equals(gardsSelfbuiltStations.getId())) {
throw new RuntimeException("当前数据已存在,修改失败!");
if (StringUtils.isNotBlank(gardsSelfbuiltStations.getCode())){
LambdaQueryWrapper<GardsSelfbuiltStations> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsSelfbuiltStations::getCode, gardsSelfbuiltStations.getCode());
GardsSelfbuiltStations selfbuiltStations = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(selfbuiltStations) && !selfbuiltStations.getId().equals(gardsSelfbuiltStations.getId())) {
throw new RuntimeException("当前数据已存在,修改失败!");
}
}
//获取request
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();

View File

@ -4,6 +4,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.api.QueryRequest;
@ -64,12 +65,14 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
public Result create(GardsStations gardsStations) {
Result result = new Result();
//根据传递的台站编码查询
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsStations::getStationCode,gardsStations.getStationCode());
GardsStations stations = this.baseMapper.selectOne(queryWrapper);
//如果数据不为空
if (Objects.nonNull(stations)) {
throw new RuntimeException("当前台站信息已存在,新增失败");
if (StringUtils.isNotBlank(gardsStations.getStationCode())){
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsStations::getStationCode, gardsStations.getStationCode());
GardsStations stations = this.baseMapper.selectOne(queryWrapper);
//如果数据不为空
if (Objects.nonNull(stations)) {
throw new RuntimeException("当前台站信息已存在,新增失败");
}
}
Long id = IdWorker.getId();
gardsStations.setStationId(id.intValue());
@ -93,12 +96,14 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
if (Objects.isNull(stations)){
throw new RuntimeException("修改失败,当前数据不存在!");
}
//根据传递的台站编码查询
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsStations::getStationCode,gardsStations.getStationCode());
GardsStations oldStations = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(oldStations) && !oldStations.getStationId().equals(gardsStations.getStationId())) {
throw new RuntimeException("当前台站信息已存在,修改失败");
if (StringUtils.isNotBlank(gardsStations.getStationCode())){
//根据传递的台站编码查询
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsStations::getStationCode,gardsStations.getStationCode());
GardsStations oldStations = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(oldStations) && !oldStations.getStationId().equals(gardsStations.getStationId())) {
throw new RuntimeException("当前台站信息已存在,修改失败");
}
}
LambdaQueryWrapper<GardsStations> stationsQueryWrapper = new LambdaQueryWrapper<>();
stationsQueryWrapper.eq(GardsStations::getStationId,gardsStations.getStationId());