Search in sources :

Example 6 with UserInfoEntity

use of com.hb0730.boot.admin.project.system.user.model.entity.UserInfoEntity in project boot-admin by hb0730.

the class UserInfoController method getUserInfoById.

/**
 * 获取用户详情
 *
 * @param id 用户id
 * @return 用户详情(不包含相关信息)
 */
@GetMapping("/{id}")
public Result<UserInfoDTO> getUserInfoById(@PathVariable("id") Long id) {
    UserInfoEntity entity = service.getById(id);
    UserInfoDTO info = BeanUtil.toBean(entity, UserInfoDTO.class);
    return R.success(info);
}
Also used : UserInfoEntity(com.hb0730.boot.admin.project.system.user.model.entity.UserInfoEntity) UserInfoDTO(com.hb0730.boot.admin.project.system.user.model.dto.UserInfoDTO) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 7 with UserInfoEntity

use of com.hb0730.boot.admin.project.system.user.model.entity.UserInfoEntity in project boot-admin by hb0730.

the class UserInfoController method restPassword.

/**
 * 重置密码
 *
 * @param id 用户id
 * @return 是否成功
 */
@GetMapping("/rest/password/{id}")
@PreAuthorize("hasAnyAuthority('ROLE_ADMINISTRATOR','user:rest:password')")
@Log(value = "重置密码")
public Result<String> restPassword(@PathVariable("id") Long id) {
    UserInfoEntity entity = service.getById(id);
    if (entity.getIsAdmin() == 1) {
        throw new BusinessException("超级管理员无法重置");
    }
    service.restPassword(id);
    return R.success("重置成功");
}
Also used : BusinessException(com.hb0730.boot.admin.exceptions.BusinessException) UserInfoEntity(com.hb0730.boot.admin.project.system.user.model.entity.UserInfoEntity) GetMapping(org.springframework.web.bind.annotation.GetMapping) Log(com.hb0730.boot.admin.annotation.Log) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

UserInfoEntity (com.hb0730.boot.admin.project.system.user.model.entity.UserInfoEntity)7 BusinessException (com.hb0730.boot.admin.exceptions.BusinessException)2 UserAccountEntity (com.hb0730.boot.admin.project.system.user.model.entity.UserAccountEntity)2 Transactional (org.springframework.transaction.annotation.Transactional)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 Log (com.hb0730.boot.admin.annotation.Log)1 PermissionEntity (com.hb0730.boot.admin.project.system.permission.model.entity.PermissionEntity)1 RoleEntity (com.hb0730.boot.admin.project.system.role.model.entity.RoleEntity)1 UserDTO (com.hb0730.boot.admin.project.system.user.model.dto.UserDTO)1 UserInfoDTO (com.hb0730.boot.admin.project.system.user.model.dto.UserInfoDTO)1 UserRoleEntity (com.hb0730.boot.admin.project.system.user.model.entity.UserRoleEntity)1 List (java.util.List)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1