package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.whyc.dto.Response;
|
import com.whyc.mapper.StationInfoMapper;
|
import com.whyc.pojo.StationInfo;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
@Service
|
public class StationInfoService {
|
@Autowired(required = false)
|
private StationInfoMapper mapper;
|
//添加台站
|
public Response addStation(String stationName1, String stationName2, String stationName3) {
|
String stationName="";
|
boolean bl=true;
|
String msg="";
|
StationInfo s=new StationInfo();
|
if(stationName1!=null&&!stationName1.isEmpty()){
|
s.setStationName1(stationName1);
|
stationName=stationName+stationName1;
|
}
|
if(stationName2!=null&&!stationName2.isEmpty()){
|
s.setStationName2(stationName2);
|
stationName=stationName+"-"+stationName2;
|
}else{
|
s.setStationName2("-");
|
}
|
if(stationName3!=null&&!stationName3.isEmpty()){
|
s.setStationName3(stationName3);
|
stationName=stationName+"-"+stationName3;
|
}else{
|
s.setStationName3("-");
|
}
|
//查询stationName是否存在
|
QueryWrapper wrapper=new QueryWrapper();
|
wrapper.like("station_name",stationName);
|
int count=mapper.selectCount(wrapper);
|
if(count>0){
|
bl=false;
|
msg="台站存在,添加失败";
|
}else{
|
s.setStationId("0");
|
s.setStationName(stationName);
|
int flag=mapper.insert(s);
|
bl=flag>0;
|
}
|
return new Response().set(1,bl,msg);
|
}
|
}
|