package com.dgtis.dorm.manager.db.service;

import com.dgtis.dorm.manager.db.dao.NewsOrganizeMapper;
import com.dgtis.dorm.manager.db.domain.NewsOrganize;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class NewsOrganizeService {

    @Resource
    private NewsOrganizeMapper newsOrganizeMapper;

    /**
     * 查询新闻推送圈子的信息
     * @param newsOrganize
     * @return
     */
    public List<NewsOrganize> findNewsOrganize(NewsOrganize newsOrganize) {
        List<NewsOrganize> lstNewsOrganize = null;
        lstNewsOrganize = newsOrganizeMapper.selectByExample(newsOrganize);

        return lstNewsOrganize;
    }

    /**
     * 录入新闻推送圈子的信息
     * @param newsOrganize
     */
    public void add(NewsOrganize newsOrganize) {

        LocalDateTime localDateTime = LocalDateTime.now();
        newsOrganize.setCreateDate(localDateTime);

        newsOrganizeMapper.insertSelective(newsOrganize);
    }


    /**
     * 删除新闻推送圈子的信息
     * @param id 参加活动相关信息Id
     */
    public void delete(int id) {

        newsOrganizeMapper.deleteByPrimaryKey(id);
    }

    /**
     * 删除指定活动编号的圈子推送信息
     * @param newsId
     */
    public void deleteByActivityId(int newsId) {
        newsOrganizeMapper.deleteByActivityId(newsId);
    }
}
