package com.cool.store.dao;

import com.cool.store.entity.PreFryApprovalRecordsDO;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.mapper.PreFryApprovalRecordsMapper;
import org.springframework.stereotype.Repository;

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

/**
 * @Author suzhuhong
 * @Date 2025/6/20 19:12
 * @Version 1.0
 */
@Repository
public class PreFryApprovalRecordsDAO {

    @Resource
    PreFryApprovalRecordsMapper preFryApprovalRecordsMapper;


    public int createApprovalRecord(PreFryApprovalRecordsDO preFryApprovalRecordsDO) {
        return preFryApprovalRecordsMapper.insertSelective(preFryApprovalRecordsDO);
    }

    /**
     * 查询申请的所有审批记录（按时间正序）
     */
    public List<PreFryApprovalRecordsDO> getRecordsByApplyId(Long applyId) {
        if (applyId == null) {
            throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
        }
        return preFryApprovalRecordsMapper.selectByApplyId(applyId);
    }









}
