修改表单细节
This commit is contained in:
parent
5fe147a973
commit
8257edba57
|
@ -11,6 +11,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.modules.entity.CeesLocalTeacher;
|
import org.jeecg.modules.entity.CeesLocalTeacher;
|
||||||
|
import org.jeecg.modules.enums.MajorEnum;
|
||||||
import org.jeecg.modules.service.ICeesLocalTeacherService;
|
import org.jeecg.modules.service.ICeesLocalTeacherService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -53,6 +54,7 @@ public class CeesLocalTeacherController extends JeecgController<CeesLocalTeacher
|
||||||
QueryWrapper<CeesLocalTeacher> queryWrapper = QueryGenerator.initQueryWrapper(ceesLocalTeacher, req.getParameterMap());
|
QueryWrapper<CeesLocalTeacher> queryWrapper = QueryGenerator.initQueryWrapper(ceesLocalTeacher, req.getParameterMap());
|
||||||
Page<CeesLocalTeacher> page = new Page<CeesLocalTeacher>(pageNo, pageSize);
|
Page<CeesLocalTeacher> page = new Page<CeesLocalTeacher>(pageNo, pageSize);
|
||||||
IPage<CeesLocalTeacher> pageList = ceesLocalTeacherService.page(page, queryWrapper);
|
IPage<CeesLocalTeacher> pageList = ceesLocalTeacherService.page(page, queryWrapper);
|
||||||
|
pageList.convert(e->e.setMajorIdDescription(MajorEnum.describe(e.getMajorId())));
|
||||||
return Result.OK(pageList);
|
return Result.OK(pageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.modules.entity.CeesWaiTeacher;
|
import org.jeecg.modules.entity.CeesWaiTeacher;
|
||||||
|
import org.jeecg.modules.enums.MajorEnum;
|
||||||
import org.jeecg.modules.service.ICeesWaiTeacherService;
|
import org.jeecg.modules.service.ICeesWaiTeacherService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -54,6 +55,7 @@ public class CeesWaiTeacherController extends JeecgController<CeesWaiTeacher, IC
|
||||||
QueryWrapper<CeesWaiTeacher> queryWrapper = QueryGenerator.initQueryWrapper(ceesWaiTeacher, req.getParameterMap());
|
QueryWrapper<CeesWaiTeacher> queryWrapper = QueryGenerator.initQueryWrapper(ceesWaiTeacher, req.getParameterMap());
|
||||||
Page<CeesWaiTeacher> page = new Page<CeesWaiTeacher>(pageNo, pageSize);
|
Page<CeesWaiTeacher> page = new Page<CeesWaiTeacher>(pageNo, pageSize);
|
||||||
IPage<CeesWaiTeacher> pageList = ceesWaiTeacherService.page(page, queryWrapper);
|
IPage<CeesWaiTeacher> pageList = ceesWaiTeacherService.page(page, queryWrapper);
|
||||||
|
pageList.convert(e->e.setMajorIdDescription(MajorEnum.describe(e.getMajorId())));
|
||||||
return Result.OK(pageList);
|
return Result.OK(pageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.modules.entity.Student;
|
import org.jeecg.modules.entity.Student;
|
||||||
|
import org.jeecg.modules.enums.MajorEnum;
|
||||||
import org.jeecg.modules.service.IStudentService;
|
import org.jeecg.modules.service.IStudentService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -54,6 +55,7 @@ public class StudentController extends JeecgController<Student, IStudentService>
|
||||||
QueryWrapper<Student> queryWrapper = QueryGenerator.initQueryWrapper(student, req.getParameterMap());
|
QueryWrapper<Student> queryWrapper = QueryGenerator.initQueryWrapper(student, req.getParameterMap());
|
||||||
Page<Student> page = new Page<Student>(pageNo, pageSize);
|
Page<Student> page = new Page<Student>(pageNo, pageSize);
|
||||||
IPage<Student> pageList = studentService.page(page, queryWrapper);
|
IPage<Student> pageList = studentService.page(page, queryWrapper);
|
||||||
|
pageList.convert(e->e.setMajorIdDescription(MajorEnum.describe(e.getMajorId())));
|
||||||
return Result.OK(pageList);
|
return Result.OK(pageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.jeecg.modules.entity;
|
package org.jeecg.modules.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
@ -60,10 +61,15 @@ public class CeesLocalTeacher implements Serializable {
|
||||||
@Excel(name = "用户名", width = 15)
|
@Excel(name = "用户名", width = 15)
|
||||||
@ApiModelProperty(value = "用户名")
|
@ApiModelProperty(value = "用户名")
|
||||||
private String userName;
|
private String userName;
|
||||||
/**专业id,0表示未选择*/
|
/**专业id*/
|
||||||
@Excel(name = "专业id,0表示未选择", width = 15)
|
@Excel(name = "学科ID", width = 15)
|
||||||
@ApiModelProperty(value = "专业id,0表示未选择")
|
@ApiModelProperty(value = "学科ID")
|
||||||
private Integer majorId;
|
private Integer majorId;
|
||||||
|
/**专业id*/
|
||||||
|
@Excel(name = "学科描述", width = 15)
|
||||||
|
@ApiModelProperty(value = "专业id")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String majorIdDescription;
|
||||||
/**用户专业id*/
|
/**用户专业id*/
|
||||||
@Excel(name = "用户专业id", width = 15)
|
@Excel(name = "用户专业id", width = 15)
|
||||||
@ApiModelProperty(value = "用户专业id")
|
@ApiModelProperty(value = "用户专业id")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.jeecg.modules.entity;
|
package org.jeecg.modules.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
@ -57,9 +58,14 @@ public class CeesWaiTeacher implements Serializable {
|
||||||
@ApiModelProperty(value = "用户id")
|
@ApiModelProperty(value = "用户id")
|
||||||
private String userId;
|
private String userId;
|
||||||
/**专业id*/
|
/**专业id*/
|
||||||
@Excel(name = "专业id", width = 15)
|
@Excel(name = "学科ID", width = 15)
|
||||||
@ApiModelProperty(value = "专业id")
|
@ApiModelProperty(value = "学科ID")
|
||||||
private Integer majorId;
|
private Integer majorId;
|
||||||
|
/**专业id*/
|
||||||
|
@Excel(name = "学科描述", width = 15)
|
||||||
|
@ApiModelProperty(value = "专业id")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String majorIdDescription;
|
||||||
/**用户专业id*/
|
/**用户专业id*/
|
||||||
@Excel(name = "用户专业id", width = 15)
|
@Excel(name = "用户专业id", width = 15)
|
||||||
@ApiModelProperty(value = "用户专业id")
|
@ApiModelProperty(value = "用户专业id")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.jeecg.modules.entity;
|
package org.jeecg.modules.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
@ -60,10 +61,15 @@ public class Student implements Serializable {
|
||||||
@Excel(name = "用户名", width = 15)
|
@Excel(name = "用户名", width = 15)
|
||||||
@ApiModelProperty(value = "用户名")
|
@ApiModelProperty(value = "用户名")
|
||||||
private String userName;
|
private String userName;
|
||||||
/**专业id,0表示未选择*/
|
/**专业id*/
|
||||||
@Excel(name = "专业id,0表示未选择", width = 15)
|
@Excel(name = "学科ID", width = 15)
|
||||||
@ApiModelProperty(value = "专业id,0表示未选择")
|
@ApiModelProperty(value = "学科ID")
|
||||||
private Integer majorId;
|
private Integer majorId;
|
||||||
|
/**专业id*/
|
||||||
|
@Excel(name = "学科描述", width = 15)
|
||||||
|
@ApiModelProperty(value = "专业id")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String majorIdDescription;
|
||||||
/**用户专业id*/
|
/**用户专业id*/
|
||||||
@Excel(name = "用户专业id", width = 15)
|
@Excel(name = "用户专业id", width = 15)
|
||||||
@ApiModelProperty(value = "用户专业id")
|
@ApiModelProperty(value = "用户专业id")
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
package org.jeecg.modules.enums;
|
||||||
|
|
||||||
|
import org.jeecg.modules.utils.EnumUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
|
public enum MajorEnum {
|
||||||
|
/**
|
||||||
|
* 语文
|
||||||
|
*/
|
||||||
|
CHINESE(1, "语文"),
|
||||||
|
/**
|
||||||
|
* 地理
|
||||||
|
*/
|
||||||
|
GEOGRAPHY(4, "地理"),
|
||||||
|
/**
|
||||||
|
* 历史
|
||||||
|
*/
|
||||||
|
HISTORY(7, "历史"),
|
||||||
|
/**
|
||||||
|
* 政治
|
||||||
|
*/
|
||||||
|
POLITICS(8, "政治");
|
||||||
|
|
||||||
|
|
||||||
|
private Integer value;
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
MajorEnum(Integer value, String label) {
|
||||||
|
this.value = value;
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<MajorEnum> valueOf(Integer typeId) {
|
||||||
|
return EnumUtil.getEnumObject(MajorEnum.class, e -> Objects.equals(e.getValue(), typeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String describe(Integer typeId) {
|
||||||
|
return MajorEnum.valueOf(typeId).map(MajorEnum::getLabel).orElse("");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Map<String, Object>> getOptionList() {
|
||||||
|
return EnumUtil.getEnumOptionList(MajorEnum.class,
|
||||||
|
MajorEnum::getLabel,
|
||||||
|
MajorEnum::getValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package org.jeecg.modules.utils;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
public class EnumUtil {
|
||||||
|
private static Map<Class, Object> map = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件获取枚举对象
|
||||||
|
*
|
||||||
|
* @param className 枚举类
|
||||||
|
* @param predicate 筛选条件
|
||||||
|
* @param <T>
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static <T> Optional<T> getEnumObject(Class<T> className, Predicate<T> predicate) {
|
||||||
|
if (!className.isEnum()) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
Object obj = map.get(className);
|
||||||
|
T[] ts = null;
|
||||||
|
if (obj == null) {
|
||||||
|
ts = className.getEnumConstants();
|
||||||
|
map.put(className, ts);
|
||||||
|
} else {
|
||||||
|
ts = (T[]) obj;
|
||||||
|
}
|
||||||
|
return Arrays.stream(ts).filter(predicate).findFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取枚举类的选项列表
|
||||||
|
* @param enumClass 枚举类的Class对象
|
||||||
|
* @param labelExtractor label值提取器
|
||||||
|
* @param valueExtractor value值提取器
|
||||||
|
* @param <T> 枚举类的泛型类型
|
||||||
|
* @param <L> labelExtractor返回值的泛型类型
|
||||||
|
* @param <V> valueExtractor返回值的泛型类型
|
||||||
|
* @return 选项列表
|
||||||
|
*/
|
||||||
|
public static <T extends Enum<T>, L, V> List<Map<String, Object>> getEnumOptionList(Class<T> enumClass, Function<T, L> labelExtractor, Function<T, V> valueExtractor) {
|
||||||
|
T[] enumConstants = enumClass.getEnumConstants();
|
||||||
|
List<Map<String, Object>> optionList = new ArrayList<>();
|
||||||
|
for (T enumConstant : enumConstants) {
|
||||||
|
Map<String, Object> option = new HashMap<>();
|
||||||
|
option.put("label", labelExtractor.apply(enumConstant));
|
||||||
|
option.put("value", valueExtractor.apply(enumConstant));
|
||||||
|
optionList.add(option);
|
||||||
|
}
|
||||||
|
return optionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue