All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sagacity.sqltoy.solon.service.impl.SqlToyCRUDServiceForSolon Maven / Gradle / Ivy

There is a newer version: 5.6.32.jre8
Show newest version
package org.sagacity.sqltoy.solon.service.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Singleton;
import org.noear.solon.data.annotation.Tran;
import org.sagacity.sqltoy.dao.SqlToyLazyDao;
import org.sagacity.sqltoy.model.CacheMatchFilter;
import org.sagacity.sqltoy.model.LockMode;
import org.sagacity.sqltoy.model.Page;
import org.sagacity.sqltoy.model.ParallQuery;
import org.sagacity.sqltoy.model.ParallelConfig;
import org.sagacity.sqltoy.model.QueryResult;
import org.sagacity.sqltoy.model.TreeTableModel;
import org.sagacity.sqltoy.service.SqlToyCRUDService;
import org.sagacity.sqltoy.translate.TranslateHandler;


/**
 *
 * @author 夜の孤城
 * @since 1.10
 * */
@Singleton(false) //因为会被多数据源使用,所以不能是单例
@Component
public class SqlToyCRUDServiceForSolon implements SqlToyCRUDService {
    protected SqlToyLazyDao sqlToyLazyDao;

    public void setSqlToyLazyDao(SqlToyLazyDao sqlToyLazyDao) {
        this.sqlToyLazyDao = sqlToyLazyDao;
    }

    @Tran
    public Object save(Serializable entity) {
        return this.sqlToyLazyDao.save(entity);
    }

    @Tran
    public  Long saveAll(List entities) {
        return this.sqlToyLazyDao.saveAll(entities);
    }

    @Tran
    public  Long saveAllIgnoreExist(List entities) {
        return this.sqlToyLazyDao.saveAllIgnoreExist(entities);
    }

    @Tran
    public Long update(Serializable entity, String... forceUpdateProps) {
        if (null == entity) {
            throw new IllegalArgumentException("update 数据对象为null!");
        } else {
            return this.sqlToyLazyDao.update(entity, forceUpdateProps);
        }
    }

    @Tran
    public Long updateCascade(Serializable entity, String... forceUpdateProps) {
        if (null == entity) {
            throw new IllegalArgumentException("update 数据对象为null!");
        } else {
            return this.sqlToyLazyDao.updateCascade(entity, forceUpdateProps, (Class[])null, (HashMap)null);
        }
    }

    @Tran
    public Long updateDeeply(Serializable entity) {
        if (null == entity) {
            throw new IllegalArgumentException("updateDeeply 数据对象为null!");
        } else {
            return this.sqlToyLazyDao.updateDeeply(entity);
        }
    }

    @Tran
    public  Long updateAll(List entities, String... forceUpdateProps) {
        return this.sqlToyLazyDao.updateAll(entities, forceUpdateProps);
    }

    @Tran
    public  Long updateAllDeeply(List entities) {
        return this.sqlToyLazyDao.updateAllDeeply(entities);
    }

    @Tran
    public Long saveOrUpdate(Serializable entity, String... forceUpdateProps) {
        if (null == entity) {
            throw new IllegalArgumentException("saveOrUpdate  数据对象为null!");
        } else {
            return this.sqlToyLazyDao.saveOrUpdate(entity, forceUpdateProps);
        }
    }

    @Tran
    public  Long saveOrUpdateAll(List entities, String... forceUpdateProps) {
        return this.sqlToyLazyDao.saveOrUpdateAll(entities, forceUpdateProps);
    }

    @Tran
    public  T load(T entity) {
        return this.sqlToyLazyDao.load(entity);
    }

    @Tran
    public  T loadCascade(T entity) {
        return this.sqlToyLazyDao.loadCascade(entity, (LockMode)null, new Class[0]);
    }

    @Tran
    public  List loadAll(List entities) {
        return this.sqlToyLazyDao.loadAll(entities);
    }

