caozixuan 1 жил өмнө
parent
commit
0446379ef3

+ 68 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/CourseWeightDetailDto.java

@@ -0,0 +1,68 @@
+package com.qmth.distributed.print.business.bean.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+
+/**
+ * @Description: 课程评价方式权重详情
+ * @Author: CaoZixuan
+ * @Date: 2024-03-01
+ */
+public class CourseWeightDetailDto {
+
+    @ApiModelProperty("评价方式id")
+    private Long evaluationId;
+
+    @ApiModelProperty("评价方式名称")
+    private String evaluationName;
+
+    @ApiModelProperty("是否启用")
+    private Boolean enable;
+
+    @ApiModelProperty("权重")
+    private BigDecimal weight;
+
+    @ApiModelProperty("目标分值")
+    private BigDecimal targetScore;
+
+    public Long getEvaluationId() {
+        return evaluationId;
+    }
+
+    public void setEvaluationId(Long evaluationId) {
+        this.evaluationId = evaluationId;
+    }
+
+    public String getEvaluationName() {
+        return evaluationName;
+    }
+
+    public void setEvaluationName(String evaluationName) {
+        this.evaluationName = evaluationName;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    public BigDecimal getWeight() {
+        return weight;
+    }
+
+    public void setWeight(BigDecimal weight) {
+        this.weight = weight;
+    }
+
+    public BigDecimal getTargetScore() {
+        return targetScore;
+    }
+
+    public void setTargetScore(BigDecimal targetScore) {
+        this.targetScore = targetScore;
+    }
+}

+ 80 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/CourseWeightDto.java

@@ -0,0 +1,80 @@
+package com.qmth.distributed.print.business.bean.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @Description: 课程权重dto
+ * @Author: CaoZixuan
+ * @Date: 2024-03-01
+ */
+public class CourseWeightDto {
+
+    @ApiModelProperty("课程目标id")
+    private Long courseTargetId;
+
+    @ApiModelProperty("课程目标名称")
+    private String courseTargetName;
+
+    @ApiModelProperty("毕业要求指标(评价依据)")
+    private List<CourseDimensionDto> dimensionList;
+
+    @ApiModelProperty("支撑毕业要求")
+    private String degreeRequirement;
+
+    @ApiModelProperty("目标整体权重")
+    private BigDecimal totalWeight;
+
+    @ApiModelProperty("评价方式权重详情")
+    private List<CourseWeightDetailDto> evaluationList;
+
+    public Long getCourseTargetId() {
+        return courseTargetId;
+    }
+
+    public void setCourseTargetId(Long courseTargetId) {
+        this.courseTargetId = courseTargetId;
+    }
+
+    public String getCourseTargetName() {
+        return courseTargetName;
+    }
+
+    public void setCourseTargetName(String courseTargetName) {
+        this.courseTargetName = courseTargetName;
+    }
+
+    public List<CourseDimensionDto> getDimensionList() {
+        return dimensionList;
+    }
+
+    public void setDimensionList(List<CourseDimensionDto> dimensionList) {
+        this.dimensionList = dimensionList;
+    }
+
+    public String getDegreeRequirement() {
+        return degreeRequirement;
+    }
+
+    public void setDegreeRequirement(String degreeRequirement) {
+        this.degreeRequirement = degreeRequirement;
+    }
+
+    public BigDecimal getTotalWeight() {
+        return totalWeight;
+    }
+
+    public void setTotalWeight(BigDecimal totalWeight) {
+        this.totalWeight = totalWeight;
+    }
+
+    public List<CourseWeightDetailDto> getEvaluationList() {
+        return evaluationList;
+    }
+
+    public void setEvaluationList(List<CourseWeightDetailDto> evaluationList) {
+        this.evaluationList = evaluationList;
+    }
+}

+ 59 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/CourseWeightParam.java

@@ -0,0 +1,59 @@
+package com.qmth.distributed.print.business.bean.params;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.bean.dto.CourseWeightDto;
+import io.swagger.annotations.ApiModelProperty;
+import org.hibernate.validator.constraints.Length;
+import org.hibernate.validator.constraints.Range;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * @Description: 课程权重设置参数
+ * @Author: CaoZixuan
+ * @Date: 2024-03-01
+ */
+public class CourseWeightParam {
+
+    @ApiModelProperty("考试id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    @NotNull(message = "缺少考试")
+    @Range(min = 1L, message = "缺少考试")
+    private Long examId;
+
+    @ApiModelProperty("课程编号(新增必填)")
+    @NotNull(message = "缺少课程编号")
+    @Length(min = 1, message = "缺少课程编号")
+    private String courseCode;
+
+    @ApiModelProperty("课程权重表单")
+    @NotEmpty(message = "缺少权重设置表单")
+    private List<CourseWeightDto> submitForm;
+
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public List<CourseWeightDto> getSubmitForm() {
+        return submitForm;
+    }
+
+    public void setSubmitForm(List<CourseWeightDto> submitForm) {
+        this.submitForm = submitForm;
+    }
+}

+ 12 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/CourseEvaluationResult.java

@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.bean.result;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.enums.CourseEvaluationTypeEnum;
 import io.swagger.annotations.ApiModelProperty;
 
 /**
@@ -21,6 +22,9 @@ public class CourseEvaluationResult {
     @ApiModelProperty("课程评价方式描述")
     private String evaluationDesc;
 
+    @ApiModelProperty("评价方式类型")
+    private CourseEvaluationTypeEnum type;
+
     public Long getEvaluationId() {
         return evaluationId;
     }
@@ -44,4 +48,12 @@ public class CourseEvaluationResult {
     public void setEvaluationDesc(String evaluationDesc) {
         this.evaluationDesc = evaluationDesc;
     }
+
+    public CourseEvaluationTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(CourseEvaluationTypeEnum type) {
+        this.type = type;
+    }
 }

+ 13 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/CourseTargetResult.java

@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.distributed.print.business.bean.dto.CourseDimensionDto;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -14,6 +15,7 @@ import java.util.List;
  * @Date: 2024-02-28
  */
 public class CourseTargetResult {
+
     @ApiModelProperty("课程目标id")
     @JsonSerialize(using = ToStringSerializer.class)
     private Long id;
@@ -31,6 +33,9 @@ public class CourseTargetResult {
     @ApiModelProperty("课程目标毕业要求")
     private List<CourseDimensionDto> dimensionList;
 
+    @ApiModelProperty("目标整体权重")
+    private BigDecimal totalWeight;
+
     public Long getId() {
         return id;
     }
@@ -70,4 +75,12 @@ public class CourseTargetResult {
     public void setDimensionList(List<CourseDimensionDto> dimensionList) {
         this.dimensionList = dimensionList;
     }
+
+    public BigDecimal getTotalWeight() {
+        return totalWeight;
+    }
+
+    public void setTotalWeight(BigDecimal totalWeight) {
+        this.totalWeight = totalWeight;
+    }
 }

+ 29 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/CourseWeightService.java

@@ -1,7 +1,12 @@
 package com.qmth.distributed.print.business.service;
 
+import com.qmth.distributed.print.business.bean.dto.CourseWeightDto;
+import com.qmth.distributed.print.business.bean.params.CourseWeightParam;
 import com.qmth.distributed.print.business.entity.CourseWeight;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.teachcloud.common.entity.SysUser;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +18,28 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface CourseWeightService extends IService<CourseWeight> {
 
+    /**
+     * 查询课程权重
+     *
+     * @param examId     考试id
+     * @param courseCode 课程编号
+     * @param userId     教师id
+     * @return 课程权重信息
+     */
+    List<CourseWeightDto> findCourseWeight(Long examId, String courseCode, Long userId);
+
+    /**
+     * 保存课程权重
+     *
+     * @param courseWeightParam 课程权重参数
+     * @param requestUser       请求人
+     */
+    void saveCourseWeight(CourseWeightParam courseWeightParam, SysUser requestUser);
+
+    /**
+     * 删除课程权重设置
+     *
+     * @param teachCourseId 教学课程id
+     */
+    void deleteCourseWeight(Long teachCourseId);
 }

+ 1 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/CourseTargetServiceImpl.java

@@ -63,6 +63,7 @@ public class CourseTargetServiceImpl extends ServiceImpl<CourseTargetMapper, Cou
             cell.setId(e.getId());
             cell.setTargetName(e.getTargetName());
             cell.setDegreeRequirement(e.getDegreeRequirement());
+            cell.setTotalWeight(e.getTotalWeight());
             String targetContent = e.getTargetContent();
             List<Long> dimensionIdList = JSON.parseArray(targetContent, Long.class);
             List<CourseDimensionDto> dimensionList = new ArrayList<>();

+ 220 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/CourseWeightServiceImpl.java

@@ -1,10 +1,37 @@
 package com.qmth.distributed.print.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.distributed.print.business.bean.dto.CourseDimensionDto;
+import com.qmth.distributed.print.business.bean.dto.CourseWeightDetailDto;
+import com.qmth.distributed.print.business.bean.dto.CourseWeightDto;
+import com.qmth.distributed.print.business.bean.params.CourseWeightParam;
+import com.qmth.distributed.print.business.bean.result.CourseEvaluationResult;
+import com.qmth.distributed.print.business.bean.result.CourseTargetResult;
+import com.qmth.distributed.print.business.entity.CourseTarget;
 import com.qmth.distributed.print.business.entity.CourseWeight;
+import com.qmth.distributed.print.business.entity.TeachCourse;
+import com.qmth.distributed.print.business.enums.CourseSettingTypeEnum;
 import com.qmth.distributed.print.business.mapper.CourseWeightMapper;
+import com.qmth.distributed.print.business.service.CourseEvaluationService;
+import com.qmth.distributed.print.business.service.CourseTargetService;
 import com.qmth.distributed.print.business.service.CourseWeightService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.distributed.print.business.service.TeachCourseService;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -17,4 +44,195 @@ import org.springframework.stereotype.Service;
 @Service
 public class CourseWeightServiceImpl extends ServiceImpl<CourseWeightMapper, CourseWeight> implements CourseWeightService {
 
-}
+    @Resource
+    private TeachCourseService teachCourseService;
+
+    @Resource
+    private CourseTargetService courseTargetService;
+
+    @Resource
+    private CourseEvaluationService courseEvaluationService;
+
+    @Override
+    public List<CourseWeightDto> findCourseWeight(Long examId, String courseCode, Long userId) {
+        TeachCourse teachCourse = teachCourseService.findByExamIdCourseCodeAndUserId(examId, courseCode, userId);
+        Long teachCourseId = teachCourse.getId();
+
+        // 现有目标
+        List<CourseTargetResult> courseTargetList = courseTargetService.findCourseTargetList(examId, courseCode, userId);
+        // 现有评价方式
+        List<CourseEvaluationResult> courseEvaluationResultList = courseEvaluationService.findCourseEvaluationList(
+                examId, courseCode, userId);
+        // 现有权重
+        List<CourseWeight> courseWeightList = this.list(
+                new QueryWrapper<CourseWeight>().lambda().eq(CourseWeight::getTeachCourseId, teachCourseId));
+        // 权重map
+        Map<String, CourseWeight> courseWeightMap = courseWeightList.stream()
+                .collect(Collectors.toMap(k -> k.getTargetId() + SystemConstant.HYPHEN + k.getEvaluationId(), v -> v));
+
+        List<CourseWeightDto> result = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(courseTargetList)) {
+            for (CourseTargetResult courseTarget : courseTargetList) {
+                Long targetId = courseTarget.getId();
+                String targetName = courseTarget.getTargetName();
+                List<CourseDimensionDto> dimensionList = courseTarget.getDimensionList();
+                String degreeRequirement = courseTarget.getDegreeRequirement();
+                BigDecimal totalWeight = courseTarget.getTotalWeight();
+
+                List<CourseWeightDetailDto> courseWeightDetailDtoList = new ArrayList<>();
+                for (CourseEvaluationResult courseEvaluationResult : courseEvaluationResultList) {
+                    Long evaluationId = courseEvaluationResult.getEvaluationId();
+                    String evaluationName = courseEvaluationResult.getEvaluation();
+                    String key = targetId + SystemConstant.HYPHEN + evaluationId;
+
+                    Boolean enable = false;
+                    BigDecimal weight = BigDecimal.ZERO;
+                    BigDecimal targetScore = BigDecimal.ZERO;
+                    if (courseWeightMap.containsKey(key)) {
+                        // 权重表中包含该目标评价的设置 - 获取权重表的数据
+                        CourseWeight courseWeight = courseWeightMap.get(key);
+                        enable = courseWeight.getEnable();
+                        weight = courseWeight.getWeight();
+                        targetScore = courseWeight.getTargetScore();
+                    }
+                    CourseWeightDetailDto detail = new CourseWeightDetailDto();
+                    detail.setEvaluationId(evaluationId);
+                    detail.setEvaluationName(evaluationName);
+                    detail.setEnable(enable);
+                    detail.setWeight(weight);
+                    detail.setTargetScore(targetScore);
+                    courseWeightDetailDtoList.add(detail);
+                }
+
+                CourseWeightDto courseWeightDto = new CourseWeightDto();
+                courseWeightDto.setCourseTargetId(targetId);
+                courseWeightDto.setCourseTargetName(targetName);
+                courseWeightDto.setDimensionList(dimensionList);
+                courseWeightDto.setDegreeRequirement(degreeRequirement);
+                courseWeightDto.setTotalWeight(totalWeight);
+                courseWeightDto.setEvaluationList(courseWeightDetailDtoList);
+                result.add(courseWeightDto);
+            }
+        }
+
+        return result;
+    }
+
+    @Transactional
+    @Override
+    public void saveCourseWeight(CourseWeightParam courseWeightParam, SysUser requestUser) {
+        Long requestUserId = requestUser.getId();
+        Long examId = courseWeightParam.getExamId();
+        String courseCode = courseWeightParam.getCourseCode();
+        List<CourseWeightDto> submitForm = courseWeightParam.getSubmitForm();
+
+        TeachCourse teachCourse = teachCourseService.findByExamIdCourseCodeAndUserId(examId, courseCode, requestUserId);
+        Long teachCourseId = teachCourse.getId();
+
+        teachCourseService.clearCourseSetting(teachCourseId, CourseSettingTypeEnum.COURSE_WEIGHT);
+
+        List<CourseTarget> courseTargetList = new ArrayList<>();
+        List<CourseWeight> courseWeightList = new ArrayList<>();
+
+        // 目标分值检测
+        BigDecimal checkTotalScore = BigDecimal.ZERO;
+
+        // 评价方式整体权重检测
+        BigDecimal checkEvaluationTotalWeight = BigDecimal.ZERO;
+
+        // 课程目标整体权重检测
+        BigDecimal checkTargetTotalWeight = BigDecimal.ZERO;
+
+        for (CourseWeightDto courseWeightDto : submitForm) {
+            Long courseTargetId = courseWeightDto.getCourseTargetId();
+            CourseTarget courseTarget = courseTargetService.getById(courseTargetId);
+            if (Objects.isNull(courseTarget)) {
+                throw ExceptionResultEnum.ERROR.exception("课程目标不存在");
+            }
+
+            BigDecimal totalWeight = courseWeightDto.getTotalWeight();
+            courseTarget.setTotalWeight(totalWeight);
+            courseTarget.updateInfo(requestUserId);
+            courseTargetList.add(courseTarget);
+            checkTargetTotalWeight = checkTargetTotalWeight.add(totalWeight);
+
+            List<CourseWeightDetailDto> detailDtoList = courseWeightDto.getEvaluationList();
+            for (CourseWeightDetailDto detail : detailDtoList) {
+                Long evaluationId = detail.getEvaluationId();
+                Boolean enable = detail.getEnable();
+                BigDecimal weight = detail.getWeight();
+                BigDecimal targetScore = detail.getTargetScore();
+
+                CourseWeight courseWeight = new CourseWeight();
+                courseWeight.setTeachCourseId(teachCourseId);
+                courseWeight.setSchoolId(requestUser.getSchoolId());
+                courseWeight.setExamId(examId);
+                courseWeight.setCourseCode(courseCode);
+                courseWeight.setUserId(requestUserId);
+                courseWeight.setTargetId(courseTargetId);
+                courseWeight.setEvaluationId(evaluationId);
+                courseWeight.setEnable(enable);
+                courseWeight.setWeight(weight);
+                courseWeight.setTargetScore(targetScore);
+                courseWeight.insertInfo(requestUserId);
+                courseWeightList.add(courseWeight);
+
+                if (enable) {
+                    checkTotalScore = checkTotalScore.add(targetScore);
+                    checkEvaluationTotalWeight = checkEvaluationTotalWeight.add(weight);
+                }
+            }
+        }
+        List<String> errorMsgList = new ArrayList<>();
+        // 数据校验1:所有课程目标的总目标分值等于100分;
+        int checkTotalScoreCompareResult = checkTotalScore.compareTo(new BigDecimal(100));
+        if (checkTotalScoreCompareResult > 0) {
+            errorMsgList.add(String.format("所有课程目标的总目标分值为[%s],超过100分", checkTotalScore));
+        } else if (checkTotalScoreCompareResult < 0) {
+            errorMsgList.add(String.format("所有课程目标的总目标分值为[%s],低于100分", checkTotalScore));
+        }
+
+        // 数据校验2:各课程目标下评价方式的总权重应等于100%;
+        int checkEvaluationTotalWeightCompareResult = checkEvaluationTotalWeight.compareTo(new BigDecimal(100));
+        if (checkEvaluationTotalWeightCompareResult > 0) {
+            errorMsgList.add(
+                    String.format("所有课程目标下评价方式的总权重为[%s],超过[%s]", String.valueOf(checkEvaluationTotalWeight) + '%',
+                            "100%"));
+        } else if (checkEvaluationTotalWeightCompareResult < 0) {
+            errorMsgList.add(
+                    String.format("所有课程目标下评价方式的总权重为[%s],低于[%s]", String.valueOf(checkEvaluationTotalWeight) + '%',
+                            "100%"));
+        }
+
+        // 数据校验3:目标整体权重应等于100%,用于计算课程整体达成度。
+        int checkTargetTotalWeightCompareResult = checkTargetTotalWeight.compareTo(new BigDecimal(100));
+        if (checkTargetTotalWeightCompareResult > 0) {
+            errorMsgList.add(
+                    String.format("所有课程目标整体权重为[%s],超过[%s]", String.valueOf(checkTargetTotalWeight) + '%', "100%"));
+        } else if (checkTargetTotalWeightCompareResult < 0) {
+            errorMsgList.add(
+                    String.format("所有课程目标整体权重为[%s],低于[%s]", String.valueOf(checkTargetTotalWeight) + '%', "100%"));
+        }
+        if (CollectionUtils.isNotEmpty(errorMsgList)) {
+            throw ExceptionResultEnum.ERROR.exception(String.join(";", errorMsgList));
+        }
+
+        // 更新目标整体权重
+        courseTargetService.updateBatchById(courseTargetList);
+        // 保存课程权重设置
+        this.saveBatch(courseWeightList);
+        // 更新课程权重设置状态
+        teachCourse.setWeightSetting(true);
+        teachCourseService.updateById(teachCourse);
+    }
+
+    @Transactional
+    @Override
+    public void deleteCourseWeight(Long teachCourseId) {
+        this.remove(new QueryWrapper<CourseWeight>().lambda().eq(CourseWeight::getTeachCourseId, teachCourseId));
+        UpdateWrapper<CourseTarget> courseTargetUpdateWrapper = new UpdateWrapper<>();
+        courseTargetUpdateWrapper.lambda().eq(CourseTarget::getTeachCourseId, teachCourseId)
+                .set(CourseTarget::getTotalWeight, null);
+        courseTargetService.update(courseTargetUpdateWrapper);
+    }
+}

+ 1 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TeachCourseServiceImpl.java

@@ -430,7 +430,6 @@ public class TeachCourseServiceImpl extends ServiceImpl<TeachCourseMapper, Teach
                     new QueryWrapper<CourseTarget>().lambda().eq(CourseTarget::getTeachCourseId, teachCourseId));
         }
         // 删除权重设置
