package com.bonus.sgzb.app.controller;

import com.bonus.sgzb.app.domain.BmAgreementInfo;
import com.bonus.sgzb.app.mapper.BmAgreementInfoMapper;
import com.bonus.sgzb.app.service.impl.BmAgreementInfoServiceImpl;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
* 协议管理(bm_agreement_info)表控制层
* @author 阮世耀
*/
@RestController
@RequestMapping("/base/agreement_info")
public class BmAgreementInfoController extends BaseController {

    /**
    * 服务对象
    */
    @Resource
    private BmAgreementInfoServiceImpl bmAgreementInfoServiceImpl;

    @Resource
    private BmAgreementInfoMapper bmAgreementInfoMapper;

    /**
     * 根据 工程+往来单位 判断是否有权限
     *
     * @param record 查询条件
     * @return AjaxResult对象，包含判断结果
     */
    @Log(title = "协议管理", businessType = BusinessType.QUERY)
    @GetMapping("isPrimaryByProAndUnit")
    public AjaxResult isPrimaryByProAndUnit(BmAgreementInfo record) {
        try {
            return toAjax(bmAgreementInfoMapper.isPrimaryByProAndUnit(record));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }



    /**
    * 通过主键查询单条数据
    *
    * @param id 主键
    * @return 单条数据
    */
    @GetMapping("selectOne")
    public BmAgreementInfo selectOne(Integer id) {
        return bmAgreementInfoServiceImpl.selectByPrimaryKey(id);
    }

}
