package com.bonus.sgzb.app.service.impl;

import com.bonus.sgzb.app.domain.SysNotice;
import com.bonus.sgzb.app.mapper.SysNoticeMapper;
import com.bonus.sgzb.app.service.SysNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Base64;
import java.util.List;

/**
 * @author c liu
 * @date 2023/12/11
 */
@Service("SysNoticeService")
public class SysNoticeServiceImpl implements SysNoticeService {
    @Autowired
    private SysNoticeMapper mapper;

    @Override
    public List<SysNotice> getList(String keyword) {
        List<SysNotice> list = mapper.getList(keyword);
        for (SysNotice bean : list){
            if (bean.getNoticeContent() != null){
                String noticeContent = Base64.getEncoder().encodeToString(bean.getNoticeContent());
                bean.setNoticeContentStr(noticeContent);
            }
        }
        return list;
    }

    @Override
    public SysNotice getById(Long noticeId) {
        SysNotice bean = mapper.getById(noticeId);
        if (bean.getNoticeContent() != null){
            String noticeContent = Base64.getEncoder().encodeToString(bean.getNoticeContent());
            bean.setNoticeContentStr(noticeContent);
        }
        return bean;
    }
}
