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

com.github.developframework.resource.spring.mybatis.BaseDaoMapper Maven / Gradle / Ivy

The newest version!
package com.github.developframework.resource.spring.mybatis;

import develop.toolkit.base.struct.KeyValuePairs;
import develop.toolkit.base.struct.TwoValues;
import org.apache.ibatis.annotations.*;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Optional;

/**
 * 基础Mapper
 *
 * @author qiushui on 2020-05-28.
 */
public interface BaseDaoMapper, ID extends Serializable> {

    Class getEntityClass();

    @UpdateProvider(type = BaseMapperMysqlProvider.class, method = "createTable")
    void createTable(Class entityClass);

    @InsertProvider(type = BaseMapperMysqlProvider.class, method = "insert")
    void insert(PO entity);

    @InsertProvider(type = BaseMapperMysqlProvider.class, method = "insertAll")
    void insertAll(@Param("entityClass") Class entityClass, @Param("entities") Collection entities);

    @UpdateProvider(type = BaseMapperMysqlProvider.class, method = "update")
    boolean update(PO entity);

    @DeleteProvider(type = BaseMapperMysqlProvider.class, method = "deleteById")
    void deleteById(@Param("entityClass") Class entityClass, @Param("id") ID id);

    @SelectProvider(type = BaseMapperMysqlProvider.class, method = "existsById")
    boolean existsById(@Param("entityClass") Class entityClass, @Param("id") ID id);

    @SelectProvider(type = BaseMapperMysqlProvider.class, method = "existsById")
    boolean existsByFields(@Param("entityClass") Class entityClass, @Param("fields") KeyValuePairs fields);

    @SelectProvider(type = BaseMapperMysqlProvider.class, method = "findById")
    Optional findById(@Param("entityClass") Class entityClass, @Param("id") ID id);

    @SelectProvider(type = BaseMapperMysqlProvider.class, method = "findByIdForUpdate")
    Optional findByIdForUpdate(@Param("entityClass") Class entityClass, @Param("id") ID id);

    @SelectProvider(type = BaseMapperMysqlProvider.class, method = "findList")
    List findList(
            @Param("entityClass") Class entityClass,
            @Param("search") MybatisSearch search,
            @Param("orderBy") OrderBy[] orderBy,
            @Param("limit") TwoValues limit
    );

    @SelectProvider(type = BaseMapperMysqlProvider.class, method = "findListByWhere")
    List findListByWhere(
            @Param("entityClass") Class entityClass,
            @Param("where") String where,
            @Param("orderBy") OrderBy[] orderBy,
            @Param("limit") TwoValues limit
    );

    @SelectProvider(type = BaseMapperMysqlProvider.class, method = "countBy")
    long countBy(@Param("entityClass") Class entityClass, @Param("search") MybatisSearch search);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy