Commit 293bf5fd by 谢海旭

学习中心:培训计划新增、培训计划生效或失效、培训计划详情

1 parent 58ed6882
......@@ -16,6 +16,6 @@ public class TrainingPlanCourseDetailDTO {
* 课程详情-课程详细信息
*/
@ApiModelProperty(notes = "课程详情-课程详细信息")
private Object courseDetail;
private CoursePageInfo courseDetail;
}
\ No newline at end of file
......@@ -105,7 +105,7 @@ public class TrainingPlanDetailDTO {
private String deletedFlag;
@ApiModelProperty(notes = "课程,map结构,Map<考试等级id, Map<必|选修, 课程信息>>,1:必修, 2:选修")
private Map<Integer, Map<Integer, List<TrainingPlanCourseDetailDTO>>> courseMap;
private Map<Integer, Map<Byte, List<TrainingPlanCourseDetailDTO>>> courseMap;
@ApiModelProperty(notes = "白名单名称列表")
private List<String> whiteNameList;
......
package cn.com.glsx.dj.riskmanage.enums.learningcenter;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2025/12/1
**/
public enum TrainingPlanCourseTypeEnum {
REQUIRED((byte) 1, "必修"),
OPTIONAL((byte) 2, "选修");
private byte value;
private String desc;
TrainingPlanCourseTypeEnum(byte value, String desc) {
this.value = value;
this.desc = desc;
}
public byte getValue() {
return value;
}
public String getDesc() {
return desc;
}
public static TrainingPlanCourseTypeEnum getByValue(byte value) {
for (TrainingPlanCourseTypeEnum item : values()) {
if (item.value == value) {
return item;
}
}
return null;
}
public static TrainingPlanCourseTypeEnum getByDesc(String desc) {
for (TrainingPlanCourseTypeEnum item : values()) {
if (item.desc.equals(desc)) {
return item;
}
}
return null;
}
}
package cn.com.glsx.dj.riskmanage.enums.learningcenter;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2025/12/1
**/
public enum TrainingPlanOrderPermissionStatusEnum {
NOT_ENABLED((byte) 0, "不启用"),
ENABLED((byte) 1, "启用"),
;
private byte value;
private String desc;
TrainingPlanOrderPermissionStatusEnum(byte value, String desc) {
this.value = value;
this.desc = desc;
}
public byte getValue() {
return value;
}
public String getDesc() {
return desc;
}
public static String getDescByValue(byte value) {
for (TrainingPlanOrderPermissionStatusEnum item : values()) {
if (item.getValue() == value) {
return item.getDesc();
}
}
return null;
}
public static byte getValueByDesc(String desc) {
for (TrainingPlanOrderPermissionStatusEnum item : values()) {
if (item.getDesc().equals(desc)) {
return item.getValue();
}
}
return -1;
}
}
package cn.com.glsx.dj.riskmanage.enums.learningcenter;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2025/12/1
**/
public enum TrainingPlanStatusEnum {
DRAFT((byte) 0, "草稿"),
EFFECTIVE((byte) 1, "生效"),
INVALID((byte) 2, "失效");
private byte value;
private String desc;
TrainingPlanStatusEnum(byte value, String desc) {
this.value = value;
this.desc = desc;
}
public byte getValue() {
return value;
}
public String getDesc() {
return desc;
}
public static String getDescByValue(byte value) {
for (TrainingPlanStatusEnum item : TrainingPlanStatusEnum.values()) {
if (item.getValue() == value) {
return item.getDesc();
}
}
return null;
}
public static byte getValueByDesc(String desc) {
for (TrainingPlanStatusEnum item : TrainingPlanStatusEnum.values()) {
if (item.getDesc().equals(desc)) {
return item.getValue();
}
}
return -1;
}
}
......@@ -2,6 +2,7 @@ package cn.com.glsx.dj.riskmanage.remote;
import cn.com.glsx.dj.riskmanage.dto.beisen.BeiSenEmployeeDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.TrainingPlanDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.TrainingPlanDetailDTO;
import cn.com.glsx.framework.core.annotation.*;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
......@@ -18,4 +19,18 @@ public interface LearningCenterTrainingPlanRemote {
@ApiParam(name = "pagination", notes = "分页信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("分页查询")
RpcResponse<RpcPagination<BeiSenEmployeeDTO>> beiSenEmployeePage(RpcPagination<BeiSenEmployeeDTO> pagination);
@ApiMethod("新增培训计划")
@ApiParam(name = "dto", notes = "新增培训计划信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("培训计划id")
RpcResponse<Integer> addTrainingPlan(TrainingPlanDetailDTO request);
@ApiMethod("培训计划-失效|生效")
@ApiParam(name = "dto", notes = "培训计划信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
RpcResponse<String> trainingPlanStatusToggle(TrainingPlanDetailDTO request);
@ApiMethod("查询培训计划详情")
@ApiParam(name = "id", notes = "培训计划id", dataType = ApiParam.DataTypeEnum.INTEGER, required = true)
@ApiResponse("培训计划详情")
RpcResponse<TrainingPlanDetailDTO> trainingPlanDetail(Integer id);
}
package cn.com.glsx.dj.riskmanage.remote.learningcenter;
import cn.com.glsx.dj.riskmanage.dto.beisen.BeiSenEmployeeDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamPersonDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.TrainingPlanDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.TrainingPlanDetailDTO;
import cn.com.glsx.dj.riskmanage.remote.LearningCenterTrainingPlanRemote;
import cn.com.glsx.dj.riskmanage.service.learningcenter.LearningCenterTrainingPlanService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
......@@ -17,12 +17,12 @@ import org.springframework.beans.factory.annotation.Autowired;
@DubboService(retries = 0, timeout = 30000)
public class LearningCenterTrainingPlanRemoteImpl implements LearningCenterTrainingPlanRemote {
@Autowired
private LearningCenterTrainingPlanService learningCenterTrainingPlanService;
private LearningCenterTrainingPlanService trainingPlanService;
@Override
public RpcResponse<RpcPagination<TrainingPlanDTO>> listWithPage(RpcPagination<TrainingPlanDTO> pagination) {
try {
return RpcResponse.success(RpcPagination.copyPage(learningCenterTrainingPlanService.listWithPage(pagination)));
return RpcResponse.success(RpcPagination.copyPage(trainingPlanService.listWithPage(pagination)));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
......@@ -32,7 +32,7 @@ public class LearningCenterTrainingPlanRemoteImpl implements LearningCenterTrain
@Override
public RpcResponse<RpcPagination<BeiSenEmployeeDTO>> beiSenEmployeePage(RpcPagination<BeiSenEmployeeDTO> pagination) {
try {
Page<BeiSenEmployeeDTO> page = learningCenterTrainingPlanService.beiSenEmployeePage(pagination);
Page<BeiSenEmployeeDTO> page = trainingPlanService.beiSenEmployeePage(pagination);
return RpcResponse.success(RpcPagination.copyPage(page));
}catch(RpcServiceException e){
log.error(e.getMessage(),e);
......@@ -42,4 +42,46 @@ public class LearningCenterTrainingPlanRemoteImpl implements LearningCenterTrain
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<Integer> addTrainingPlan(TrainingPlanDetailDTO request) {
try {
Integer id = trainingPlanService.addTrainingPlan(request);
return RpcResponse.success(id);
}catch(RpcServiceException e){
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}catch(Exception e){
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<String> trainingPlanStatusToggle(TrainingPlanDetailDTO request) {
try {
trainingPlanService.trainingPlanStatusToggle(request);
return RpcResponse.success("success");
}catch(RpcServiceException e){
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}catch(Exception e){
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<TrainingPlanDetailDTO> trainingPlanDetail(Integer id) {
try {
TrainingPlanDetailDTO detail = trainingPlanService.trainingPlanDetail(id);
return RpcResponse.success(detail);
}catch(RpcServiceException e){
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}catch(Exception e){
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
}
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

    1. TrainingPlanCourseDetailDTO 类

    问题描述:

    • courseDetail 字段类型从 Object 改为 CoursePageInfo,这是一个好的改进,但需要确保 CoursePageInfo 类已经定义并且包含了所有必要的信息。

    优化建议:

    • 确认 CoursePageInfo 类的定义,确保它包含了所有必要的属性和方法。
    • 添加必要的 Javadoc 注释以提高代码可读性。

    2. TrainingPlanDetailDTO 类

    问题描述:

    • courseMap 的键类型从 Integer 改为 Byte,这可能会影响代码的可读性和可维护性。通常情况下,枚举类型更适合用于表示有限且明确的状态。

    优化建议:

    • 考虑将 Byte 键类型改为 TrainingPlanCourseTypeEnum 枚举类型,这样可以提高代码的可读性和类型安全性。

    3. 新增的枚举类

    问题描述:

    • 新增的枚举类 TrainingPlanCourseTypeEnum, TrainingPlanOrderPermissionStatusEnum, 和 TrainingPlanStatusEnum 都有 getValue 和 getDesc 方法,但它们的 getByValue 和 getByDesc 方法返回值类型不一致。

    优化建议:

    • 统一 getByValue 和 getByDesc 方法的返回值类型,例如都返回枚举类型本身而不是 String 或 byte。如果需要返回特定的值或描述,可以通过调用相应的方法来获取。

    4. LearningCenterTrainingPlanRemote 接口

    问题描述:

    • 新增的方法 addTrainingPlan, trainingPlanStatusToggle, 和 trainingPlanDetail 使用了 TrainingPlanDetailDTO 作为参数和返回值,但没有对这些 DTO 的字段进行验证。

    优化建议:

    • 添加必要的验证逻辑,确保传入的 DTO 对象满足业务需求。可以使用 @Valid 注解和自定义校验注解来实现。

    5. LearningCenterTrainingPlanRemoteImpl 类

    问题描述:

    • 所有的远程方法都捕获了 Exception 异常,这可能会隐藏潜在的问题并且不利于调试。

    优化建议:

    • 只捕获具体的异常类型,而不是 Exception。这样可以更好地控制错误处理流程,并且更容易调试和定位问题。

    6. LearningCenterTrainingPlanService 类

    问题描述:

    • 在 addTrainingPlan 方法中,使用了多个 Example 对象来查询数据库,这可能会导致性能问题,特别是在数据量较大的情况下。

    优化建议:

    • 考虑使用更高效的查询方式,例如批量查询或者优化 SQL 语句。此外,可以考虑缓存一些静态数据,减少数据库访问次数。

    评分明细

    1. 功能实现的正确性与健壮性(40分):

      • 代码逻辑基本正确,但需要进一步完善异常处理和输入验证。
      • 评分: 35分
    2. 安全性与潜在风险(30分):

      • 代码中没有明显的安全漏洞,但需要增加输入验证以防止潜在的安全问题。
      • 评分: 25分
    3. 是否符合最佳实践(20分):

      • 代码结构合理,但可以进一步优化枚举类的设计和异常处理机制。
      • 评分: 18分
    4. 性能与资源利用效率(5分):

      • 代码中有多次数据库查询,可能存在性能瓶颈。
      • 评分: 3分
    5. Commits信息的清晰性与准确性(5分):

      • 提交信息简洁明了,便于理解。
      • 评分: 5分

    总分: 86分


    以上是对员工提交代码的审查报告,希望这些建议能够帮助改进代码质量。

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!