package com.yinet.system.service.impl;

import com.yinet.common.core.text.Convert;
import com.yinet.system.domain.TouchScreenNotice;
import com.yinet.system.mapper.TouchScreenNoticeMapper;
import com.yinet.system.service.TouchScreenNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 参数配置 服务层实现
 *
 * @author ruoyi
 */
@Service
public class TouchScreenNoticeServiceImpl implements TouchScreenNoticeService {
    @Autowired
    private TouchScreenNoticeMapper touchScreenNoticeMapper;

    @Override
    public List<TouchScreenNotice> selectNoticeList() {
        List<TouchScreenNotice> touchScreenNotices = touchScreenNoticeMapper.selectNoticeList();
        return touchScreenNotices;
    }

    @Override
    public int insertNotice(TouchScreenNotice touchScreenNotice) {
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        touchScreenNotice.setTsNoticeId(uuid);
        touchScreenNotice.setSubmitTime(new Date());
        String content = touchScreenNotice.getContent();
        content = content.replaceAll("\r|\n", "");
        touchScreenNotice.setContent(content);
        return touchScreenNoticeMapper.insertNotice(touchScreenNotice);
    }

    public static String delHtmlTag(String str) {
        String newstr = "";
        newstr = str.replaceAll("<[.[^>]]*>", "");
        newstr = newstr.replaceAll(" ", "");
        return newstr;
    }

    @Override
    public TouchScreenNotice selectNoticeById(String id) {
        return touchScreenNoticeMapper.selectNoticeById(id);
    }

    @Override
    public int updateNotice(TouchScreenNotice touchScreenNotice) {
        touchScreenNotice.setSubmitTime(new Date());
        String content = touchScreenNotice.getContent();
        content = content.replaceAll("\r|\n", "");
        touchScreenNotice.setContent(content);
        return touchScreenNoticeMapper.updateNotice(touchScreenNotice);
    }

    @Override
    public int deletNotice(String ids) {
        String[] NoticeIds = Convert.toStrArray(ids);
        return touchScreenNoticeMapper.deletNotice(NoticeIds);
    }

    @Override
    public List<TouchScreenNotice> selectNoticeListLimit(Integer count) {
        return touchScreenNoticeMapper.selectNoticeListLimit(count);
    }
}
