package cn.muchinfo.rma.global.dao;


import android.database.Cursor;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import java.util.List;

import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo;

@Dao
public interface GoodsInfoDao {

    @Query("SELECT * FROM goods_infos")
    List<GoodsInfo> getAll();

    @Query("SELECT * FROM goods_infos order by goods_code limit 0, :limit")
    List<GoodsInfo> getLimit(int limit);

    @Query("SELECT * FROM goods_infos WHERE goods_group_id = :groupid")
    List<GoodsInfo> getGoodsGroups(int groupid);

    @Query("SELECT count(*) as count FROM goods_infos")
    Cursor getCount();

//    @Query("SELECT * FROM goods_infos WHERE " +
//            "chinese_initials like :findStr or " +
//            "GoodsId like :findStr or " +
//            "GoodsCode like :findStr or " +
//            "GoodsName like :findStr order by GoodsCode")
//    Maybe<List<GoodsInfo>> findGoodsInfo(String findStr);

    @Query("delete from goods_infos")
    void clearAllData();

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(List<GoodsInfo> goodsInfos);

}
