【线路、发布逻辑修改】
This commit is contained in:
parent
d3d856d45d
commit
be85419ab6
@ -35,7 +35,7 @@ public class LineInfoService {
|
||||
// 可以做权限判断
|
||||
|
||||
LambdaQueryWrapper<LineInfo> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(LineInfo::getName, lineInfo.getName());
|
||||
wrapper.eq(LineInfo::getLineId, lineInfo.getLineId());
|
||||
long count = lineInfoRepository.count(wrapper);
|
||||
if (count > 0) {
|
||||
throw BusinessExceptionAssertEnum.DATA_ALREADY_EXISTS.exception("线路名称已存在");
|
||||
@ -58,10 +58,10 @@ public class LineInfoService {
|
||||
throw BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception(String.format("线路[%s]信息不存在", id));
|
||||
}
|
||||
LambdaQueryWrapper<LineInfo> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(LineInfo::getName, lineInfo.getName()).ne(LineInfo::getId, id);
|
||||
wrapper.eq(LineInfo::getLineId, lineInfo.getLineId()).ne(LineInfo::getId, id);
|
||||
long count = lineInfoRepository.count(wrapper);
|
||||
if (count > 0) {
|
||||
throw BusinessExceptionAssertEnum.DATA_ALREADY_EXISTS.exception(String.format("线路名称[%s]已存在", lineInfo.getName()));
|
||||
throw BusinessExceptionAssertEnum.DATA_ALREADY_EXISTS.exception(String.format("线路ID[%s]已存在", lineInfo.getLineId()));
|
||||
}
|
||||
lineInfo.setId(id);
|
||||
lineInfo.setUpdateAt(LocalDateTime.now());
|
||||
|
@ -2,9 +2,11 @@ package club.joylink.xiannccda.service;
|
||||
|
||||
import club.joylink.xiannccda.dto.PublishedGIDto;
|
||||
import club.joylink.xiannccda.entity.Drafting;
|
||||
import club.joylink.xiannccda.entity.LineInfo;
|
||||
import club.joylink.xiannccda.entity.PublishedGi;
|
||||
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.xiannccda.repository.IDraftingRepository;
|
||||
import club.joylink.xiannccda.repository.ILineInfoRepository;
|
||||
import club.joylink.xiannccda.repository.IPublishedGiRepository;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@ -22,10 +24,13 @@ public class PublishedGiService {
|
||||
|
||||
final IDraftingRepository draftingRepository;
|
||||
|
||||
final ILineInfoRepository lineInfoRepository;
|
||||
|
||||
public PublishedGiService(IPublishedGiRepository publishedGiRepository, IDraftingRepository draftingRepository) {
|
||||
|
||||
public PublishedGiService(IPublishedGiRepository publishedGiRepository, IDraftingRepository draftingRepository, ILineInfoRepository lineInfoRepository) {
|
||||
this.publishedGiRepository = publishedGiRepository;
|
||||
this.draftingRepository = draftingRepository;
|
||||
this.lineInfoRepository = lineInfoRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,6 +46,13 @@ public class PublishedGiService {
|
||||
if (drafting == null) {
|
||||
throw BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception(String.format("草稿[%s]信息不存在", publishedDto.getDraftingId()));
|
||||
}
|
||||
// 查询线路信息是否存在
|
||||
LambdaQueryWrapper<LineInfo> lineInfoWrapper = Wrappers.lambdaQuery();
|
||||
lineInfoWrapper.eq(LineInfo::getLineId, publishedDto.getLineId());
|
||||
LineInfo lineInfo = lineInfoRepository.getOne(lineInfoWrapper);
|
||||
if (lineInfo == null) {
|
||||
throw BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception(String.format("线路[%s]信息不存在", publishedDto.getLineId()));
|
||||
}
|
||||
// 删除已发布的绘图数据
|
||||
LambdaQueryWrapper<PublishedGi> wrapper = Wrappers.lambdaQuery();
|
||||
String name = StringUtils.isNotEmpty(publishedDto.getName()) ? publishedDto.getName() : drafting.getName();
|
||||
@ -50,7 +62,7 @@ public class PublishedGiService {
|
||||
PublishedGi publishedGi = new PublishedGi();
|
||||
publishedGi.setName(name);
|
||||
publishedGi.setType(drafting.getType());
|
||||
publishedGi.setLineId(publishedDto.getLineId());
|
||||
publishedGi.setLineId(lineInfo.getLineId());
|
||||
publishedGi.setProto(drafting.getProto());
|
||||
publishedGi.setUserId(Integer.valueOf(user.getName()));
|
||||
publishedGi.setPublishAt(LocalDateTime.now());
|
||||
|
Loading…
Reference in New Issue
Block a user