skyouc
2024-12-21 c635d78b479510ebe2556a420948effcd30a0731
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.zy.asrs.common.sys.entity;
 
 
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zy.asrs.common.sys.service.UserService;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SpringUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
 
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
 
@Data
@TableName("sys_user_login")
public class UserLogin implements Serializable {
 
    private static final long serialVersionUID = 1L;
 
    /**
     * 编号
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
 
    /**
     * 仓库
     */
    @ApiModelProperty(value= "仓库")
    private Long hostId;
 
    /**
     * 员工
     */
    private Long userId;
 
    /**
     * 类型 0: 登录成功  1: 登录失败  2: 退出登录  3: 续签token
     */
    @ApiModelProperty(value= "类型 0: 登录成功  1: 登录失败  2: 退出登录  3: 续签token")
    private Integer type;
 
    /**
     * 凭证值
     */
    private String token;
 
    /**
     * 添加时间
     */
    private Date createTime;
 
    /**
     * 登陆系统
     */
    private String system;
 
    public String getUserUsername(){
        UserService service = SpringUtils.getBean(UserService.class);
        User user = service.getById(this.userId);
        if (!Cools.isEmpty(user)){
            return user.getUsername();
        }
        return null;
    }
 
    public String getCreateTime$(){
        if (Cools.isEmpty(this.createTime)){
            return "";
        }
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime);
    }
 
    public String getType$(){
        if (Cools.isEmpty(this.getType())){
            return "";
        }
        //0: 登录成功  1: 登录失败  2: 退出登录  3: 续签token
        switch (this.getType()) {
            case 0:
                return "登录成功";
            case 1:
                return "登录失败";
            case 2:
                return "退出登录";
            case 3:
                return "续签token";
            default:
                return String.valueOf(this.getType());
        }
    }
 
}