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.entity.GardsDetectors;
import org.jeecg.modules.system.service.IGardsDetectorsService; import org.jeecg.modules.system.service.IGardsDetectorsService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@RestController @RestController
@ -19,35 +20,35 @@ public class GardsDetectorsController {
private IGardsDetectorsService gardsDetectorsService; private IGardsDetectorsService gardsDetectorsService;
@GetMapping("findPage") @GetMapping("findPage")
@ApiOperation(value = "分页查询监测器", tags = "分页查询监测器") @ApiOperation(value = "分页查询监测器", notes = "分页查询监测器")
public Result<IPage<GardsDetectors>> findPage(QueryRequest queryRequest, GardsDetectors gardsDetectors){ public Result<IPage<GardsDetectors>> findPage(QueryRequest queryRequest, GardsDetectors gardsDetectors){
Result<IPage<GardsDetectors>> result = gardsDetectorsService.findPage(queryRequest, gardsDetectors); Result<IPage<GardsDetectors>> result = gardsDetectorsService.findPage(queryRequest, gardsDetectors);
return result; return result;
} }
@GetMapping("findInfo") @GetMapping("findInfo")
@ApiOperation(value = "查询监测器详情信息", tags = "查询监测器详情信息") @ApiOperation(value = "查询监测器详情信息", notes = "查询监测器详情信息")
public GardsDetectors findInfo(Integer id){ public GardsDetectors findInfo(Integer id){
GardsDetectors result = gardsDetectorsService.findInfo(id); GardsDetectors result = gardsDetectorsService.findInfo(id);
return result; return result;
} }
@PostMapping("create") @PostMapping("create")
@ApiOperation(value = "新增监测器信息", tags = "新增监测器信息") @ApiOperation(value = "新增监测器信息", notes = "新增监测器信息")
public Result create(@RequestBody GardsDetectors gardsDetectors){ public Result create(@RequestBody @Validated GardsDetectors gardsDetectors){
Result result = gardsDetectorsService.create(gardsDetectors); Result result = gardsDetectorsService.create(gardsDetectors);
return result; return result;
} }
@PutMapping("update") @PutMapping("update")
@ApiOperation(value = "修改监测器信息", tags = "修改监测器信息") @ApiOperation(value = "修改监测器信息", notes = "修改监测器信息")
public Result update(@RequestBody GardsDetectors gardsDetectors){ public Result update(@RequestBody @Validated GardsDetectors gardsDetectors){
Result result = gardsDetectorsService.update(gardsDetectors); Result result = gardsDetectorsService.update(gardsDetectors);
return result; return result;
} }
@DeleteMapping("deleteById") @DeleteMapping("deleteById")
@ApiOperation(value = "删除监测器信息", tags = "删除监测器信息") @ApiOperation(value = "删除监测器信息", notes = "删除监测器信息")
public Result deleteById(Integer id){ public Result deleteById(Integer id){
Result result = gardsDetectorsService.deleteById(id); Result result = gardsDetectorsService.deleteById(id);
return result; 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.entity.GardsNuclearfacility;
import org.jeecg.modules.system.service.IGardsNuclearfacilityService; import org.jeecg.modules.system.service.IGardsNuclearfacilityService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@RestController @RestController
@ -19,35 +20,35 @@ public class GardsNuclearfacilityController {
private IGardsNuclearfacilityService gardsNuclearfacilityService; private IGardsNuclearfacilityService gardsNuclearfacilityService;
@GetMapping("findPage") @GetMapping("findPage")
@ApiOperation(value = "分页查询核设施信息", tags = "分页查询核设施信息") @ApiOperation(value = "分页查询核设施信息", notes = "分页查询核设施信息")
public Result<IPage<GardsNuclearfacility>> findPage(QueryRequest queryRequest, GardsNuclearfacility gardsNuclearfacility){ public Result<IPage<GardsNuclearfacility>> findPage(QueryRequest queryRequest, GardsNuclearfacility gardsNuclearfacility){
Result<IPage<GardsNuclearfacility>> result = gardsNuclearfacilityService.findPage(queryRequest, gardsNuclearfacility); Result<IPage<GardsNuclearfacility>> result = gardsNuclearfacilityService.findPage(queryRequest, gardsNuclearfacility);
return result; return result;
} }
@GetMapping("findInfo") @GetMapping("findInfo")
@ApiOperation(value = "查询核设施详情信息", tags = "查询核设施详情信息") @ApiOperation(value = "查询核设施详情信息", notes = "查询核设施详情信息")
public GardsNuclearfacility findInfo(Integer id){ public GardsNuclearfacility findInfo(Integer id){
GardsNuclearfacility result = gardsNuclearfacilityService.findInfo(id); GardsNuclearfacility result = gardsNuclearfacilityService.findInfo(id);
return result; return result;
} }
@PostMapping("create") @PostMapping("create")
@ApiOperation(value = "新增核设施信息", tags = "新增核设施信息") @ApiOperation(value = "新增核设施信息", notes = "新增核设施信息")
public Result create(@RequestBody GardsNuclearfacility gardsNuclearfacility){ public Result create(@RequestBody @Validated GardsNuclearfacility gardsNuclearfacility){
Result result = gardsNuclearfacilityService.create(gardsNuclearfacility); Result result = gardsNuclearfacilityService.create(gardsNuclearfacility);
return result; return result;
} }
@PutMapping("update") @PutMapping("update")
@ApiOperation(value = "修改核设施信息", tags = "修改核设施信息") @ApiOperation(value = "修改核设施信息", notes = "修改核设施信息")
public Result update(@RequestBody GardsNuclearfacility gardsNuclearfacility){ public Result update(@RequestBody @Validated GardsNuclearfacility gardsNuclearfacility){
Result result = gardsNuclearfacilityService.update(gardsNuclearfacility); Result result = gardsNuclearfacilityService.update(gardsNuclearfacility);
return result; return result;
} }
@DeleteMapping("deleteById") @DeleteMapping("deleteById")
@ApiOperation(value = "删除核设施信息", tags = "删除核设施信息") @ApiOperation(value = "删除核设施信息", notes = "删除核设施信息")
public Result deleteById(Integer id){ public Result deleteById(Integer id){
Result result = gardsNuclearfacilityService.deleteById(id); Result result = gardsNuclearfacilityService.deleteById(id);
return result; 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.entity.GardsSelfbuiltStations;
import org.jeecg.modules.system.service.IGardsSelfbuiltService; import org.jeecg.modules.system.service.IGardsSelfbuiltService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@RestController @RestController
@ -19,35 +20,35 @@ public class GardsSelfbuiltController {
private IGardsSelfbuiltService gardsSelfbuiltService; private IGardsSelfbuiltService gardsSelfbuiltService;
@GetMapping("findPage") @GetMapping("findPage")
@ApiOperation(value = "分页查询自建台站信息", tags = "分页查询自建台站信息") @ApiOperation(value = "分页查询自建台站信息", notes = "分页查询自建台站信息")
public Result<IPage<GardsSelfbuiltStations>> findPage(QueryRequest queryRequest, GardsSelfbuiltStations gardsSelfbuiltStations){ public Result<IPage<GardsSelfbuiltStations>> findPage(QueryRequest queryRequest, GardsSelfbuiltStations gardsSelfbuiltStations){
Result<IPage<GardsSelfbuiltStations>> result = gardsSelfbuiltService.findPage(queryRequest, gardsSelfbuiltStations); Result<IPage<GardsSelfbuiltStations>> result = gardsSelfbuiltService.findPage(queryRequest, gardsSelfbuiltStations);
return result; return result;
} }
@GetMapping("findInfo") @GetMapping("findInfo")
@ApiOperation(value = "查询自建台站详情信息", tags = "查询自建台站详情信息") @ApiOperation(value = "查询自建台站详情信息", notes = "查询自建台站详情信息")
public GardsSelfbuiltStations findInfo(Integer id){ public GardsSelfbuiltStations findInfo(Integer id){
GardsSelfbuiltStations info = gardsSelfbuiltService.findInfo(id); GardsSelfbuiltStations info = gardsSelfbuiltService.findInfo(id);
return info; return info;
} }
@PostMapping("create") @PostMapping("create")
@ApiOperation(value = "新增自建台站信息", tags = "新增自建台站信息") @ApiOperation(value = "新增自建台站信息", notes = "新增自建台站信息")
public Result create(@RequestBody GardsSelfbuiltStations gardsSelfbuiltStations){ public Result create(@RequestBody @Validated GardsSelfbuiltStations gardsSelfbuiltStations){
Result result = gardsSelfbuiltService.create(gardsSelfbuiltStations); Result result = gardsSelfbuiltService.create(gardsSelfbuiltStations);
return result; return result;
} }
@PutMapping("update") @PutMapping("update")
@ApiOperation(value = "修改自建台站信息", tags = "修改自建台站信息") @ApiOperation(value = "修改自建台站信息", notes = "修改自建台站信息")
public Result update(@RequestBody GardsSelfbuiltStations gardsSelfbuiltStations){ public Result update(@RequestBody @Validated GardsSelfbuiltStations gardsSelfbuiltStations){
Result result = gardsSelfbuiltService.update(gardsSelfbuiltStations); Result result = gardsSelfbuiltService.update(gardsSelfbuiltStations);
return result; return result;
} }
@DeleteMapping("deleteById") @DeleteMapping("deleteById")
@ApiOperation(value = "删除自建台站信息", tags = "删除自建台站信息") @ApiOperation(value = "删除自建台站信息", notes = "删除自建台站信息")
public Result deleteById(Integer id){ public Result deleteById(Integer id){
Result result = gardsSelfbuiltService.deleteById(id); Result result = gardsSelfbuiltService.deleteById(id);
return result; 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.entity.GardsStations;
import org.jeecg.modules.system.service.IGardsStationsService; import org.jeecg.modules.system.service.IGardsStationsService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@RestController @RestController
@ -25,7 +26,7 @@ public class GardsStationsController {
* @return * @return
*/ */
@GetMapping("findPage") @GetMapping("findPage")
@ApiOperation(value = "分页查询台站管理信息", tags = "分页查询台站管理信息") @ApiOperation(value = "分页查询台站管理信息", notes = "分页查询台站管理信息")
public Result<IPage<GardsStations>> findPage(QueryRequest queryRequest, GardsStations gardsStations){ public Result<IPage<GardsStations>> findPage(QueryRequest queryRequest, GardsStations gardsStations){
Result<IPage<GardsStations>> result = gardsStationsService.findPage(queryRequest, gardsStations); Result<IPage<GardsStations>> result = gardsStationsService.findPage(queryRequest, gardsStations);
return result; return result;
@ -37,7 +38,7 @@ public class GardsStationsController {
* @return * @return
*/ */
@GetMapping("findInfo") @GetMapping("findInfo")
@ApiOperation(value = "查询台站管理详情信息", tags = "查询台站管理详情信息") @ApiOperation(value = "查询台站管理详情信息", notes = "查询台站管理详情信息")
public GardsStations findInfo(Integer stationId){ public GardsStations findInfo(Integer stationId){
GardsStations result = gardsStationsService.findInfo(stationId); GardsStations result = gardsStationsService.findInfo(stationId);
return result; return result;
@ -47,8 +48,8 @@ public class GardsStationsController {
* 新增台站信息接口 * 新增台站信息接口
*/ */
@PostMapping("create") @PostMapping("create")
@ApiOperation(value = "新增台站管理信息", tags = "新增台站管理信息") @ApiOperation(value = "新增台站管理信息", notes = "新增台站管理信息")
public Result create(@RequestBody GardsStations gardsStations){ public Result create(@RequestBody @Validated GardsStations gardsStations){
Result result = gardsStationsService.create(gardsStations); Result result = gardsStationsService.create(gardsStations);
return result; return result;
} }
@ -57,8 +58,8 @@ public class GardsStationsController {
* 修改台站信息接口 * 修改台站信息接口
*/ */
@PutMapping("update") @PutMapping("update")
@ApiOperation(value = "修改台站管理信息", tags = "修改台站管理信息") @ApiOperation(value = "修改台站管理信息", notes = "修改台站管理信息")
public Result update(@RequestBody GardsStations gardsStations){ public Result update(@RequestBody @Validated GardsStations gardsStations){
Result result = gardsStationsService.update(gardsStations); Result result = gardsStationsService.update(gardsStations);
return result; return result;
} }
@ -68,7 +69,7 @@ public class GardsStationsController {
* @param stationId * @param stationId
*/ */
@DeleteMapping("deleteById") @DeleteMapping("deleteById")
@ApiOperation(value = "删除台站管理信息", tags = "删除台站管理信息") @ApiOperation(value = "删除台站管理信息", notes = "删除台站管理信息")
public Result deleteById(Integer stationId){ public Result deleteById(Integer stationId){
Result result = gardsStationsService.deleteById(stationId); Result result = gardsStationsService.deleteById(stationId);
return result; 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.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
@ -15,6 +18,7 @@ public class GardsDetectors implements Serializable {
private Integer detectorId; private Integer detectorId;
@TableField(value = "DETECTOR_CODE") @TableField(value = "DETECTOR_CODE")
@NotBlank(message = "不能为空")
private String detectorCode; private String detectorCode;
@TableField(value = "LON") @TableField(value = "LON")
@ -39,9 +43,13 @@ public class GardsDetectors implements Serializable {
private Double ecalRangeMax; private Double ecalRangeMax;
@TableField(value = "DATE_BEGIN") @TableField(value = "DATE_BEGIN")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date dateBegin; private Date dateBegin;
@TableField(value = "DATE_END") @TableField(value = "DATE_END")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date dateEnd; private Date dateEnd;
@TableField(value = "STATUS") @TableField(value = "STATUS")
@ -51,6 +59,7 @@ public class GardsDetectors implements Serializable {
private String description; private String description;
@TableField(value = "MODDATE") @TableField(value = "MODDATE")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date moddate; private Date moddate;
@TableField(value = "STATION_ID") @TableField(value = "STATION_ID")

View File

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

View File

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

View File

@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Date; import java.util.Date;
@ -19,6 +20,7 @@ public class GardsStations implements Serializable {
private Integer stationId; private Integer stationId;
@TableField(value = "STATION_CODE") @TableField(value = "STATION_CODE")
@NotBlank(message = "不能为空")
private String stationCode; private String stationCode;
@TableField(value = "COUNTRY_CODE") @TableField(value = "COUNTRY_CODE")
@ -54,7 +56,6 @@ public class GardsStations implements Serializable {
@TableField(value = "MODDATE") @TableField(value = "MODDATE")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date moddate; 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.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; 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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.api.QueryRequest; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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.List;
import java.util.Objects; import java.util.Objects;
@ -73,12 +78,14 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
@Override @Override
public Result create(GardsDetectors gardsDetectors) { public Result create(GardsDetectors gardsDetectors) {
Result result = new Result(); Result result = new Result();
if (StringUtils.isNotBlank(gardsDetectors.getDetectorCode())){
LambdaQueryWrapper<GardsDetectors> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsDetectors> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsDetectors::getDetectorCode, gardsDetectors.getDetectorCode()); queryWrapper.eq(GardsDetectors::getDetectorCode, gardsDetectors.getDetectorCode());
GardsDetectors detectors = this.baseMapper.selectOne(queryWrapper); GardsDetectors detectors = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(detectors)) { if (Objects.nonNull(detectors)) {
throw new RuntimeException("当前数据已存在,新增失败!"); throw new RuntimeException("当前数据已存在,新增失败!");
} }
}
Long id = IdWorker.getId(); Long id = IdWorker.getId();
gardsDetectors.setDetectorId(id.intValue()); gardsDetectors.setDetectorId(id.intValue());
this.baseMapper.insert(gardsDetectors); this.baseMapper.insert(gardsDetectors);
@ -95,12 +102,14 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
if (Objects.isNull(stations)) { if (Objects.isNull(stations)) {
throw new RuntimeException("当前数据不存在,修改失败"); throw new RuntimeException("当前数据不存在,修改失败");
} }
if (StringUtils.isNotBlank(gardsDetectors.getDetectorCode())){
LambdaQueryWrapper<GardsDetectors> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsDetectors> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsDetectors::getDetectorCode, gardsDetectors.getDetectorCode()); queryWrapper.eq(GardsDetectors::getDetectorCode, gardsDetectors.getDetectorCode());
GardsDetectors detectors = this.baseMapper.selectOne(queryWrapper); GardsDetectors detectors = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(detectors) && !detectors.getDetectorId().equals(gardsDetectors.getDetectorId())) { if (Objects.nonNull(detectors) && !detectors.getDetectorId().equals(gardsDetectors.getDetectorId())) {
throw new RuntimeException("当前数据已存在,修改失败!"); throw new RuntimeException("当前数据已存在,修改失败!");
} }
}
LambdaQueryWrapper<GardsDetectors> detectorsQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsDetectors> detectorsQueryWrapper = new LambdaQueryWrapper<>();
detectorsQueryWrapper.eq(GardsDetectors::getDetectorId, gardsDetectors.getDetectorId()); detectorsQueryWrapper.eq(GardsDetectors::getDetectorId, gardsDetectors.getDetectorId());
this.baseMapper.update(gardsDetectors, detectorsQueryWrapper); this.baseMapper.update(gardsDetectors, detectorsQueryWrapper);

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

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.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; 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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.api.QueryRequest; import org.jeecg.common.api.QueryRequest;
@ -49,12 +50,14 @@ public class GardsSelfbuiltServiceImpl extends ServiceImpl<GardsSelfbuiltStation
@Transactional @Transactional
public Result create(GardsSelfbuiltStations gardsSelfbuiltStations) { public Result create(GardsSelfbuiltStations gardsSelfbuiltStations) {
Result result = new Result(); Result result = new Result();
if (StringUtils.isNotBlank(gardsSelfbuiltStations.getCode())){
LambdaQueryWrapper<GardsSelfbuiltStations> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsSelfbuiltStations> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsSelfbuiltStations::getCode, gardsSelfbuiltStations.getCode()); queryWrapper.eq(GardsSelfbuiltStations::getCode, gardsSelfbuiltStations.getCode());
GardsSelfbuiltStations selfbuiltStations = this.baseMapper.selectOne(queryWrapper); GardsSelfbuiltStations selfbuiltStations = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(selfbuiltStations)) { if (Objects.nonNull(selfbuiltStations)) {
throw new RuntimeException("当前数据已存在,新增失败!"); throw new RuntimeException("当前数据已存在,新增失败!");
} }
}
//获取request //获取request
HttpServletRequest request = SpringContextUtils.getHttpServletRequest(); HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
//获取当前操作人用户名 //获取当前操作人用户名
@ -82,12 +85,14 @@ public class GardsSelfbuiltServiceImpl extends ServiceImpl<GardsSelfbuiltStation
if (Objects.isNull(stations)){ if (Objects.isNull(stations)){
throw new RuntimeException("修改失败,当前数据不存在!"); throw new RuntimeException("修改失败,当前数据不存在!");
} }
if (StringUtils.isNotBlank(gardsSelfbuiltStations.getCode())){
LambdaQueryWrapper<GardsSelfbuiltStations> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsSelfbuiltStations> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsSelfbuiltStations::getCode, gardsSelfbuiltStations.getCode()); queryWrapper.eq(GardsSelfbuiltStations::getCode, gardsSelfbuiltStations.getCode());
GardsSelfbuiltStations selfbuiltStations = this.baseMapper.selectOne(queryWrapper); GardsSelfbuiltStations selfbuiltStations = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(selfbuiltStations) && !selfbuiltStations.getId().equals(gardsSelfbuiltStations.getId())) { if (Objects.nonNull(selfbuiltStations) && !selfbuiltStations.getId().equals(gardsSelfbuiltStations.getId())) {
throw new RuntimeException("当前数据已存在,修改失败!"); throw new RuntimeException("当前数据已存在,修改失败!");
} }
}
//获取request //获取request
HttpServletRequest request = SpringContextUtils.getHttpServletRequest(); 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.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; 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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.api.QueryRequest; import org.jeecg.common.api.QueryRequest;
@ -64,13 +65,15 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
public Result create(GardsStations gardsStations) { public Result create(GardsStations gardsStations) {
Result result = new Result(); Result result = new Result();
//根据传递的台站编码查询 //根据传递的台站编码查询
if (StringUtils.isNotBlank(gardsStations.getStationCode())){
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsStations::getStationCode,gardsStations.getStationCode()); queryWrapper.eq(GardsStations::getStationCode, gardsStations.getStationCode());
GardsStations stations = this.baseMapper.selectOne(queryWrapper); GardsStations stations = this.baseMapper.selectOne(queryWrapper);
//如果数据不为空 //如果数据不为空
if (Objects.nonNull(stations)) { if (Objects.nonNull(stations)) {
throw new RuntimeException("当前台站信息已存在,新增失败"); throw new RuntimeException("当前台站信息已存在,新增失败");
} }
}
Long id = IdWorker.getId(); Long id = IdWorker.getId();
gardsStations.setStationId(id.intValue()); gardsStations.setStationId(id.intValue());
this.baseMapper.insert(gardsStations); this.baseMapper.insert(gardsStations);
@ -93,6 +96,7 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
if (Objects.isNull(stations)){ if (Objects.isNull(stations)){
throw new RuntimeException("修改失败,当前数据不存在!"); throw new RuntimeException("修改失败,当前数据不存在!");
} }
if (StringUtils.isNotBlank(gardsStations.getStationCode())){
//根据传递的台站编码查询 //根据传递的台站编码查询
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsStations::getStationCode,gardsStations.getStationCode()); queryWrapper.eq(GardsStations::getStationCode,gardsStations.getStationCode());
@ -100,6 +104,7 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
if (Objects.nonNull(oldStations) && !oldStations.getStationId().equals(gardsStations.getStationId())) { if (Objects.nonNull(oldStations) && !oldStations.getStationId().equals(gardsStations.getStationId())) {
throw new RuntimeException("当前台站信息已存在,修改失败"); throw new RuntimeException("当前台站信息已存在,修改失败");
} }
}
LambdaQueryWrapper<GardsStations> stationsQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsStations> stationsQueryWrapper = new LambdaQueryWrapper<>();
stationsQueryWrapper.eq(GardsStations::getStationId,gardsStations.getStationId()); stationsQueryWrapper.eq(GardsStations::getStationId,gardsStations.getStationId());
this.baseMapper.update(gardsStations, stationsQueryWrapper); this.baseMapper.update(gardsStations, stationsQueryWrapper);