package com.java110.user.dao.impl;

import com.java110.core.base.dao.BaseServiceDao;
import com.java110.user.dao.property.IRepairOrderV1ServiceDao;
import com.java110.po.property.RepairOrderPo;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

@Service("repairOrderV1ServiceDaoImpl")
public class RepairOrderV1ServiceDaoImpl extends BaseServiceDao implements IRepairOrderV1ServiceDao {

    @Override
    public int saveRepairOrder(RepairOrderPo po) {
        return sqlSessionTemplate.insert("RepairOrderV1ServiceDaoImpl.saveRepairOrder", po);
    }

    @Override
    public int updateRepairOrder(RepairOrderPo po) {
        return sqlSessionTemplate.update("RepairOrderV1ServiceDaoImpl.updateRepairOrder", po);
    }

    @Override
    public List<Map> queryRepairOrders(Map params) {
        return sqlSessionTemplate.selectList("RepairOrderV1ServiceDaoImpl.queryRepairOrders", params);
    }

    @Override
    public int queryRepairOrdersCount(Map params) {
        List<Map> result = sqlSessionTemplate.selectList("RepairOrderV1ServiceDaoImpl.queryRepairOrdersCount", params);
        if (result == null || result.isEmpty()) return 0;
        return Integer.parseInt(result.get(0).get("count").toString());
    }

    @Override
    public Map queryRepairOrderById(String id) {
        List<Map> result = sqlSessionTemplate.selectList("RepairOrderV1ServiceDaoImpl.queryRepairOrderById", id);
        return (result != null && !result.isEmpty()) ? result.get(0) : null;
    }
}
