package cn.iocoder.yudao.module.course.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.base.entity.DriveSchoolCourseDeduct;
import cn.iocoder.yudao.module.base.service.DlDriveSchoolCourseDeductService;
import cn.iocoder.yudao.module.base.vo.SchemeFormDTO;
import cn.iocoder.yudao.module.course.entity.SchoolCourseScheme;
import cn.iocoder.yudao.module.course.service.SchoolCourseSchemeService;
import cn.iocoder.yudao.module.course.vo.SchoolCourseSchemeVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;

import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Arrays;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 课程-方案关联")
@RestController
@RequestMapping("/courseScheme")
@Validated
public class SchoolCourseSchemeController {

    @Autowired
    private SchoolCourseSchemeService schoolCourseSchemeService;

    @GetMapping("/get/{id}")
    @Operation(summary = "获取提成方案详情")
    public CommonResult<SchoolCourseSchemeVO> getScheme(@PathVariable String id) {
        return CommonResult.success(schoolCourseSchemeService.getSchemeDetail(id));
    }

    @PostMapping("/save")
    @Operation(summary = "新增/修改提成方案")
    public CommonResult<Boolean> saveScheme(@Valid @RequestBody SchemeFormDTO reqVO) {
        schoolCourseSchemeService.saveOrUpdateScheme(reqVO);
        return CommonResult.success(true);
    }

    @DeleteMapping("/delete/{id}")
    @Operation(summary = "删除提成方案")
    public CommonResult<Boolean> deleteScheme(@PathVariable String id) {
        schoolCourseSchemeService.deleteScheme(id);
        return CommonResult.success(true);
    }
}
