PageRenderTime 3076ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java

https://gitlab.com/mrsunchangemyselfsun/ruoyi-vue
Java | 266 lines | 165 code | 45 blank | 56 comment | 0 complexity | 1c1e07c1b507657a03967c4a56b60414 MD5 | raw file
  1. package com.ruoyi.common.core.domain.model;
  2. import java.util.Collection;
  3. import java.util.Set;
  4. import org.springframework.security.core.GrantedAuthority;
  5. import org.springframework.security.core.userdetails.UserDetails;
  6. import com.alibaba.fastjson.annotation.JSONField;
  7. import com.ruoyi.common.core.domain.entity.SysUser;
  8. /**
  9. * 登录用户身份权限
  10. *
  11. * @author ruoyi
  12. */
  13. public class LoginUser implements UserDetails
  14. {
  15. private static final long serialVersionUID = 1L;
  16. /**
  17. * 用户ID
  18. */
  19. private Long userId;
  20. /**
  21. * 部门ID
  22. */
  23. private Long deptId;
  24. /**
  25. * 用户唯一标识
  26. */
  27. private String token;
  28. /**
  29. * 登录时间
  30. */
  31. private Long loginTime;
  32. /**
  33. * 过期时间
  34. */
  35. private Long expireTime;
  36. /**
  37. * 登录IP地址
  38. */
  39. private String ipaddr;
  40. /**
  41. * 登录地点
  42. */
  43. private String loginLocation;
  44. /**
  45. * 浏览器类型
  46. */
  47. private String browser;
  48. /**
  49. * 操作系统
  50. */
  51. private String os;
  52. /**
  53. * 权限列表
  54. */
  55. private Set<String> permissions;
  56. /**
  57. * 用户信息
  58. */
  59. private SysUser user;
  60. public Long getUserId()
  61. {
  62. return userId;
  63. }
  64. public void setUserId(Long userId)
  65. {
  66. this.userId = userId;
  67. }
  68. public Long getDeptId()
  69. {
  70. return deptId;
  71. }
  72. public void setDeptId(Long deptId)
  73. {
  74. this.deptId = deptId;
  75. }
  76. public String getToken()
  77. {
  78. return token;
  79. }
  80. public void setToken(String token)
  81. {
  82. this.token = token;
  83. }
  84. public LoginUser()
  85. {
  86. }
  87. public LoginUser(SysUser user, Set<String> permissions)
  88. {
  89. this.user = user;
  90. this.permissions = permissions;
  91. }
  92. public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions)
  93. {
  94. this.userId = userId;
  95. this.deptId = deptId;
  96. this.user = user;
  97. this.permissions = permissions;
  98. }
  99. @JSONField(serialize = false)
  100. @Override
  101. public String getPassword()
  102. {
  103. return user.getPassword();
  104. }
  105. @Override
  106. public String getUsername()
  107. {
  108. return user.getUserName();
  109. }
  110. /**
  111. * 账户是否未过期,过期无法验证
  112. */
  113. @JSONField(serialize = false)
  114. @Override
  115. public boolean isAccountNonExpired()
  116. {
  117. return true;
  118. }
  119. /**
  120. * 指定用户是否解锁,锁定的用户无法进行身份验证
  121. *
  122. * @return
  123. */
  124. @JSONField(serialize = false)
  125. @Override
  126. public boolean isAccountNonLocked()
  127. {
  128. return true;
  129. }
  130. /**
  131. * 指示是否已过期的用户的凭据(密码),过期的凭据防止认证
  132. *
  133. * @return
  134. */
  135. @JSONField(serialize = false)
  136. @Override
  137. public boolean isCredentialsNonExpired()
  138. {
  139. return true;
  140. }
  141. /**
  142. * 是否可用 ,禁用的用户不能身份验证
  143. *
  144. * @return
  145. */
  146. @JSONField(serialize = false)
  147. @Override
  148. public boolean isEnabled()
  149. {
  150. return true;
  151. }
  152. public Long getLoginTime()
  153. {
  154. return loginTime;
  155. }
  156. public void setLoginTime(Long loginTime)
  157. {
  158. this.loginTime = loginTime;
  159. }
  160. public String getIpaddr()
  161. {
  162. return ipaddr;
  163. }
  164. public void setIpaddr(String ipaddr)
  165. {
  166. this.ipaddr = ipaddr;
  167. }
  168. public String getLoginLocation()
  169. {
  170. return loginLocation;
  171. }
  172. public void setLoginLocation(String loginLocation)
  173. {
  174. this.loginLocation = loginLocation;
  175. }
  176. public String getBrowser()
  177. {
  178. return browser;
  179. }
  180. public void setBrowser(String browser)
  181. {
  182. this.browser = browser;
  183. }
  184. public String getOs()
  185. {
  186. return os;
  187. }
  188. public void setOs(String os)
  189. {
  190. this.os = os;
  191. }
  192. public Long getExpireTime()
  193. {
  194. return expireTime;
  195. }
  196. public void setExpireTime(Long expireTime)
  197. {
  198. this.expireTime = expireTime;
  199. }
  200. public Set<String> getPermissions()
  201. {
  202. return permissions;
  203. }
  204. public void setPermissions(Set<String> permissions)
  205. {
  206. this.permissions = permissions;
  207. }
  208. public SysUser getUser()
  209. {
  210. return user;
  211. }
  212. public void setUser(SysUser user)
  213. {
  214. this.user = user;
  215. }
  216. @Override
  217. public Collection<? extends GrantedAuthority> getAuthorities()
  218. {
  219. return null;
  220. }
  221. }