feat:台站相关代码
This commit is contained in:
parent
48c4a8b57f
commit
1fb3afb5d5
|
@ -0,0 +1,27 @@
|
||||||
|
package org.jeecg.common.api;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class QueryRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页码
|
||||||
|
*/
|
||||||
|
private Integer pageNum = 1;
|
||||||
|
/**
|
||||||
|
* 一页显示条数
|
||||||
|
*/
|
||||||
|
private Integer pageSize = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序字段
|
||||||
|
*/
|
||||||
|
private String field;
|
||||||
|
/**
|
||||||
|
* 排序类型
|
||||||
|
*/
|
||||||
|
private String order;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
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.GardsStations;
|
||||||
|
import org.jeecg.modules.system.service.IGardsStationsService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("gardsStations")
|
||||||
|
public class GardsStationsController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IGardsStationsService gardsStationsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询台站数据信息
|
||||||
|
* @param queryRequest
|
||||||
|
* @param gardsStations
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("findPage")
|
||||||
|
public Result<IPage<GardsStations>> findPage(QueryRequest queryRequest, GardsStations gardsStations){
|
||||||
|
Result<IPage<GardsStations>> result = gardsStationsService.findPage(queryRequest, gardsStations);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询台站信息详情接口
|
||||||
|
* @param stationId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("findInfo")
|
||||||
|
public GardsStations findInfo(Integer stationId){
|
||||||
|
GardsStations result = gardsStationsService.findInfo(stationId);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增台站信息接口
|
||||||
|
*/
|
||||||
|
@PostMapping("create")
|
||||||
|
public void create(@RequestBody GardsStations gardsStations){
|
||||||
|
gardsStationsService.create(gardsStations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改台站信息接口
|
||||||
|
*/
|
||||||
|
@PutMapping("update")
|
||||||
|
public void update(@RequestBody GardsStations gardsStations){
|
||||||
|
gardsStationsService.update(gardsStations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除台站信息接口
|
||||||
|
* @param stationId
|
||||||
|
*/
|
||||||
|
@DeleteMapping("deleteById")
|
||||||
|
public void deleteById(Integer stationId){
|
||||||
|
gardsStationsService.deleteById(stationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package org.jeecg.modules.system.entity;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
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 java.io.Serializable;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName(value = "GARDS_STATIONS")
|
||||||
|
public class GardsStations implements Serializable {
|
||||||
|
|
||||||
|
@TableField(value = "STATION_ID")
|
||||||
|
private Integer stationId;
|
||||||
|
|
||||||
|
@TableField(value = "STATION_CODE")
|
||||||
|
private String stationCode;
|
||||||
|
|
||||||
|
@TableField(value = "COUNTRY_CODE")
|
||||||
|
private String countryCode;
|
||||||
|
|
||||||
|
@TableField(value = "TYPE")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@TableField(value = "LON")
|
||||||
|
private Double lon;
|
||||||
|
|
||||||
|
@TableField(value = "LAT")
|
||||||
|
private Double lat;
|
||||||
|
|
||||||
|
@TableField(value = "ELEVATION")
|
||||||
|
private Double elevation;
|
||||||
|
|
||||||
|
@TableField(value = "DESCRIPTION")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@TableField(value = "DATE_BEGIN")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date dateBegin;
|
||||||
|
|
||||||
|
@TableField(value = "DATE_END")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date dateEnd;
|
||||||
|
|
||||||
|
@TableField(value = "STATUS")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@TableField(value = "MODDATE")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date moddate;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package org.jeecg.modules.system.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.jeecg.modules.system.entity.GardsStations;
|
||||||
|
|
||||||
|
public interface GardsStationsMapper extends BaseMapper<GardsStations> {
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
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.GardsStations;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IGardsStationsService extends IService<GardsStations> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询台站信息
|
||||||
|
* @param queryRequest
|
||||||
|
* @param gardsStations
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Result<IPage<GardsStations>> findPage(QueryRequest queryRequest, GardsStations gardsStations);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询台站数据详情
|
||||||
|
* @param stationId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
GardsStations findInfo(Integer stationId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增台站信息接口
|
||||||
|
* @param gardsStations
|
||||||
|
*/
|
||||||
|
void create(GardsStations gardsStations);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改台站信息接口
|
||||||
|
* @param gardsStations
|
||||||
|
*/
|
||||||
|
void update(GardsStations gardsStations);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除台站信息接口
|
||||||
|
* @param stationId
|
||||||
|
*/
|
||||||
|
void deleteById(Integer stationId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部台站数据接口
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<GardsStations> getGardsStations();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,123 @@
|
||||||
|
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.modules.system.entity.GardsStations;
|
||||||
|
import org.jeecg.modules.system.mapper.GardsStationsMapper;
|
||||||
|
import org.jeecg.modules.system.service.IGardsStationsService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service("gardsStationsService")
|
||||||
|
@DS("ora")
|
||||||
|
public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, GardsStations> implements IGardsStationsService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询台站信息接口
|
||||||
|
* @param queryRequest
|
||||||
|
* @param gardsStations
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<IPage<GardsStations>> findPage(QueryRequest queryRequest, GardsStations gardsStations) {
|
||||||
|
Result<IPage<GardsStations>> result = new Result<>();
|
||||||
|
Page<GardsStations> page = new Page<>(queryRequest.getPageNum(), queryRequest.getPageSize());
|
||||||
|
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
Page<GardsStations> pageList = this.baseMapper.selectPage(page, queryWrapper);
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.setResult(pageList);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询台站信息详情接口
|
||||||
|
* @param stationId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public GardsStations findInfo(Integer stationId) {
|
||||||
|
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(GardsStations::getStationId,stationId);
|
||||||
|
GardsStations stations = this.baseMapper.selectOne(queryWrapper);
|
||||||
|
if (Objects.isNull(stations)){
|
||||||
|
throw new RuntimeException("当前查询数据不存在!");
|
||||||
|
}
|
||||||
|
return stations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增台站信息接口
|
||||||
|
* @param gardsStations
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void create(GardsStations gardsStations) {
|
||||||
|
//根据传递的台站编码查询
|
||||||
|
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());
|
||||||
|
this.baseMapper.insert(gardsStations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改台站信息接口
|
||||||
|
* @param gardsStations
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void update(GardsStations gardsStations) {
|
||||||
|
LambdaQueryWrapper<GardsStations> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(GardsStations::getStationId,gardsStations.getStationId());
|
||||||
|
GardsStations stations = this.baseMapper.selectOne(wrapper);
|
||||||
|
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("当前台站信息已存在,修改失败");
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<GardsStations> stationsQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
stationsQueryWrapper.eq(GardsStations::getStationId,gardsStations.getStationId());
|
||||||
|
this.baseMapper.update(gardsStations, stationsQueryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除台站信息接口
|
||||||
|
* @param stationId
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteById(Integer stationId) {
|
||||||
|
LambdaQueryWrapper<GardsStations> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(GardsStations::getStationId,stationId);
|
||||||
|
this.baseMapper.delete(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部台站信息接口
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
|
public List<GardsStations> getGardsStations() {
|
||||||
|
LambdaQueryWrapper<GardsStations> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
List<GardsStations> gardsStations = this.baseMapper.selectList(queryWrapper);
|
||||||
|
return gardsStations;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user