001/*
002 *    Copyright 2024-2025, Warm-Flow (290631660@qq.com).
003 *
004 *    Licensed under the Apache License, Version 2.0 (the "License");
005 *    you may not use this file except in compliance with the License.
006 *    You may obtain a copy of the License at
007 *
008 *       https://www.apache.org/licenses/LICENSE-2.0
009 *
010 *    Unless required by applicable law or agreed to in writing, software
011 *    distributed under the License is distributed on an "AS IS" BASIS,
012 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *    See the License for the specific language governing permissions and
014 *    limitations under the License.
015 */
016package org.dromara.warm.flow.core.dao;
017
018import org.dromara.warm.flow.core.orm.agent.WarmQuery;
019import org.dromara.warm.flow.core.utils.page.Page;
020
021import java.io.Serializable;
022import java.util.Collection;
023import java.util.List;
024
025/**
026 * BaseMapper接口
027 *
028 * @author warm
029 * @since 2023-03-17
030 */
031public interface WarmDao<T> {
032
033    T newEntity();
034
035    /**
036     * 根据id查询
037     *
038     * @param id 主键
039     * @return 实体
040     */
041    T selectById(Serializable id);
042
043    /**
044     * 根据ids查询
045     *
046     * @param ids 主键
047     * @return 实体
048     */
049    List<T> selectByIds(Collection<? extends Serializable> ids);
050
051    /**
052     * 分页查询
053     *
054     * @param entity 实体列表
055     * @return 集合
056     */
057    Page<T> selectPage(T entity, Page<T> page);
058
059    /**
060     * 分页查询
061     *
062     * @param entity 实体列表
063     * @param query
064     * @return 集合
065     */
066    List<T> selectList(T entity, WarmQuery<T> query);
067
068    /**
069     * 查询数量
070     *
071     * @param entity 实体列表
072     * @return 集合
073     */
074    long selectCount(T entity);
075
076    /**
077     * 新增
078     *
079     * @param entity 实体
080     * @return 结果
081     */
082    int save(T entity);
083
084    /**
085     * 根据id修改
086     *
087     * @param entity 实体
088     * @return 结果
089     */
090    int updateById(T entity);
091
092    /**
093     * 根据entity删除
094     *
095     * @param entity 实体
096     * @return 结果
097     */
098    int delete(T entity);
099
100    /**
101     * 根据id删除
102     *
103     * @param id 主键
104     * @return 结果
105     */
106    int deleteById(Serializable id);
107
108    /**
109     * 根据ids批量删除
110     *
111     * @param ids 需要删除的数据主键集合
112     * @return 结果
113     */
114    int deleteByIds(Collection<? extends Serializable> ids);
115
116    /**
117     * 批量新增
118     *
119     * @param list 集合
120     */
121    void saveBatch(List<T> list);
122
123    /**
124     * 批量修改
125     *
126     * @param list 集合
127     */
128    void updateBatch(List<T> list);
129}