package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.communityNews.CommunityNews;
import com.ruoyi.system.mapper.CommunityNewsMapper;
import com.ruoyi.system.service.ICommunityNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 社区资讯Service业务层处理
 * 
 * @author boman
 * @date 2025-02-14
 */
@Service
public class CommunityNewsServiceImpl implements ICommunityNewsService 
{
    @Autowired
    private CommunityNewsMapper communityNewsMapper;

    /**
     * 查询社区资讯
     * 
     * @param communityId 社区资讯主键
     * @return 社区资讯
     */
    @Override
    public CommunityNews selectCommunityNewsByCommunityId(Long communityId)
    {
        return communityNewsMapper.selectCommunityNewsByCommunityId(communityId);
    }

    /**
     * 查询社区资讯列表
     * 
     * @param communityNews 社区资讯
     * @return 社区资讯
     */
    @Override
    public List<CommunityNews> selectCommunityNewsList(CommunityNews communityNews)
    {
        return communityNewsMapper.selectCommunityNewsList(communityNews);
    }

    /**
     * 新增社区资讯
     * 
     * @param communityNews 社区资讯
     * @return 结果
     */
    @Override
    public int insertCommunityNews(CommunityNews communityNews)
    {
        communityNews.setCreateTime(DateUtils.getNowDate());
        return communityNewsMapper.insertCommunityNews(communityNews);
    }

    /**
     * 修改社区资讯
     * 
     * @param communityNews 社区资讯
     * @return 结果
     */
    @Override
    public int updateCommunityNews(CommunityNews communityNews)
    {
        communityNews.setUpdateTime(DateUtils.getNowDate());
        return communityNewsMapper.updateCommunityNews(communityNews);
    }

    /**
     * 批量删除社区资讯
     * 
     * @param communityIds 需要删除的社区资讯主键
     * @return 结果
     */
    @Override
    public int deleteCommunityNewsByCommunityIds(Long[] communityIds)
    {
        return communityNewsMapper.deleteCommunityNewsByCommunityIds(communityIds);
    }

    /**
     * 删除社区资讯信息
     * 
     * @param communityId 社区资讯主键
     * @return 结果
     */
    @Override
    public int deleteCommunityNewsByCommunityId(Long communityId)
    {
        return communityNewsMapper.deleteCommunityNewsByCommunityId(communityId);
    }
}
