package org.linlinjava.jz.db.service;

import org.linlinjava.jz.db.dao.JzTicketConsultMapper;
import org.linlinjava.jz.db.domain.JzTicketConsult;
import org.linlinjava.jz.db.domain.JzTicketConsultExample;
import org.springframework.stereotype.Service;

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

/**
 * 工单咨询类型处理类
 */
@Service
public class JzTicketConsultService {

    private final JzTicketConsult.Column[] result = new JzTicketConsult.Column[]{JzTicketConsult.Column.id, JzTicketConsult.Column.ticketId, JzTicketConsult.Column.consultId};


    @Resource
    private JzTicketConsultMapper handleMapper;

    public List<JzTicketConsult> queryByTocketId(Integer id) {
        JzTicketConsultExample example = new JzTicketConsultExample();
        example.or().andTicketIdEqualTo(id);
        return handleMapper.selectByExampleSelective(example, result);
    }

    public int add(JzTicketConsult ticket) {
        ticket.setCreateTime(LocalDateTime.now());
        ticket.setUpdateTime(LocalDateTime.now());
        return handleMapper.insertSelective(ticket);
    }

    public int updateById(JzTicketConsult ticket) {
        ticket.setUpdateTime(LocalDateTime.now());
        return handleMapper.updateByPrimaryKeySelective(ticket);
    }

    public JzTicketConsult findById(Integer id) {
        return handleMapper.selectByPrimaryKey(id);
    }
}
