|
@@ -1,6 +1,8 @@
|
|
package com.zfire.mall.manager.logic.admin;
|
|
package com.zfire.mall.manager.logic.admin;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
+import com.zfire.mall.manager.bean.admin.AdminModuleBean;
|
|
import com.zfire.mall.manager.bean.admin.AdminModuleTree;
|
|
import com.zfire.mall.manager.bean.admin.AdminModuleTree;
|
|
import com.zfire.mall.manager.bean.admin.AdminModuleVO;
|
|
import com.zfire.mall.manager.bean.admin.AdminModuleVO;
|
|
import com.zfire.mall.manager.bean.admin.AdminUserCom;
|
|
import com.zfire.mall.manager.bean.admin.AdminUserCom;
|
|
@@ -35,7 +37,7 @@ public class AdminModuleLogic {
|
|
* 新增模块
|
|
* 新增模块
|
|
* @param adminModule
|
|
* @param adminModule
|
|
*/
|
|
*/
|
|
- public void add(AdminModule adminModule){
|
|
|
|
|
|
+ public void add(AdminModuleBean adminModule){
|
|
Integer level = 1;
|
|
Integer level = 1;
|
|
if(!adminModule.getParentId().equals("0")){
|
|
if(!adminModule.getParentId().equals("0")){
|
|
AdminModule parent = adminModuleService.getById(adminModule.getParentId());
|
|
AdminModule parent = adminModuleService.getById(adminModule.getParentId());
|
|
@@ -43,62 +45,49 @@ public class AdminModuleLogic {
|
|
throw new RemoteServiceException("请选择正确的父级菜单");
|
|
throw new RemoteServiceException("请选择正确的父级菜单");
|
|
}
|
|
}
|
|
level = parent.getLevel() + 1;
|
|
level = parent.getLevel() + 1;
|
|
-// parent.setType(1);
|
|
|
|
-// parent.updateById();
|
|
|
|
|
|
+ parent.updateById();
|
|
}
|
|
}
|
|
Integer count = adminModuleService.lambdaQuery()
|
|
Integer count = adminModuleService.lambdaQuery()
|
|
- .and(v -> v.eq(AdminModule::getFullUrl, adminModule.getFullUrl()).or().eq(AdminModule::getCode, adminModule.getCode()))
|
|
|
|
|
|
+ .eq(AdminModule::getCode,adminModule.getCode())
|
|
|
|
+ .eq(AdminModule::getParentId,adminModule.getParentId())
|
|
.count();
|
|
.count();
|
|
if(count > 0){
|
|
if(count > 0){
|
|
throw new RemoteServiceException("code或者url重复");
|
|
throw new RemoteServiceException("code或者url重复");
|
|
}
|
|
}
|
|
-// adminModule.setUrl(adminModule.getUrl().replaceAll(" ",""));
|
|
|
|
-// if(adminModule.getUrl().indexOf("http:") > -1 || adminModule.getUrl().indexOf("https:") > -1){
|
|
|
|
-// adminModule.setType(4);
|
|
|
|
-// }else{
|
|
|
|
-// adminModule.setType(2);
|
|
|
|
-// }
|
|
|
|
adminModule.setLevel(level);
|
|
adminModule.setLevel(level);
|
|
adminModule.setCreateTime(new Date());
|
|
adminModule.setCreateTime(new Date());
|
|
- adminModule.setCurUrl(adminModule.getFullUrl());
|
|
|
|
adminModule.insert();
|
|
adminModule.insert();
|
|
|
|
+ //添加子集
|
|
|
|
+ if(CollectionUtils.isNotEmpty(adminModule.getChildList())){
|
|
|
|
+ for (AdminModule module : adminModule.getChildList()) {
|
|
|
|
+ module.setLevel(adminModule.getLevel() + 1);
|
|
|
|
+ module.setParentId(adminModule.getModuleId());
|
|
|
|
+ }
|
|
|
|
+ adminModuleService.saveBatch(adminModule.getChildList());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public void update(AdminModule adminModule){
|
|
public void update(AdminModule adminModule){
|
|
Integer level = 1;
|
|
Integer level = 1;
|
|
- if(!adminModule.getParentId().equals("0")){
|
|
|
|
|
|
+ if(adminModule.getParentId() != null && !adminModule.getParentId().equals("0")){
|
|
AdminModule parent = adminModuleService.getById(adminModule.getParentId());
|
|
AdminModule parent = adminModuleService.getById(adminModule.getParentId());
|
|
if(parent == null){
|
|
if(parent == null){
|
|
throw new RemoteServiceException("请选择正确的父级菜单");
|
|
throw new RemoteServiceException("请选择正确的父级菜单");
|
|
}
|
|
}
|
|
level = parent.getLevel() + 1;
|
|
level = parent.getLevel() + 1;
|
|
- //parent.setType(1);
|
|
|
|
- //parent.updateById();
|
|
|
|
}
|
|
}
|
|
Integer count = adminModuleService.lambdaQuery()
|
|
Integer count = adminModuleService.lambdaQuery()
|
|
- .and(v -> v.eq(AdminModule::getFullUrl, adminModule.getFullUrl()).or().eq(AdminModule::getCode, adminModule.getCode()))
|
|
|
|
.ne(AdminModule::getModuleId,adminModule.getModuleId())
|
|
.ne(AdminModule::getModuleId,adminModule.getModuleId())
|
|
|
|
+ .eq(AdminModule::getCode,adminModule.getCode())
|
|
|
|
+ .eq(AdminModule::getParentId,adminModule.getParentId())
|
|
.count();
|
|
.count();
|
|
if(count > 0){
|
|
if(count > 0){
|
|
throw new RemoteServiceException("code或者url重复");
|
|
throw new RemoteServiceException("code或者url重复");
|
|
}
|
|
}
|
|
- adminModule.setUrl(adminModule.getUrl().replaceAll(" ",""));
|
|
|
|
-// if(adminModule.getUrl().indexOf("http:") > -1 || adminModule.getUrl().indexOf("https:") > -1){
|
|
|
|
-// adminModule.setType(4);
|
|
|
|
-// }else{
|
|
|
|
-// //查询是否有子项
|
|
|
|
-// Integer count1 = adminModuleService.lambdaQuery()
|
|
|
|
-// .eq(AdminModule::getParentId, adminModule.getModuleId())
|
|
|
|
-// .ne(AdminModule::getType,3)
|
|
|
|
-// .count();
|
|
|
|
-// if(count1 > 0){
|
|
|
|
-// adminModule.setType(1);
|
|
|
|
-// }else {
|
|
|
|
-// adminModule.setType(2);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
- adminModule.setLevel(level);
|
|
|
|
|
|
+ if(adminModule.getType() != 3) {
|
|
|
|
+ adminModule.setLevel(level);
|
|
|
|
+ }
|
|
adminModule.updateById();
|
|
adminModule.updateById();
|
|
}
|
|
}
|
|
|
|
|