-        courseWeightService.remove(
-                new QueryWrapper<CourseWeight>().lambda().eq(CourseWeight::getTeachCourseId, teachCourseId));
+        courseWeightService.deleteCourseWeight(teachCourseId);
     }
 }

+ 2 - 1
distributed-print-business/src/main/resources/mapper/CourseEvaluationMapper.xml

@@ -7,7 +7,8 @@
         SELECT
             id AS evaluationId,
             evaluation,
-            evaluation_desc AS evaluationDesc
+            evaluation_desc AS evaluationDesc,
+            type
         FROM
             course_evaluation
         <where>

+ 43 - 4
distributed-print/src/main/java/com/qmth/distributed/print/api/CourseWeightController.java

@@ -1,9 +1,22 @@
 package com.qmth.distributed.print.api;
 
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.distributed.print.business.bean.dto.CourseWeightDto;
+import com.qmth.distributed.print.business.bean.params.CourseWeightParam;
+import com.qmth.distributed.print.business.service.CourseWeightService;
+import com.qmth.teachcloud.common.annotation.OperationLogDetail;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.enums.log.CustomizedOperationTypeEnum;
+import com.qmth.teachcloud.common.util.Result;
+import com.qmth.teachcloud.common.util.ResultUtil;
+import com.qmth.teachcloud.common.util.ServletUtil;
+import io.swagger.annotations.*;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
+import javax.annotation.Resource;
+import javax.validation.Valid;
 
 /**
  * <p>
@@ -13,8 +26,34 @@ import org.springframework.web.bind.annotation.RestController;
  * @author CaoZixuan
  * @since 2024-02-22
  */
+@Api(tags = "课程权重管理controller")
 @RestController
-@RequestMapping("/course-weight")
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_TEACH + "/course_weight")
 public class CourseWeightController {
 
+    @Resource
+    private CourseWeightService courseWeightService;
+
+    @ApiOperation(value = "课程权重管理-列表查询")
+    @RequestMapping(value = "/list", method = RequestMethod.POST)
+    @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = CourseWeightDto.class) })
+    public Result findCourseWeightList(@ApiParam(value = "学期id") @RequestParam(required = false) String examId,
+            @ApiParam(value = "考试id") @RequestParam(required = false) String courseCode) {
+        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
+        return ResultUtil.ok(courseWeightService.findCourseWeight(SystemConstant.convertIdToLong(examId), courseCode,
+                requestUser.getId()));
+    }
+
+    @ApiOperation(value = "课程权重管理-新增/编辑")
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    @ApiResponses({ @ApiResponse(code = 200, message = "更新成功", response = Result.class) })
+    @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.ADD)
+    public Result saveCourseWeight(@Valid @RequestBody CourseWeightParam courseWeightParam, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        courseWeightService.saveCourseWeight(courseWeightParam, sysUser);
+        return ResultUtil.ok();
+    }
 }