package com.rongwei.sfcommon.sys.dao;

import com.rongwe.scentity.domian.CheckItemsDutyuserDo;
import com.rongwe.scentity.vo.CheckItemsVo;
import com.rongwei.rwcommon.base.BaseDao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;

/**
 * 设备责任人表
 *
 * @author chglee
 * @email 1992lcg@163.com
 * @date 2020-08-21 15:34:06
 */
public interface CheckItemsDutyuserDao extends BaseDao<CheckItemsDutyuserDo> {

    @Select("select * from (select a.DUTYUSERID,b.*, b.MODIFYDATE AS SORTDATE from asp_check_items_dutyuser a left join asp_check_items b on a.CHECKITEMID = b.id where a.DUTYUSERID = #{userId} and a.DELETED = '0' and b.DELETED = '0') t1 order by SORTDATE desc")
    List<CheckItemsVo> getCheckItemsByUserId(@Param("userId") String userId);

    @Update("update asp_check_items_dutyuser set DELETED = '1',MODIFYDATE = NOW() where DUTYUSERID = #{userId} and CHECKITEMID in (${checkItemsIds})")
    void relieveCheckItems(@Param("userId") String userId,@Param("checkItemsIds") String checkItemsIds);

}