package jnpf.personnels.controller.web.scheme;

import jnpf.base.ActionResult;
import jnpf.model.personnels.dto.scheme.FtbPersonAddSchemeDTO;
import jnpf.model.personnels.dto.scheme.FtbPersonEditSchemeDTO;
import jnpf.model.personnels.vo.scheme.FtbPersonSchemeDetailsVO;
import jnpf.model.personnels.vo.scheme.FtbPersonSchemeListVO;
import jnpf.personnels.service.FtbPersonnelsStaffRosterSchemeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * web端花名册导出方案模块
 * @author wcx
 * @date 2026/03/09
 */
@RestController
@RequestMapping("/web/personnels-staff-scheme")
public class FtbPersonnelsStaffRosterSchemeController {

    @Resource
    private FtbPersonnelsStaffRosterSchemeService ftbPersonnelsStaffRosterSchemeService;

    /**
    * 新增方案
    */
    @PostMapping("/add-scheme")
    public ActionResult<Void> addScheme(@RequestBody @Valid FtbPersonAddSchemeDTO schemeDTO) {
        ftbPersonnelsStaffRosterSchemeService.addScheme(schemeDTO);
        return ActionResult.success();
    }

    /**
    * 删除方案
    */
    @DeleteMapping("/delete-scheme/{id}")
    public ActionResult<Void> deleteScheme(@PathVariable("id") String id) {
        ftbPersonnelsStaffRosterSchemeService.deleteScheme(id);
        return ActionResult.success();
    }

    /**
    * 修改方案
    */
    @PutMapping("/update-scheme")
    public ActionResult<Void> updateScheme(@RequestBody @Valid FtbPersonEditSchemeDTO schemeDTO) {
        ftbPersonnelsStaffRosterSchemeService.updateScheme(schemeDTO);
        return ActionResult.success();
    }

    /**
    * 方案详情
    */
    @GetMapping("/detail-scheme")
    public ActionResult<FtbPersonSchemeDetailsVO> detailScheme(@RequestParam("id") String id) {
        FtbPersonSchemeDetailsVO result = ftbPersonnelsStaffRosterSchemeService.detailScheme(id);
        return ActionResult.success(result);
    }

    /**
    * 获取方案列表
    */
    @GetMapping("/get-scheme-list")
    public ActionResult<List<FtbPersonSchemeListVO>> getSchemeList() {
        List<FtbPersonSchemeListVO> result = ftbPersonnelsStaffRosterSchemeService.getSchemeList();
        return ActionResult.success(result);
    }

}
