| | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.moral.api.entity.ManageRole; |
| | | import com.moral.api.pojo.dto.account.AccountInsertDTO; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import lombok.Data; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | @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"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * @Description: 用于插入账户返回数据使用 |
| | | * @Param: [dto] |
| | | * @return: com.moral.api.pojo.vo.account.AccountVO |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/15 |
| | | */ |
| | | public static AccountInsertVO convert(AccountInsertDTO dto){ |
| | | * @Description: 用于插入账户返回数据使用 |
| | | * @Param: [dto] |
| | | * @return: com.moral.api.pojo.vo.account.AccountVO |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/15 |
| | | */ |
| | | public static AccountInsertVO convert(AccountInsertDTO dto) { |
| | | if (dto.getCode() != ResponseCodeEnum.SUCCESS.getCode()) |
| | | return null; |
| | | |
| | | 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(); |
| | | |
| | | //转换成角色名集合 |
| | | 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.setRoleNames(roleNames); |
| | | 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(); |
| | | //转换成角色名集合 |
| | | List<ManageRole> roles = dto.getRoles(); |
| | | List<String> roleNames = new ArrayList<>(); |
| | | if (!ObjectUtils.isEmpty(roles)) { |
| | | roles.forEach(role -> roleNames.add(role.getName())); |
| | | } |
| | | vo.setId(id); |
| | | vo.setUserName(userName); |
| | | vo.setEmail(email); |
| | | vo.setMobile(mobile); |
| | | vo.setWechat(wechat); |
| | | vo.setRoleNames(roleNames); |
| | | |
| | | String code = dto.getCode(); |
| | | vo.setCode(code); |
| | | return vo; |
| | | } |
| | | |