| | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.moral.api.pojo.dto.login.AccountInfoDTO; |
| | | import com.moral.api.pojo.dto.login.LoginDTO; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import lombok.Data; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | |
| | | @Data |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | public class LoginVO { |
| | | /* |
| | | * 登陆成功 |
| | | * */ |
| | | public static final String SUCCESS = "0"; |
| | | |
| | | /* |
| | | * 用户不存在 |
| | | * */ |
| | | public static final String NOT_EXIST = "-1"; |
| | | |
| | | /* |
| | | * 用户已被封禁 |
| | | * */ |
| | | public static final String IS_DELETE = "-2"; |
| | | |
| | | /* |
| | | * 密码错误 |
| | | * */ |
| | | public static final String PASSWORD_ERROR = "-3"; |
| | | |
| | | /* |
| | | * 角色尚未分配 |
| | | * */ |
| | | public static final String ROLE_EMPTY = "-4"; |
| | | |
| | | /* |
| | | * 菜单尚未分配 |
| | | * */ |
| | | public static final String MENU_EMPTY = "-5"; |
| | | |
| | | /* |
| | | * 状态码 |
| | | * */ |
| | | private String code; |
| | | |
| | | /* |
| | | *用户token |
| | |
| | | * @Date: 2021/3/13 |
| | | */ |
| | | public static LoginVO convert(LoginDTO dto) { |
| | | if (dto.getCode() != ResponseCodeEnum.SUCCESS.getCode()) |
| | | return null; |
| | | |
| | | LoginVO vo = new LoginVO(); |
| | | String code = dto.getCode(); |
| | | String token = dto.getToken(); |
| | | AccountInfoDTO accountInfoDTO = dto.getAccountInfoDTO(); |
| | | if (!ObjectUtils.isEmpty(accountInfoDTO)) { |
| | | AccountInfoVO accountInfoVO = AccountInfoVO.convert(accountInfoDTO); |
| | | vo.setAccountInfoVO(accountInfoVO); |
| | | } |
| | | AccountInfoVO accountInfoVO = AccountInfoVO.convert(accountInfoDTO); |
| | | vo.setAccountInfoVO(accountInfoVO); |
| | | vo.setToken(token); |
| | | vo.setCode(code); |
| | | return vo; |
| | | } |
| | | } |