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;
|
}
|
}
|
|
}
|