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

io.github.nichetoolkit.mybatis.provider.PostgresOperateLinkProvider Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package io.github.nichetoolkit.mybatis.provider;

import io.github.nichetoolkit.mybatis.MybatisSqlProvider;
import io.github.nichetoolkit.mybatis.MybatisTable;
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.actuator.ConsumerActuator;
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;

/**
 * PostgresOperateLinkProvider
 * 

The postgres operate 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 PostgresOperateLinkProvider implements MybatisSqlProvider { @Override public DatabaseType databaseType() { return DatabaseType.POSTGRESQL; } /** * operateByLinkId *

The operate 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.

* @param operate {@link java.lang.Integer}

The operate parameter is Integer type.

* @return {@link java.lang.String}

The operate 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.Integer * @see java.lang.String * @see io.github.nichetoolkit.rest.RestException */ public static String operateByLinkId(ProviderContext providerContext, L linkId, Integer operate) throws RestException { return operateDynamicByLinkId(providerContext, null, linkId, operate); } /** * operateDynamicByLinkId *

The operate 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.

* @param operate {@link java.lang.Integer}

The operate parameter is Integer type.

* @return {@link java.lang.String}

The operate 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 java.lang.Integer * @see io.github.nichetoolkit.rest.RestException */ public static String operateDynamicByLinkId(ProviderContext providerContext, String tablename, L linkId, Integer operate) throws RestException { OptionalUtils.ofEmpty(linkId, "The link id param of 'operateByLinkId' method cannot be empty!", message -> new MybatisTableErrorException("operateByLinkId", "linkId", message)); OptionalUtils.ofEmpty(operate, "The operate param of 'operateByLinkId' method cannot be empty!", message -> new MybatisParamErrorException("operateByLinkId", "operate", message)); String operateColumn = "The operate column of table with 'operateByLinkId' method cannot be empty!"; ConsumerActuator tableOptional = table -> OptionalUtils.ofEmpty(table.getLogicColumn(), operateColumn, log, message -> new MybatisTableErrorException("operateByLinkId", "operateColumn", message)); return MybatisSqlProvider.providingOfLinkId(providerContext, tablename, linkId, tableOptional, OPERATE_SQL_SUPPLY); } /** * operateAllByLinkIds *

The operate 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.

* @param operate {@link java.lang.Integer}

The operate parameter is Integer type.

* @return {@link java.lang.String}

The operate 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.Integer * @see java.lang.String * @see io.github.nichetoolkit.rest.RestException */ public static String operateAllByLinkIds(ProviderContext providerContext, Collection linkIdList, Integer operate) throws RestException { return operateDynamicAllByLinkIds(providerContext, null, linkIdList, operate); } /** * operateDynamicAllByLinkIds *

The operate 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.

* @param operate {@link java.lang.Integer}

The operate parameter is Integer type.

* @return {@link java.lang.String}

The operate 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 java.lang.Integer * @see io.github.nichetoolkit.rest.RestException */ public static String operateDynamicAllByLinkIds(ProviderContext providerContext, String tablename, Collection linkIdList, Integer operate) throws RestException { OptionalUtils.ofEmpty(linkIdList, "The link id list param of 'operateAllByLinkIds' method cannot be empty!", message -> new MybatisParamErrorException("operateAllByLinkIds", "linkIdList", message)); OptionalUtils.ofEmpty(operate, "The operate param of 'operateAllByLinkIds' method cannot be empty!", message -> new MybatisParamErrorException("operateAllByLinkIds", "operate", message)); String operateColumn = "The operate column of table with 'operateAllByLinkIds' method cannot be empty!"; ConsumerActuator tableOptional = table -> OptionalUtils.ofEmpty(table.getLogicColumn(), operateColumn, log, message -> new MybatisTableErrorException("operateAllByLinkIds", "operateColumn", message)); return MybatisSqlProvider.providingOfLinkIdAll(providerContext, tablename, linkIdList, tableOptional, OPERATE_SQL_SUPPLY); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy