package com.java110.user.dao.impl;

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

@Service("patrolRecordV1ServiceDaoImpl")
public class PatrolRecordV1ServiceDaoImpl extends BaseServiceDao implements IPatrolRecordV1ServiceDao {

    @Override
    public int savePatrolRecord(PatrolRecordPo po) {
        return sqlSessionTemplate.insert("PatrolRecordV1ServiceDaoImpl.savePatrolRecord", po);
    }

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

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