package cn.reghao.tnb.content.app.vod.rpc;

import cn.reghao.tnb.content.api.iface.AdminSiteService;
import cn.reghao.tnb.content.app.vod.db.mapper.SiteNoticeMapper;
import cn.reghao.tnb.content.app.vod.model.po.SiteNotice;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

/**
 * @author reghao
 * @date 2024-07-06 09:33:10
 */
@DubboService
@Service
public class AdminSiteServiceImpl implements AdminSiteService {
    private final SiteNoticeMapper siteNoticeMapper;

    public AdminSiteServiceImpl(SiteNoticeMapper siteNoticeMapper) {
        this.siteNoticeMapper = siteNoticeMapper;
    }

    @Override
    public void setSiteNotice(String content) {
        long createBy = 10000;
        SiteNotice siteNotice = new SiteNotice(content, createBy);
        siteNoticeMapper.save(siteNotice);
    }

    public String getSiteNotice() {
        SiteNotice siteNotice = siteNoticeMapper.findLatest();
        return siteNotice != null ? siteNotice.getContent() : "N/A";
    }
}