    @Tran
    public  List loadAllCascade(List entities, Class... cascadeTypes) {
        return this.sqlToyLazyDao.loadAllCascade(entities, cascadeTypes);
    }

    @Tran
    public  List loadByIds(Class voClass, Object... ids) {
        return this.sqlToyLazyDao.loadByIds(voClass, ids);
    }

    @Tran
    public Long delete(Serializable entity) {
        return this.sqlToyLazyDao.delete(entity);
    }

    @Tran
    public  Long deleteAll(List entities) {
        return this.sqlToyLazyDao.deleteAll(entities);
    }

    public Long deleteByIds(Class entityClass, Object... ids) {
        return this.sqlToyLazyDao.deleteByIds(entityClass, ids);
    }

    @Tran
    public void truncate(Class entityClass) {
        this.sqlToyLazyDao.truncate(entityClass);
    }

    @Tran
    public boolean isUnique(Serializable entity, String... paramsNamed) {
        return this.sqlToyLazyDao.isUnique(entity, paramsNamed);
    }

    @Tran
    public boolean wrapTreeTableRoute(Serializable entity, String pidField) {
        return this.sqlToyLazyDao.wrapTreeTableRoute((new TreeTableModel(entity)).pidField(pidField));
    }

    @Tran
    public boolean wrapTreeTableRoute(Serializable entity, String pidField, int appendIdSize) {
        return this.sqlToyLazyDao.wrapTreeTableRoute((new TreeTableModel(entity)).pidField(pidField).idLength(appendIdSize));
    }

    @Tran
    public  List> parallQuery(List parallQueryList, String[] paramNames, Object[] paramValues) {
        return this.sqlToyLazyDao.parallQuery(parallQueryList, paramNames, paramValues, (ParallelConfig)null);
    }

    @Tran
    public  List> parallQuery(List parallQueryList, String[] paramNames, Object[] paramValues, ParallelConfig parallelConfig) {
        return this.sqlToyLazyDao.parallQuery(parallQueryList, paramNames, paramValues, parallelConfig);
    }

    @Tran
    public  List> parallQuery(List parallQueryList, Map paramsMap, ParallelConfig parallelConfig) {
        return this.sqlToyLazyDao.parallQuery(parallQueryList, paramsMap, parallelConfig);
    }

    public long generateBizId(String signature, int increment) {
        return this.sqlToyLazyDao.generateBizId(signature, increment);
    }

    public String generateBizId(Serializable entity) {
        return this.sqlToyLazyDao.generateBizId(entity);
    }

    public void translate(Collection dataSet, String cacheName, TranslateHandler handler) {
        this.sqlToyLazyDao.translate(dataSet, cacheName, (String)null, 1, handler);
    }

    public void translate(Collection dataSet, String cacheName, String dictType, Integer index, TranslateHandler handler) {
        this.sqlToyLazyDao.translate(dataSet, cacheName, dictType, index, handler);
    }

    public boolean existCache(String cacheName) {
        return this.sqlToyLazyDao.existCache(cacheName);
    }

    public Set getCacheNames() {
        return this.sqlToyLazyDao.getCacheNames();
    }

    public String[] cacheMatchKeys(String matchRegex, CacheMatchFilter cacheMatchFilter) {
        return this.sqlToyLazyDao.cacheMatchKeys(matchRegex, cacheMatchFilter);
    }

    @Override
    public String[] cacheMatchKeys(CacheMatchFilter cacheMatchFilter, String... strings) {
        return this.sqlToyLazyDao.cacheMatchKeys(cacheMatchFilter, strings);
    }

    public  List convertType(List sourceList, Class resultType) {
        return this.sqlToyLazyDao.convertType(sourceList, resultType, new String[0]);
    }

    public  T convertType(Serializable source, Class resultType) {
        return this.sqlToyLazyDao.convertType(source, resultType, new String[0]);
    }

    public  Page convertType(Page sourcePage, Class resultType) {
        return this.sqlToyLazyDao.convertType(sourcePage, resultType, new String[0]);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy