first commit
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
package com.mhd.user.domain.roleAggregate.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@TableName("custom_auth_role")
|
||||
@Data
|
||||
public class CustomAuthRoleEntity extends BaseVOEntity implements Serializable {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "用户自定义权限表id")
|
||||
private Long customAuthRoleId;
|
||||
@ApiModelProperty(name = "角色id")
|
||||
private Long roleId;
|
||||
@ApiModelProperty(name = "菜单id")
|
||||
private Long menuId;
|
||||
@ApiModelProperty(name = "表格json")
|
||||
private String tableJson;
|
||||
@ApiModelProperty(name = "表单json")
|
||||
private String formJson;
|
||||
@ApiModelProperty(name = "按钮json")
|
||||
private String buttonJson;
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.mhd.user.domain.roleAggregate.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@TableName("custom_auth_user")
|
||||
@Data
|
||||
public class CustomAuthUserEntity extends BaseVOEntity implements Serializable {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "角色自定义权限表id")
|
||||
private Long customAuthUserId;
|
||||
@ApiModelProperty(name = "用户id")
|
||||
private Long userId;
|
||||
@ApiModelProperty(name = "菜单id")
|
||||
private Long menuId;
|
||||
@ApiModelProperty(name = "表格json")
|
||||
private String tableJson;
|
||||
@ApiModelProperty(name = "表单json")
|
||||
private String formJson;
|
||||
@ApiModelProperty(name = "按钮json")
|
||||
private String buttonJson;
|
||||
}
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.mhd.user.domain.roleAggregate.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("role")
|
||||
public class RoleEntity extends BaseVOEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty(name = "角色表ID")
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long roleId;
|
||||
@ApiModelProperty(name = "上级角色ID(预留字段)")
|
||||
private Long parentRoleId;
|
||||
@ApiModelProperty(name = "角色业务场景数据字典ID")
|
||||
private Long roleBusinessExampleId;
|
||||
@ApiModelProperty(name = "角色业务场景名称")
|
||||
private String roleBusinessExampleName;
|
||||
@ApiModelProperty(name = "角色分类:0-无状态,1-托运人,2-承运人")
|
||||
private Integer roleType;
|
||||
@ApiModelProperty(name = "组织表ID")
|
||||
private Long organizationId;
|
||||
@ApiModelProperty(name = "职务/角色权限字符,控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)")
|
||||
private String roleCode;
|
||||
@ApiModelProperty(name = "职务/角色名称")
|
||||
private String roleName;
|
||||
@ApiModelProperty(name = "职务/角色描述")
|
||||
private String roleRemark;
|
||||
@ApiModelProperty(name = "数据权限范围:0-无状态,1-全公司,2-本部门,3-本部门及以下,4-自定义权限")
|
||||
private Integer roleDataScope;
|
||||
@ApiModelProperty(name = "职务/角色状态:0-无状态,1-开启,2-关闭")
|
||||
private Integer roleStatus;
|
||||
@ApiModelProperty(name = "角色等级:0-无状态,1-内置角色,2-组织角色,3-货主自建角色")
|
||||
private Integer roleGrade;
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.mhd.user.domain.roleAggregate.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
@TableName("role_menu")
|
||||
public class RoleMenuEntity extends BaseVOEntity {
|
||||
|
||||
@ApiModelProperty(name = "职务/角色权限表ID")
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long roleMenuId;
|
||||
@ApiModelProperty(name = "职务/角色表ID")
|
||||
private Long roleId;
|
||||
@ApiModelProperty(name = "权限表ID")
|
||||
private Long menuId;
|
||||
@ApiModelProperty(name = "组织id")
|
||||
private Long organizationId;
|
||||
|
||||
@ApiModelProperty(name = "角色权限客户端:0-无状态,1-PC端,2-手机端")
|
||||
private Integer roleMenuClient;
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.mhd.user.domain.roleAggregate.factory;
|
||||
|
||||
import com.mhd.user.domain.roleAggregate.entity.CustomAuthRoleEntity;
|
||||
import com.mhd.user.domain.roleAggregate.entity.CustomAuthUserEntity;
|
||||
import com.mhd.user.domain.roleAggregate.entity.RoleEntity;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.CustomAuthDO;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.RoleDo;
|
||||
import com.mhd.common.core.utils.IgnoreNullUtil;
|
||||
import com.mhd.common.core.utils.bean.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class RoleFactory {
|
||||
|
||||
public RoleEntity getRoleEntity(RoleDo roleDo) {
|
||||
RoleEntity roleEntity = new RoleEntity();
|
||||
BeanUtils.copyProperties(roleDo, roleEntity, IgnoreNullUtil.getNullPropertyNames(roleDo));
|
||||
return roleEntity;
|
||||
}
|
||||
public CustomAuthRoleEntity getCustomAuthRoleEntity(CustomAuthDO customAuthDO) {
|
||||
CustomAuthRoleEntity customAuthRoleEntity = new CustomAuthRoleEntity();
|
||||
BeanUtils.copyProperties(customAuthDO, customAuthRoleEntity, IgnoreNullUtil.getNullPropertyNames(customAuthDO));
|
||||
return customAuthRoleEntity;
|
||||
}
|
||||
|
||||
|
||||
public CustomAuthUserEntity getCustomAuthUserEntity(CustomAuthDO customAuthDO) {
|
||||
CustomAuthUserEntity customAuthUserEntity = new CustomAuthUserEntity();
|
||||
BeanUtils.copyProperties(customAuthDO, customAuthUserEntity, IgnoreNullUtil.getNullPropertyNames(customAuthDO));
|
||||
return customAuthUserEntity;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.mhd.user.domain.roleAggregate.factory;
|
||||
|
||||
import com.mhd.user.domain.roleAggregate.entity.RoleMenuEntity;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.RoleMenuDo;
|
||||
import com.mhd.common.core.utils.IgnoreNullUtil;
|
||||
import com.mhd.common.core.utils.bean.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class RoleMenuFactory {
|
||||
|
||||
public RoleMenuEntity getRoleMenuEntity(RoleMenuDo roleMenuDo) {
|
||||
RoleMenuEntity roleMenuEntity = new RoleMenuEntity();
|
||||
BeanUtils.copyProperties(roleMenuDo, roleMenuEntity, IgnoreNullUtil.getNullPropertyNames(roleMenuDo));
|
||||
return roleMenuEntity;
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.facade;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mhd.user.domain.roleAggregate.entity.CustomAuthRoleEntity;
|
||||
import com.mhd.user.domain.roleAggregate.repository.po.CustomAuthRoleOrUserPO;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.CustomAuthDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CustomAuthRoleRepositoryInterface extends IService<CustomAuthRoleEntity> {
|
||||
|
||||
List<CustomAuthRoleOrUserPO> getCustomAuthByRoleOrUserId(CustomAuthDO customAuthDO);
|
||||
|
||||
CustomAuthRoleOrUserPO getCustomAuthMenuByRoleOrUserId(CustomAuthDO customAuthDO);
|
||||
|
||||
int insertCustomAuthRole(CustomAuthRoleEntity customAuthRoleEntity);
|
||||
|
||||
void deleteCustomAuthRoleByRoleId(CustomAuthDO customAuthDO);
|
||||
|
||||
List<CustomAuthRoleEntity> selectByRoleIdList(List<Long> codeList);
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.facade;
|
||||
|
||||
import com.mhd.user.domain.roleAggregate.entity.CustomAuthUserEntity;
|
||||
import com.mhd.user.domain.roleAggregate.repository.po.CustomAuthRoleOrUserPO;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.CustomAuthDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CustomAuthUserRepositoryInterface {
|
||||
|
||||
List<CustomAuthRoleOrUserPO> getCustomAuthByRoleOrUserId(CustomAuthDO customAuthDO);
|
||||
List<CustomAuthRoleOrUserPO> getCustomAuthByRole(CustomAuthDO customAuthDO);
|
||||
|
||||
int insertCustomAuthUser(CustomAuthUserEntity customAuthUserEntity);
|
||||
|
||||
void deleteCustomAuthUserByUserId(CustomAuthDO customAuthDO);
|
||||
|
||||
CustomAuthRoleOrUserPO getCustomAuthMenuByRoleOrUserId(CustomAuthDO customAuthDO);
|
||||
|
||||
CustomAuthRoleOrUserPO getCustomAuthByRoleId(CustomAuthDO customAuthDO);
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.facade;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mhd.user.domain.roleAggregate.entity.RoleMenuEntity;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.RoleMenuDo;
|
||||
import com.mhd.common.core.domain.po.UserRoleMenuPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RoleMenuRepositoryInterface extends IService<RoleMenuEntity> {
|
||||
|
||||
int addRoleMenu(RoleMenuEntity roleMenuEntity);
|
||||
|
||||
int updateRoleMenu(RoleMenuEntity roleMenuEntity);
|
||||
|
||||
void removeByRoleId(RoleMenuDo roleMenuDo);
|
||||
|
||||
List<RoleMenuEntity> selectList(RoleMenuDo roleMenuDo);
|
||||
|
||||
List<UserRoleMenuPO> selectRoleMenuList(RoleMenuDo roleMenuDo);
|
||||
|
||||
RoleMenuEntity findByRoleMenuId(RoleMenuDo roleMenuDo);
|
||||
|
||||
List<RoleMenuEntity> selectByRoleList(List<Long> roleList);
|
||||
}
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.facade;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mhd.user.domain.roleAggregate.entity.RoleEntity;
|
||||
import com.mhd.common.core.domain.po.RolePO;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.RoleDo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RoleRepositoryInterface extends IService<RoleEntity> {
|
||||
|
||||
int addRole(RoleEntity roleEntity);
|
||||
|
||||
void saveBatchList(List<RoleEntity> list);
|
||||
|
||||
int updateRole(RoleEntity roleEntity);
|
||||
|
||||
RoleEntity selectByOrganizationIdAndRoleCode(RoleDo roleDo);
|
||||
|
||||
List<RolePO> selecRolePoList(RoleDo roleDo);
|
||||
|
||||
RolePO findDelByRoleId(Long roleId);
|
||||
|
||||
RolePO findByRoleId(Long roleId);
|
||||
|
||||
RolePO selectByRoleCodeAndOrganizationId(String roleCode, Long organizationId);
|
||||
|
||||
|
||||
RolePO selectRoleByOrganizationAndCode(RoleDo roleDo);
|
||||
|
||||
void deleteByOrganizationId(Long organizationId);
|
||||
|
||||
String findRoleNameByRoleIds(List<Long> roleIds);
|
||||
|
||||
List<RoleEntity> selectByRoleIds(List<Long> roleIds);
|
||||
|
||||
List<RoleEntity> queryList(RoleDo roleDo);
|
||||
|
||||
List<RoleEntity> selectByCodesAndOrganizationIds(List<String> delCodes, List<Long> longs);
|
||||
|
||||
List<RoleEntity> selectByOrganizations(String roleCode , List<Long> organizationIds);
|
||||
|
||||
List<RolePO> getRoleListByUserId(Long userId);
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhd.user.domain.roleAggregate.entity.CustomAuthRoleEntity;
|
||||
import com.mhd.user.domain.roleAggregate.repository.po.CustomAuthRoleOrUserPO;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.CustomAuthDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CustomAuthRoleMapper extends BaseMapper<CustomAuthRoleEntity>{
|
||||
|
||||
List<CustomAuthRoleOrUserPO> getCustomAuthByRoleOrUserId(CustomAuthDO customAuthDO);
|
||||
|
||||
CustomAuthRoleOrUserPO getCustomAuthMenuByRoleOrUserId(CustomAuthDO customAuthDO);
|
||||
|
||||
void deleteCustomAuthRoleByRoleId(CustomAuthDO customAuthDO);
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhd.user.domain.roleAggregate.entity.CustomAuthUserEntity;
|
||||
import com.mhd.user.domain.roleAggregate.repository.po.CustomAuthRoleOrUserPO;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.CustomAuthDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CustomAuthUserMapper extends BaseMapper<CustomAuthUserEntity> {
|
||||
|
||||
List<CustomAuthRoleOrUserPO> getCustomAuthByRoleOrUserId(CustomAuthDO customAuthDO);
|
||||
@Select("SELECT * FROM `custom_auth_role` WHERE role_id IN (SELECT role_id FROM user_role WHERE user_id = #{userId})")
|
||||
List<CustomAuthRoleOrUserPO> getCustomAuthByRole(@Param("userId") Long userId);
|
||||
|
||||
void deleteCustomAuthUserByUserId(CustomAuthDO customAuthDO);
|
||||
|
||||
CustomAuthRoleOrUserPO getCustomAuthMenuByRoleOrUserId(CustomAuthDO customAuthDO);
|
||||
|
||||
CustomAuthRoleOrUserPO getCustomAuthByRoleId(CustomAuthDO customAuthDO);
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhd.user.domain.roleAggregate.entity.RoleEntity;
|
||||
import com.mhd.common.core.domain.po.RolePO;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.RoleDo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RoleMapper extends BaseMapper<RoleEntity> {
|
||||
|
||||
List<RolePO> queryList(RoleDo roleDo);
|
||||
|
||||
RoleEntity selectByOrganizationIdAndRoleCode(RoleDo roleDo);
|
||||
|
||||
RolePO findDelByRoleId(Long roleId);
|
||||
|
||||
RolePO selectByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* @description 根据角色code加组织id查询角色
|
||||
* @author ZhouGY
|
||||
* @date 2023/10/10 11:18
|
||||
* @param roleCode
|
||||
* @param organizationId
|
||||
* @return RolePO
|
||||
*/
|
||||
RolePO selectByRoleCodeAndOrganizationId(@Param("roleCode") String roleCode, @Param("organizationId") Long organizationId);
|
||||
|
||||
void deleteByOrganizationId(Long organizationId);
|
||||
|
||||
RolePO selectRoleByOrganizationAndCode(RoleDo roleDo);
|
||||
|
||||
String findRoleNameByRoleIds(List<Long> roleIds);
|
||||
|
||||
RolePO selectByRoleCode(RoleDo query);
|
||||
|
||||
List<RolePO> getRoleListByUserId(@Param("userId") Long userId);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhd.user.domain.roleAggregate.entity.RoleMenuEntity;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.RoleMenuDo;
|
||||
import com.mhd.common.core.domain.po.UserRoleMenuPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RoleMenuMapper extends BaseMapper<RoleMenuEntity> {
|
||||
|
||||
List<RoleMenuEntity> queryList(RoleMenuDo roleMenuDo);
|
||||
|
||||
List<UserRoleMenuPO> selectRoleMenuList(RoleMenuDo roleMenuDo);
|
||||
|
||||
void removeByRoleId(RoleMenuDo roleMenuDo);
|
||||
|
||||
RoleMenuEntity selectByRoleMenuId(RoleMenuDo roleMenuDo);
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.persistence;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mhd.user.domain.roleAggregate.entity.CustomAuthRoleEntity;
|
||||
import com.mhd.user.domain.roleAggregate.repository.facade.CustomAuthRoleRepositoryInterface;
|
||||
import com.mhd.user.domain.roleAggregate.repository.mapper.CustomAuthRoleMapper;
|
||||
import com.mhd.user.domain.roleAggregate.repository.po.CustomAuthRoleOrUserPO;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.CustomAuthDO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class CustomAuthRoleRepositoryImpl extends ServiceImpl<CustomAuthRoleMapper, CustomAuthRoleEntity> implements CustomAuthRoleRepositoryInterface {
|
||||
|
||||
@Resource
|
||||
private CustomAuthRoleMapper customAuthRoleMapper;
|
||||
|
||||
@Override
|
||||
public List<CustomAuthRoleOrUserPO> getCustomAuthByRoleOrUserId(CustomAuthDO customAuthDO) {
|
||||
return customAuthRoleMapper.getCustomAuthByRoleOrUserId(customAuthDO);
|
||||
}
|
||||
@Override
|
||||
public CustomAuthRoleOrUserPO getCustomAuthMenuByRoleOrUserId(CustomAuthDO customAuthDO) {
|
||||
return customAuthRoleMapper.getCustomAuthMenuByRoleOrUserId(customAuthDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertCustomAuthRole(CustomAuthRoleEntity customAuthRoleEntity) {
|
||||
return customAuthRoleMapper.insert(customAuthRoleEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCustomAuthRoleByRoleId(CustomAuthDO customAuthDO) {
|
||||
customAuthRoleMapper.deleteCustomAuthRoleByRoleId(customAuthDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomAuthRoleEntity> selectByRoleIdList(List<Long> codeList) {
|
||||
return customAuthRoleMapper.selectList(new LambdaQueryWrapper<CustomAuthRoleEntity>().eq(CustomAuthRoleEntity::getDelFlag, 1)
|
||||
.in(CustomAuthRoleEntity::getRoleId, codeList));
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.persistence;
|
||||
|
||||
import com.mhd.user.domain.roleAggregate.entity.CustomAuthUserEntity;
|
||||
import com.mhd.user.domain.roleAggregate.repository.facade.CustomAuthUserRepositoryInterface;
|
||||
import com.mhd.user.domain.roleAggregate.repository.mapper.CustomAuthUserMapper;
|
||||
import com.mhd.user.domain.roleAggregate.repository.po.CustomAuthRoleOrUserPO;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.CustomAuthDO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CustomAuthUserRepositoryImpl implements CustomAuthUserRepositoryInterface {
|
||||
|
||||
@Resource
|
||||
private CustomAuthUserMapper customAuthUserMapper;
|
||||
|
||||
@Override
|
||||
public List<CustomAuthRoleOrUserPO> getCustomAuthByRoleOrUserId(CustomAuthDO customAuthDO) {
|
||||
return customAuthUserMapper.getCustomAuthByRoleOrUserId(customAuthDO);
|
||||
}
|
||||
@Override
|
||||
public List<CustomAuthRoleOrUserPO> getCustomAuthByRole(CustomAuthDO customAuthDO) {
|
||||
return customAuthUserMapper.getCustomAuthByRole(customAuthDO.getUserId());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int insertCustomAuthUser(CustomAuthUserEntity customAuthUserEntity) {
|
||||
return customAuthUserMapper.insert(customAuthUserEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCustomAuthUserByUserId(CustomAuthDO customAuthDO) {
|
||||
customAuthUserMapper.deleteCustomAuthUserByUserId(customAuthDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomAuthRoleOrUserPO getCustomAuthMenuByRoleOrUserId(CustomAuthDO customAuthDO) {
|
||||
return customAuthUserMapper.getCustomAuthMenuByRoleOrUserId(customAuthDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomAuthRoleOrUserPO getCustomAuthByRoleId(CustomAuthDO customAuthDO) {
|
||||
return customAuthUserMapper.getCustomAuthByRoleId(customAuthDO);
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.persistence;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mhd.user.domain.roleAggregate.repository.facade.RoleMenuRepositoryInterface;
|
||||
import com.mhd.user.domain.roleAggregate.repository.mapper.RoleMenuMapper;
|
||||
import com.mhd.user.domain.roleAggregate.entity.RoleMenuEntity;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.RoleMenuDo;
|
||||
import com.mhd.common.core.domain.po.UserRoleMenuPO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RoleMenuRepositoryImpl extends ServiceImpl<RoleMenuMapper,RoleMenuEntity> implements RoleMenuRepositoryInterface {
|
||||
|
||||
@Resource
|
||||
private RoleMenuMapper roleMenuMapper;
|
||||
|
||||
@Override
|
||||
public int addRoleMenu(RoleMenuEntity roleMenuEntity) {
|
||||
return roleMenuMapper.insert(roleMenuEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateRoleMenu(RoleMenuEntity RoleMenuEntity) {
|
||||
return roleMenuMapper.updateById(RoleMenuEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeByRoleId(RoleMenuDo roleMenuDo) {
|
||||
roleMenuMapper.removeByRoleId(roleMenuDo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleMenuEntity> selectList(RoleMenuDo roleMenuDo) {
|
||||
return roleMenuMapper.queryList(roleMenuDo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRoleMenuPO> selectRoleMenuList(RoleMenuDo roleMenuDo) {
|
||||
return roleMenuMapper.selectRoleMenuList(roleMenuDo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleMenuEntity findByRoleMenuId(RoleMenuDo roleMenuDo) {
|
||||
return roleMenuMapper.selectByRoleMenuId(roleMenuDo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleMenuEntity> selectByRoleList(List<Long> roleList) {
|
||||
return roleMenuMapper.selectList(new LambdaQueryWrapper<RoleMenuEntity>().in(RoleMenuEntity::getRoleId , roleList));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.persistence;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mhd.user.domain.roleAggregate.entity.RoleEntity;
|
||||
import com.mhd.user.domain.roleAggregate.repository.facade.RoleRepositoryInterface;
|
||||
import com.mhd.user.domain.roleAggregate.repository.mapper.RoleMapper;
|
||||
import com.mhd.common.core.domain.po.RolePO;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.RoleDo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RoleRepositoryImpl extends ServiceImpl<RoleMapper,RoleEntity> implements RoleRepositoryInterface {
|
||||
|
||||
@Resource
|
||||
private RoleMapper roleMapper;
|
||||
|
||||
@Override
|
||||
public int addRole(RoleEntity roleEntity) {
|
||||
return roleMapper.insert(roleEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveBatchList(List<RoleEntity> list) {
|
||||
this.saveBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateRole(RoleEntity roleEntity) {
|
||||
return roleMapper.updateById(roleEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleEntity selectByOrganizationIdAndRoleCode(RoleDo roleDo) {
|
||||
RoleEntity roleEntity = roleMapper.selectByOrganizationIdAndRoleCode(roleDo);
|
||||
return roleEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByOrganizationId(Long organizationId) {
|
||||
roleMapper.deleteByOrganizationId(organizationId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Author Alex
|
||||
* @Date 2022/12/9 01:21
|
||||
*/
|
||||
@Override
|
||||
public List<RolePO> selecRolePoList(RoleDo roleDo) {
|
||||
List<RolePO> rolePoList = roleMapper.queryList(roleDo);
|
||||
return rolePoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 根据角色ID查询历史角色信息,可查询出已逻辑删除角色信息
|
||||
* @Author Alex
|
||||
* @Date 2023/1/9 23:02
|
||||
*/
|
||||
@Override
|
||||
public RolePO findDelByRoleId(Long roleId) {
|
||||
return roleMapper.findDelByRoleId(roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RolePO findByRoleId(Long roleId) {
|
||||
return roleMapper.selectByRoleId(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据角色code加组织id查询角色
|
||||
* @author ZhouGY
|
||||
* @date 2023/10/10 11:18
|
||||
* @param roleCode
|
||||
* @param organizationId
|
||||
* @return RolePO
|
||||
*/
|
||||
@Override
|
||||
public RolePO selectByRoleCodeAndOrganizationId(String roleCode, Long organizationId) {
|
||||
return roleMapper.selectByRoleCodeAndOrganizationId(roleCode, organizationId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 根据组织ID和角色编码查询角色ID
|
||||
* @Author Alex
|
||||
* @Date 2022/12/7 00:46
|
||||
*/
|
||||
@Override
|
||||
public RolePO selectRoleByOrganizationAndCode(RoleDo roleDo) {
|
||||
return roleMapper.selectRoleByOrganizationAndCode(roleDo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 根据角色IDs获取角色名称
|
||||
* @Author Alex
|
||||
* @Date 2022/12/20 17:27
|
||||
*/
|
||||
@Override
|
||||
public String findRoleNameByRoleIds(List<Long> roleIds) {
|
||||
return roleMapper.findRoleNameByRoleIds(roleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> selectByRoleIds(List<Long> roleIds) {
|
||||
List<RoleEntity> roleEntities = roleMapper.selectBatchIds(roleIds);
|
||||
return roleEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> queryList(RoleDo roleDo) {
|
||||
QueryWrapper<RoleEntity> qw = new QueryWrapper<>();
|
||||
if (roleDo.getOrganizationId() != null){
|
||||
qw.eq("organization_id" ,roleDo.getOrganizationId());
|
||||
}
|
||||
if (roleDo.getRoleGrade() != null){
|
||||
qw.eq("role_grade" ,roleDo.getRoleGrade());
|
||||
}
|
||||
if (roleDo.getDelFlag() != null){
|
||||
qw.eq("del_flag" ,roleDo.getDelFlag());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(roleDo.getRoleCodes())){
|
||||
qw.in("role_code",roleDo.getRoleCodes());
|
||||
}
|
||||
return roleMapper.selectList(qw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> selectByCodesAndOrganizationIds(List<String> delCodes, List<Long> longs) {
|
||||
|
||||
return roleMapper.selectList(new LambdaQueryWrapper<RoleEntity>()
|
||||
.in(RoleEntity::getRoleCode ,delCodes)
|
||||
.in(RoleEntity::getOrganizationId ,longs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleEntity> selectByOrganizations(String roleCode , List<Long> organizationIds) {
|
||||
return roleMapper.selectList(new LambdaQueryWrapper<RoleEntity>()
|
||||
.in(RoleEntity::getOrganizationId ,organizationIds)
|
||||
.eq(RoleEntity::getRoleCode , roleCode));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RolePO> getRoleListByUserId(Long userId) {
|
||||
return roleMapper.getRoleListByUserId(userId);
|
||||
}
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.po;
|
||||
|
||||
import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class CustomAuthRoleOrUserPO extends BaseVOEntity implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "角色自定义id")
|
||||
private Long customAuthRoleId = 0L;
|
||||
@ApiModelProperty(name = "用户自定义id")
|
||||
private Long customAuthUserId = 0L;
|
||||
@ApiModelProperty(name = "菜单id")
|
||||
private Long menuId = 0L;
|
||||
@ApiModelProperty(name = "表格json")
|
||||
private String tableJson = "";
|
||||
@ApiModelProperty(name = "表单json")
|
||||
private String formJson = "";
|
||||
@ApiModelProperty(name = "按钮json")
|
||||
private String buttonJson = "";
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.todo;
|
||||
|
||||
import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class CustomAuthDO extends BaseVOEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty(name = "菜单表ID")
|
||||
private Long menuId;
|
||||
@ApiModelProperty(name = "角色表ID")
|
||||
private Long roleId;
|
||||
@ApiModelProperty(name = "用户表ID")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(name = "表格json")
|
||||
private String tableJson;
|
||||
@ApiModelProperty(name = "表单json")
|
||||
private String formJson;
|
||||
@ApiModelProperty(name = "按钮json")
|
||||
private String buttonJson;
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.todo;
|
||||
|
||||
import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class CustomAuthRoleDO extends BaseVOEntity implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "角色自定义权限表id")
|
||||
private Long customAuthRoleId;
|
||||
@ApiModelProperty(name = "角色id")
|
||||
private Long roleId;
|
||||
@ApiModelProperty(name = "菜单id")
|
||||
private Long menuId;
|
||||
@ApiModelProperty(name = "表格json")
|
||||
private String tableJson;
|
||||
@ApiModelProperty(name = "表单json")
|
||||
private String formJson;
|
||||
@ApiModelProperty(name = "按钮json")
|
||||
private String buttonJson;
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.todo;
|
||||
|
||||
import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class CustomAuthUserDO extends BaseVOEntity implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "用户自定义权限表id")
|
||||
private Long customAuthUserId;
|
||||
@ApiModelProperty(name = "用户id")
|
||||
private Long userId;
|
||||
@ApiModelProperty(name = "菜单id")
|
||||
private Long menuId;
|
||||
@ApiModelProperty(name = "表格json")
|
||||
private String tableJson;
|
||||
@ApiModelProperty(name = "表单json")
|
||||
private String formJson;
|
||||
@ApiModelProperty(name = "按钮json")
|
||||
private String buttonJson;
|
||||
}
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.todo;
|
||||
|
||||
import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class RoleDo extends BaseVOEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty(name = "角色表ID")
|
||||
private Long roleId;
|
||||
@ApiModelProperty(name = "上级角色ID(预留字段)")
|
||||
private Long parentRoleId;
|
||||
@ApiModelProperty(name = "组织表ID")
|
||||
private Long organizationId;
|
||||
@ApiModelProperty(name = "角色业务场景数据字典ID")
|
||||
private Long roleBusinessExampleId;
|
||||
@ApiModelProperty(name = "角色业务场景名称")
|
||||
private String roleBusinessExampleName;
|
||||
@ApiModelProperty(name = "角色分类:0-无状态,1-托运人,2-承运人")
|
||||
private Integer roleType;
|
||||
@ApiModelProperty(name = "角色分类名称")
|
||||
private String roleTypeName;
|
||||
@ApiModelProperty(name = "职务/角色权限字符,控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)")
|
||||
private String roleCode;
|
||||
@ApiModelProperty(name = "职务/角色名称")
|
||||
private String roleName;
|
||||
@ApiModelProperty(name = "职务/角色描述")
|
||||
private String roleRemark;
|
||||
@ApiModelProperty(name = "数据权限范围:0-无状态,1-全公司,2-本部门,3-本部门及以下,4-自定义权限")
|
||||
private Integer roleDataScope;
|
||||
@ApiModelProperty(name = "职务/角色状态:0-无状态,1-开启,2-关闭")
|
||||
private Integer roleStatus;
|
||||
@ApiModelProperty(name = "职务/角色表ID集合")
|
||||
private List<Long> roleIds;
|
||||
@ApiModelProperty(name = "职务/角色表code集合")
|
||||
private List<String> roleCodes;
|
||||
private List<String> roleCodeList;
|
||||
@ApiModelProperty(name = "组织表ID集合")
|
||||
private List<Long> organizationIds;
|
||||
|
||||
@ApiModelProperty(name = "角色等级:0-无状态,1-内置角色,2-组织角色,3-货主自建角色")
|
||||
private Integer roleGrade;
|
||||
|
||||
@ApiModelProperty(name = "菜单表ID")
|
||||
public Long permissionMenuId;
|
||||
@ApiModelProperty(name = "组织表ID集合")
|
||||
public List<Long> permissionOrganizationIds = null;
|
||||
@ApiModelProperty("原角色id(用来复制之前的菜单使用)")
|
||||
private Long copyRoleId;
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.mhd.user.domain.roleAggregate.repository.todo;
|
||||
|
||||
import com.mhd.common.core.domain.po.MenuVo;
|
||||
import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class RoleMenuDo extends BaseVOEntity implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "职务/角色权限表ID")
|
||||
private Long roleMenuId;
|
||||
@ApiModelProperty(name = "职务/角色表ID")
|
||||
private Long roleId;
|
||||
@ApiModelProperty(name = "权限表ID")
|
||||
private Long menuId;
|
||||
@ApiModelProperty(name = "菜单表ID集合")
|
||||
private List<Long> menuIds;
|
||||
@ApiModelProperty(name = "角色表ID集合")
|
||||
private List<Long> roleIds;
|
||||
@ApiModelProperty(name = "组织表ID")
|
||||
private Long organizationId;
|
||||
|
||||
@ApiModelProperty(name = "角色权限客户端:0-无状态,1-PC端,2-手机端")
|
||||
private Integer roleMenuClient;
|
||||
|
||||
@ApiModelProperty(name = "唯一key集合")
|
||||
private List<String> idKeyList;
|
||||
@ApiModelProperty(name = "菜单权限集合")
|
||||
private List<MenuVo> menuVoList;
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.mhd.user.domain.roleAggregate.service;
|
||||
|
||||
import com.mhd.user.domain.roleAggregate.entity.CustomAuthRoleEntity;
|
||||
import com.mhd.user.domain.roleAggregate.factory.RoleFactory;
|
||||
import com.mhd.user.domain.roleAggregate.repository.facade.CustomAuthRoleRepositoryInterface;
|
||||
import com.mhd.user.domain.roleAggregate.repository.po.CustomAuthRoleOrUserPO;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.CustomAuthDO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CustomAuthRoleDomainService {
|
||||
|
||||
@Resource
|
||||
private RoleFactory roleFactory;
|
||||
@Resource
|
||||
private CustomAuthRoleRepositoryInterface customAuthRoleRepository;
|
||||
|
||||
/**
|
||||
* @Description 获取角色自定义权限
|
||||
* @Author Alex
|
||||
* @Date 2023/1/9 23:25
|
||||
*/
|
||||
public List<CustomAuthRoleOrUserPO> getCustomAuthByRoleOrUserId(CustomAuthDO customAuthDO) {
|
||||
return customAuthRoleRepository.getCustomAuthByRoleOrUserId(customAuthDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 查询角色自定义权限表
|
||||
* @Author Alex
|
||||
* @Date 2023/1/9 23:24
|
||||
*/
|
||||
public CustomAuthRoleOrUserPO getCustomAuthMenuByRoleOrUserId(CustomAuthDO customAuthDO) {
|
||||
return customAuthRoleRepository.getCustomAuthMenuByRoleOrUserId(customAuthDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 分配角色自定义权限
|
||||
* @Author Alex
|
||||
* @Date 2023/1/9 23:24
|
||||
*/
|
||||
public int assignCustomAuthByRoleId(CustomAuthDO customAuthDO) {
|
||||
CustomAuthRoleEntity customAuthRoleEntity = roleFactory.getCustomAuthRoleEntity(customAuthDO);
|
||||
return customAuthRoleRepository.insertCustomAuthRole(customAuthRoleEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 删除角色自定义权限
|
||||
* @Author Alex
|
||||
* @Date 2023/1/9 23:25
|
||||
*/
|
||||
public void deleteCustomAuthRoleByRoleId(CustomAuthDO customAuthDO) {
|
||||
customAuthRoleRepository.deleteCustomAuthRoleByRoleId(customAuthDO);
|
||||
}
|
||||
|
||||
public List<CustomAuthRoleEntity> selectByRoleIdList(List<Long> codeList) {
|
||||
return customAuthRoleRepository.selectByRoleIdList(codeList);
|
||||
}
|
||||
|
||||
public void saveBatch(List<CustomAuthRoleEntity> customAuthRoleEntityList) {
|
||||
customAuthRoleRepository.saveBatch(customAuthRoleEntityList);
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package com.mhd.user.domain.roleAggregate.service;
|
||||
|
||||
import com.mhd.user.domain.roleAggregate.entity.CustomAuthUserEntity;
|
||||
import com.mhd.user.domain.roleAggregate.factory.RoleFactory;
|
||||
import com.mhd.user.domain.roleAggregate.repository.facade.CustomAuthRoleRepositoryInterface;
|
||||
import com.mhd.user.domain.roleAggregate.repository.facade.CustomAuthUserRepositoryInterface;
|
||||
import com.mhd.user.domain.roleAggregate.repository.po.CustomAuthRoleOrUserPO;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.CustomAuthDO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CustomAuthUserDomainService {
|
||||
|
||||
@Resource
|
||||
private RoleFactory roleFactory;
|
||||
@Resource
|
||||
private CustomAuthRoleRepositoryInterface customAuthRoleRepository;
|
||||
@Resource
|
||||
private CustomAuthUserRepositoryInterface customAuthUserRepositoryInterface;
|
||||
|
||||
/**
|
||||
* @Description 获取用户自定义权限
|
||||
* @Author Alex
|
||||
* @Date 2023/1/9 23:25
|
||||
*/
|
||||
public List<CustomAuthRoleOrUserPO> getCustomAuthByRoleOrUserId(CustomAuthDO customAuthDO) {
|
||||
return customAuthUserRepositoryInterface.getCustomAuthByRoleOrUserId(customAuthDO);
|
||||
}
|
||||
public List<CustomAuthRoleOrUserPO> getCustomAuthByRole(CustomAuthDO customAuthDO) {
|
||||
return customAuthUserRepositoryInterface.getCustomAuthByRole(customAuthDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 删除用户自定义权限
|
||||
* @Author Alex
|
||||
* @Date 2023/1/9 23:25
|
||||
*/
|
||||
public void deleteCustomAuthUserByUserId(CustomAuthDO customAuthDO) {
|
||||
customAuthUserRepositoryInterface.deleteCustomAuthUserByUserId(customAuthDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 查询用户自定义权限表
|
||||
* @Author Alex
|
||||
* @Date 2023/1/9 23:24
|
||||
*/
|
||||
public CustomAuthRoleOrUserPO getCustomAuthMenuByRoleOrUserId(CustomAuthDO customAuthDO) {
|
||||
return customAuthUserRepositoryInterface.getCustomAuthMenuByRoleOrUserId(customAuthDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 分配用户自定义权限
|
||||
* @Author Alex
|
||||
* @Date 2023/1/9 23:24
|
||||
*/
|
||||
public int assignCustomAuthByUserId(CustomAuthDO customAuthDO) {
|
||||
CustomAuthUserEntity customAuthUserEntity = roleFactory.getCustomAuthUserEntity(customAuthDO);
|
||||
return customAuthUserRepositoryInterface.insertCustomAuthUser(customAuthUserEntity);
|
||||
}
|
||||
|
||||
public CustomAuthRoleOrUserPO getCustomAuthByRoleId(CustomAuthDO customAuthDO) {
|
||||
return customAuthUserRepositoryInterface.getCustomAuthByRoleId(customAuthDO);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.mhd.user.domain.roleAggregate.service;
|
||||
|
||||
import com.mhd.user.domain.roleAggregate.entity.RoleMenuEntity;
|
||||
import com.mhd.user.domain.roleAggregate.factory.RoleMenuFactory;
|
||||
import com.mhd.user.domain.roleAggregate.repository.facade.RoleMenuRepositoryInterface;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.RoleMenuDo;
|
||||
import com.mhd.common.core.domain.po.UserRoleMenuPO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RoleAuthDomainService {
|
||||
|
||||
@Autowired
|
||||
private RoleMenuFactory roleMenuFactory;
|
||||
@Resource
|
||||
private RoleMenuRepositoryInterface roleMenuRepositoryInterface;
|
||||
|
||||
public List<RoleMenuEntity> selectList(RoleMenuDo roleMenuDo) {
|
||||
return roleMenuRepositoryInterface.selectList(roleMenuDo);
|
||||
}
|
||||
|
||||
public List<UserRoleMenuPO> selectRoleMenuList(RoleMenuDo roleMenuDo) {
|
||||
return roleMenuRepositoryInterface.selectRoleMenuList(roleMenuDo);
|
||||
}
|
||||
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
package com.mhd.user.domain.roleAggregate.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.mhd.user.domain.roleAggregate.entity.RoleEntity;
|
||||
import com.mhd.user.domain.roleAggregate.factory.RoleFactory;
|
||||
import com.mhd.user.domain.roleAggregate.repository.facade.RoleRepositoryInterface;
|
||||
import com.mhd.user.domain.roleAggregate.repository.mapper.RoleMapper;
|
||||
import com.mhd.common.core.domain.po.RolePO;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.RoleDo;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.RoleError;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RoleDomainService {
|
||||
|
||||
@Autowired
|
||||
private RoleFactory roleFactory;
|
||||
@Resource
|
||||
private RoleRepositoryInterface roleRepositoryInterface;
|
||||
@Resource
|
||||
private RoleMapper roleMapper;
|
||||
|
||||
/**
|
||||
* @Description 新增角色信息
|
||||
* @Author Alex
|
||||
* @Date 2023/1/9 23:35
|
||||
*/
|
||||
public int addRole(RoleDo roleDo) {
|
||||
RoleEntity roleEntity = roleFactory.getRoleEntity(roleDo);
|
||||
int i = roleRepositoryInterface.addRole(roleEntity);
|
||||
roleDo.setRoleId(roleEntity.getRoleId());
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 批量新增角色信息
|
||||
* @Author Alex
|
||||
* @Date 2023/1/9 23:35
|
||||
*/
|
||||
public void saveBatchList(List<RoleEntity> list) {
|
||||
roleRepositoryInterface.saveBatchList(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 新增/修改角色信息
|
||||
* @Author Alex
|
||||
* @Date 2023/1/9 23:35
|
||||
*/
|
||||
public int updateRole(RoleDo roleDo) {
|
||||
//校验角色编码是否重复
|
||||
Long topOrganizationId = SecurityUtils.getLoginUser().getUserPo().getTopOrganizationId();
|
||||
RoleEntity roleEntity = roleFactory.getRoleEntity(roleDo);
|
||||
RoleDo query = new RoleDo();
|
||||
if (roleDo.getOrganizationId() != null){
|
||||
query.setOrganizationId(roleDo.getOrganizationId());
|
||||
}else {
|
||||
query.setOrganizationId(topOrganizationId);
|
||||
}
|
||||
query.setRoleCode(roleDo.getRoleCode());
|
||||
|
||||
if (roleDo.getRoleId() != null){
|
||||
query.setRoleId(roleDo.getRoleId());
|
||||
}
|
||||
RolePO rolePO = roleMapper.selectByRoleCode(query);
|
||||
if (rolePO != null){
|
||||
throw new DigitalLogisticsException(RoleError.ROLE_CODE_EXIST);
|
||||
}
|
||||
if (ObjectUtil.isNull(roleDo.getRoleId())) {
|
||||
return roleRepositoryInterface.addRole(roleEntity);
|
||||
} else {
|
||||
return roleRepositoryInterface.updateRole(roleEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public List<RolePO> selecRolePoList(RoleDo roleDo) {
|
||||
return roleRepositoryInterface.selecRolePoList(roleDo);
|
||||
}
|
||||
|
||||
public List<RolePO> selectList(RoleDo roleDo) {
|
||||
return roleRepositoryInterface.selecRolePoList(roleDo);
|
||||
}
|
||||
|
||||
public RoleEntity selectByOrganizationIdAndRoleCode(RoleDo roleDo) {
|
||||
return roleRepositoryInterface.selectByOrganizationIdAndRoleCode(roleDo);
|
||||
}
|
||||
|
||||
public RolePO findDelByRoleId(Long roleId) {
|
||||
return roleRepositoryInterface.findDelByRoleId(roleId);
|
||||
}
|
||||
|
||||
public RolePO selectByRoleId(Long roleId) {
|
||||
return roleRepositoryInterface.findByRoleId(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据角色code加组织id查询角色
|
||||
* @author ZhouGY
|
||||
* @date 2023/10/10 11:18
|
||||
* @param roleCode
|
||||
* @param organizationId
|
||||
* @return RolePO
|
||||
*/
|
||||
public RolePO selectByRoleCodeAndOrganizationId(String roleCode, Long organizationId) {
|
||||
return roleRepositoryInterface.selectByRoleCodeAndOrganizationId(roleCode, organizationId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 根据组织ID和角色编码查询角色ID
|
||||
* @Author Alex
|
||||
* @Date 2022/12/7 00:46
|
||||
*/
|
||||
public RolePO selectRoleByOrganizationAndCode(RoleDo roleDo) {
|
||||
return roleRepositoryInterface.selectRoleByOrganizationAndCode(roleDo);
|
||||
}
|
||||
|
||||
|
||||
public void deleteByOrganizationId(Long organizationId) {
|
||||
roleRepositoryInterface.deleteByOrganizationId(organizationId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 根据角色IDs获取角色名称
|
||||
* @Author Alex
|
||||
* @Date 2022/12/20 17:27
|
||||
*/
|
||||
public String findRoleNameByRoleIds(List<Long> roleIds) {
|
||||
return roleRepositoryInterface.findRoleNameByRoleIds(roleIds);
|
||||
}
|
||||
|
||||
public List<RoleEntity> selectByRoleIds(List<Long> roleIds) {
|
||||
List<RoleEntity> roleEntities = roleRepositoryInterface.selectByRoleIds(roleIds);
|
||||
return roleEntities;
|
||||
}
|
||||
|
||||
public void updateBatchListById(List<RoleEntity> list) {
|
||||
roleRepositoryInterface.updateBatchById(list);
|
||||
}
|
||||
|
||||
public List<RoleEntity> queryList(RoleDo roleDo) {
|
||||
return roleRepositoryInterface.queryList(roleDo);
|
||||
}
|
||||
|
||||
public List<RoleEntity> selectByCodesAndOrganizationIds(List<String> delCodes, List<Long> longs) {
|
||||
return roleRepositoryInterface.selectByCodesAndOrganizationIds(delCodes , longs);
|
||||
}
|
||||
|
||||
public List<RoleEntity> selectByOrganizations(String roleCode , List<Long> organizationIds) {
|
||||
return roleRepositoryInterface.selectByOrganizations(roleCode ,organizationIds);
|
||||
}
|
||||
|
||||
public List<RolePO> getRoleListByUserId(Long userId) {
|
||||
return roleRepositoryInterface.getRoleListByUserId(userId);
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package com.mhd.user.domain.roleAggregate.service;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.mhd.user.domain.roleAggregate.entity.RoleMenuEntity;
|
||||
import com.mhd.user.domain.roleAggregate.factory.RoleMenuFactory;
|
||||
import com.mhd.user.domain.roleAggregate.repository.facade.RoleMenuRepositoryInterface;
|
||||
import com.mhd.user.domain.roleAggregate.repository.todo.RoleMenuDo;
|
||||
import com.mhd.common.core.domain.po.UserRoleMenuPO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class RoleMenuDomainService {
|
||||
|
||||
@Autowired
|
||||
private RoleMenuFactory roleMenuFactory;
|
||||
@Resource
|
||||
private RoleMenuRepositoryInterface roleMenuRepositoryInterface;
|
||||
|
||||
@Resource
|
||||
private CustomAuthRoleDomainService customAuthRoleDomainService;
|
||||
|
||||
@Resource
|
||||
private CustomAuthRoleDomainService customAuthUserRepositoryInterface;
|
||||
|
||||
public int addRoleMenu(RoleMenuDo roleMenuDo) {
|
||||
RoleMenuEntity roleMenuEntity = roleMenuFactory.getRoleMenuEntity(roleMenuDo);
|
||||
return roleMenuRepositoryInterface.addRoleMenu(roleMenuEntity);
|
||||
}
|
||||
|
||||
public List<RoleMenuEntity> selectList(RoleMenuDo roleMenuDo) {
|
||||
return roleMenuRepositoryInterface.selectList(roleMenuDo);
|
||||
}
|
||||
|
||||
public List<UserRoleMenuPO> selectRoleMenuList(RoleMenuDo roleMenuDo) {
|
||||
return roleMenuRepositoryInterface.selectRoleMenuList(roleMenuDo);
|
||||
}
|
||||
|
||||
public void removeByRoleId(RoleMenuDo roleMenuDo) {
|
||||
roleMenuRepositoryInterface.removeByRoleId(roleMenuDo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的内置角色对应的菜单
|
||||
* @param roleList
|
||||
* @return
|
||||
*/
|
||||
public List<RoleMenuDo> selectByRoleList(List<Long> roleList) {
|
||||
//查询所有的角色菜单配置表
|
||||
if (CollectionUtil.isEmpty(roleList)){
|
||||
return null;
|
||||
}
|
||||
List<RoleMenuEntity> list = roleMenuRepositoryInterface.selectByRoleList(roleList);
|
||||
List<RoleMenuDo> roleMenuList = new ArrayList<>();
|
||||
Map<Long, List<RoleMenuEntity>> collect = list.stream().collect(Collectors.groupingBy(RoleMenuEntity::getRoleId));
|
||||
for (Long aLong : collect.keySet()) {
|
||||
RoleMenuDo roleMenuDo = new RoleMenuDo();
|
||||
roleMenuDo.setRoleId(aLong);
|
||||
List<RoleMenuEntity> list1 = collect.get(aLong);
|
||||
if (CollectionUtil.isNotEmpty(list1)){
|
||||
List<Long> collect1 = list1.stream().map(RoleMenuEntity::getMenuId).collect(Collectors.toList());
|
||||
roleMenuDo.setMenuIds(collect1);
|
||||
}
|
||||
roleMenuList.add(roleMenuDo);
|
||||
}
|
||||
|
||||
return roleMenuList;
|
||||
}
|
||||
|
||||
public void saveBatchList(List<RoleMenuEntity> roleMenuEntityList) {
|
||||
roleMenuRepositoryInterface.saveBatch(roleMenuEntityList);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user