package com.moral.api.pojo.vo;
|
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.moral.api.entity.ManageRole;
|
import com.moral.api.pojo.dto.AccountDTO;
|
import lombok.Data;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* @ClassName AccountVO
|
* @Description TODO
|
* @Author 陈凯裕
|
* @Date 2021/3/13 17:25
|
* @Version TODO
|
**/
|
@Data
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
public class AccountVO {
|
/*
|
* 添加成功
|
* */
|
public static final String SUCCESS = "0";
|
|
/*
|
* 账号长度不符合规则
|
* */
|
public static final String ACCOUNT_LENGTH_INVALID = "-1";
|
|
/*
|
* 密码长度不符合规则
|
* */
|
public static final String PASSWORD_LENGTH_INVALID = "-2";
|
|
/*
|
* 手机号不符合规则
|
* */
|
public static final String MOBILE_INVALID = "-3";
|
|
/*
|
* 邮箱不符合规则
|
* */
|
public static final String EMAIL_INVALID = "-4";
|
|
/*
|
* 用户名已经存在
|
* */
|
public static final String ACCOUNT_EXIST = "-5";
|
|
/*
|
* 用户名包含特殊字符
|
* */
|
public static final String ACCOUNT_EXIST_SPECIAL_CHAR = "-6";
|
|
/*
|
* 密码包含特殊字符
|
* */
|
public static final String PASSWORD_EXIST_SPECIAL_CHAR = "-7";
|
|
private String code;
|
|
private Integer id;
|
|
private String userName;
|
|
private String password;
|
|
private String email;
|
|
private String mobile;
|
|
private String wechat;
|
|
private String createTime;
|
|
private String updateTime;
|
|
private String isDelete;
|
|
private List<String> roleNames;
|
|
private List<ManageRole> roles;
|
|
public static AccountVO convertToInsert(AccountDTO dto){
|
AccountVO vo = new AccountVO();
|
if(dto.getCode()==AccountDTO.SUCCESS){
|
Integer id = dto.getAccount().getId();
|
String userName = dto.getAccount().getUserName();
|
String email = dto.getAccount().getEmail();
|
String mobile = dto.getAccount().getMobile();
|
String wechat = dto.getAccount().getWechat();
|
String isDelete = dto.getAccount().getIsDelete();
|
|
//转换成角色名集合
|
List<ManageRole> roles = dto.getRoles();
|
List<String> roleNames = new ArrayList<>();
|
roles.forEach(role->roleNames.add(role.getName()));
|
|
vo.setId(id);
|
vo.setUserName(userName);
|
vo.setEmail(email);
|
vo.setMobile(mobile);
|
vo.setWechat(wechat);
|
vo.setIsDelete(isDelete);
|
vo.setRoleNames(roleNames);
|
}
|
|
String code = dto.getCode();
|
vo.setCode(code);
|
return vo;
|
}
|
|
}
|