Search in sources :

Example 1 with UserDTO

use of io.kenxue.cicd.coreclient.dto.sys.user.UserDTO in project cicd-platform by ken-xue.

the class UserInfoGetQryExe method execute.

public SingleResponse<UserDTO> execute(UserFullGetQry qry) {
    // 查询用户信息
    User user = userRepository.getByUserId(qry.getUserId());
    Assert.notNull(user.getUuid(), "查询用户信息失败");
    // 查询对应的角色
    Set<Role> roles = userOfRoleRepository.getByUserId(user.getUuid());
    UserDTO userDTO = user2DTOAssembler.toDTO(user);
    userDTO.setRoles(roles.stream().map(v -> role2DTOAssembler.toDTO(v)).collect(Collectors.toSet()));
    return SingleResponse.of(userDTO);
}
Also used : Role(io.kenxue.cicd.domain.domain.sys.Role) User(io.kenxue.cicd.domain.domain.sys.User) UserDTO(io.kenxue.cicd.coreclient.dto.sys.user.UserDTO)

Example 2 with UserDTO

use of io.kenxue.cicd.coreclient.dto.sys.user.UserDTO in project cicd-platform by ken-xue.

the class ContextInterceptorTest method testNoOperatorContext.

@Test
public void testNoOperatorContext() {
    UserAddCmd userAddCmd = new UserAddCmd();
    userAddCmd.setUserDTO(new UserDTO());
// ContextInterceptor contextInterceptor = new ContextInterceptor();
// contextInterceptor.preIntercept(userProfileAddCmd);
}
Also used : UserDTO(io.kenxue.cicd.coreclient.dto.sys.user.UserDTO) UserAddCmd(io.kenxue.cicd.coreclient.dto.sys.user.UserAddCmd) Test(org.junit.Test)

Example 3 with UserDTO

use of io.kenxue.cicd.coreclient.dto.sys.user.UserDTO in project cicd-platform by ken-xue.

the class ContextInterceptorTest method testOperatorContext.

@Test
public void testOperatorContext() {
    UserAddCmd userAddCmd = new UserAddCmd();
    userAddCmd.setUserDTO(new UserDTO());
    userAddCmd.setOperator("Frank");
// ContextInterceptor contextInterceptor = new ContextInterceptor();
// contextInterceptor.preIntercept(userProfileAddCmd);
}
Also used : UserDTO(io.kenxue.cicd.coreclient.dto.sys.user.UserDTO) UserAddCmd(io.kenxue.cicd.coreclient.dto.sys.user.UserAddCmd) Test(org.junit.Test)

Example 4 with UserDTO

use of io.kenxue.cicd.coreclient.dto.sys.user.UserDTO in project cicd-platform by ken-xue.

the class UserGetQryExe method execute.

public SingleResponse<UserDTO> execute(UserGetQry qry) {
    User user = userRepository.getById(qry.getId());
    // 查询所属角色
    Set<Role> roles = userOfRoleRepository.getByUserId(user.getUuid());
    List<String> roleUuids = roles.stream().map(v -> v.getUuid()).collect(Collectors.toList());
    UserDTO userDTO = user2DTOAssembler.toDTO(user);
    userDTO.setRoleIdList(roleUuids);
    userDTO.setRoles(roles.stream().map(v -> role2DTOAssembler.toDTO(v)).collect(Collectors.toSet()));
    return SingleResponse.of(userDTO);
}
Also used : Role(io.kenxue.cicd.domain.domain.sys.Role) Role2DTOAssembler(io.kenxue.cicd.application.sys.role.assembler.Role2DTOAssembler) Resource(javax.annotation.Resource) Set(java.util.Set) Collectors(java.util.stream.Collectors) Component(org.springframework.stereotype.Component) List(java.util.List) User(io.kenxue.cicd.domain.domain.sys.User) UserGetQry(io.kenxue.cicd.coreclient.dto.sys.user.UserGetQry) Role(io.kenxue.cicd.domain.domain.sys.Role) SingleResponse(io.kenxue.cicd.coreclient.dto.common.response.SingleResponse) UserOfRoleRepository(io.kenxue.cicd.domain.repository.sys.UserOfRoleRepository) UserRepository(io.kenxue.cicd.domain.repository.sys.UserRepository) UserDTO(io.kenxue.cicd.coreclient.dto.sys.user.UserDTO) User2DTOAssembler(io.kenxue.cicd.application.sys.user.assembler.User2DTOAssembler) User(io.kenxue.cicd.domain.domain.sys.User) UserDTO(io.kenxue.cicd.coreclient.dto.sys.user.UserDTO)

