DataDictionaryDaoImpl.java 3.73 KB
package com.diligrp.website.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.diligrp.website.dao.DataDictionaryDao;
import com.diligrp.website.domain.DataDictionary;
import com.diligrp.website.domain.DataDictionaryValue;
import com.diligrp.website.domain.SysConfig;
import com.diligrp.website.util.dao.BaseQuery;
import com.diligrp.website.util.dao.impl.BaseDaoImpl;
import com.google.common.collect.Maps;

@Component("dataDictionaryDao")
public class DataDictionaryDaoImpl extends BaseDaoImpl<DataDictionary>
        implements DataDictionaryDao {

    private static final String PREFIX = DataDictionaryDaoImpl.class
            .getCanonicalName();

    @Override
    public DataDictionary getDataDictionaryByCode(String code) {
        return getSqlSessionTemplate().selectOne(
                PREFIX + ".getDataDictionaryByCode", code);
    }

    @Override
    public List<DataDictionaryValue> getDataDictionaryValue(Long id) {
        return getSqlSessionTemplate().selectList(
                PREFIX + ".getDataDictionaryValue", id);
    }

    @Override
    public Integer getDataDicListCount(BaseQuery query) {
        return getSqlSessionTemplate().selectOne(
                PREFIX + ".getDataDicListCount", query);
    }

    @Override
    public List<SysConfig> getDataDicList(BaseQuery query) {
        return getSqlSessionTemplate().selectList(PREFIX + ".getDataDicList",
                query);
    }

    @Override
    public boolean deleteValue(Long id) {
        return getSqlSessionTemplate().delete(PREFIX + ".deleteValue", id) > 0;
    }

    @Override
    public boolean delete(Long id) {
        return getSqlSessionTemplate().delete(PREFIX + ".delete", id) > 0;
    }

    /*
     * (non-Javadoc)
     * @see com.diligrp.website.util.dao.impl.BaseDaoImpl#save(java.lang.Object)
     */
    @Override
    public boolean save(DataDictionary value) {
        return super.save(value);
    }

    /*
     * (non-Javadoc)
     * @see
     * com.diligrp.website.util.dao.impl.BaseDaoImpl#update(java.lang.Object)
     */
    @Override
    public boolean update(DataDictionary value) {
        return super.update(value);
    }

    @Override
    public DataDictionary getDataDictionaryById(Long id) {
        return super.getById(id);
    }

    @Override
    public boolean saveValue(DataDictionaryValue dicv) {
        return getSqlSessionTemplate().insert(PREFIX + ".saveValue", dicv) > 0;
    }

    @Override
    public DataDictionaryValue getDataDicValById(Long id) {
        return getSqlSessionTemplate().selectOne(
                PREFIX + ".getDataDicValById", id);
    }

    @Override
    public boolean editValue(DataDictionaryValue dicv) {
        return getSqlSessionTemplate().update(PREFIX + ".editValue", dicv) > 0;
    }

    @Override
    public DataDictionaryValue getDataDicValByCode(String code, Integer ddId) {
        Map<String, Object> param = Maps.newHashMap();
        param.put("code", code);
        param.put("ddId", ddId);
        return getSqlSessionTemplate().selectOne(
                PREFIX + ".getDataDicValByCode", param);
    }

    @Override
    public DataDictionaryValue getDataDicValByName(String name, Integer ddId) {
        Map<String, Object> param = Maps.newHashMap();
        param.put("name", name);
        param.put("ddId", ddId);
        return getSqlSessionTemplate().selectOne(
                PREFIX + ".getDataDicValByName", param);
    }

    @Override
    public DataDictionaryValue getDataDicValBySort(Integer sort, Integer ddId) {
        Map<String, Object> param = Maps.newHashMap();
        param.put("sort", sort);
        param.put("ddId", ddId);
        return getSqlSessionTemplate().selectOne(
                PREFIX + ".getDataDicValBySort", param);
    }

}