package com.education.api.controller.student;


import com.education.business.service.education.StuGoalInfoService;
import com.education.common.base.BaseController;
import com.education.common.utils.Result;
import com.education.model.dto.StuGoalInfoDto;
import com.education.model.dto.StuGoalInfoRespDto;
import com.education.model.entity.StuGoalInfo;
import com.education.model.request.PageParam;
import jakarta.validation.constraints.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 学生导向目标管理
 */
@RequestMapping("/student/stuGoalInfo")
@RestController("student-stuGoalInfo")
public class StuGoalInfoController extends BaseController {

    @Resource
    private StuGoalInfoService stuGoalInfoService;

    /**
     * 查询学生导出目标列表
     * @param pageParam
     * @param courseId
     * @return
     */
    @GetMapping("/listByCourseId")
    public Result selectPageByCourseId(PageParam pageParam, @NotNull Integer courseId) {
        return Result.success(stuGoalInfoService.selectPageByCourseId(pageParam, courseId));
    }

    /**
     * 答题
     * @param stuGoalInfo
     * @return
     */
    @PostMapping
    //@RequiresPermissions("student:stuGoalInfo:update")
    public Result answer(@RequestBody @Validated StuGoalInfo stuGoalInfo) {
        stuGoalInfoService.saveOrUpdate(stuGoalInfo);
        return Result.success();
    }

    /**
     * 学生导向目标答题记录分页列表
     * @param pageParam
     * @param stuGoalInfo
     * @return
     */
    @GetMapping
    //@RequiresPermissions("system:stuGoalInfo:list")
    public Result selectPage(PageParam pageParam, StuGoalInfo stuGoalInfo) {
        return Result.success(stuGoalInfoService.selectPageList(pageParam, stuGoalInfo));
    }

//    /**
//     * 添加或修改
//     * @param stuGoalInfoDto
//     * @return
//     */
//    @PostMapping
//    //@RequiresPermissions(value = {"system:stuGoalInfo:save","system:stuGoalInfo:update"}, logical = Logical.OR)
//    public Result saveOrUpdate(@RequestBody StuGoalInfoDto stuGoalInfoDto) {
//        stuGoalInfoService.saveOrUpdate(stuGoalInfoDto);
//        return Result.success();
//    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("{id}")
    //@RequiresPermissions("system:stuGoalInfo:deleteById")
    public Result deleteById(@PathVariable Integer id) {
        stuGoalInfoService.removeById(id);
        return Result.success();
    }
}