package org.springblade.modules.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wn.common.datamodel.ResultDTO;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.modules.app.common.dto.ContractDTO;
import org.springblade.modules.app.common.dto.WaybillDTO;
import org.springblade.modules.app.common.query.ContractQuery;
import org.springblade.modules.app.manager.ContractManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@NonDS
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_SYSTEM_NAME + "/contract")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
public class ContractController extends BladeController {
    @Autowired
    private ContractManager contractManager;

    //@ApiOperation(value = "分页查询合同列表")
    @GetMapping("/page")
    public R<Page<ContractDTO>> pageContract(ContractQuery contractQuery) {
        return R.data(contractManager.pageContract(contractQuery));
    }

    @GetMapping("/{id}")
    public R<ContractDTO> getContract(@PathVariable Long id) {
        return R.data(contractManager.getContractDetail(id));
    }
}
