package com.jwipc.supplier.controller.pc;

import com.jwipc.page.PageView;
import com.jwipc.supplier.constant.ModuleConst;
import com.jwipc.supplier.dto.SupplierAgreementDTO;
import com.jwipc.supplier.logic.SupplierAgreementLogic;
import com.jwipc.supplier.model.query.SupplierAgreementQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shenyang.ou
 * @date 2024/1/31 15:14
 * @desc 协议
 */
@RestController
@RequestMapping(ModuleConst.MODULE_ROOT + "/supplierAgreement/rest")
@RequiredArgsConstructor
public class SupplierAgreementRestController {
    private final SupplierAgreementLogic supplierAgreementLogic;
    /**
     * 列表
     * @param query
     * @return
     */
    @RequestMapping("/list")
    public PageView list(SupplierAgreementQuery query) {
        return supplierAgreementLogic.findByPage(query);
    }

    /**
     * 保存更新
     *
     * @param param 参数
     */
    @PostMapping("/saveOrUpdate")
    public ResponseEntity saveOrUpdate(SupplierAgreementDTO param) {
        supplierAgreementLogic.saveOrUpdate(param);
        return ResponseEntity.ok(true);
    }

    /**
     * 删除
     *
     * @param id 参数
     */
    @PostMapping("/remove")
    public ResponseEntity remove(Long id) {
        supplierAgreementLogic.remove(id);
        return ResponseEntity.ok(true);
    }
}
