Search in sources :

Example 6 with AuthUser

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

the class UserServiceImpl method getUserInfo.

@Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> getUserInfo() {
    AuthUser currentAdmin = getCurrentAdmin();
    Map<String, Object> data = menuService.getTreeListById(currentAdmin.getId());
    data.put("username", currentAdmin.getNickName());
    data.put("icon", currentAdmin.getIcon());
    List<AuthRole> roleList = getRoleList(currentAdmin.getId());
    if (CollUtil.isNotEmpty(roleList)) {
        List<String> roles = roleList.stream().map(AuthRole::getName).collect(Collectors.toList());
        data.put("roles", roles);
    }
    // 设置登录时间
    setLoginTime(LocalDateTime.now(), currentAdmin.getId());
    return data;
}
Also used : AuthRole(com.besscroft.aurora.mall.common.entity.AuthRole) AuthUser(com.besscroft.aurora.mall.common.entity.AuthUser) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with AuthUser

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

the class UserServiceImpl method register.

@Override
@Transactional(rollbackFor = Exception.class)
public boolean register(AdminParam adminParam) {
    AuthUser authUser = AuthUser.builder().build();
    BeanUtils.copyProperties(adminParam, authUser);
    // 设置用户注册的时间
    authUser.setCreateTime(LocalDateTime.now());
    // 设置用户状态
    authUser.setStatus(1);
    // 对密码进行加密
    authUser.setPassword(new BCryptPasswordEncoder().encode(adminParam.getPassword()));
    // 更新到数据库
    return this.baseMapper.insert(authUser) > 0;
}
Also used : AuthUser(com.besscroft.aurora.mall.common.entity.AuthUser) BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with AuthUser

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

the class MenuController method changeSwitch.

@WebLog(description = "菜单是否显示状态更新")
@ApiOperation("菜单是否显示状态更新")
@ApiImplicitParams({ @ApiImplicitParam(name = "hidden", value = "显示状态", required = true, dataType = "Boolean"), @ApiImplicitParam(name = "id", value = "菜单id", required = true, dataType = "Long") })
@PutMapping("/changeSwitch")
public AjaxResult changeSwitch(@RequestParam("hidden") boolean hidden, @RequestParam("id") Long id) {
    AuthUser currentAdmin = userService.getCurrentAdmin();
    boolean b = menuService.changeSwitch(hidden, id, currentAdmin.getId());
    if (b) {
        return AjaxResult.success("修改成功");
    }
    return AjaxResult.success("修改失败");
}
Also used : AuthUser(com.besscroft.aurora.mall.common.entity.AuthUser) WebLog(com.besscroft.aurora.mall.common.annotation.WebLog) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ApiOperation(io.swagger.annotations.ApiOperation)

Example 9 with AuthUser

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

the class MenuController method getRouter.

@WebLog(description = "获取当前用户管理系统菜单")
@ApiOperation(value = "获取当前用户管理系统菜单")
@GetMapping(value = "/getMenu")
public AjaxResult getRouter() {
    AuthUser currentAdmin = userService.getCurrentAdmin();
    List<AuthMenu> list = menuService.getMenuListById(currentAdmin.getId());
    log.info("菜单:{}", list);
    return AjaxResult.success(list);
}
Also used : AuthMenu(com.besscroft.aurora.mall.common.entity.AuthMenu) AuthUser(com.besscroft.aurora.mall.common.entity.AuthUser) WebLog(com.besscroft.aurora.mall.common.annotation.WebLog) ApiOperation(io.swagger.annotations.ApiOperation)

Example 10 with AuthUser

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

the class UserServiceTest method updateUser.

@Test
void updateUser() throws Exception {
    AuthUser user = AuthUser.builder().build();
    user.setId(3L);
    user.setNickName("测试");
    boolean b = userService.updateUser(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)

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