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

import cn.iocoder.lyzsys.framework.common.pojo.CommonResult;
import cn.iocoder.lyzsys.framework.common.pojo.PageResult;
import cn.iocoder.lyzsys.module.tjt.controller.admin.profit.vo.ProjectProfitPageReqVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.profit.vo.ProjectProfitRespVO;
import cn.iocoder.lyzsys.module.tjt.service.profit.ProjectProfitService;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

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

@Tag(name = "管理后台 - 特建投项目盈亏")
@RestController
@RequestMapping("/tjt/profit")
@Validated
public class ProjectProfitController {

    @Resource
    private ProjectProfitService projectProfitService;

    @GetMapping("/get")
    @Operation(summary = "获得项目盈亏详情")
    @Parameter(name = "projectId", description = "项目 ID", required = true, example = "1")
    @PreAuthorize("@ss.hasPermission('tjt:profit:query')")
    public CommonResult<ProjectProfitRespVO> getProjectProfit(@RequestParam("projectId") Long projectId) {
        return success(projectProfitService.getProjectProfit(projectId));
    }

    @GetMapping("/page")
    @Operation(summary = "获得项目盈亏分页")
    @PreAuthorize("@ss.hasPermission('tjt:profit:query')")
    public CommonResult<PageResult<ProjectProfitRespVO>> getProjectProfitPage(@Valid ProjectProfitPageReqVO pageReqVO) {
        return success(projectProfitService.getProjectProfitPage(pageReqVO));
    }

}
