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.constant.MallServiceAgreementConstants;
import com.ruoyi.web.modules.content.domain.BizMallServiceAgreement;
import com.ruoyi.web.modules.content.facade.IMallServiceAgreementFacade;
import com.ruoyi.web.modules.content.mapper.BizMallServiceAgreementMapper;
import com.ruoyi.web.modules.content.service.IMallServiceAgreementService;

/**
 * 商城服务协议 Facade 实现
 */
@Service
public class MallServiceAgreementFacadeImpl implements IMallServiceAgreementFacade
{
    @Autowired
    private IMallServiceAgreementService agreementService;

    @Autowired
    private BizMallServiceAgreementMapper agreementMapper;

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

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

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

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

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