| | |
| | | import com.moral.api.entity.ManageRole; |
| | | import com.moral.api.pojo.dto.account.AccountInsertDTO; |
| | | import com.moral.api.pojo.dto.account.AccountUpdateDTO; |
| | | 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 AccountUpdateVO extends AccountVO{ |
| | | /* |
| | | * 更新成功 |
| | | * */ |
| | | public static final String SUCCESS = "0"; |
| | | public class AccountUpdateVO extends AccountVO { |
| | | |
| | | /* |
| | | * 用户不存在 |
| | | * */ |
| | | public static final String ACCOUNT_NOT_EXIST = "-1"; |
| | | public static AccountUpdateVO convert(AccountUpdateDTO dto) { |
| | | if (dto.getCode() != ResponseCodeEnum.SUCCESS.getCode()) |
| | | return null; |
| | | |
| | | /* |
| | | * 手机号不符合规则 |
| | | * */ |
| | | public static final String MOBILE_INVALID = "-2"; |
| | | |
| | | /* |
| | | * 邮箱不符合规则 |
| | | * */ |
| | | public static final String EMAIL_INVALID = "-3"; |
| | | |
| | | public static AccountUpdateVO convert(AccountUpdateDTO dto){ |
| | | AccountUpdateVO vo = new AccountUpdateVO(); |
| | | if(dto.getCode()== AccountUpdateDTO.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())); |
| | | 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(); |
| | | |
| | | vo.setId(id); |
| | | vo.setUserName(userName); |
| | | vo.setEmail(email); |
| | | vo.setMobile(mobile); |
| | | vo.setWechat(wechat); |
| | | vo.setRoleNames(roleNames); |
| | | //转换成角色名集合 |
| | | 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; |
| | | } |
| | | } |