puzhibing
2023-07-04 75b60332f174363cfe67f61dea87832be708ac15
cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
@@ -3,17 +3,15 @@
import com.dsh.course.entity.TCoursePackage;
import com.dsh.course.entity.TCoursePackagePayment;
import com.dsh.course.feignclient.model.CourseOfStoreVo;
import com.dsh.course.feignclient.model.StuCourseResp;
import com.dsh.course.service.TCoursePackagePaymentService;
import com.dsh.course.service.TCoursePackageService;
import com.dsh.course.servs.CoursePackagePaymentRepository;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@@ -26,19 +24,22 @@
    private Logger logger = LoggerFactory.getLogger("business-log");
    @Autowired
    private CoursePackagePaymentRepository coursePackagePaymentRepository;
    private TCoursePackagePaymentService packagePaymentService;
    @Autowired
    private TCoursePackageService tcpService;
    /**
     * 获取 没有学员信息的图片配置
     * @param stuId 学员id
     * @return  课包列表
     */
    @PostMapping("/coursePack/queryPayment")
    public List<StuCourseResp> getStuCoursePackagePayment(Integer stuId){
    public List<StuCourseResp> getStuCoursePackagePayment(@RequestBody Integer stuId){
        List<StuCourseResp> resps = new ArrayList<>();
        List<TCoursePackagePayment> byUserId = coursePackagePaymentRepository.findByUserId(stuId);
        List<TCoursePackagePayment> byUserId = packagePaymentService.queryAllCoursePackage(stuId);
        if (byUserId.size() > 0 ){
            for (TCoursePackagePayment tCoursePackagePayment : byUserId) {
                TCoursePackage tCoursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId());
@@ -48,9 +49,31 @@
                resp.setTotalCourseNums(tCoursePackagePayment.getTotalClassHours());
                resp.setResidueNums(tCoursePackagePayment.getLaveClassHours());
                resp.setDeductionNums(tCoursePackagePayment.getTotalClassHours()-tCoursePackagePayment.getLaveClassHours());
                resps.add(resp);
            }
        }
        return resps;
    }
    /**
     *
     * 获取发布的 课包列表
     */
    @PostMapping("/coursePack/storeOfCourse")
    public List<CourseOfStoreVo> getStuCourseWithStores(){
        List<CourseOfStoreVo> courseOfStoreVos = tcpService.queryStoreOfCourse();
        if (courseOfStoreVos.size() > 0){
            for (CourseOfStoreVo courseOfStoreVo : courseOfStoreVos) {
                String[] split = courseOfStoreVo.getClassWeeks().split(";");
                List<Integer> integers = new ArrayList<>();
                for (String s : split) {
                    int num = Integer.parseInt(s);
                    integers.add(num);
                }
                courseOfStoreVo.setClassWeekList(integers);
            }
        }
        return tcpService.queryStoreOfCourse();
    }
}