| | |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.param.AddClientPrarm; |
| | | import com.sandu.ximon.admin.param.PwdParam; |
| | | import com.sandu.ximon.admin.param.UpdateClientPrarm; |
| | | import com.sandu.ximon.admin.param.UserPwsParm; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils; |
| | | import com.sandu.ximon.dao.bo.MenuNode; |
| | | import com.sandu.ximon.dao.domain.Client; |
| | | import com.sandu.ximon.dao.domain.ClientRoleRelation; |
| | | import com.sandu.ximon.dao.domain.Role; |
| | | import com.sandu.ximon.dao.domain.RoleMenuRelation; |
| | | import com.sandu.ximon.dao.mapper.ClientMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | |
| | | if (role == null) { |
| | | throw new BusinessException("角色不存在"); |
| | | } |
| | | if (!RoleLevelStatus.NORMAL.getCode().equals(role.getLevel())) { |
| | | throw new BusinessException("无法添加超级管理员或用户管理员"); |
| | | if (RoleLevelStatus.SUPER.getCode().equals(role.getLevel())) { |
| | | throw new BusinessException("无法添加超级管理员"); |
| | | } |
| | | |
| | | |
| | |
| | | if (!clientRoleRelationService.save(clientRoleRelation)) { |
| | | throw new BusinessException("添加管理员角色失败"); |
| | | } |
| | | |
| | | /** |
| | | * 添加普通用户 日志记录开始 |
| | | */ |
| | | String content = "新注册用户:" + addClientPrarm.getClientName(); |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "添加普通用户", content); |
| | | /** |
| | | * 添加普通用户 日志记录结束 |
| | | */ |
| | | |
| | | return flag; |
| | | } |
| | |
| | | client.setLinkMan(updateClientPrarm.getLinkMan()); |
| | | client.setMobile(updateClientPrarm.getMobile()); |
| | | |
| | | /** |
| | | * 编辑普通用户 日志记录开始 |
| | | */ |
| | | String content = "编辑普通用户:" + client.getClientName() + "用户id:" + id; |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "编辑普通用户", content); |
| | | /** |
| | | * 编辑普通用户 日志记录结束 |
| | | */ |
| | | return updateById(client); |
| | | } |
| | | |
| | |
| | | if (list != null && list.size() != 0) { |
| | | throw new BusinessException("删除的用户下有下级用户,不允许删除"); |
| | | } |
| | | /** |
| | | * 删除普通用户 日志记录开始 |
| | | */ |
| | | String content = "删除普通用户:" + one.getClientName() + "用户id:" + id; |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "删除普通用户", content); |
| | | /** |
| | | * 删除普通用户 日志记录结束 |
| | | */ |
| | | |
| | | return removeById(id); |
| | | } |
| | |
| | | one.setIcon(IconUrl); |
| | | return updateById(one); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户权限列表地 |
| | | */ |
| | | public List<MenuNode> getUserPermissionList() { |
| | | //通过用户UserID获取用户角色 |
| | | ClientRoleRelation one = SpringContextHolder.getBean(ClientRoleRelationService.class). |
| | | getOne(Wrappers.lambdaQuery(ClientRoleRelation.class).eq(ClientRoleRelation::getClientId, SecurityUtils.getUserId())); |
| | | //判空 |
| | | if (one == null) { |
| | | throw new BusinessException("该用户未绑定角色"); |
| | | } |
| | | |
| | | //通过RoleID获取MeunId列表 |
| | | List<RoleMenuRelation> menuIdList = SpringContextHolder.getBean(RoleMenuRelationService.class) |
| | | .list(Wrappers.lambdaQuery(RoleMenuRelation.class).eq(RoleMenuRelation::getRoleId, one.getRoleId())); |
| | | |
| | | //判空 |
| | | if (menuIdList.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | List<Long> menuIds = new ArrayList<>(menuIdList.size()); |
| | | for (RoleMenuRelation bean : menuIdList) { |
| | | menuIds.add(bean.getMenuId()); |
| | | } |
| | | |
| | | List<MenuNode> resultList = SpringContextHolder.getBean(MenuService.class).getUserPermissionListById(menuIds); |
| | | return resultList; |
| | | } |
| | | } |