问题知识库-模板维护,新增、编辑完善。

This commit is contained in:
wangzhijiang
2022-08-09 10:23:29 +08:00
parent 2f99a59ff3
commit 39f002df34
3 changed files with 61 additions and 17 deletions
@@ -97,7 +97,7 @@ public class CountryCardTempEOController extends JeroController<CountryCardTempE
*/
@AutoLog(value = "Country Card模板维护表-编辑")
@ApiOperation(value="Country Card模板维护表-编辑", notes="Country Card模板维护表-编辑")
@PutMapping(value = "/edit")
@PostMapping(value = "/edit")
public Result<?> edit(@Validated @RequestBody CountryCardTempEO countryCardTempEO) {
countryCardTempEOService.editById(countryCardTempEO);
return Result.OK("编辑成功!");
@@ -69,8 +69,14 @@ public interface ICountryCardTempEOService extends IService<CountryCardTempEO> {
void disposeData(List<CountryCardTempEO> datas, String cut);
/**
* 设置排序号
* 设置编辑时排序号
* @param countryCardTempEO
*/
void setOrderNum(CountryCardTempEO countryCardTempEO);
void setEditOrderNum(CountryCardTempEO countryCardTempEO);
/**
* 设置新增时的排序号
* @param countryCardTempEO
*/
void setAddOrderNum(CountryCardTempEO countryCardTempEO);
}
@@ -44,15 +44,15 @@ public class CountryCardTempEOServiceImpl extends ServiceImpl<CountryCardTempEOM
*/
@Override
public void add(CountryCardTempEO countryCardTempEO) {
this.setOrderNum(countryCardTempEO);
this.setAddOrderNum(countryCardTempEO);
Date now = new Date();
countryCardTempEO.setCreateTime(now);
countryCardTempEO.setUpdateTime(now);
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());
}
}*/
}
/**
@@ -63,14 +63,14 @@ public class CountryCardTempEOServiceImpl extends ServiceImpl<CountryCardTempEOM
*/
@Override
public void editById(CountryCardTempEO countryCardTempEO) {
this.setOrderNum(countryCardTempEO);
this.setEditOrderNum(countryCardTempEO);
Date now = new Date();
countryCardTempEO.setUpdateTime(now);
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());
}
}*/
}
/**
@@ -154,34 +154,72 @@ public class CountryCardTempEOServiceImpl extends ServiceImpl<CountryCardTempEOM
}
@Override
public void setOrderNum(CountryCardTempEO countryCardTempEO){
public void setEditOrderNum(CountryCardTempEO countryCardTempEO){
Integer inputOrderNum = countryCardTempEO.getOrderNum();
if(inputOrderNum != null) {
QueryWrapper<CountryCardTempEO> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByAsc("order_num");
List<CountryCardTempEO> countryCardTempEOList = this.list(queryWrapper);
Integer orderNumData = countryCardTempEOList.stream().filter(e -> e.getId().equals(countryCardTempEO.getId()))
.map(e -> e.getOrderNum()).collect(Collectors.toList()).get(0);
if(CollectionUtils.isNotEmpty(countryCardTempEOList)){
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);
Integer orderNumCount = this.baseMapper.selectCount(queryWrapper);
//有重复展示顺序的,后面的号全+1
if (orderNumCount > 0 && !orderNumData.equals(inputOrderNum)) {
if (orderNumCount > 0) {
//设置排序
QueryWrapper<CountryCardTempEO> orderNumQueryWrapper = new QueryWrapper<>();
orderNumQueryWrapper.ge("order_num", inputOrderNum)
.orderByAsc("order_num");
List<CountryCardTempEO> geOrderNumList = this.list(orderNumQueryWrapper);
List<CountryCardTempEO> geOrderNumList = list(orderNumQueryWrapper);
//判断相邻的序号,去掉不邻的
for (int i = 0; i < geOrderNumList.size(); i++) {
if (geOrderNumList.size() == 1) {
break;
} else if(i+1 >= geOrderNumList.size()){
}else if(i+1 >= geOrderNumList.size()){
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();
geOrderNumList = geOrderNumList.stream().filter(e -> e.getOrderNum() < deleteStart).collect(Collectors.toList());
break;