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.MainStudentProjectBo;
import org.dromara.main.domain.vo.MainStudentProjectVo;
import org.dromara.main.service.IMainStudentProjectService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/main/studentProject")
public class MainStudentProjectController extends BaseController {
    private final IMainStudentProjectService mainStudentProjectService;
    @SaIgnore
    @GetMapping("/list")
    public R<List<MainStudentProjectVo>> list(MainStudentProjectBo bo) {
        return R.ok(mainStudentProjectService.queryList(bo));
    }
    @SaIgnore
    @GetMapping("/{id}")
    public R<MainStudentProjectVo> getInfo(@PathVariable Long id) {
        return R.ok(mainStudentProjectService.queryById(id));
    }
    @SaIgnore
    @PostMapping()
    public R<Void> add(@RequestBody MainStudentProjectBo bo) {
        return toAjax(mainStudentProjectService.insertByBo(bo));
    }
    @SaIgnore
    @PutMapping()
    public R<Void> edit(@RequestBody MainStudentProjectBo bo) {
        return toAjax(mainStudentProjectService.updateByBo(bo));
    }
    @SaIgnore
    @DeleteMapping("/{ids}")
    public R<Void> remove(@PathVariable Long[] ids) {
        return toAjax(mainStudentProjectService.deleteWithValidByIds(List.of(ids), true));
    }
}
