|
@@ -1,6 +1,8 @@
|
|
package cn.com.ty.lift.system.settings.service.impl;
|
|
package cn.com.ty.lift.system.settings.service.impl;
|
|
|
|
|
|
import cn.com.ty.lift.common.constants.ApiConstants;
|
|
import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
|
+import cn.com.ty.lift.common.constants.CommonEnum;
|
|
|
|
+import cn.com.ty.lift.common.constants.DefaultMenuConstants;
|
|
import cn.com.ty.lift.common.utils.PojoUtils;
|
|
import cn.com.ty.lift.common.utils.PojoUtils;
|
|
import cn.com.ty.lift.common.utils.ProjectUtils;
|
|
import cn.com.ty.lift.common.utils.ProjectUtils;
|
|
import cn.com.ty.lift.system.constants.CommonConstants;
|
|
import cn.com.ty.lift.system.constants.CommonConstants;
|
|
@@ -12,6 +14,7 @@ import cn.com.ty.lift.system.settings.dao.mapper.MtCompanyAttestationMapper;
|
|
import cn.com.ty.lift.system.settings.service.GlobalSetService;
|
|
import cn.com.ty.lift.system.settings.service.GlobalSetService;
|
|
import cn.com.ty.lift.system.settings.service.IMaintenanceCompanyService;
|
|
import cn.com.ty.lift.system.settings.service.IMaintenanceCompanyService;
|
|
import cn.com.ty.lift.system.settings.service.IMtCompanyAttestationService;
|
|
import cn.com.ty.lift.system.settings.service.IMtCompanyAttestationService;
|
|
|
|
+import cn.com.ty.lift.system.user.dao.entity.Role;
|
|
import cn.com.ty.lift.system.user.dao.entity.UserAccount;
|
|
import cn.com.ty.lift.system.user.dao.entity.UserAccount;
|
|
import cn.com.ty.lift.system.user.dao.entity.UserInfo;
|
|
import cn.com.ty.lift.system.user.dao.entity.UserInfo;
|
|
import cn.com.ty.lift.system.user.dao.entity.model.ApplyPageResponse;
|
|
import cn.com.ty.lift.system.user.dao.entity.model.ApplyPageResponse;
|
|
@@ -55,6 +58,9 @@ public class MtCompanyAttestationServiceImpl extends ServiceImpl<MtCompanyAttest
|
|
@Resource
|
|
@Resource
|
|
private IMenuService menuService;
|
|
private IMenuService menuService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private IRoleMenuService roleMenuService;
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private GlobalSetService globalSetService;
|
|
private GlobalSetService globalSetService;
|
|
|
|
|
|
@@ -124,19 +130,18 @@ public class MtCompanyAttestationServiceImpl extends ServiceImpl<MtCompanyAttest
|
|
if (!this.updateById(mtCompanyAttestation)) {
|
|
if (!this.updateById(mtCompanyAttestation)) {
|
|
return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
|
|
return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
|
|
}
|
|
}
|
|
- //4.给企业分配默认角色,并绑定角色默认菜单
|
|
|
|
- if (!roleService.saveDefaultMessage(companyId, companyAttestationRequest.getDefaultAssign(),
|
|
|
|
- companyAttestationRequest.getMenuIds())) {
|
|
|
|
|
|
+ //4.分配角色和菜单
|
|
|
|
+ RestResponse restResponse = assignRoleAndMenu(companyAttestationRequest, companyId);
|
|
|
|
+ if (restResponse != null) {
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
- return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
|
|
|
|
|
|
+ return restResponse;
|
|
}
|
|
}
|
|
- //5.保存给企业分配的菜单
|
|
|
|
- menuService.companyMenu(new MenuRequest(companyId, companyAttestationRequest.getMenuIds()));
|
|
|
|
- //6.生成企业设置数据
|
|
|
|
|
|
+ //5.生成企业设置数据
|
|
if (!globalSetService.teamInitSetting(companyId)) {
|
|
if (!globalSetService.teamInitSetting(companyId)) {
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
|
|
return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
|
|
}
|
|
}
|
|
|
|
+ //保存公司消息
|
|
if (!maintenanceCompanyService.updateById(maintenanceCompany)) {
|
|
if (!maintenanceCompanyService.updateById(maintenanceCompany)) {
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
|
|
return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
|
|
@@ -306,4 +311,52 @@ public class MtCompanyAttestationServiceImpl extends ServiceImpl<MtCompanyAttest
|
|
maintenanceCompany.setIsCertificated(auditResult);
|
|
maintenanceCompany.setIsCertificated(auditResult);
|
|
return maintenanceCompany;
|
|
return maintenanceCompany;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param companyAttestationRequest 请求信息
|
|
|
|
+ * @param companyId 公司id
|
|
|
|
+ * @description 分配菜单和角色
|
|
|
|
+ * @date 2020/4/26 10:57 上午
|
|
|
|
+ */
|
|
|
|
+ private RestResponse assignRoleAndMenu(CompanyAttestationRequest companyAttestationRequest, Long companyId) {
|
|
|
|
+ int defaultAssign = companyAttestationRequest.getDefaultAssign();
|
|
|
|
+ //1.分配默认角色
|
|
|
|
+ List<Role> defaultRoleList = new ArrayList<>();
|
|
|
|
+ for (CommonEnum.DefaultRole defaultRole : DefaultMenuConstants.DEFAULT_ROLE) {
|
|
|
|
+ Role newRole = new Role(defaultRole);
|
|
|
|
+ newRole.setCompanyId(companyId);
|
|
|
|
+ newRole.setDescription(defaultRole.getLabel());
|
|
|
|
+ defaultRoleList.add(newRole);
|
|
|
|
+ }
|
|
|
|
+ if (!roleService.saveBatch(defaultRoleList)) {
|
|
|
|
+ return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败-分配默认角色失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //2.给企业分配菜单
|
|
|
|
+ String menuIds = companyAttestationRequest.getMenuIds();
|
|
|
|
+ if (0 == defaultAssign) {
|
|
|
|
+ menuIds = ProjectUtils.arrayToStrByComma(DefaultMenuConstants.ENTERPRISE_MENUIDS);
|
|
|
|
+ }
|
|
|
|
+ RestResponse restResponse = menuService.companyMenu(new MenuRequest(companyId, menuIds));
|
|
|
|
+ if (restResponse != null) {
|
|
|
|
+ return restResponse;
|
|
|
|
+ }
|
|
|
|
+ //3.设置企业管理员菜单
|
|
|
|
+ //获取当前企业的企业管理员
|
|
|
|
+ Role enterpriseAdminRole = roleService.getOne(new QueryWrapper<Role>()
|
|
|
|
+ .eq("company_id", companyId)
|
|
|
|
+ .eq("code", CommonEnum.DefaultRole.ENTERPRISE_ADMIN.getCode()));
|
|
|
|
+ if (enterpriseAdminRole == null) {
|
|
|
|
+ return RestResponse.fail(ApiConstants.RESULT_ERROR, "企业管理员不存在,无法通过审核");
|
|
|
|
+ }
|
|
|
|
+ long[] enterpriseMenuIds = ProjectUtils.getLongIdArrayFromIds(menuIds);
|
|
|
|
+ DefaultMenuConstants.DEFAULT_ROLE_MENUIDS.put(CommonEnum.DefaultRole.ENTERPRISE_ADMIN.getCode(),
|
|
|
|
+ enterpriseMenuIds);
|
|
|
|
+ //4.角色菜单分配
|
|
|
|
+ if(!roleService.assignDefaultMenu(defaultAssign, defaultRoleList, enterpriseAdminRole)){
|
|
|
|
+ return RestResponse.fail(ApiConstants.RESULT_ERROR, "分配默认角色菜单失败");
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|