package com.bonus.canteen.core.alloc.service.impl;

import java.util.List;

import com.bonus.canteen.core.nutrition.common.enums.YesOrNoEnum;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.alloc.mapper.AllocCanteenSuggestionMapper;
import com.bonus.canteen.core.alloc.domain.AllocCanteenSuggestion;
import com.bonus.canteen.core.alloc.service.IAllocCanteenSuggestionService;

/**
 * 投诉建议 Service业务层处理
 * 
 * @author xsheng
 * @date 2025-04-20
 */
@Service
public class AllocCanteenSuggestionServiceImpl implements IAllocCanteenSuggestionService {
    @Autowired
    private AllocCanteenSuggestionMapper allocCanteenSuggestionMapper;

    /**
     * 查询投诉建议 
     * 
     * @param id 投诉建议 主键
     * @return 投诉建议 
     */
    @Override
    public AllocCanteenSuggestion selectAllocCanteenSuggestionById(Long id) {
        return allocCanteenSuggestionMapper.selectAllocCanteenSuggestionById(id);
    }

    /**
     * 查询投诉建议 列表
     * 
     * @param allocCanteenSuggestion 投诉建议 
     * @return 投诉建议 
     */
    @Override
    public List<AllocCanteenSuggestion> selectAllocCanteenSuggestionList(AllocCanteenSuggestion allocCanteenSuggestion) {
        return allocCanteenSuggestionMapper.selectAllocCanteenSuggestionList(allocCanteenSuggestion);
    }

    /**
     * 新增投诉建议 
     * 
     * @param allocCanteenSuggestion 投诉建议 
     * @return 结果
     */
    @Override
    public int insertAllocCanteenSuggestion(AllocCanteenSuggestion allocCanteenSuggestion) {
        allocCanteenSuggestion.setCreateTime(DateUtils.getNowDate());
        allocCanteenSuggestion.setCreateBy(SecurityUtils.getUsername());
        allocCanteenSuggestion.setUserId(SecurityUtils.getUserId());
        allocCanteenSuggestion.setSourceType(7L);
        allocCanteenSuggestion.setReplyState(YesOrNoEnum.NO.key().longValue());
        try {
            return allocCanteenSuggestionMapper.insertAllocCanteenSuggestion(allocCanteenSuggestion);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述, " + e.getMessage());
        }
    }

    /**
     * 修改投诉建议 
     * 
     * @param allocCanteenSuggestion 投诉建议 
     * @return 结果
     */
    @Override
    public int updateAllocCanteenSuggestion(AllocCanteenSuggestion allocCanteenSuggestion) {
        allocCanteenSuggestion.setUpdateTime(DateUtils.getNowDate());
        allocCanteenSuggestion.setUpdateBy(SecurityUtils.getUsername());
        try {
            return allocCanteenSuggestionMapper.updateAllocCanteenSuggestion(allocCanteenSuggestion);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述, " + e.getMessage());
        }
    }

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

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