| | |
| | | package com.xiaopeng.operation.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.xiaopeng.api.model.operation.XpOpenCity; |
| | | import com.xiaopeng.api.model.operation.XpRoutePlan; |
| | | import com.xiaopeng.common.core.exception.ServiceException; |
| | |
| | | if (openCity == null) { |
| | | throw new ServiceException("开通城市不存在"); |
| | | } |
| | | long count = this.count(new QueryWrapper<XpRoutePlan>().eq("open_city_id", openCity.getId()) |
| | | .eq("is_deleted", 0)); |
| | | if(count >= 3){ |
| | | throw new ServiceException("同一个城市只能添加三个路线规划"); |
| | | } |
| | | count = this.count(new QueryWrapper<XpRoutePlan>().eq("open_city_id", openCity.getId()) |
| | | .eq("plan_name", dto.getPlanName()).eq("is_deleted", 0)); |
| | | if(count > 0){ |
| | | throw new ServiceException("路线规划名称不能重复"); |
| | | } |
| | | |
| | | // 2. 创建路线规划配置对象 |
| | | XpRoutePlan routePlan = new XpRoutePlan(); |
| | |
| | | if (openCity == null) { |
| | | throw new ServiceException("开通城市不存在"); |
| | | } |
| | | long count = this.count(new QueryWrapper<XpRoutePlan>().eq("open_city_id", openCity.getId()) |
| | | .eq("plan_name", dto.getPlanName()).eq("is_deleted", 0).ne("id", dto.getId())); |
| | | if(count > 0){ |
| | | throw new ServiceException("路线规划名称不能重复"); |
| | | } |
| | | |
| | | // 3. 更新字段 |
| | | routePlan.setOpenCityId(dto.getOpenCityId()); |