Search in sources :

Example 1 with AuthUser

use of com.besscroft.aurora.mall.common.entity.AuthUser in project aurora-mall by besscroft.

the class UserServiceTest method getUserById.

@Test
void getUserById() throws Exception {
    Long adminId = 1L;
    AuthUser user = userService.getUserById(adminId);
    assertNotNull(user, "获取用户详细信息失败!");
    LOGGER.info("用户详细信息:{}", objectMapper.writeValueAsString(user));
}
Also used : AuthUser(com.besscroft.aurora.mall.common.entity.AuthUser) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with AuthUser

use of com.besscroft.aurora.mall.common.entity.AuthUser in project aurora-mall by besscroft.

the class UserServiceTest method getCurrentAdmin.

@Test
void getCurrentAdmin() throws Exception {
    AuthUser currentAdmin = userService.getCurrentAdmin();
    assertNotNull(currentAdmin, "获取当前登录用户失败!");
}
Also used : AuthUser(com.besscroft.aurora.mall.common.entity.AuthUser) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with AuthUser

use of com.besscroft.aurora.mall.common.entity.AuthUser in project aurora-mall by besscroft.

the class UserServiceTest method addUser.

@Test
void addUser() throws Exception {
    AuthUser user = AuthUser.builder().build();
    user.setUsername("test666");
    user.setPassword("666666");
    boolean b = userService.addUser(user);
    assertTrue(b, "添加用户失败!");
}
Also used : AuthUser(com.besscroft.aurora.mall.common.entity.AuthUser) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with AuthUser

use of com.besscroft.aurora.mall.common.entity.AuthUser in project aurora-mall by besscroft.

the class UserServiceImpl method logout.

@Override
public boolean logout(Long adminId) {
    AuthUser user = this.baseMapper.selectById(adminId);
    redisTemplate.delete(AuthConstants.ADMIN_CLIENT_ID + ":token:user:" + user.getUsername());
    redisTemplate.boundHashOps("admin").delete("user:tree:" + adminId);
    return true;
}
Also used : AuthUser(com.besscroft.aurora.mall.common.entity.AuthUser)

Example 5 with AuthUser

use of com.besscroft.aurora.mall.common.entity.AuthUser in project aurora-mall by besscroft.

the class UserServiceImpl method loadUserByUsername.

@Override
public UserDto loadUserByUsername(String username) {
    AuthUser authUser = this.baseMapper.selectAuthUserByUsername(username);
    if (authUser != null) {
        List<AuthRole> authRoles = authRoleMapper.selectAuthRoleListByAdminId(authUser.getId());
        UserDto userDto = new UserDto();
        BeanUtils.copyProperties(authUser, userDto);
        if (CollUtil.isNotEmpty(authRoles)) {
            List<String> roleStrList = authRoles.stream().map(item -> item.getId() + "_" + item.getName()).collect(Collectors.toList());
            userDto.setRoles(roleStrList);
        }
        return userDto;
    }
    return null;
}
Also used : BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) AuthUserExcelDto(com.besscroft.aurora.mall.common.domain.AuthUserExcelDto) UserDto(com.besscroft.aurora.mall.common.domain.UserDto) AuthFeignClient(com.besscroft.aurora.mall.admin.api.AuthFeignClient) RequiredArgsConstructor(lombok.RequiredArgsConstructor) LocalDateTime(java.time.LocalDateTime) HashMap(java.util.HashMap) EasyExcel(com.alibaba.excel.EasyExcel) AdminParam(com.besscroft.aurora.mall.admin.domain.param.AdminParam) JSONUtil(cn.hutool.json.JSONUtil) HttpServletRequest(javax.servlet.http.HttpServletRequest) UserService(com.besscroft.aurora.mall.admin.service.UserService) Service(org.springframework.stereotype.Service) RedisTemplate(org.springframework.data.redis.core.RedisTemplate) Map(java.util.Map) AuthRole(com.besscroft.aurora.mall.common.entity.AuthRole) ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) MenuService(com.besscroft.aurora.mall.admin.service.MenuService) AuthConstants(com.besscroft.aurora.mall.common.constant.AuthConstants) HttpServletResponse(javax.servlet.http.HttpServletResponse) UserConverterMapper(com.besscroft.aurora.mall.admin.converter.UserConverterMapper) PageHelper(com.github.pagehelper.PageHelper) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) CollUtil(cn.hutool.core.collection.CollUtil) StrUtil(cn.hutool.core.util.StrUtil) AjaxResult(com.besscroft.aurora.mall.common.result.AjaxResult) Slf4j(lombok.extern.slf4j.Slf4j) URLEncoder(java.net.URLEncoder) List(java.util.List) AuthRoleMapper(com.besscroft.aurora.mall.admin.mapper.AuthRoleMapper) AuthUser(com.besscroft.aurora.mall.common.entity.AuthUser) AuthUserMapper(com.besscroft.aurora.mall.admin.mapper.AuthUserMapper) BeanUtils(org.springframework.beans.BeanUtils) Transactional(org.springframework.transaction.annotation.Transactional) AuthRole(com.besscroft.aurora.mall.common.entity.AuthRole) UserDto(com.besscroft.aurora.mall.common.domain.UserDto) AuthUser(com.besscroft.aurora.mall.common.entity.AuthUser)

Aggregations

AuthUser (com.besscroft.aurora.mall.common.entity.AuthUser)13 Test (org.junit.jupiter.api.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 Transactional (org.springframework.transaction.annotation.Transactional)4 WebLog (com.besscroft.aurora.mall.common.annotation.WebLog)3 ApiOperation (io.swagger.annotations.ApiOperation)3 AuthRole (com.besscroft.aurora.mall.common.entity.AuthRole)2 IOException (java.io.IOException)2 BCryptPasswordEncoder (org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder)2 CollUtil (cn.hutool.core.collection.CollUtil)1 StrUtil (cn.hutool.core.util.StrUtil)1 JSONUtil (cn.hutool.json.JSONUtil)1 EasyExcel (com.alibaba.excel.EasyExcel)1 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)1 AuthFeignClient (com.besscroft.aurora.mall.admin.api.AuthFeignClient)1 UserConverterMapper (com.besscroft.aurora.mall.admin.converter.UserConverterMapper)1 AdminParam (com.besscroft.aurora.mall.admin.domain.param.AdminParam)1 AuthRoleMapper (com.besscroft.aurora.mall.admin.mapper.AuthRoleMapper)1 AuthUserMapper (com.besscroft.aurora.mall.admin.mapper.AuthUserMapper)1 MenuService (com.besscroft.aurora.mall.admin.service.MenuService)1