问题知识库-模板维护,新增、编辑完善。
This commit is contained in:
+1
-1
@@ -97,7 +97,7 @@ public class CountryCardTempEOController extends JeroController<CountryCardTempE
|
|||||||
*/
|
*/
|
||||||
@AutoLog(value = "Country Card模板维护表-编辑")
|
@AutoLog(value = "Country Card模板维护表-编辑")
|
||||||
@ApiOperation(value="Country Card模板维护表-编辑", notes="Country Card模板维护表-编辑")
|
@ApiOperation(value="Country Card模板维护表-编辑", notes="Country Card模板维护表-编辑")
|
||||||
@PutMapping(value = "/edit")
|
@PostMapping(value = "/edit")
|
||||||
public Result<?> edit(@Validated @RequestBody CountryCardTempEO countryCardTempEO) {
|
public Result<?> edit(@Validated @RequestBody CountryCardTempEO countryCardTempEO) {
|
||||||
countryCardTempEOService.editById(countryCardTempEO);
|
countryCardTempEOService.editById(countryCardTempEO);
|
||||||
return Result.OK("编辑成功!");
|
return Result.OK("编辑成功!");
|
||||||
|
|||||||
+8
-2
@@ -69,8 +69,14 @@ public interface ICountryCardTempEOService extends IService<CountryCardTempEO> {
|
|||||||
void disposeData(List<CountryCardTempEO> datas, String cut);
|
void disposeData(List<CountryCardTempEO> datas, String cut);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置排序号
|
* 设置编辑时排序号
|
||||||
* @param countryCardTempEO
|
* @param countryCardTempEO
|
||||||
*/
|
*/
|
||||||
void setOrderNum(CountryCardTempEO countryCardTempEO);
|
void setEditOrderNum(CountryCardTempEO countryCardTempEO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置新增时的排序号
|
||||||
|
* @param countryCardTempEO
|
||||||
|
*/
|
||||||
|
void setAddOrderNum(CountryCardTempEO countryCardTempEO);
|
||||||
}
|
}
|
||||||
|
|||||||
+52
-14
@@ -44,15 +44,15 @@ public class CountryCardTempEOServiceImpl extends ServiceImpl<CountryCardTempEOM
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void add(CountryCardTempEO countryCardTempEO) {
|
public void add(CountryCardTempEO countryCardTempEO) {
|
||||||
this.setOrderNum(countryCardTempEO);
|
this.setAddOrderNum(countryCardTempEO);
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
countryCardTempEO.setCreateTime(now);
|
countryCardTempEO.setCreateTime(now);
|
||||||
countryCardTempEO.setUpdateTime(now);
|
countryCardTempEO.setUpdateTime(now);
|
||||||
save(countryCardTempEO);
|
save(countryCardTempEO);
|
||||||
//如果选择了下拉框
|
//如果选择了下拉框
|
||||||
if(StringUtils.equals(countryCardTempEO.getLableType(), LableTypeEnum.PULL_SINGLE.getValue())){
|
/*if(StringUtils.equals(countryCardTempEO.getLableType(), LableTypeEnum.PULL_SINGLE.getValue())){
|
||||||
this.countryCardTempItemEOService.batchInsert(countryCardTempEO.getCountryCardTempItemEOList(),countryCardTempEO.getId(),countryCardTempEO.getCut());
|
this.countryCardTempItemEOService.batchInsert(countryCardTempEO.getCountryCardTempItemEOList(),countryCardTempEO.getId(),countryCardTempEO.getCut());
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,14 +63,14 @@ public class CountryCardTempEOServiceImpl extends ServiceImpl<CountryCardTempEOM
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void editById(CountryCardTempEO countryCardTempEO) {
|
public void editById(CountryCardTempEO countryCardTempEO) {
|
||||||
this.setOrderNum(countryCardTempEO);
|
this.setEditOrderNum(countryCardTempEO);
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
countryCardTempEO.setUpdateTime(now);
|
countryCardTempEO.setUpdateTime(now);
|
||||||
saveOrUpdate(countryCardTempEO);
|
saveOrUpdate(countryCardTempEO);
|
||||||
//如果选择了下拉框
|
//如果选择了下拉框
|
||||||
if(StringUtils.equals(countryCardTempEO.getLableType(), LableTypeEnum.PULL_SINGLE.getValue())){
|
/*if(StringUtils.equals(countryCardTempEO.getLableType(), LableTypeEnum.PULL_SINGLE.getValue())){
|
||||||
this.countryCardTempItemEOService.batchInsert(countryCardTempEO.getCountryCardTempItemEOList(),countryCardTempEO.getId(),countryCardTempEO.getCut());
|
this.countryCardTempItemEOService.batchInsert(countryCardTempEO.getCountryCardTempItemEOList(),countryCardTempEO.getId(),countryCardTempEO.getCut());
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -154,34 +154,72 @@ public class CountryCardTempEOServiceImpl extends ServiceImpl<CountryCardTempEOM
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOrderNum(CountryCardTempEO countryCardTempEO){
|
public void setEditOrderNum(CountryCardTempEO countryCardTempEO){
|
||||||
Integer inputOrderNum = countryCardTempEO.getOrderNum();
|
Integer inputOrderNum = countryCardTempEO.getOrderNum();
|
||||||
if(inputOrderNum != null) {
|
if(inputOrderNum != null) {
|
||||||
QueryWrapper<CountryCardTempEO> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<CountryCardTempEO> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.orderByAsc("order_num");
|
queryWrapper.orderByAsc("order_num");
|
||||||
List<CountryCardTempEO> countryCardTempEOList = this.list(queryWrapper);
|
List<CountryCardTempEO> countryCardTempEOList = this.list(queryWrapper);
|
||||||
|
|
||||||
Integer orderNumData = countryCardTempEOList.stream().filter(e -> e.getId().equals(countryCardTempEO.getId()))
|
if(CollectionUtils.isNotEmpty(countryCardTempEOList)){
|
||||||
.map(e -> e.getOrderNum()).collect(Collectors.toList()).get(0);
|
Integer orderNumData = countryCardTempEOList.stream().filter(e -> e.getId().equals(countryCardTempEO.getId()))
|
||||||
|
.map(e -> e.getOrderNum()).collect(Collectors.toList()).get(0);
|
||||||
|
|
||||||
|
queryWrapper.eq("order_num", inputOrderNum);
|
||||||
|
Integer orderNumCount = this.baseMapper.selectCount(queryWrapper);
|
||||||
|
//有重复展示顺序的,后面的号全+1
|
||||||
|
if (orderNumCount > 0 && !orderNumData.equals(inputOrderNum)) {
|
||||||
|
|
||||||
|
//设置排序
|
||||||
|
QueryWrapper<CountryCardTempEO> orderNumQueryWrapper = new QueryWrapper<>();
|
||||||
|
orderNumQueryWrapper.ge("order_num", inputOrderNum)
|
||||||
|
.orderByAsc("order_num");
|
||||||
|
List<CountryCardTempEO> geOrderNumList = this.list(orderNumQueryWrapper);
|
||||||
|
|
||||||
|
//判断相邻的序号,去掉不邻的
|
||||||
|
for (int i = 0; i < geOrderNumList.size(); i++) {
|
||||||
|
if (geOrderNumList.size() == 1) {
|
||||||
|
break;
|
||||||
|
} else if(i+1 >= geOrderNumList.size()){
|
||||||
|
break;
|
||||||
|
}else if (geOrderNumList.get(i + 1).getOrderNum() - geOrderNumList.get(i).getOrderNum() > 1) {
|
||||||
|
int deleteStart = geOrderNumList.get(i + 1).getOrderNum();
|
||||||
|
geOrderNumList = geOrderNumList.stream().filter(e -> e.getOrderNum() < deleteStart).collect(Collectors.toList());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
geOrderNumList.stream().forEach(e -> e.setOrderNum(e.getOrderNum() + 1));
|
||||||
|
saveOrUpdateBatch(geOrderNumList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAddOrderNum(CountryCardTempEO countryCardTempEO) {
|
||||||
|
Integer inputOrderNum = countryCardTempEO.getOrderNum();
|
||||||
|
if(inputOrderNum != null) {
|
||||||
|
//查询展示顺序相同的
|
||||||
|
QueryWrapper<CountryCardTempEO> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByAsc("order_num");
|
||||||
queryWrapper.eq("order_num", inputOrderNum);
|
queryWrapper.eq("order_num", inputOrderNum);
|
||||||
Integer orderNumCount = this.baseMapper.selectCount(queryWrapper);
|
Integer orderNumCount = this.baseMapper.selectCount(queryWrapper);
|
||||||
//有重复展示顺序的,后面的号全+1
|
//有重复展示顺序的,后面的号全+1
|
||||||
if (orderNumCount > 0 && !orderNumData.equals(inputOrderNum)) {
|
if (orderNumCount > 0) {
|
||||||
|
|
||||||
//设置排序
|
//设置排序
|
||||||
QueryWrapper<CountryCardTempEO> orderNumQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<CountryCardTempEO> orderNumQueryWrapper = new QueryWrapper<>();
|
||||||
orderNumQueryWrapper.ge("order_num", inputOrderNum)
|
orderNumQueryWrapper.ge("order_num", inputOrderNum)
|
||||||
.orderByAsc("order_num");
|
.orderByAsc("order_num");
|
||||||
List<CountryCardTempEO> geOrderNumList = this.list(orderNumQueryWrapper);
|
List<CountryCardTempEO> geOrderNumList = list(orderNumQueryWrapper);
|
||||||
|
|
||||||
//判断相邻的序号,去掉不邻的
|
//判断相邻的序号,去掉不邻的
|
||||||
for (int i = 0; i < geOrderNumList.size(); i++) {
|
for (int i = 0; i < geOrderNumList.size(); i++) {
|
||||||
if (geOrderNumList.size() == 1) {
|
if (geOrderNumList.size() == 1) {
|
||||||
break;
|
break;
|
||||||
} else if(i+1 >= geOrderNumList.size()){
|
}else if(i+1 >= geOrderNumList.size()){
|
||||||
break;
|
break;
|
||||||
}else if (geOrderNumList.get(i + 1).getOrderNum() - geOrderNumList.get(i).getOrderNum() > 1) {
|
} else if (geOrderNumList.get(i + 1).getOrderNum() - geOrderNumList.get(i).getOrderNum() > 1) {
|
||||||
int deleteStart = geOrderNumList.get(i + 1).getOrderNum();
|
int deleteStart = geOrderNumList.get(i + 1).getOrderNum();
|
||||||
geOrderNumList = geOrderNumList.stream().filter(e -> e.getOrderNum() < deleteStart).collect(Collectors.toList());
|
geOrderNumList = geOrderNumList.stream().filter(e -> e.getOrderNum() < deleteStart).collect(Collectors.toList());
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user