package com.ruoyi.bst.complaint.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bst.complaint.mapper.ComplaintMapper;
import com.ruoyi.bst.complaint.domain.Complaint;
import com.ruoyi.bst.complaint.domain.ComplaintVO;
import com.ruoyi.bst.complaint.domain.ComplaintQuery;
import com.ruoyi.bst.complaint.service.ComplaintService;

/**
 * 投诉Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-31
 */
@Service
public class ComplaintServiceImpl implements ComplaintService
{
    @Autowired
    private ComplaintMapper complaintMapper;

    /**
     * 查询投诉
     *
     * @param id 投诉主键
     * @return 投诉
     */
    @Override
    public ComplaintVO selectComplaintById(Long id)
    {
        return complaintMapper.selectComplaintById(id);
    }

    /**
     * 查询投诉列表
     *
     * @param complaint 投诉
     * @return 投诉
     */
    @Override
    public List<ComplaintVO> selectComplaintList(ComplaintQuery complaint)
    {
        return complaintMapper.selectComplaintList(complaint);
    }

    /**
     * 新增投诉
     *
     * @param complaint 投诉
     * @return 结果
     */
    @Override
    public int insertComplaint(Complaint complaint)
    {
        complaint.setCreateTime(DateUtils.getNowDate());
        ServiceUtil.assertion(complaint.getType()==null,"类型不能为空");
        ServiceUtil.assertion(complaint.getContact()==null,"联系方式不能为空");
        return complaintMapper.insertComplaint(complaint);
    }

    /**
     * 修改投诉
     *
     * @param complaint 投诉
     * @return 结果
     */
    @Override
    public int updateComplaint(Complaint complaint)
    {
        return complaintMapper.updateComplaint(complaint);
    }

    /**
     * 批量删除投诉
     *
     * @param ids 需要删除的投诉主键
     * @return 结果
     */
    @Override
    public int deleteComplaintByIds(Long[] ids)
    {
        return complaintMapper.deleteComplaintByIds(ids);
    }

    /**
     * 删除投诉信息
     *
     * @param id 投诉主键
     * @return 结果
     */
    @Override
    public int deleteComplaintById(Long id)
    {
        return complaintMapper.deleteComplaintById(id);
    }
}
