package com.hai.service.impl;

import com.hai.dao.BsRequestRecordMapper;
import com.hai.entity.BsRequestRecord;
import com.hai.entity.BsRequestRecordExample;
import com.hai.service.BsRequestRecordService;
import org.springframework.stereotype.Service;

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

@Service("bsRequestRecordService")
public class BsRequestRecordServiceImpl implements BsRequestRecordService {

    @Resource
    private BsRequestRecordMapper bsRequestRecordMapper;

    @Override
    public void insertRequestRecord(BsRequestRecord bsRequestRecord) {
        bsRequestRecordMapper.insert(bsRequestRecord);
    }

    @Override
    public void updateRequestRecord(BsRequestRecord bsRequestRecord) {
        bsRequestRecordMapper.updateByPrimaryKey(bsRequestRecord);
    }

    @Override
    public BsRequestRecord findRequestRecordByOrderNo(String orderNo) {
        BsRequestRecordExample example = new BsRequestRecordExample();

        example.createCriteria().andOrderNoEqualTo(orderNo);

        List<BsRequestRecord> list = bsRequestRecordMapper.selectByExample(example);

        if (list.size() > 0) {
            return list.get(0);
        }

        return null;
    }
}
