feat:id字段改为前端页面带入,移除自建台站相关代码全部存入台站信息中
This commit is contained in:
parent
c654110170
commit
bde23854be
|
@ -1,59 +0,0 @@
|
||||||
package org.jeecg.modules.system.controller;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
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;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("gardsSelfbuilt")
|
|
||||||
@Api(value = "自建台站管理", tags = "自建台站管理")
|
|
||||||
public class GardsSelfbuiltController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IGardsSelfbuiltService gardsSelfbuiltService;
|
|
||||||
|
|
||||||
@GetMapping("findPage")
|
|
||||||
@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 = "查询自建台站详情信息", notes = "查询自建台站详情信息")
|
|
||||||
public GardsSelfbuiltStations findInfo(Integer id){
|
|
||||||
GardsSelfbuiltStations info = gardsSelfbuiltService.findInfo(id);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("create")
|
|
||||||
@ApiOperation(value = "新增自建台站信息", notes = "新增自建台站信息")
|
|
||||||
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(value = UpdateGroup.class) GardsSelfbuiltStations gardsSelfbuiltStations){
|
|
||||||
Result result = gardsSelfbuiltService.update(gardsSelfbuiltStations);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("deleteById")
|
|
||||||
@ApiOperation(value = "删除自建台站信息", notes = "删除自建台站信息")
|
|
||||||
public Result deleteById(Integer id){
|
|
||||||
Result result = gardsSelfbuiltService.deleteById(id);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -19,8 +19,7 @@ import java.util.Date;
|
||||||
public class GardsDetectors implements Serializable {
|
public class GardsDetectors implements Serializable {
|
||||||
|
|
||||||
@TableField(value = "DETECTOR_ID")
|
@TableField(value = "DETECTOR_ID")
|
||||||
@Null(message = "必须为空", groups = InsertGroup.class)
|
@NotNull(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
||||||
@NotNull(message = "不能为空", groups = UpdateGroup.class)
|
|
||||||
private Integer detectorId;
|
private Integer detectorId;
|
||||||
|
|
||||||
@TableField(value = "DETECTOR_CODE")
|
@TableField(value = "DETECTOR_CODE")
|
||||||
|
@ -65,6 +64,7 @@ public class GardsDetectors implements Serializable {
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@TableField(value = "MODDATE")
|
@TableField(value = "MODDATE")
|
||||||
|
@NotBlank(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date moddate;
|
private Date moddate;
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,7 @@ import java.util.Date;
|
||||||
public class GardsNuclearfacility implements Serializable {
|
public class GardsNuclearfacility implements Serializable {
|
||||||
|
|
||||||
@TableField(value = "FACILITY_ID")
|
@TableField(value = "FACILITY_ID")
|
||||||
@Null(message = "必须为空", groups = InsertGroup.class)
|
@NotNull(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
||||||
@NotNull(message = "不能为空", groups = UpdateGroup.class)
|
|
||||||
private Integer facilityId;
|
private Integer facilityId;
|
||||||
|
|
||||||
@TableField(value = "FACILITY_NAME")
|
@TableField(value = "FACILITY_NAME")
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
package org.jeecg.modules.system.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
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;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@TableName("GARDS_SELFBUILT_STATIONS")
|
|
||||||
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 = "不能为空" , groups = {InsertGroup.class, UpdateGroup.class})
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
@TableField(value = "NAME")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@TableField(value = "TYPE")
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
@TableField(value = "OPERATE_IP")
|
|
||||||
private String operateIp;
|
|
||||||
|
|
||||||
@TableField(value = "PORT")
|
|
||||||
private Integer port;
|
|
||||||
|
|
||||||
@TableField(value = "LON")
|
|
||||||
private String lon;
|
|
||||||
|
|
||||||
@TableField(value = "LAT")
|
|
||||||
private String lat;
|
|
||||||
|
|
||||||
@TableField(value = "STATUS")
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
@TableField(value = "CREATE_TIME")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
@TableField(value = "CREATE_BY")
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
@TableField(value = "UPDATE_TIME")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
@TableField(value = "UPDATE_BY")
|
|
||||||
private String updateBy;
|
|
||||||
|
|
||||||
}
|
|
|
@ -21,8 +21,7 @@ import java.util.Date;
|
||||||
public class GardsStations implements Serializable {
|
public class GardsStations implements Serializable {
|
||||||
|
|
||||||
@TableField(value = "STATION_ID")
|
@TableField(value = "STATION_ID")
|
||||||
@Null(message = "必须为空", groups = InsertGroup.class)
|
@NotNull(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
||||||
@NotNull(message = "不能为空", groups = UpdateGroup.class)
|
|
||||||
private Integer stationId;
|
private Integer stationId;
|
||||||
|
|
||||||
@TableField(value = "STATION_CODE")
|
@TableField(value = "STATION_CODE")
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package org.jeecg.modules.system.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.jeecg.modules.system.entity.GardsSelfbuiltStations;
|
|
||||||
|
|
||||||
public interface GardsSelfbuiltStationsMapper extends BaseMapper<GardsSelfbuiltStations> {
|
|
||||||
}
|
|
|
@ -6,6 +6,8 @@ import org.jeecg.common.api.QueryRequest;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.modules.system.entity.GardsDetectors;
|
import org.jeecg.modules.system.entity.GardsDetectors;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface IGardsDetectorsService extends IService<GardsDetectors> {
|
public interface IGardsDetectorsService extends IService<GardsDetectors> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,4 +45,10 @@ public interface IGardsDetectorsService extends IService<GardsDetectors> {
|
||||||
*/
|
*/
|
||||||
Result deleteById(Integer id);
|
Result deleteById(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部监测器信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<GardsDetectors> findDetectors();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
package org.jeecg.modules.system.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import org.jeecg.common.api.QueryRequest;
|
|
||||||
import org.jeecg.common.api.vo.Result;
|
|
||||||
import org.jeecg.modules.system.entity.GardsSelfbuiltStations;
|
|
||||||
|
|
||||||
public interface IGardsSelfbuiltService extends IService<GardsSelfbuiltStations> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询自建台站信息
|
|
||||||
* @param queryRequest
|
|
||||||
* @param gardsSelfbuiltStations
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Result<IPage<GardsSelfbuiltStations>> findPage(QueryRequest queryRequest, GardsSelfbuiltStations gardsSelfbuiltStations);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询自建台站详情信息
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
GardsSelfbuiltStations findInfo(Integer id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增自建台站信息
|
|
||||||
* @param gardsSelfbuiltStations
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Result create(GardsSelfbuiltStations gardsSelfbuiltStations);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改自建台站信息
|
|
||||||
* @param gardsSelfbuiltStations
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Result update(GardsSelfbuiltStations gardsSelfbuiltStations);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除自建台站信息
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Result deleteById(Integer id);
|
|
||||||
|
|
||||||
}
|
|
|
@ -17,6 +17,8 @@ import org.jeecg.modules.system.service.IGardsDetectorsService;
|
||||||
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.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
@ -86,8 +88,6 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
|
||||||
throw new RuntimeException("当前数据已存在,新增失败!");
|
throw new RuntimeException("当前数据已存在,新增失败!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Long id = IdWorker.getId();
|
|
||||||
gardsDetectors.setDetectorId(id.intValue());
|
|
||||||
this.baseMapper.insert(gardsDetectors);
|
this.baseMapper.insert(gardsDetectors);
|
||||||
result.success("新增成功");
|
result.success("新增成功");
|
||||||
return result;
|
return result;
|
||||||
|
@ -107,7 +107,7 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
|
||||||
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("当前数据"+gardsDetectors.getDetectorCode()+"已存在,修改失败!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LambdaQueryWrapper<GardsDetectors> detectorsQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<GardsDetectors> detectorsQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
@ -126,4 +126,11 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
|
||||||
result.success("删除成功");
|
result.success("删除成功");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
|
public List<GardsDetectors> findDetectors(){
|
||||||
|
List<GardsDetectors> gardsDetectors = this.baseMapper.selectList(new LambdaQueryWrapper<>());
|
||||||
|
return gardsDetectors;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,6 @@ public class GardsNuclearfacilityServiceImpl extends ServiceImpl<GardsNuclearfac
|
||||||
throw new RuntimeException("当前同名称的核设施已存在,新增失败");
|
throw new RuntimeException("当前同名称的核设施已存在,新增失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Long id = IdWorker.getId();
|
|
||||||
gardsNuclearfacility.setFacilityId(id.intValue());
|
|
||||||
this.baseMapper.insert(gardsNuclearfacility);
|
this.baseMapper.insert(gardsNuclearfacility);
|
||||||
result.success("新增成功");
|
result.success("新增成功");
|
||||||
return result;
|
return result;
|
||||||
|
@ -77,7 +75,7 @@ public class GardsNuclearfacilityServiceImpl extends ServiceImpl<GardsNuclearfac
|
||||||
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("当前核设施"+gardsNuclearfacility.getFacilityName()+"已存在,修改失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LambdaQueryWrapper<GardsNuclearfacility> nuclearfacilityQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<GardsNuclearfacility> nuclearfacilityQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
|
@ -1,120 +0,0 @@
|
||||||
package org.jeecg.modules.system.service.impl;
|
|
||||||
|
|
||||||
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;
|
|
||||||
import org.jeecg.common.api.vo.Result;
|
|
||||||
import org.jeecg.common.system.util.JwtUtil;
|
|
||||||
import org.jeecg.common.util.IpUtils;
|
|
||||||
import org.jeecg.common.util.SpringContextUtils;
|
|
||||||
import org.jeecg.modules.system.entity.GardsSelfbuiltStations;
|
|
||||||
import org.jeecg.modules.system.mapper.GardsSelfbuiltStationsMapper;
|
|
||||||
import org.jeecg.modules.system.service.IGardsSelfbuiltService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Service("gardsSelfbuiltService")
|
|
||||||
@DS("ora")
|
|
||||||
public class GardsSelfbuiltServiceImpl extends ServiceImpl<GardsSelfbuiltStationsMapper, GardsSelfbuiltStations> implements IGardsSelfbuiltService {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<IPage<GardsSelfbuiltStations>> findPage(QueryRequest queryRequest, GardsSelfbuiltStations gardsSelfbuiltStations) {
|
|
||||||
Result<IPage<GardsSelfbuiltStations>> result = new Result<>();
|
|
||||||
Page<GardsSelfbuiltStations> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
|
|
||||||
LambdaQueryWrapper<GardsSelfbuiltStations> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
Page<GardsSelfbuiltStations> selfbuiltStationsPage = this.baseMapper.selectPage(page, queryWrapper);
|
|
||||||
result.setSuccess(true);
|
|
||||||
result.setResult(selfbuiltStationsPage);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GardsSelfbuiltStations findInfo(Integer id) {
|
|
||||||
GardsSelfbuiltStations gardsSelfbuiltStations = this.baseMapper.selectById(id);
|
|
||||||
if (Objects.isNull(gardsSelfbuiltStations)) {
|
|
||||||
throw new RuntimeException("当前数据不存在");
|
|
||||||
}
|
|
||||||
return gardsSelfbuiltStations;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public Result create(GardsSelfbuiltStations gardsSelfbuiltStations) {
|
|
||||||
Result result = new Result();
|
|
||||||
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();
|
|
||||||
//获取当前操作人用户名
|
|
||||||
String username = JwtUtil.getUserNameByToken(request);
|
|
||||||
//设置IP地址
|
|
||||||
String ipAddr = IpUtils.getIpAddr(request);
|
|
||||||
Long id = IdWorker.getId();
|
|
||||||
gardsSelfbuiltStations.setId(id.intValue());
|
|
||||||
gardsSelfbuiltStations.setOperateIp(ipAddr);
|
|
||||||
gardsSelfbuiltStations.setCreateBy(username);
|
|
||||||
gardsSelfbuiltStations.setCreateTime(new Date());
|
|
||||||
this.baseMapper.insert(gardsSelfbuiltStations);
|
|
||||||
result.setSuccess(true);
|
|
||||||
result.success("新增成功");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public Result update(GardsSelfbuiltStations gardsSelfbuiltStations) {
|
|
||||||
Result result = new Result();
|
|
||||||
LambdaQueryWrapper<GardsSelfbuiltStations> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(GardsSelfbuiltStations::getId,gardsSelfbuiltStations.getId());
|
|
||||||
GardsSelfbuiltStations stations = this.baseMapper.selectOne(wrapper);
|
|
||||||
if (Objects.isNull(stations)){
|
|
||||||
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();
|
|
||||||
//获取当前操作人用户名
|
|
||||||
String username = JwtUtil.getUserNameByToken(request);
|
|
||||||
//设置IP地址
|
|
||||||
String ipAddr = IpUtils.getIpAddr(request);
|
|
||||||
gardsSelfbuiltStations.setOperateIp(ipAddr);
|
|
||||||
gardsSelfbuiltStations.setUpdateBy(username);
|
|
||||||
gardsSelfbuiltStations.setUpdateTime(new Date());
|
|
||||||
this.updateById(gardsSelfbuiltStations);
|
|
||||||
result.setSuccess(true);
|
|
||||||
result.success("修改成功");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public Result deleteById(Integer id) {
|
|
||||||
Result result = new Result();
|
|
||||||
this.baseMapper.deleteById(id);
|
|
||||||
result.setSuccess(true);
|
|
||||||
result.success("删除成功");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -74,8 +74,6 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
|
||||||
throw new RuntimeException("当前台站信息已存在,新增失败");
|
throw new RuntimeException("当前台站信息已存在,新增失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Long id = IdWorker.getId();
|
|
||||||
gardsStations.setStationId(id.intValue());
|
|
||||||
this.baseMapper.insert(gardsStations);
|
this.baseMapper.insert(gardsStations);
|
||||||
result.setSuccess(true);
|
result.setSuccess(true);
|
||||||
result.success("新增成功");
|
result.success("新增成功");
|
||||||
|
@ -102,7 +100,7 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
|
||||||
queryWrapper.eq(GardsStations::getStationCode,gardsStations.getStationCode());
|
queryWrapper.eq(GardsStations::getStationCode,gardsStations.getStationCode());
|
||||||
GardsStations oldStations = this.baseMapper.selectOne(queryWrapper);
|
GardsStations oldStations = this.baseMapper.selectOne(queryWrapper);
|
||||||
if (Objects.nonNull(oldStations) && !oldStations.getStationId().equals(gardsStations.getStationId())) {
|
if (Objects.nonNull(oldStations) && !oldStations.getStationId().equals(gardsStations.getStationId())) {
|
||||||
throw new RuntimeException("当前台站信息已存在,修改失败");
|
throw new RuntimeException("当前台站信息"+gardsStations.getStationCode()+"已存在,修改失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LambdaQueryWrapper<GardsStations> stationsQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<GardsStations> stationsQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user