io.github.nichetoolkit.mybatis.provider.PostgresDeleteLinkProvider Maven / Gradle / Ivy
Show all versions of mybatis-toolkit-starter Show documentation
package io.github.nichetoolkit.mybatis.provider;
import io.github.nichetoolkit.mybatis.MybatisSqlProvider;
import io.github.nichetoolkit.mybatis.enums.DatabaseType;
import io.github.nichetoolkit.mybatis.error.MybatisParamErrorException;
import io.github.nichetoolkit.mybatis.error.MybatisTableErrorException;
import io.github.nichetoolkit.rest.RestException;
import io.github.nichetoolkit.rest.util.OptionalUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.builder.annotation.ProviderContext;
import org.springframework.stereotype.Component;
import java.util.Collection;
/**
* PostgresDeleteLinkProvider
* The postgres delete link provider class.
* @author Cyan ([email protected])
* @see io.github.nichetoolkit.mybatis.MybatisSqlProvider
* @see lombok.extern.slf4j.Slf4j
* @see org.springframework.stereotype.Component
* @since Jdk1.8
*/
@Slf4j
@Component
public class PostgresDeleteLinkProvider implements MybatisSqlProvider {
@Override
public DatabaseType databaseType() {
return DatabaseType.POSTGRESQL;
}
/**
* deleteByLinkId
* The delete by link id method.
* @param {@link java.lang.Object} The parameter can be of any type.
* @param providerContext {@link org.apache.ibatis.builder.annotation.ProviderContext} The provider context parameter is ProviderContext
type.
* @param linkId L The link id parameter is L
type.
* @return {@link java.lang.String} The delete by link id return object is String
type.
* @throws RestException {@link io.github.nichetoolkit.rest.RestException} The rest exception is RestException
type.
* @see org.apache.ibatis.builder.annotation.ProviderContext
* @see java.lang.String
* @see io.github.nichetoolkit.rest.RestException
*/
public static String deleteByLinkId(ProviderContext providerContext, L linkId) throws RestException {
return deleteDynamicByLinkId(providerContext, null, linkId);
}
/**
* deleteDynamicByLinkId
* The delete dynamic by link id method.
* @param {@link java.lang.Object} The parameter can be of any type.
* @param providerContext {@link org.apache.ibatis.builder.annotation.ProviderContext} The provider context parameter is ProviderContext
type.
* @param tablename {@link java.lang.String} The tablename parameter is String
type.
* @param linkId L The link id parameter is L
type.
* @return {@link java.lang.String} The delete dynamic by link id return object is String
type.
* @throws RestException {@link io.github.nichetoolkit.rest.RestException} The rest exception is RestException
type.
* @see org.apache.ibatis.builder.annotation.ProviderContext
* @see java.lang.String
* @see io.github.nichetoolkit.rest.RestException
*/
public static String deleteDynamicByLinkId(ProviderContext providerContext, String tablename, L linkId) throws RestException {
OptionalUtils.ofEmpty(linkId, "The link id param of 'deleteByLinkId' method cannot be empty!", message -> new MybatisTableErrorException("deleteByLinkId", "linkId", message));
return MybatisSqlProvider.providingOfLinkId(providerContext, tablename, linkId, table -> {}, DELETE_SQL_SUPPLY);
}
/**
* deleteAllByLinkIds
* The delete all by link ids method.
* @param {@link java.lang.Object} The parameter can be of any type.
* @param providerContext {@link org.apache.ibatis.builder.annotation.ProviderContext} The provider context parameter is ProviderContext
type.
* @param linkIdList {@link java.util.Collection} The link id list parameter is Collection
type.
* @return {@link java.lang.String} The delete all by link ids return object is String
type.
* @throws RestException {@link io.github.nichetoolkit.rest.RestException} The rest exception is RestException
type.
* @see org.apache.ibatis.builder.annotation.ProviderContext
* @see java.util.Collection
* @see java.lang.String
* @see io.github.nichetoolkit.rest.RestException
*/
public static String deleteAllByLinkIds(ProviderContext providerContext, Collection linkIdList) throws RestException {
return deleteDynamicAllByLinkIds(providerContext, null, linkIdList);
}
/**
* deleteDynamicAllByLinkIds
* The delete dynamic all by link ids method.
* @param {@link java.lang.Object} The parameter can be of any type.
* @param providerContext {@link org.apache.ibatis.builder.annotation.ProviderContext} The provider context parameter is ProviderContext
type.
* @param tablename {@link java.lang.String} The tablename parameter is String
type.
* @param linkIdList {@link java.util.Collection} The link id list parameter is Collection
type.
* @return {@link java.lang.String} The delete dynamic all by link ids return object is String
type.
* @throws RestException {@link io.github.nichetoolkit.rest.RestException} The rest exception is RestException
type.
* @see org.apache.ibatis.builder.annotation.ProviderContext
* @see java.lang.String
* @see java.util.Collection
* @see io.github.nichetoolkit.rest.RestException
*/
public static String deleteDynamicAllByLinkIds(ProviderContext providerContext, String tablename, Collection linkIdList) throws RestException {
OptionalUtils.ofEmpty(linkIdList, "The link id list param of 'deleteAllByLinkIds' method cannot be empty!", message -> new MybatisParamErrorException("deleteAllByLinkIds", "linkIdList", message));
return MybatisSqlProvider.providingOfLinkIdAll(providerContext, tablename, linkIdList, table -> {}, DELETE_SQL_SUPPLY);
}
}