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

import com.github.microservice.auth.client.constant.AuthConstant;
import com.github.microservice.auth.security.annotations.ResourceAuth;
import com.github.microservice.auth.security.type.AuthType;
import com.zhongshu.card.client.model.openApi.AppParam;
import com.zhongshu.card.server.core.service.openAPI.OpenAppManagerService;
import com.zhongshu.opengateway.client.model.param.SignParam;
import com.zhongshu.opengateway.client.service.OpenApiConfigService;
import com.zhongshu.opengateway.client.type.AppState;
import com.zhongshu.opengateway.client.type.AppType;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/openApi/app")
@Tag(name = "OpenApi--应用管理")
public class OpenAppManagerController {

    @Autowired
    OpenAppManagerService openAppManagerService;

    @Autowired
    OpenApiConfigService openApiConfigService;

//    @Operation(summary = "添加应用", description = "添加应用")
//    @RequestMapping(value = "add", method = {RequestMethod.POST})
////    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
////    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
//    public Object add(@RequestBody SignParam param){
//        return openAppManagerService.add(param);
//    }
//
//    @Operation(summary = "删除应用", description = "删除应用")
//    @RequestMapping(value = "delete", method = {RequestMethod.GET})
////    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
////    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
//    public Object delete(@Parameter(name = "appId", description = "应用id") @RequestParam(name = "appId") String appId){
//        return openAppManagerService.delete(appId);
//    }


//    @Operation(summary = "禁用/启用", description = "禁用/启用")
////    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
////    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
//    @RequestMapping(value = "disable", method = {RequestMethod.GET})
//    public Object disable(@Parameter(name = "appId", description = "应用id")@RequestParam(name = "appId")String appId,
//                          @Parameter(name = "appState", description = "应用状态")@RequestParam(name = "appState")AppState appState){
//        return openAppManagerService.disable(appId, appState);
//    }

    /**
     * 分页获取该项目下的app列表
     */
    @Operation(summary = "分页获取该项目下的app列表", description = "分页获取该项目下的app列表")
//    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
//    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
    @RequestMapping(value = "page", method = {RequestMethod.POST})
    public Object page(AppParam appParam,
                       @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable){
        return openAppManagerService.page(appParam, pageable);
    }


    //**--------------------------------------------超管接口------------------------------------------------------**/

}
