package com.za.room.db.water_marker

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Transaction
import com.za.bean.db.water_marker.WaterMarkerItemBean
import com.za.bean.db.water_marker.WaterMarkerTemplateAndItemRef
import com.za.bean.db.water_marker.WaterMarkerTemplateBean

@Dao
interface WaterMarkerDao {
    @Transaction
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertWaterMarkerTemplate(waterMarkerTemplateBean: WaterMarkerTemplateBean)

    @Transaction
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertWaterMarkerItem(waterMarkerItemBean: WaterMarkerItemBean)

    @Transaction
    @Query("delete from water_template where taskCode=:taskCode")
    fun deleteWaterTemplate(taskCode: String)

    @Transaction
    @Query("delete from water_marker_item where taskCode=:taskCode")
    fun deleteWaterMarkerItem(taskCode: String)

    @Transaction
    @Query("select * from water_template where taskCode=:taskCode")
    fun query(taskCode: String): WaterMarkerTemplateAndItemRef?

    @Transaction
    @Query("select * from water_template")
    fun queryAll(): List<WaterMarkerTemplateAndItemRef>?

    @Query("delete from water_template")
    fun deleteWaterTemplate()

    @Query("delete from water_marker_item")
    fun deleteWaterTemplateItem()
}
