package com.java110.user.dao.impl;

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

@Service("propertyUserV1ServiceDaoImpl")
public class PropertyUserV1ServiceDaoImpl extends BaseServiceDao implements IPropertyUserV1ServiceDao {

    @Override
    public int savePropertyUser(PropertyUserPo po) {
        return sqlSessionTemplate.insert("PropertyUserV1ServiceDaoImpl.savePropertyUser", po);
    }

    @Override
    public int updatePropertyUser(PropertyUserPo po) {
        return sqlSessionTemplate.update("PropertyUserV1ServiceDaoImpl.updatePropertyUser", po);
    }

    @Override
    public int deletePropertyUser(PropertyUserPo po) {
        return sqlSessionTemplate.update("PropertyUserV1ServiceDaoImpl.deletePropertyUser", po);
    }

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

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