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

import com.github.microservice.auth.security.annotations.ResourceAuth;
import com.github.microservice.auth.security.type.AuthType;
import com.github.microservice.net.ResultContent;
import com.github.microservice.types.deviceUse.DeviceCategory;
import com.github.microservice.types.deviceUse.DeviceType;
import com.github.microservice.types.deviceUse.OnLineState;
import com.zhongshu.card.server.core.service.base.CommonService;
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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 通用服务
 *
 * @author TRX
 * @date 2024/3/21
 */
@RequestMapping("/common")
@RestController
@Validated
@Tag(name = "通用功能管理")
public class CommonController {

    @Autowired
    private CommonService commonService;

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "设备类型 选择项")
    @RequestMapping(value = "getDeviceType", method = {RequestMethod.GET})
    public ResultContent getDeviceType() {
        return ResultContent.buildSuccess(commonService.getEnums(DeviceType.values()));
    }

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "设备节点 选择项")
    @RequestMapping(value = "getDeviceCategory", method = {RequestMethod.GET})
    public ResultContent getDeviceCategory() {
        return ResultContent.buildSuccess(commonService.getEnums(DeviceCategory.values()));
    }

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "设备状态 选择项")
    @RequestMapping(value = "getOnLineState", method = {RequestMethod.GET})
    public ResultContent getOnLineState() {
        return ResultContent.buildSuccess(commonService.getEnums(OnLineState.values()));
    }
}
