package com.hfkj.service.impl;

import com.hfkj.dao.BsDeviceOrderAssignMapper;
import com.hfkj.entity.BsDeviceOrderAssign;
import com.hfkj.entity.BsDeviceOrderAssignExample;
import com.hfkj.service.BsDeviceOrderAssignService;
import org.springframework.stereotype.Service;

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

/**
 * @className: BsDeviceOrderAssignServiceImpl
 * @author: HuRui
 * @date: 2023/1/3
 **/
@Service("deviceOrderAssignService")
public class BsDeviceOrderAssignServiceImpl implements BsDeviceOrderAssignService {

    @Resource
    private BsDeviceOrderAssignMapper deviceOrderAssignMapper;

    @Override
    public void editData(BsDeviceOrderAssign deviceOrderAssign) {
        if (deviceOrderAssign.getId() == null) {
            deviceOrderAssign.setCreateTime(new Date());
            deviceOrderAssignMapper.insert(deviceOrderAssign);
        } else {
            deviceOrderAssignMapper.updateByPrimaryKey(deviceOrderAssign);
        }
    }

    @Override
    public BsDeviceOrderAssign getDetailById(Long id) {
        return deviceOrderAssignMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<BsDeviceOrderAssign> getAssignListByOrderNo(String orderNo) {
        BsDeviceOrderAssignExample example = new BsDeviceOrderAssignExample();
        example.createCriteria().andOrderNoEqualTo(orderNo).andStatusNotEqualTo(0);
        return deviceOrderAssignMapper.selectByExample(example);
    }
}
