doum
6 天以前 2b287056e2f59518888d05a1bbc7e5a55fbd84d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.doumee.lib_coremodel.base.room;
 
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Update;
 
import java.util.List;
 
@Dao
public interface BaseDao<T> {
    /**
     * 添加单个对象,返回插入行号
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    abstract Long insert(T t);
 
    /**
     * 添加数组对象数据
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    abstract Long[] insert(T[] ts);
 
    /**
     * 添加对象集合
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    abstract List<Long> insert(List<T> ts);
 
    /**
     * 根据对象中的主键删除(主键是自动增长的,无需手动赋值)
     */
    @Delete
    abstract void delete(T t);
 
    /**
     * 根据对象中的主键更新(主键是自动增长的,无需手动赋值)
     */
    @Update
    abstract int update(T t);
}