lxw
2022-09-09 1853bc2851bad682cd69c0f557eb9e49243202ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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);
    }
}