package com.xingxi.business.News.service.impl;

import com.xingxi.common.core.text.Convert;
import com.xingxi.common.utils.DateUtils;
import com.xingxi.business.News.domain.NewsPic;
import com.xingxi.business.News.mapper.NewsPicMapper;
import com.xingxi.business.News.service.INewsPicService;
import org.springframework.stereotype.Service;

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

/**
 * 新闻图片Service业务层处理
 *
 * @author xingxi
 * @date 2025-03-06
 */
@Service
public class NewsPicServiceImpl implements INewsPicService {
    @Resource
    private NewsPicMapper newsPicMapper;

    /**
     * 查询新闻图片
     *
     * @param id 新闻图片主键
     * @return 新闻图片
     */
    @Override
    public NewsPic selectNewsPicById(Long id) {
        return newsPicMapper.selectNewsPicById(id);
    }

    /**
     * 查询新闻图片列表
     *
     * @param newsPic 新闻图片
     * @return 新闻图片
     */
    @Override
    public List<NewsPic> selectNewsPicList(NewsPic newsPic) {
        return newsPicMapper.selectNewsPicList(newsPic);
    }

    /**
     * 新增新闻图片
     *
     * @param newsPic 新闻图片
     * @return 结果
     */
    @Override
    public int insertNewsPic(NewsPic newsPic) {
        newsPic.setCreateTime(DateUtils.getNowDate());
        return newsPicMapper.insertNewsPic(newsPic);
    }

    /**
     * 新增新闻图片
     *
     * @param newsPicList 新闻图片
     * @return 结果
     */
    @Override
    public int batchInsertNewsPic(List<NewsPic> newsPicList) {
        return newsPicMapper.batchInsertNewsPic(newsPicList);
    }

    /**
     * 修改新闻图片
     *
     * @param newsPic 新闻图片
     * @return 结果
     */
    @Override
    public int updateNewsPic(NewsPic newsPic) {
        newsPic.setUpdateTime(DateUtils.getNowDate());
        return newsPicMapper.updateNewsPic(newsPic);
    }

    /**
     * 批量删除新闻图片
     *
     * @param ids 需要删除的新闻图片主键
     * @return 结果
     */
    @Override
    public int deleteNewsPicByIds(String ids) {
        return newsPicMapper.deleteNewsPicByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除新闻图片信息
     *
     * @param id 新闻图片主键
     * @return 结果
     */
    @Override
    public int deleteNewsPicById(Long id) {
        return newsPicMapper.deleteNewsPicById(id);
    }

    /**
     * 逻辑删除新闻图片
     *
     * @param id 新闻图片主键
     * @return 结果
     */
    @Override
    public int logicDeleteNewsPicById(Long id) {
        return newsPicMapper.logicDeleteNewsPicById(id);
    }

    /**
     * 逻辑批量删除新闻图片
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    @Override
    public int logicDeleteNewsPicByIds(String[] ids) {
        return newsPicMapper.logicDeleteNewsPicByIds(ids);
    }

    /**
     * 逻辑批量删除新闻图片
     *
     * @param newsPic 新闻图片
     * @return 结果
     */
    @Override
    public int logicDeleteNewsPicByCondition(NewsPic newsPic) {
        return newsPicMapper.logicDeleteNewsPicByCondition(newsPic);
    }
}
