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

import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.utils.SM4EncryptUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.kitchen.mapper.KitchenStaffIllegalWarningMapper;
import com.bonus.canteen.core.kitchen.domain.KitchenStaffIllegalWarning;
import com.bonus.canteen.core.kitchen.service.IKitchenStaffIllegalWarningService;

/**
 * 厨房员工违规报警Service业务层处理
 * 
 * @author xsheng
 * @date 2025-06-16
 */
@Service
public class KitchenStaffIllegalWarningServiceImpl implements IKitchenStaffIllegalWarningService {
    @Autowired
    private KitchenStaffIllegalWarningMapper kitchenStaffIllegalWarningMapper;

    /**
     * 查询厨房员工违规报警
     * 
     * @param illegalWarningId 厨房员工违规报警主键
     * @return 厨房员工违规报警
     */
    @Override
    public KitchenStaffIllegalWarning selectKitchenStaffIllegalWarningByIllegalWarningId(Long illegalWarningId) {
        return kitchenStaffIllegalWarningMapper.selectKitchenStaffIllegalWarningByIllegalWarningId(illegalWarningId);
    }

    /**
     * 查询厨房员工违规报警列表
     * 
     * @param kitchenStaffIllegalWarning 厨房员工违规报警
     * @return 厨房员工违规报警
     */
    @Override
    public List<KitchenStaffIllegalWarning> selectKitchenStaffIllegalWarningList(KitchenStaffIllegalWarning kitchenStaffIllegalWarning) {
        String encryptedSearchValue = SM4EncryptUtils.sm4Encrypt(kitchenStaffIllegalWarning.getSearchValue());
        kitchenStaffIllegalWarning.setEncryptedSearchValue(encryptedSearchValue);
        return kitchenStaffIllegalWarningMapper.selectKitchenStaffIllegalWarningList(kitchenStaffIllegalWarning);
    }

    /**
     * 新增厨房员工违规报警
     * 
     * @param kitchenStaffIllegalWarning 厨房员工违规报警
     * @return 结果
     */
    @Override
    public int insertKitchenStaffIllegalWarning(KitchenStaffIllegalWarning kitchenStaffIllegalWarning) {
        kitchenStaffIllegalWarning.setCreateTime(DateUtils.getNowDate());
        try {
            return kitchenStaffIllegalWarningMapper.insertKitchenStaffIllegalWarning(kitchenStaffIllegalWarning);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改厨房员工违规报警
     * 
     * @param kitchenStaffIllegalWarning 厨房员工违规报警
     * @return 结果
     */
    @Override
    public int updateKitchenStaffIllegalWarning(KitchenStaffIllegalWarning kitchenStaffIllegalWarning) {
        kitchenStaffIllegalWarning.setUpdateTime(DateUtils.getNowDate());
        try {
            return kitchenStaffIllegalWarningMapper.updateKitchenStaffIllegalWarning(kitchenStaffIllegalWarning);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除厨房员工违规报警
     * 
     * @param illegalWarningIds 需要删除的厨房员工违规报警主键
     * @return 结果
     */
    @Override
    public int deleteKitchenStaffIllegalWarningByIllegalWarningIds(Long[] illegalWarningIds) {
        return kitchenStaffIllegalWarningMapper.deleteKitchenStaffIllegalWarningByIllegalWarningIds(illegalWarningIds);
    }

    /**
     * 删除厨房员工违规报警信息
     * 
     * @param illegalWarningId 厨房员工违规报警主键
     * @return 结果
     */
    @Override
    public int deleteKitchenStaffIllegalWarningByIllegalWarningId(Long illegalWarningId) {
        return kitchenStaffIllegalWarningMapper.deleteKitchenStaffIllegalWarningByIllegalWarningId(illegalWarningId);
    }
}
