package cn.iocoder.lyzsys.module.tjt.controller.admin.specialtyrolesplit;

import cn.iocoder.lyzsys.framework.common.pojo.CommonResult;
import cn.iocoder.lyzsys.module.tjt.controller.admin.specialtyrolesplit.vo.SpecialtyRoleSplitBatchSaveReqVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.specialtyrolesplit.vo.SpecialtyRoleSplitRespVO;
import cn.iocoder.lyzsys.module.tjt.service.specialtyrolesplit.SpecialtyRoleSplitService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

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

import static cn.iocoder.lyzsys.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 特建投页面5角色比例")
@RestController
@RequestMapping("/tjt/specialty-role-split")
@Validated
public class SpecialtyRoleSplitController {

    @Resource
    private SpecialtyRoleSplitService specialtyRoleSplitService;

    @GetMapping("/list-by-planning")
    @Operation(summary = "根据合约规划获得页面5角色比例列表")
    @Parameter(name = "planningId", description = "合约规划 ID", required = true, example = "1")
    @PreAuthorize("@ss.hasPermission('tjt:specialty-role-split:query')")
    public CommonResult<List<SpecialtyRoleSplitRespVO>> getSpecialtyRoleSplitListByPlanningId(@RequestParam("planningId") Long planningId) {
        return success(specialtyRoleSplitService.getSpecialtyRoleSplitListByPlanningId(planningId));
    }

    @PutMapping("/save-batch")
    @Operation(summary = "批量保存页面5角色比例")
    @PreAuthorize("@ss.hasPermission('tjt:specialty-role-split:update')")
    public CommonResult<Boolean> saveSpecialtyRoleSplitBatch(@Valid @RequestBody SpecialtyRoleSplitBatchSaveReqVO reqVO) {
        specialtyRoleSplitService.saveSpecialtyRoleSplitBatch(reqVO);
        return success(true);
    }

}