Example 5 with UserDTO

use of io.kenxue.cicd.coreclient.dto.sys.user.UserDTO in project cicd-platform by ken-xue.

the class ProjectInfoRepositoryImpl method page.

@Override
public Page<ProjectInfo> page(ProjectInfoPageQry qry) {
    QueryWrapper<ProjectInfoDO> qw = new QueryWrapper<>();
    UserDTO user = UserThreadContext.getUser();
    UserDO userDO = userMapper.selectOne(new QueryWrapper<UserDO>().eq("user_id", user.getUserId()));
    String uuid = userDO.getUuid();
    qw.eq("user_uuid", uuid);
    ProjectTypeEnum projectType = qry.getProjectType();
    IPage<ProjectInfoDO> doPage;
    PageDTO pageDTO = new PageDTO(qry.getPageIndex(), qry.getPageSize());
    if (projectType == ProjectTypeEnum.JOIN) {
        doPage = projectInfoMapper.queryRelatedProject(pageDTO, userDO.getUuid(), qry.getProjectInfoDTO().getUsername(), qry.getProjectInfoDTO().getProjectName());
    } else {
        if (Objects.nonNull(qry.getProjectInfoDTO()) && StringUtils.isNotBlank(qry.getProjectInfoDTO().getProjectName()))
            qw.like("project_name", qry.getProjectInfoDTO().getProjectName());
        doPage = projectInfoMapper.selectPage(pageDTO, qw);
        doPage.getRecords().forEach(v -> v.setUsername(userDO.getUserName()));
    }
    return Page.of(doPage.getCurrent(), doPage.getSize(), doPage.getTotal(), projectInfo2DOConvector.toDomainList(doPage.getRecords()));
}
Also used : PageDTO(com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO) ProjectInfoDO(io.kenxue.cicd.infrastructure.repositoryimpl.project.database.dataobject.ProjectInfoDO) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) UserDO(io.kenxue.cicd.infrastructure.repositoryimpl.sys.database.dataobject.UserDO) UserDTO(io.kenxue.cicd.coreclient.dto.sys.user.UserDTO) ProjectTypeEnum(io.kenxue.cicd.sharedataboject.project.enums.ProjectTypeEnum)

Aggregations

UserDTO (io.kenxue.cicd.coreclient.dto.sys.user.UserDTO)6 UserAddCmd (io.kenxue.cicd.coreclient.dto.sys.user.UserAddCmd)2 Role (io.kenxue.cicd.domain.domain.sys.Role)2 User (io.kenxue.cicd.domain.domain.sys.User)2 Test (org.junit.Test)2 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 PageDTO (com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO)1 GrantedAuthorityImpl (io.kenxue.cicd.acl.authorize.impl.GrantedAuthorityImpl)1 Role2DTOAssembler (io.kenxue.cicd.application.sys.role.assembler.Role2DTOAssembler)1 User2DTOAssembler (io.kenxue.cicd.application.sys.user.assembler.User2DTOAssembler)1 SingleResponse (io.kenxue.cicd.coreclient.dto.common.response.SingleResponse)1 UserGetQry (io.kenxue.cicd.coreclient.dto.sys.user.UserGetQry)1 UserOfRoleRepository (io.kenxue.cicd.domain.repository.sys.UserOfRoleRepository)1 UserRepository (io.kenxue.cicd.domain.repository.sys.UserRepository)1 ProjectInfoDO (io.kenxue.cicd.infrastructure.repositoryimpl.project.database.dataobject.ProjectInfoDO)1 UserDO (io.kenxue.cicd.infrastructure.repositoryimpl.sys.database.dataobject.UserDO)1 ProjectTypeEnum (io.kenxue.cicd.sharedataboject.project.enums.ProjectTypeEnum)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1