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

import com.github.microservice.auth.security.annotations.ResourceAuth;
import com.github.microservice.auth.security.type.AuthType;
import com.github.microservice.net.ResultContent;
import com.zhongshu.card.client.model.base.ProjectOidParam;
import com.zhongshu.card.client.model.projectAbout.ProjectIotInfoModel;
import com.zhongshu.card.client.model.projectAbout.ProjectIotInfoParam;
import com.zhongshu.card.server.core.service.projectAbout.ProjectIotInfoService;
import io.swagger.v3.oas.annotations.Hidden;
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;

/**
 * 项目的 物联网 ak  sk  设置
 *
 * @author TRX
 * @date 2024/7/26
 */
@RestController
@RequestMapping("/project/projectIotInfo")
@Tag(name = "项目-物联网设置")
public class ProjectIotInfoController {

    @Autowired
    ProjectIotInfoService projectIotInfoService;

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "保存项目的物联网设置", description = "保存项目的物联网设置")
    @RequestMapping(value = "saveProjectIotInfo", method = {RequestMethod.POST})
    public ResultContent saveProjectIotInfo(@RequestBody @Valid ProjectIotInfoParam param) {
        return projectIotInfoService.saveProjectIotInfo(param);
    }

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "得到项目的物联网配置", description = "得到项目的物联网配置")
    @RequestMapping(value = "getProjectIotInfo", method = {RequestMethod.POST})
    public ResultContent<ProjectIotInfoModel> getProjectWeChatInfo(@RequestBody ProjectOidParam param) {
        return projectIotInfoService.getProjectIotInfo(param.getProjectOid());
    }

    //------------------------------feign start -----------------------
    @Operation(hidden = true, summary = "得到项目的物联网配置", description = "得到项目的物联网配置")
    @RequestMapping(value = "manager/getProjectIotInfo", method = {RequestMethod.POST})
    @Hidden
    public ResultContent<ProjectIotInfoModel> getProjectIotInfo(
            @RequestBody ProjectOidParam param) {
        return projectIotInfoService.getProjectIotInfo(param.getProjectOid());
    }

}
