You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
3.0 KiB
Java

package com.ibeetl.jlw.entity;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.auth0.jwt.interfaces.Claim;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ibeetl.admin.core.entity.CoreUser;
import lombok.*;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* : <br>
*
*
* @Author: lx
* @Date: 2022/12/11 14:56
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ToString
public class LoginTodo implements Serializable {
private static final long serialVersionUID = 1257693451422916110L;
/**
* #{@link CoreUser#getCode}
*/
private String username;
/**
*
*/
private String password;
/**
* ID 3 4
*/
private String roleid;
/**
* ID
*/
private String teacherId;
/**
* ID
*/
private String studentId;
/**
* #{@link CoreUser#getName}
*/
private String name;
/**
*
*/
private String sex;
/**
*
*/
private String school;
/**
* ID
*/
private String schoolId;
/**
* ID
*/
private String applicationId;
/**
*
*/
private String college;
/**
*
*/
private String major;
/**
*
*/
@JsonProperty("class")
private String schoolClass;
/**
*
*/
private String studentNo;
/**
* ID
* 3 4
*/
@Getter
@RequiredArgsConstructor
public enum ThirdRole {
TEACHER_ROLE("3"), STUDENT_ROLE("4");
@JsonValue
final private String code;
}
/**
* JSON
* @return
*/
@SneakyThrows
public String toJSONString() {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return mapper.writeValueAsString(this);
}
public Map<String, ?> toMap() {
return JSONUtil.toBean(toJSONString(), HashMap.class);
}
/**
* : <br>
* JSON
*
* @return {@link LoginTodo}
* @Author: lx
* @Date: 2022/12/11 17:33
*/
@SneakyThrows
public static LoginTodo jsonToEntity(String json) {
if (ObjectUtil.isNotEmpty(json)) {
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(json, LoginTodo.class);
}
return null;
}
/**
* : <br>
* JSON
*
* @return {@link LoginTodo}
* @Author: lx
* @Date: 2022/12/11 17:33
*/
@SneakyThrows
public static LoginTodo jsonToEntity(Map<String, Claim> claims) {
if (ObjectUtil.isNotEmpty(claims)) {
Map<String, String> tempMap = new HashMap(20);
claims.forEach((key, val) -> {
tempMap.put(key, val.asString());
});
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(JSONUtil.toJsonStr(tempMap), LoginTodo.class);
}
return null;
}
}