|
|
|
|
@ -18,6 +18,7 @@ import edu.ncst.award.vo.param.query.PageQuery; |
|
|
|
|
import edu.ncst.award.vo.param.query.UserQuery; |
|
|
|
|
import edu.ncst.award.vo.result.UserInfoVO; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import org.springframework.security.core.context.SecurityContextHolder; |
|
|
|
|
import org.springframework.security.core.userdetails.UserDetails; |
|
|
|
|
import org.springframework.security.core.userdetails.UserDetailsService; |
|
|
|
|
import org.springframework.security.core.userdetails.UsernameNotFoundException; |
|
|
|
|
@ -26,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
@RequiredArgsConstructor |
|
|
|
|
@ -60,9 +62,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public CurrentUserDTO getCurrentUser() { |
|
|
|
|
UserInfoVO details = (UserInfoVO) SecurityContextHolder.getContext().getAuthentication().getDetails(); |
|
|
|
|
CurrentUserDTO user = new CurrentUserDTO(); |
|
|
|
|
user.setUsername("zhangsan"); |
|
|
|
|
user.setNickname("张三"); |
|
|
|
|
user.setUsername(details.getUsername()); |
|
|
|
|
user.setNickname(details.getFullName()); |
|
|
|
|
return user; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -155,8 +158,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU |
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public int updateUser(User user) { |
|
|
|
|
// Long userId = user.getId();
|
|
|
|
|
// 删除用户与角色关联
|
|
|
|
|
Long userId = user.getId(); |
|
|
|
|
// 删除用户与角色关联
|
|
|
|
|
// userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId));
|
|
|
|
|
// 新增用户与角色管理
|
|
|
|
|
// insertUserRole(user);
|
|
|
|
|
@ -174,6 +177,23 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU |
|
|
|
|
return baseMapper.selectUserById(userId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 批量删除用户信息 |
|
|
|
|
* 依靠mybatis的逻辑删除是不能记录删除人的id以后重写 |
|
|
|
|
* @param userIds 需要删除的用户ID |
|
|
|
|
* @return 结果 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public int deleteUserByIds(Long[] userIds) { |
|
|
|
|
for (Long userId : userIds) { |
|
|
|
|
checkUserAllowed(new User(userId)); |
|
|
|
|
} |
|
|
|
|
List<Long> ids = Arrays.asList(userIds); |
|
|
|
|
// 删除用户与角色关联
|
|
|
|
|
// userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId, ids));
|
|
|
|
|
return baseMapper.deleteBatchIds(ids); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { |
|
|
|
|
|