package com.rongyichuang.auth.entity;
|
|
import jakarta.persistence.*;
|
import org.hibernate.annotations.Where;
|
import java.time.LocalDateTime;
|
|
/**
|
* 微信登录记录实体类
|
*/
|
@Entity
|
@Table(name = "t_wx_login_record")
|
@Where(clause = "state = 1")
|
public class WxLoginRecord {
|
|
/**
|
* 主键ID
|
*/
|
@Id
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@Column(name = "id")
|
private Long id;
|
|
/**
|
* 创建时间
|
*/
|
@Column(name = "create_time", nullable = false)
|
private LocalDateTime createTime;
|
|
/**
|
* 更新时间
|
*/
|
@Column(name = "update_time", nullable = false)
|
private LocalDateTime updateTime;
|
|
/**
|
* 微信openid
|
*/
|
@Column(name = "wx_openid", length = 64, nullable = false)
|
private String wxOpenid;
|
|
/**
|
* 微信unionid
|
*/
|
@Column(name = "wx_unionid", length = 64)
|
private String wxUnionid;
|
|
/**
|
* 关联的用户ID
|
*/
|
@Column(name = "user_id")
|
private Long userId;
|
|
/**
|
* 登录时间
|
*/
|
@Column(name = "login_time", nullable = false)
|
private LocalDateTime loginTime;
|
|
/**
|
* 登录IP地址
|
*/
|
@Column(name = "login_ip", length = 64)
|
private String loginIp;
|
|
/**
|
* 设备信息
|
*/
|
@Column(name = "device_info", length = 255)
|
private String deviceInfo;
|
|
/**
|
* 微信session_key
|
*/
|
@Column(name = "session_key", length = 128)
|
private String sessionKey;
|
|
/**
|
* 是否已授权手机号:0-未授权,1-已授权
|
*/
|
@Column(name = "phone_authorized")
|
private Boolean phoneAuthorized = false;
|
|
/**
|
* 手机号授权时间
|
*/
|
@Column(name = "phone_auth_time")
|
private LocalDateTime phoneAuthTime;
|
|
/**
|
* 状态:1-正常,0-删除
|
*/
|
@Column(name = "state", nullable = false)
|
private Integer state = 1;
|
|
|
|
// 构造函数
|
public WxLoginRecord() {}
|
|
public WxLoginRecord(String wxOpenid, String wxUnionid, LocalDateTime loginTime) {
|
this.wxOpenid = wxOpenid;
|
this.wxUnionid = wxUnionid;
|
this.loginTime = loginTime;
|
}
|
|
// Getter和Setter方法
|
public String getWxOpenid() {
|
return wxOpenid;
|
}
|
|
public void setWxOpenid(String wxOpenid) {
|
this.wxOpenid = wxOpenid;
|
}
|
|
public String getWxUnionid() {
|
return wxUnionid;
|
}
|
|
public void setWxUnionid(String wxUnionid) {
|
this.wxUnionid = wxUnionid;
|
}
|
|
public Long getUserId() {
|
return userId;
|
}
|
|
public void setUserId(Long userId) {
|
this.userId = userId;
|
}
|
|
public LocalDateTime getLoginTime() {
|
return loginTime;
|
}
|
|
public void setLoginTime(LocalDateTime loginTime) {
|
this.loginTime = loginTime;
|
}
|
|
public String getLoginIp() {
|
return loginIp;
|
}
|
|
public void setLoginIp(String loginIp) {
|
this.loginIp = loginIp;
|
}
|
|
public String getDeviceInfo() {
|
return deviceInfo;
|
}
|
|
public void setDeviceInfo(String deviceInfo) {
|
this.deviceInfo = deviceInfo;
|
}
|
|
public String getSessionKey() {
|
return sessionKey;
|
}
|
|
public void setSessionKey(String sessionKey) {
|
this.sessionKey = sessionKey;
|
}
|
|
public Boolean getPhoneAuthorized() {
|
return phoneAuthorized;
|
}
|
|
public void setPhoneAuthorized(Boolean phoneAuthorized) {
|
this.phoneAuthorized = phoneAuthorized;
|
}
|
|
public LocalDateTime getPhoneAuthTime() {
|
return phoneAuthTime;
|
}
|
|
public void setPhoneAuthTime(LocalDateTime phoneAuthTime) {
|
this.phoneAuthTime = phoneAuthTime;
|
}
|
|
public Integer getState() {
|
return state;
|
}
|
|
public void setState(Integer state) {
|
this.state = state;
|
}
|
|
public Long getId() {
|
return id;
|
}
|
|
public void setId(Long id) {
|
this.id = id;
|
}
|
|
public LocalDateTime getCreateTime() {
|
return createTime;
|
}
|
|
public void setCreateTime(LocalDateTime createTime) {
|
this.createTime = createTime;
|
}
|
|
public LocalDateTime getUpdateTime() {
|
return updateTime;
|
}
|
|
public void setUpdateTime(LocalDateTime updateTime) {
|
this.updateTime = updateTime;
|
}
|
|
@PrePersist
|
protected void onCreate() {
|
LocalDateTime now = LocalDateTime.now();
|
this.createTime = now;
|
this.updateTime = now;
|
}
|
|
@PreUpdate
|
protected void onUpdate() {
|
this.updateTime = LocalDateTime.now();
|
}
|
}
|