|
@@ -1,5 +1,6 @@
|
|
|
package org.jeecg.modules.system.app.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -23,6 +24,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static org.jeecg.common.constant.CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
|
|
|
|
|
@@ -67,14 +70,44 @@ public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> impl
|
|
|
return Boolean.TRUE;
|
|
|
}
|
|
|
|
|
|
+ //比较两个list
|
|
|
+ //取出存在menuOneList中,但不存在resourceList中的数据,差异数据放入differentList
|
|
|
+ private List<String> listCompare(List<String> menuOneList, List<String> resourceList) {
|
|
|
+ Map<String, Integer> map = new HashMap<String, Integer>(resourceList.size());
|
|
|
+ List<String> differentList = new ArrayList<>();
|
|
|
+ for (String resource : resourceList) {
|
|
|
+ map.put(resource, 1);
|
|
|
+ }
|
|
|
+ for (String resource1 : menuOneList) {
|
|
|
+ if (map.get(resource1) == null) {
|
|
|
+ differentList.add(resource1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return differentList;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean editSite(AppSiteDTO siteCuDTO) {
|
|
|
String id = siteCuDTO.getId();
|
|
|
- AppSite oldSite = baseMapper.selectById(id);
|
|
|
- //比较运动类目,做新增删除修改
|
|
|
- if (!oldSite.getCategoryId().equals(siteCuDTO.getCategoryId())){
|
|
|
-
|
|
|
+ if (StrUtil.isNotBlank(id)) {
|
|
|
+ AppSite oldSite = baseMapper.selectById(id);
|
|
|
+ //比较运动类目,做新增删除修改
|
|
|
+ if (!oldSite.getCategoryId().equals(siteCuDTO.getCategoryId())) {
|
|
|
+ List<String> oldList = Arrays.stream(oldSite.getCategoryId().split(",")).collect(Collectors.toList());
|
|
|
+ List<String> newList = Arrays.stream(siteCuDTO.getCategoryId().split(",")).collect(Collectors.toList());
|
|
|
+ List<String> diffList = listCompare(oldList, newList);
|
|
|
+ if (ObjectUtils.isNotEmpty(diffList)) {
|
|
|
+// //删除
|
|
|
+// priceRulesMapper.delete(Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getSiteId, id).in(AppSitePriceRules::getCategoryId, diffList));
|
|
|
+// //新增
|
|
|
+// for (String categoryId : newList) {
|
|
|
+// AppSitePriceRules priceRules = new AppSitePriceRules();
|
|
|
+// priceRules.setSiteId(id);
|
|
|
+// priceRules.setCategoryId(categoryId);
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
AppSite site = new AppSite();
|
|
|
BeanUtils.copyProperties(siteCuDTO, site);
|