package org.dromara.main.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
import org.dromara.main.domain.bo.MainStudentAppendixBo;
import org.dromara.main.domain.vo.MainStudentAppendixVo;
import org.dromara.main.service.IMainStudentAppendixService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 学员简历附件控制器
 *
 * @author antigravity
 * @date 2026-04-08
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/main/studentAppendix")
public class MainStudentAppendixController extends BaseController {

    private final IMainStudentAppendixService mainStudentAppendixService;

    /**
     * 查询学员简历附件列表
     */
    @SaIgnore
    @GetMapping("/list")
    public R<List<MainStudentAppendixVo>> list(@RequestParam Long studentId) {
        return R.ok(mainStudentAppendixService.queryList(studentId));
    }

    /**
     * 新增学员简历附件
     */
    @SaIgnore
    @PostMapping("/add")
    public R<Void> add(@RequestBody MainStudentAppendixBo bo) {
        return toAjax(mainStudentAppendixService.insertByBo(bo));
    }

    /**
     * 删除学员简历附件
     */
    @SaIgnore
    @DeleteMapping("/{ids}")
    public R<Void> remove(@PathVariable Long[] ids) {
        return toAjax(mainStudentAppendixService.deleteWithValidByIds(List.of(ids), true));
    }
}
