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

win.doyto.query.service.UserIdDataAccess Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
// Generated by delombok at Wed Nov 06 09:48:14 UTC 2024
/*
 * Copyright © 2019-2024 Forb Yuan
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package win.doyto.query.service;

import win.doyto.query.core.DataAccess;
import win.doyto.query.core.DoytoQuery;
import win.doyto.query.entity.Persistable;
import win.doyto.query.entity.UserIdProvider;
import java.io.Serializable;

/**
 * UserIdDataAccess
 *
 * @author f0rb on 2023/6/21
 * @since 1.0.2
 */
public class UserIdDataAccess, I extends Serializable, Q extends DoytoQuery> implements DataAccess {
    private final DataAccess delegate;
    private final UserIdProvider userIdProvider;

    @Override
    public void create(E e) {
        userIdProvider.setupUserId(e);
        delegate.create(e);
    }

    @Override
    public int batchInsert(Iterable entities, String... columns) {
        if (userIdProvider.getUserId() != null) {
            for (E e : entities) {
                userIdProvider.setupUserId(e);
            }
        }
        return delegate.batchInsert(entities, columns);
    }

    @Override
    public int update(E e) {
        userIdProvider.setupPatchUserId(e);
        return delegate.update(e);
    }

    @Override
    public int patch(E e) {
        userIdProvider.setupPatchUserId(e);
        return delegate.patch(e);
    }

    public int patch(E e, Q q) {
        userIdProvider.setupPatchUserId(e);
        return delegate.patch(e, q);
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public UserIdDataAccess(final DataAccess delegate, final UserIdProvider userIdProvider) {
        this.delegate = delegate;
        this.userIdProvider = userIdProvider;
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public java.util.List query(final Q query) {
        return this.delegate.query(query);
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public long count(final Q query) {
        return this.delegate.count(query);
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public win.doyto.query.core.PageList page(final Q query) {
        return this.delegate.page(query);
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public  java.util.List queryColumns(final Q q, final java.lang.Class clazz, final java.lang.String... columns) {
        return this.delegate.queryColumns(q, clazz, columns);
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public E get(final I id) {
        return this.delegate.get(id);
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public E get(final win.doyto.query.core.IdWrapper w) {
        return this.delegate.get(w);
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public int delete(final I id) {
        return this.delegate.delete(id);
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public int delete(final win.doyto.query.core.IdWrapper w) {
        return this.delegate.delete(w);
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public int delete(final Q query) {
        return this.delegate.delete(query);
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public java.util.List queryIds(final Q query) {
        return this.delegate.queryIds(query);
    }
}