UserUtils.java 548 B

12345678910111213141516171819202122232425262728
  1. package com.dataeasy.server.utiis;
  2. /**
  3. * @author tyuio
  4. * @version 1.0.0
  5. * @date 2024/11/25 10:15
  6. * @description 用户信息相关工具类
  7. */
  8. public class UserUtils {
  9. public static final ThreadLocal<Long> threadLocal = new ThreadLocal<>();
  10. /**
  11. * 设置当前用户的ID
  12. * @param id
  13. */
  14. public static void setCurrentId(Long id) {
  15. threadLocal.set(id);
  16. }
  17. /**
  18. * 获取当前用户的ID
  19. * @return
  20. */
  21. public static Long getCurrentUserId() {
  22. return threadLocal.get();
  23. }
  24. }