package com.doumee.keyCabinet.dao;
|
|
import androidx.room.Dao;
|
import androidx.room.Delete;
|
import androidx.room.Insert;
|
import androidx.room.Query;
|
import androidx.room.Transaction;
|
import androidx.room.Update;
|
|
import java.util.List;
|
/**"SELECT user.id, user.name, user.departmentId," +
|
"department.name AS departmentName FROM user " +
|
"INNER JOIN department ON user.departmentId = department.id"*/
|
|
/**
|
* 一对一
|
* @Entity
|
public class User {
|
@PrimaryKey public long userId;
|
public String name;
|
public int age;
|
}
|
|
@Entity
|
public class Library {
|
@PrimaryKey public long libraryId;
|
public long userOwnerId;
|
}
|
*/
|
@Dao
|
public interface CabinetGridDao {
|
|
@Transaction
|
@Query("SELECT * FROM cabinet_grid")
|
List<CabinetGridDo> loadAll();
|
|
@Transaction
|
@Query("SELECT * FROM cabinet_grid WHERE id = :id")
|
CabinetGridDo getGridBuyId(int id);
|
|
@Transaction
|
@Query("SELECT * FROM cabinet_grid WHERE grid_key = :key")
|
CabinetGridDo getGridByKey(String key);
|
|
@Transaction
|
@Query("SELECT * FROM cabinet_grid WHERE grid_key IN (:keys)")
|
List<CabinetGridDo> getGridByKeys(List<String> keys);
|
|
@Transaction
|
@Query("SELECT * FROM cabinet_grid WHERE id = :id")
|
List<CabinetGridDo> getGridsById(int id);
|
|
@Transaction
|
@Query("SELECT * FROM cabinet_grid WHERE id IN (:ids)")
|
List<CabinetGridDo> getGridsByIds(int... ids);
|
|
/*
|
@Transaction
|
@Query("SELECT * FROM cabinet_grid WHERE cabinet_name = :name LIMIT 1")
|
List<CabinetGridDo> getStudentByName(String name);
|
|
@Transaction
|
@Query("SELECT * FROM cabinet_grid WHERE cabinet_name LIKE '%' || :name || '%'")
|
List<CabinetGridDo> searchStudentByName(String name);
|
*/
|
|
@Transaction
|
@Query("SELECT * FROM cabinet_grid WHERE is_open = :isOpen")
|
List<CabinetGridDo> getGridByOpenStatus(int isOpen);
|
|
@Transaction
|
@Query("SELECT * FROM cabinet_grid WHERE is_open = 1 and working_status = 0 and grid_status = 0 and key_status !=3 order by grid_key asc")
|
List<CabinetGridDo> getOpenGrids();
|
|
@Transaction
|
@Query("SELECT count(*) FROM cabinet_grid WHERE is_open = 1")
|
int getOpenGridCount();
|
|
@Transaction
|
@Insert
|
void insert(CabinetGridDo data);
|
|
@Transaction
|
@Insert
|
void insertAll(CabinetGridDo... datas);
|
|
@Transaction
|
@Insert
|
void insert(List<CabinetGridDo> studentLists);
|
|
@Transaction
|
@Update
|
void update(CabinetGridDo... datas);
|
|
@Transaction
|
@Delete
|
void delete(CabinetGridDo... datas);
|
}
|