package com.ruoyi.web.modules.content.facade.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.modules.content.domain.BizMerchantEntryAgreement;
import com.ruoyi.web.modules.content.facade.IMerchantEntryAgreementFacade;
import com.ruoyi.web.modules.content.mapper.BizMerchantEntryAgreementMapper;
import com.ruoyi.web.modules.content.constant.MerchantEntryAgreementConstants;
import com.ruoyi.web.modules.content.service.IMerchantEntryAgreementService;

/**
 * 商家入驻协议 Facade 实现
 */
@Service
public class MerchantEntryAgreementFacadeImpl implements IMerchantEntryAgreementFacade
{
    @Autowired
    private IMerchantEntryAgreementService agreementService;

    @Autowired
    private BizMerchantEntryAgreementMapper agreementMapper;

    @Override
    public boolean isEnabled()
    {
        return agreementService.isEnabled();
    }

    @Override
    public void assertAccepted(boolean agreementAccepted)
    {
        agreementService.assertAccepted(agreementAccepted);
    }

    @Override
    public String getCheckboxLabel()
    {
        BizMerchantEntryAgreement row = agreementMapper.selectById(MerchantEntryAgreementConstants.CONFIG_ID);
        if (row == null)
        {
            return agreementService.buildCheckboxLabel("", null);
        }
        return agreementService.buildCheckboxLabel(row.getAgreementTitle(), row.getVersionLabel());
    }
}
