package org.linlinjava.jz.db.service;

import org.linlinjava.jz.db.dao.JzTicketOrderMapper;
import org.linlinjava.jz.db.domain.JzTicketOrder;
import org.linlinjava.jz.db.domain.JzTicketOrderExample;
import org.springframework.stereotype.Service;

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

/**
 * 工单关联订单
 */
@Service
public class JzTicketOrderService {

    @Resource
    private JzTicketOrderMapper ticketOrderMapper;

    public List<JzTicketOrder> queryByTocketId(Integer id){
        JzTicketOrderExample example = new JzTicketOrderExample();
        example.or().andTicketIdEqualTo(id);
        return ticketOrderMapper.selectByExample(example);
    }

    public int add(JzTicketOrder ticket) {
        ticket.setCreateTime(LocalDateTime.now());
        return ticketOrderMapper.insertSelective(ticket);
    }

    public int deleteById(JzTicketOrder ticket) {
        return   ticketOrderMapper.updateByPrimaryKeySelective(ticket);
    }

    public int updateById(JzTicketOrder ticket) {
        return ticketOrderMapper.updateByPrimaryKeySelective(ticket);
    }

    public JzTicketOrder findById(Integer id) {
        return ticketOrderMapper.selectByPrimaryKey(id);
    }
}
