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

import com.xingxi.common.core.text.Convert;
import com.xingxi.common.utils.DateUtils;
import com.xingxi.business.SuggestProd.domain.SuggestProd;
import com.xingxi.business.SuggestProd.mapper.SuggestProdMapper;
import com.xingxi.business.SuggestProd.service.ISuggestProdService;
import org.springframework.stereotype.Service;

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

/**
 * 推荐商品Service业务层处理
 *
 * @author xingxi
 * @date 2025-03-06
 */
@Service
public class SuggestProdServiceImpl implements ISuggestProdService {
    @Resource
    private SuggestProdMapper suggestProdMapper;

    /**
     * 查询推荐商品
     *
     * @param id 推荐商品主键
     * @return 推荐商品
     */
    @Override
    public SuggestProd selectSuggestProdById(Long id) {
        return suggestProdMapper.selectSuggestProdById(id);
    }

    /**
     * 查询推荐商品列表
     *
     * @param suggestProd 推荐商品
     * @return 推荐商品
     */
    @Override
    public List<SuggestProd> selectSuggestProdList(SuggestProd suggestProd) {
        return suggestProdMapper.selectSuggestProdList(suggestProd);
    }

    /**
     * 新增推荐商品
     *
     * @param suggestProd 推荐商品
     * @return 结果
     */
    @Override
    public int insertSuggestProd(SuggestProd suggestProd) {
        suggestProd.setCreateTime(DateUtils.getNowDate());
        return suggestProdMapper.insertSuggestProd(suggestProd);
    }

    /**
     * 新增推荐商品
     *
     * @param suggestProdList 推荐商品
     * @return 结果
     */
    @Override
    public int batchInsertSuggestProd(List<SuggestProd> suggestProdList) {
        return suggestProdMapper.batchInsertSuggestProd(suggestProdList);
    }

    /**
     * 修改推荐商品
     *
     * @param suggestProd 推荐商品
     * @return 结果
     */
    @Override
    public int updateSuggestProd(SuggestProd suggestProd) {
        suggestProd.setUpdateTime(DateUtils.getNowDate());
        return suggestProdMapper.updateSuggestProd(suggestProd);
    }

    /**
     * 批量删除推荐商品
     *
     * @param ids 需要删除的推荐商品主键
     * @return 结果
     */
    @Override
    public int deleteSuggestProdByIds(String ids) {
        return suggestProdMapper.deleteSuggestProdByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除推荐商品信息
     *
     * @param id 推荐商品主键
     * @return 结果
     */
    @Override
    public int deleteSuggestProdById(Long id) {
        return suggestProdMapper.deleteSuggestProdById(id);
    }

    /**
     * 逻辑删除推荐商品
     *
     * @param id 推荐商品主键
     * @return 结果
     */
    @Override
    public int logicDeleteSuggestProdById(Long id) {
        return suggestProdMapper.logicDeleteSuggestProdById(id);
    }

    /**
     * 逻辑批量删除推荐商品
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    @Override
    public int logicDeleteSuggestProdByIds(String[] ids) {
        return suggestProdMapper.logicDeleteSuggestProdByIds(ids);
    }

    /**
     * 逻辑批量删除推荐商品
     *
     * @param suggestProd 推荐商品
     * @return 结果
     */
    @Override
    public int logicDeleteSuggestProdByCondition(SuggestProd suggestProd) {
        return suggestProdMapper.logicDeleteSuggestProdByCondition(suggestProd);
    }
}
