package com.ruoyi.os.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.os.domain.DrugFiling;
import com.ruoyi.os.mapper.DrugFilingMapper;
import com.ruoyi.os.service.IDrugFilingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
 *
 *  @author 何顺
 *  @date 2024-09-17
 */
@Service
public class DrugFilingServiceImpl implements IDrugFilingService {

    @Autowired
    private DrugFilingMapper drugFilingMapper;

    @Override
    public List<DrugFiling> selectDrugFilingList(DrugFiling drugFiling) {
        return drugFilingMapper.selectDrugFilingList(drugFiling);
    }

    @Override
    public DrugFiling selectDrugFilingById(Long id) {
        return drugFilingMapper.selectDrugFilingById(id);
    }

    @Override
    @Transactional
    public int insertDrugFiling(DrugFiling drugFiling) {
        drugFiling.setCreateTime(new Date());
        drugFiling.setCreateBy(SecurityUtils.getUsername());
        return drugFilingMapper.insertDrugFiling(drugFiling);
    }

    @Override
    @Transactional
    public int updateDrugFiling(DrugFiling drugFiling) {
        drugFiling.setUpdateTime(new Date());
        drugFiling.setUpdateBy(SecurityUtils.getUsername());
        return drugFilingMapper.updateDrugFiling(drugFiling);
    }

    @Override
    @Transactional
    public int deleteDrugFilingById(Long id) {
        return drugFilingMapper.deleteDrugFilingById(id);
    }

    @Override
    @Transactional
    public int deleteDrugFilingByArchiveId(Long archiveId) {
        return drugFilingMapper.deleteDrugFilingByArchiveId(archiveId);
    }
}