package cn.iocoder.yudao.module.system.dal.mysql.worklog;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogReadDo;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 日志查看 Mapper
 *
 * @author 符溶馨
 */
@Mapper
public interface LogReadMapper extends BaseMapperX<LogReadDo> {

    default List<LogReadDo> selectUserByLogId(Long logId, Integer readStatus) {

        return selectList(new LambdaQueryWrapperX<LogReadDo>()
                .eq(LogReadDo::getLogInstanceId, logId)
                .eq(LogReadDo::getReadStatus, readStatus));
    }

    default void updateReadStatus(Long logId, Long userId){

        update(new LogReadDo().setReadStatus(1),
                new LambdaQueryWrapperX<LogReadDo>()
                        .eq(LogReadDo::getLogInstanceId, logId)
                        .eq(LogReadDo::getReadUserId, userId));
    }
}
