package com.moral.api.pojo.vo.account;
|
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.moral.api.entity.ManageRole;
|
import com.moral.api.pojo.dto.account.AccountInsertDTO;
|
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 AccountInsertVO extends 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;
|
|
|
/**
|
* @Description: 用于插入账户返回数据使用
|
* @Param: [dto]
|
* @return: com.moral.api.pojo.vo.account.AccountVO
|
* @Author: 陈凯裕
|
* @Date: 2021/3/15
|
*/
|
public static AccountInsertVO convert(AccountInsertDTO dto){
|
AccountInsertVO vo = new AccountInsertVO();
|
if(dto.getCode()== AccountInsertDTO.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;
|
}
|
|
}
|