package com.za.room.db.order

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.za.base.Const
import com.za.bean.db.order.PhotoTemplateInfo

@Dao
interface ChangeBatteryDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE, entity = PhotoTemplateInfo::class)
    fun insert(photoTemplateInfo: PhotoTemplateInfo)

    //获取当前节点的图片模板
    @Query("select * from photo_template_bean where taskCode =:taskCode and myCustomPhotoType=${Const.PhotoType.ChangeBattery}")
    fun getAllChangeBatteryPhoto(taskCode: String): List<PhotoTemplateInfo>?

    @Update(onConflict = OnConflictStrategy.REPLACE)
    fun update(photoTemplateInfo: PhotoTemplateInfo)

    @Query("delete from photo_template_bean where taskId=:taskId and myCustomPhotoType=${Const.PhotoType.ChangeBattery}")
    fun deleteFromTaskId(taskId: Int)

    @Query("delete from photo_template_bean where myCustomPhotoType=${Const.PhotoType.ChangeBattery}")
    fun deleteAll()
}
