|
|
@@ -1,5 +1,7 @@
|
|
|
package com.sqx.modules.riderStation.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.api.R;
|
|
|
@@ -24,6 +26,19 @@ public class RiderStationServiceImpl extends ServiceImpl<RiderStationDao, RiderS
|
|
|
private UserDao userDao;
|
|
|
|
|
|
@Override
|
|
|
+ public Result saveStation(RiderStation riderStation) {
|
|
|
+ String stationName = riderStation.getStationName();
|
|
|
+ LambdaQueryWrapper<RiderStation> wrapper=new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(RiderStation::getStationName,stationName);
|
|
|
+ RiderStation station = this.getOne(wrapper);
|
|
|
+ if (ObjectUtils.isNotEmpty(station)) {
|
|
|
+ return Result.error("该站点已存在");
|
|
|
+ }
|
|
|
+ this.save(riderStation);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public Result selectStationList(Integer page, Integer size) {
|
|
|
IPage<RiderStation> riderStationIPage = this.page(new Page<RiderStation>(page, size));
|
|
|
PageUtils pageUtils = new PageUtils(riderStationIPage);
|
|
|
@@ -49,4 +64,24 @@ public class RiderStationServiceImpl extends ServiceImpl<RiderStationDao, RiderS
|
|
|
return Result.success().put("data",riderStation);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result updateStation(RiderStation riderStation) {
|
|
|
+ Long id = riderStation.getId();
|
|
|
+ String stationName = riderStation.getStationName();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<RiderStation> wrapper=new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(RiderStation::getStationName,stationName);
|
|
|
+ RiderStation station = this.getOne(wrapper);
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotEmpty(station)) {
|
|
|
+ Long id1 = station.getId();
|
|
|
+ if (!id.equals(id1)) {
|
|
|
+ return Result.error("所修改的站点已存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.updateById(riderStation);
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
}
|