admin
2022-10-28 0e9b6603d4ae9d11c1fbc90257ce816c5807b8ff
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package com.yeshi.makemoney.app.vo.msg;
 
import com.yeshi.makemoney.app.entity.msg.UserMsg;
import com.yeshi.makemoney.app.entity.msg.UserMsgType;
 
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * @author hxh
 * @title: UserMsgVO
 * @description: 用户消息
 * @date 2022/4/24 11:36
 */
public class UserMsgVO {
 
    private String id;
    private UserMsgTypeVO type;
    private List<UserMsgItemVO> contentList;
    private Date createTime;
 
 
    public static UserMsgVO create(UserMsg msg) {
        UserMsgVO vo = new UserMsgVO();
        vo.setCreateTime(msg.getCreateTime());
        vo.setId(msg.getId());
        vo.setType(UserMsgTypeVO.create(msg.getType()));
        vo.setContentList(msg.getContentList().stream().map(item -> {
            UserMsgItemVO itemVO = new UserMsgItemVO();
            itemVO.setTitle(item.getKey());
            itemVO.setContent(item.getValue());
            return itemVO;
        }).collect(Collectors.toList()));
        return vo;
    }
 
 
    public String getId() {
        return id;
    }
 
    public void setId(String id) {
        this.id = id;
    }
 
    public UserMsgTypeVO getType() {
        return type;
    }
 
    public void setType(UserMsgTypeVO type) {
        this.type = type;
    }
 
    public List<UserMsgItemVO> getContentList() {
        return contentList;
    }
 
    public void setContentList(List<UserMsgItemVO> contentList) {
        this.contentList = contentList;
    }
 
    public Date getCreateTime() {
        return createTime;
    }
 
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
 
    static class UserMsgItemVO {
        private String title;
        private String content;
 
        public static UserMsgItemVO create(UserMsg.UserMsgItem item) {
            UserMsgItemVO vo = new UserMsgItemVO();
            vo.setContent(item.getValue());
            vo.setTitle(item.getValue());
            return vo;
        }
 
        public String getTitle() {
            return title;
        }
 
        public void setTitle(String title) {
            this.title = title;
        }
 
        public String getContent() {
            return content;
        }
 
        public void setContent(String content) {
            this.content = content;
        }
    }
 
    static class UserMsgTypeVO {
        private String icon;
        private String name;
 
        public static UserMsgTypeVO create(UserMsgType type) {
            UserMsgTypeVO vo = new UserMsgTypeVO();
            vo.setIcon(type.getIcon());
            vo.setName(type.getName());
            return vo;
        }
 
        public String getIcon() {
            return icon;
        }
 
        public void setIcon(String icon) {
            this.icon = icon;
        }
 
        public String getName() {
            return name;
        }
 
        public void setName(String name) {
            this.name = name;
        }
    }
 
}