| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.common.domain.BusinessRes; |
| | | import com.vincent.rsf.server.common.exception.BusinessException; |
| | | import com.vincent.rsf.server.common.service.EmailService; |
| | | import com.vincent.rsf.server.system.controller.param.TenantInitParam; |
| | | import com.vincent.rsf.server.system.entity.*; |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Boolean initTenant(TenantInitParam param) { |
| | | public Long initTenant(TenantInitParam param) { |
| | | // valid ---------------------------- |
| | | if (null == param) { |
| | | return false; |
| | | return null; |
| | | } |
| | | if (Cools.isEmpty(param.getName(), param.getFlag(), param.getUsername(), param.getPassword())) { |
| | | return false; |
| | | return null; |
| | | } |
| | | |
| | | if (null != userService.getByUsername(param.getUsername(), null)) { |
| | | throw new CoolException("the username already exist"); |
| | | throw new BusinessException(BusinessRes.USERNAME_EXIST); |
| | | } |
| | | if (!Cools.isEmpty(param.getEmail())) { |
| | | if (!emailService.isValid(param.getEmail())) { |
| | |
| | | throw new CoolException("failed to create userRole"); |
| | | } |
| | | |
| | | // save roleMenu |
| | | // save roleMenu(HTTP 审计类菜单不默认下发,需在角色里显式勾选) |
| | | List<Menu> menuList = menuService.list(); |
| | | for (Menu menu : menuList) { |
| | | if ("httpAuditLog".equals(menu.getComponent()) || "httpAuditRule".equals(menu.getComponent())) { |
| | | continue; |
| | | } |
| | | RoleMenu roleMenu = new RoleMenu(); |
| | | roleMenu.setRoleId(role.getId()); |
| | | roleMenu.setMenuId(menu.getId()); |
| | |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | return tenant.getId(); |
| | | } |
| | | |
| | | } |