package cn.iocoder.yudao.module.system.service.biz;

import cn.iocoder.yudao.module.system.dal.dataobject.biz.MedicineInOutRecordsDO;
import cn.iocoder.yudao.module.system.dal.mysql.biz.MedicineInOutRecordsMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

/**
 * 药品出入库记录 Service 实现类
 *
 * @author 系统管理员
 */
@Service
@Validated
public class MedicineInOutRecordsServiceImpl implements MedicineInOutRecordsService {

    @Resource
    private MedicineInOutRecordsMapper medicineInOutRecordsMapper;

    @Override
    public Long createRecord(MedicineInOutRecordsDO record) {
        record.setCreatedAt(LocalDateTime.now());
        record.setUpdatedAt(LocalDateTime.now());
        medicineInOutRecordsMapper.insert(record);
        return record.getId();
    }

    @Override
    public void updateRecord(MedicineInOutRecordsDO record) {
        record.setUpdatedAt(LocalDateTime.now());
        medicineInOutRecordsMapper.updateById(record);
    }

    @Override
    public MedicineInOutRecordsDO getRecord(Long id) {
        return medicineInOutRecordsMapper.selectById(id);
    }

    @Override
    public List<MedicineInOutRecordsDO> getRecordsByBarcode(String barcode) {
        return medicineInOutRecordsMapper.selectListByBarcode(barcode);
    }

    @Override
    public List<MedicineInOutRecordsDO> getRecordsByBatchNumber(String batchNumber) {
        return medicineInOutRecordsMapper.selectListByBatchNumber(batchNumber);
    }

    @Override
    public List<MedicineInOutRecordsDO> getRecordsByInOrOut(Integer inOrOut) {
        return medicineInOutRecordsMapper.selectListByInOrOut(inOrOut);
    }

    @Override
    public List<MedicineInOutRecordsDO> getRecordsByTenantId(Long tenantId) {
        return medicineInOutRecordsMapper.selectListByTenantId(tenantId);
    }

    @Override
    public void deleteRecord(Long id) {
        medicineInOutRecordsMapper.deleteById(id);
    }

    @Override
    public void deleteRecords(Long[] ids) {
        medicineInOutRecordsMapper.deleteBatchIds(Arrays.asList(ids));
    }
}




















































