package com.zhongshu.card.server.core.controller.openAPI;

import com.github.microservice.models.device.DevicePerQuery;
import com.github.microservice.models.device.UserPerQuery;
import com.github.microservice.net.ResultContent;
import com.zhongshu.card.server.core.service.devices.permiss.DevicePermissIotService;
import com.zhongshu.card.server.core.service.devices.DeviceUseRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author TRX
 * @date 2024/6/5
 */
@RestController
@RequestMapping("/openAPI/v1/projectManager")
@Tag(name = "openAPI-项目管理")
public class ProjectOpenAPIController {

    @Autowired
    private DevicePermissIotService devicePermissIotService;

    @Autowired
    private DeviceUseRecordService deviceUseRecordService;

    @Operation(summary = "查询设备权限", description = "查询设备权限")
    @RequestMapping(value = "queryDeviceBindUsers", method = {RequestMethod.POST})
    public ResultContent queryDeviceBindUsers(@RequestBody @Valid DevicePerQuery param) {
        return devicePermissIotService.queryDevicePermiss(param);
    }

    @Operation(summary = "查询设备对应的用户信息", description = "查询设备对应的用户信息")
    @RequestMapping(value = "queryDeviceUsersInfo", method = {RequestMethod.POST})
    public ResultContent queryDeviceUsersInfo(@RequestBody @Valid DevicePerQuery param) {
        return devicePermissIotService.getDeviceAboutUserInfos(param);
    }

    @Operation(summary = "查询设备对应的用户信息", description = "查询设备对应的用户信息")
    @RequestMapping(value = "queryProjectUsersInfo", method = {RequestMethod.POST})
    public ResultContent queryProjectUsersInfo(@RequestBody @Valid UserPerQuery param) {
        return devicePermissIotService.getDeviceAboutUserInfos(param);
    }

}
