学段修改
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.yunhai.bschclassmanage.enums;
|
||||
|
||||
import com.yunhai.bschclassmanage.model.vo.SelectIntVO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -7,6 +8,8 @@ import lombok.NoArgsConstructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@@ -22,8 +25,72 @@ public enum AcademicStage
|
||||
private Integer key;
|
||||
private String value;
|
||||
|
||||
|
||||
AcademicStage(int key, String value)
|
||||
{
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setId(int id)
|
||||
{
|
||||
this.key = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.value = name;
|
||||
}
|
||||
|
||||
public static List<AcademicStage> list()
|
||||
{
|
||||
return new ArrayList<>(EnumSet.allOf(AcademicStage.class));
|
||||
}
|
||||
|
||||
public static List<SelectIntVO> select() {
|
||||
List<SelectIntVO> list= list().stream()
|
||||
.map(type -> new SelectIntVO(type.getId(), type.getName()))
|
||||
.collect(Collectors.toList());
|
||||
return new ArrayList<>(list);
|
||||
}
|
||||
|
||||
public static Map<Integer, AcademicStage> map()
|
||||
{
|
||||
return list().stream().collect(Collectors.toMap(AcademicStage::getId, QuestionType->QuestionType));
|
||||
}
|
||||
|
||||
public static String nameById(int id) {
|
||||
for (AcademicStage type : list()) {
|
||||
if (type.getId() == id) return type.getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static Integer getIdByName(String name) {
|
||||
for (AcademicStage type : list()) {
|
||||
if (type.getName().equals(name)) return type.getId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static AcademicStage getById(int id)
|
||||
{
|
||||
for (AcademicStage na : list())
|
||||
{
|
||||
if (na.getId() == id)
|
||||
{
|
||||
return na;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user