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

import cn.iocoder.lyzsys.framework.common.pojo.CommonResult;
import cn.iocoder.lyzsys.framework.common.pojo.PageResult;
import cn.iocoder.lyzsys.module.tjt.controller.admin.employeeyearleaderoutput.vo.*;
import cn.iocoder.lyzsys.module.tjt.service.employeeyearleaderoutput.EmployeeYearLeaderOutputService;
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 static cn.iocoder.lyzsys.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 年度所长考核产值")
@RestController
@RequestMapping("/tjt/employee-year-leader-output")
@Validated
public class EmployeeYearLeaderOutputController {

    @Resource
    private EmployeeYearLeaderOutputService employeeYearLeaderOutputService;

    @PostMapping("/create")
    @Operation(summary = "创建年度所长考核产值")
    @PreAuthorize("@ss.hasPermission('tjt:employee-year-leader-output:create')")
    public CommonResult<Long> createEmployeeYearLeaderOutput(
            @Valid @RequestBody EmployeeYearLeaderOutputSaveReqVO createReqVO) {
        return success(employeeYearLeaderOutputService.createEmployeeYearLeaderOutput(createReqVO));
    }

    @PostMapping("/generate")
    @Operation(summary = "按年度生成年度所长考核产值")
    @PreAuthorize("@ss.hasPermission('tjt:employee-year-leader-output:create')")
    public CommonResult<EmployeeYearLeaderOutputGenerateRespVO> generateEmployeeYearLeaderOutput(
            @Valid @RequestBody EmployeeYearLeaderOutputGenerateReqVO generateReqVO) {
        return success(employeeYearLeaderOutputService.generateEmployeeYearLeaderOutput(generateReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "修改年度所长考核产值")
    @PreAuthorize("@ss.hasPermission('tjt:employee-year-leader-output:update')")
    public CommonResult<Boolean> updateEmployeeYearLeaderOutput(
            @Valid @RequestBody EmployeeYearLeaderOutputSaveReqVO updateReqVO) {
        employeeYearLeaderOutputService.updateEmployeeYearLeaderOutput(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除年度所长考核产值")
    @Parameter(name = "id", description = "编号", required = true, example = "1")
    @PreAuthorize("@ss.hasPermission('tjt:employee-year-leader-output:delete')")
    public CommonResult<Boolean> deleteEmployeeYearLeaderOutput(@RequestParam("id") Long id) {
        employeeYearLeaderOutputService.deleteEmployeeYearLeaderOutput(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得年度所长考核产值详情")
    @Parameter(name = "id", description = "编号", required = true, example = "1")
    @PreAuthorize("@ss.hasPermission('tjt:employee-year-leader-output:query')")
    public CommonResult<EmployeeYearLeaderOutputRespVO> getEmployeeYearLeaderOutput(@RequestParam("id") Long id) {
        return success(employeeYearLeaderOutputService.getEmployeeYearLeaderOutput(id));
    }

    @GetMapping("/page")
    @Operation(summary = "获得年度所长考核产值分页")
    @PreAuthorize("@ss.hasPermission('tjt:employee-year-leader-output:query')")
    public CommonResult<PageResult<EmployeeYearLeaderOutputRespVO>> getEmployeeYearLeaderOutputPage(
            @Valid EmployeeYearLeaderOutputPageReqVO pageReqVO) {
        return success(employeeYearLeaderOutputService.getEmployeeYearLeaderOutputPage(pageReqVO));
    }

}
