package org.jeecg.modules.system.app.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.app.vo.agreement.AppAgreementVORequest;
import org.jeecg.modules.app.vo.agreement.AppAgreementVoResponse;
import org.jeecg.modules.system.app.entity.Protocol;
import org.jeecg.modules.system.app.mapper.ProtocolMapper;
import org.jeecg.modules.system.app.service.IProtocolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: 协议说明
 * @Author: jeecg-boot
 * @Date:   2025-07-31
 * @Version: V1.0
 */
@Service
public class ProtocolServiceImpl extends ServiceImpl<ProtocolMapper, Protocol> implements IProtocolService {


    @Autowired
    ProtocolMapper protocolMapper;

    @Override
    public Protocol findByInsuranceName(Integer insuranceName,String id) {
        return protocolMapper.findByInsuranceName(insuranceName,id);
    }

    @Override
    public Result<AppAgreementVoResponse> findByType(AppAgreementVORequest appAgreementVORequest) {

        if (ObjectUtils.isEmpty(appAgreementVORequest.getProtocolType())||ObjectUtils.isEmpty(appAgreementVORequest.getInsuranceName())){
            return Result.error("保险公司和协议类型不能同时为空");
        }
        AppAgreementVoResponse appAgreementVoResponse =  protocolMapper.findByType(appAgreementVORequest);
        return Result.ok(appAgreementVoResponse);
    }
}
