package com.zhongshu.card.server.core.dao.devices;

import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
import com.zhongshu.card.client.type.DataState;
import com.zhongshu.card.server.core.dao.devices.extend.DevicePermissDaoExtend;
import com.zhongshu.card.server.core.domain.devices.permiss.DevicePermiss;
import com.zhongshu.card.server.core.domain.org.OrganizationUser;

import java.util.List;

/**
 * 用户设备权限
 *
 * @author TRX
 * @date 2024/3/21
 */
public interface DevicePermissDao extends MongoDao<DevicePermiss>, DevicePermissDaoExtend {

    DevicePermiss findTopById(String id);

    List<DevicePermiss> findByIdIn(List<String> ids);

    List<DevicePermiss> findByDeviceIdAndProjectOid(String deviceId, String projectOid);

    List<DevicePermiss> findByUserIdAndProjectOid(String userId, String projectOid);

    DevicePermiss findTopByDeviceIdAndOrganizationUser(String deviceId, OrganizationUser organizationUser);

    DevicePermiss findTopByUserIdAndDeviceIdAndProjectOid(String userId, String deviceId, String projectOid);

    DevicePermiss findTopByUserIdAndDeviceIdAndProjectOidAndDataState(String userId, String deviceId, String projectOid, DataState dataState);

    List<DevicePermiss> findByOrganizationUserIn(List<OrganizationUser> organizationUsers);

    List<DevicePermiss> findByDeviceIdInAndDataState(List<String> deviceIds, DataState dataState);

    List<DevicePermiss> findByUserIdInAndProjectOidAndDataState(List<String> userIds, String projectOid, DataState dataState);

}
