package org.wfc.system.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.domain.R;
import org.wfc.omada.api.accesscontrol.model.PortalAccessControlOpenApiVo;
import org.wfc.system.service.ISysAccessControlService;

/**
 * @description: access control controller
 * @author: cyc
 * @since: 2025-06-04
 */
@RestController
@RequestMapping("/access-control")
public class SysAccessControlController {

    @Autowired
    private ISysAccessControlService sysAccessControlService;

    @GetMapping("/{siteId}")
    public R<PortalAccessControlOpenApiVo> getAccessControl(@PathVariable(required = true) String siteId) {
        return R.ok(sysAccessControlService.getAccessControl(siteId));
    }

    @PostMapping("/{siteId}")
    public R<Boolean> modifyAccessControl(@PathVariable(required = true) String siteId, @RequestBody(required = false) PortalAccessControlOpenApiVo portalAccessControlOpenApiVo) {
        return R.ok(sysAccessControlService.modifyAccessControl(siteId, portalAccessControlOpenApiVo));
    }

}
