feat:新增自建台站相关接口,修改台站信息相关接口返回值
This commit is contained in:
parent
be1e1e282b
commit
2ed5ac5527
|
@ -8,7 +8,7 @@ public class QueryRequest {
|
||||||
/**
|
/**
|
||||||
* 页码
|
* 页码
|
||||||
*/
|
*/
|
||||||
private Integer pageNum = 1;
|
private Integer pageNo = 1;
|
||||||
/**
|
/**
|
||||||
* 一页显示条数
|
* 一页显示条数
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package org.jeecg.modules.system.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import org.jeecg.common.api.QueryRequest;
|
||||||
|
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.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("gardsSelfbuilt")
|
||||||
|
public class GardsSelfbuiltController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IGardsSelfbuiltService gardsSelfbuiltService;
|
||||||
|
|
||||||
|
@GetMapping("findPage")
|
||||||
|
public Result<IPage<GardsSelfbuiltStations>> findPage(QueryRequest queryRequest, GardsSelfbuiltStations gardsSelfbuiltStations){
|
||||||
|
Result<IPage<GardsSelfbuiltStations>> result = gardsSelfbuiltService.findPage(queryRequest, gardsSelfbuiltStations);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("findInfo")
|
||||||
|
public GardsSelfbuiltStations findInfo(Integer id){
|
||||||
|
GardsSelfbuiltStations info = gardsSelfbuiltService.findInfo(id);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("create")
|
||||||
|
public Result create(@RequestBody GardsSelfbuiltStations gardsSelfbuiltStations){
|
||||||
|
Result result = gardsSelfbuiltService.create(gardsSelfbuiltStations);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("update")
|
||||||
|
public Result update(@RequestBody GardsSelfbuiltStations gardsSelfbuiltStations){
|
||||||
|
Result result = gardsSelfbuiltService.update(gardsSelfbuiltStations);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("deleteById")
|
||||||
|
public Result deleteById(Integer id){
|
||||||
|
Result result = gardsSelfbuiltService.deleteById(id);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -42,16 +42,18 @@ public class GardsStationsController {
|
||||||
* 新增台站信息接口
|
* 新增台站信息接口
|
||||||
*/
|
*/
|
||||||
@PostMapping("create")
|
@PostMapping("create")
|
||||||
public void create(@RequestBody GardsStations gardsStations){
|
public Result create(@RequestBody GardsStations gardsStations){
|
||||||
gardsStationsService.create(gardsStations);
|
Result result = gardsStationsService.create(gardsStations);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改台站信息接口
|
* 修改台站信息接口
|
||||||
*/
|
*/
|
||||||
@PutMapping("update")
|
@PutMapping("update")
|
||||||
public void update(@RequestBody GardsStations gardsStations){
|
public Result update(@RequestBody GardsStations gardsStations){
|
||||||
gardsStationsService.update(gardsStations);
|
Result result = gardsStationsService.update(gardsStations);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,8 +61,9 @@ public class GardsStationsController {
|
||||||
* @param stationId
|
* @param stationId
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("deleteById")
|
@DeleteMapping("deleteById")
|
||||||
public void deleteById(Integer stationId){
|
public Result deleteById(Integer stationId){
|
||||||
gardsStationsService.deleteById(stationId);
|
Result result = gardsStationsService.deleteById(stationId);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
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.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
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)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@TableField(value = "CODE")
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
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> {
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
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> {
|
||||||
|
|
||||||
|
Result<IPage<GardsSelfbuiltStations>> findPage(QueryRequest queryRequest, GardsSelfbuiltStations gardsSelfbuiltStations);
|
||||||
|
|
||||||
|
GardsSelfbuiltStations findInfo(Integer id);
|
||||||
|
|
||||||
|
Result create(GardsSelfbuiltStations gardsSelfbuiltStations);
|
||||||
|
|
||||||
|
Result update(GardsSelfbuiltStations gardsSelfbuiltStations);
|
||||||
|
|
||||||
|
Result deleteById(Integer id);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,109 @@
|
||||||
|
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.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();
|
||||||
|
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> 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,7 +31,7 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
|
||||||
@Override
|
@Override
|
||||||
public Result<IPage<GardsStations>> findPage(QueryRequest queryRequest, GardsStations gardsStations) {
|
public Result<IPage<GardsStations>> findPage(QueryRequest queryRequest, GardsStations gardsStations) {
|
||||||
Result<IPage<GardsStations>> result = new Result<>();
|
Result<IPage<GardsStations>> result = new Result<>();
|
||||||
Page<GardsStations> page = new Page<>(queryRequest.getPageNum(), queryRequest.getPageSize());
|
Page<GardsStations> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
|
||||||
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
Page<GardsStations> pageList = this.baseMapper.selectPage(page, queryWrapper);
|
Page<GardsStations> pageList = this.baseMapper.selectPage(page, queryWrapper);
|
||||||
result.setSuccess(true);
|
result.setSuccess(true);
|
||||||
|
@ -60,7 +60,9 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
|
||||||
* @param gardsStations
|
* @param gardsStations
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void create(GardsStations gardsStations) {
|
@Transactional
|
||||||
|
public Result create(GardsStations gardsStations) {
|
||||||
|
Result result = new Result();
|
||||||
//根据传递的台站编码查询
|
//根据传递的台站编码查询
|
||||||
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(GardsStations::getStationCode,gardsStations.getStationCode());
|
queryWrapper.eq(GardsStations::getStationCode,gardsStations.getStationCode());
|
||||||
|
@ -72,6 +74,9 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
|
||||||
Long id = IdWorker.getId();
|
Long id = IdWorker.getId();
|
||||||
gardsStations.setStationId(id.intValue());
|
gardsStations.setStationId(id.intValue());
|
||||||
this.baseMapper.insert(gardsStations);
|
this.baseMapper.insert(gardsStations);
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.success("新增成功");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +84,9 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
|
||||||
* @param gardsStations
|
* @param gardsStations
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void update(GardsStations gardsStations) {
|
@Transactional
|
||||||
|
public Result update(GardsStations gardsStations) {
|
||||||
|
Result result = new Result();
|
||||||
LambdaQueryWrapper<GardsStations> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<GardsStations> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(GardsStations::getStationId,gardsStations.getStationId());
|
wrapper.eq(GardsStations::getStationId,gardsStations.getStationId());
|
||||||
GardsStations stations = this.baseMapper.selectOne(wrapper);
|
GardsStations stations = this.baseMapper.selectOne(wrapper);
|
||||||
|
@ -96,6 +103,9 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
|
||||||
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);
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.success("修改成功");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,10 +113,15 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
|
||||||
* @param stationId
|
* @param stationId
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteById(Integer stationId) {
|
@Transactional
|
||||||
|
public Result deleteById(Integer stationId) {
|
||||||
|
Result result = new Result();
|
||||||
LambdaQueryWrapper<GardsStations> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<GardsStations> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(GardsStations::getStationId,stationId);
|
wrapper.eq(GardsStations::getStationId,stationId);
|
||||||
this.baseMapper.delete(wrapper);
|
this.baseMapper.delete(wrapper);
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.success("删除成功");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user