package org.dromara.system.controller.score;

import java.util.List;

import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.system.domain.score.bo.ScoreDataStudentBo;
import org.dromara.system.domain.score.vo.ScoreDataStudentVo;
import org.dromara.system.service.score.IScoreDataStudentService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
/**
 * 成绩_子学生id
 *
 * @author boman
 * @date 2023-08-17
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/dataStudent")
public class ScoreDataStudentController extends BaseController {

    private final IScoreDataStudentService scoreDataStudentService;

    /**
     * 查询成绩_子学生id列表
     */
    @SaCheckPermission("system:dataStudent:list")
    @GetMapping("/list")
    public TableDataInfo<ScoreDataStudentVo> list(ScoreDataStudentBo bo, PageQuery pageQuery) {
        return scoreDataStudentService.queryPageList(bo, pageQuery);
    }



    /**
     * 获取成绩_子学生id详细信息
     *
     * @param scoreStudentId 主键
     */
    @SaCheckPermission("system:dataStudent:query")
    @GetMapping("/{scoreStudentId}")
    public R<ScoreDataStudentVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long scoreStudentId) {
        return R.ok(scoreDataStudentService.queryById(scoreStudentId));
    }

    /**
     * 新增成绩_子学生id
     */
    @SaCheckPermission("system:dataStudent:add")
    @Log(title = "成绩_子学生id", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody ScoreDataStudentBo bo) {
        return toAjax(scoreDataStudentService.insertByBo(bo));
    }

    /**
     * 修改成绩_子学生id
     */
    @SaCheckPermission("system:dataStudent:edit")
    @Log(title = "成绩_子学生id", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PostMapping("/put")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ScoreDataStudentBo bo) {
        return toAjax(scoreDataStudentService.updateByBo(bo));
    }

    /**
     * 删除成绩_子学生id
     *
     * @param scoreStudentIds 主键串
     */
    @SaCheckPermission("system:dataStudent:remove")
    @Log(title = "成绩_子学生id", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{scoreStudentIds}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] scoreStudentIds) {
        return toAjax(scoreDataStudentService.deleteWithValidByIds(List.of(scoreStudentIds), true));
    }
}
