/**
 * @filename:SaleContractController 2024-09-07
 * @project trade-admin V1.0 Copyright(c) 2024 wanglang Co. Ltd. All right reserved.
 */
package com.trade.admin.trade.salecontract.controller;

import com.trade.admin.trade.salecontract.service.BSaleContractService;
import com.trade.common.core.domain.ResponseResult;
import com.trade.common.core.page.GridPage;
import com.trade.service.trade.salescontract.dto.ContractSearchDto;
import com.trade.service.trade.salescontract.vo.SalesContractInfoVo;
import com.trade.service.trade.salescontract.vo.SalesContractVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import com.trade.admin.system.controller.BaseController;

import io.swagger.annotations.Api;

import javax.annotation.Resource;

/**
 * <p>
 * 说明： B端销售合同前端控制器
 * </P>
 * 
 * @version: V1.0
 * @author: wanglang
 * @time 2024-09-07
 */
@Api(tags = "销售合同接口", value = "销售合同接口")
@RestController
@RequestMapping("/salesContract")
public class SaleContractController extends BaseController {

    @Resource
    private BSaleContractService salesService;

    /**
     * 获取销售合同
     *
     * @param contractSearch 合同查询条件
     * @return 销售合同信息
     */
    @ApiOperation(value = "获取销售合同", notes = "获取销售合同")
    @PostMapping("get/salesContractPage")
    @PreAuthorize("@ss.hasPermi('trade:salesContract:pages')")
    public ResponseResult<GridPage<SalesContractVo>> getSalesContractPage(
            @RequestBody ContractSearchDto contractSearch) {
        return ResponseResult.success(salesService.getSalesContractPage(contractSearch));
    }

    /**
     * 获取销售合同详情
     *
     * @param contractId 合同id
     * @return 销售合同信息
     */
    @ApiOperation(value = "获取销售合同详情", notes = "获取销售合同详情")
    @GetMapping("get/{contractId}")
    @PreAuthorize("@ss.hasPermi('trade:salesContract:query')")
    public ResponseResult<SalesContractInfoVo> getSalesContractDetails(@PathVariable Long contractId) {
        return ResponseResult.success(salesService.getSalesContractDetails(contractId));
    }
}
