package org.wfc.system.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.domain.R;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.page.TableDataInfo;
import org.wfc.omada.api.sitesetting.model.PortalDetailResOpenApiVo;
import org.wfc.omada.api.sitesetting.model.PortalSetting;
import org.wfc.system.service.ISysPortalService;

/**
 * @description: portal controller
 * @author: cyc
 * @since: 2025-02-17
 */
@RestController
@RequestMapping("/portal")
public class SysPortalController extends BaseController {

    @Autowired
    private ISysPortalService sysPortalService;

    @GetMapping("/{siteId}")
    public TableDataInfo getPortalList(@PathVariable String siteId, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) {
        return sysPortalService.getPortalList(siteId, pageNum, pageSize);
    }

    @PostMapping("/{siteId}")
    public R<Boolean> addPortal(@PathVariable(required = true) String siteId, @RequestBody(required = false) PortalSetting portalSetting) {
        return R.ok(sysPortalService.addPortal(siteId, portalSetting));
    }

    @PutMapping("/{siteId}/{portalId}")
    public R<Boolean> modifyPortal(@PathVariable(required = true) String siteId, @PathVariable(required = true) String portalId, @RequestBody(required = false) PortalSetting portalSetting) {
        return R.ok(sysPortalService.modifyPortal(siteId, portalId, portalSetting));
    }

    @DeleteMapping("/{siteId}/{portalId}")
    public R<Boolean> deletePortal(@PathVariable(required = true) String siteId, @PathVariable(required = true) String portalId) {
        return R.ok(sysPortalService.deletePortal(siteId, portalId));
    }

    @GetMapping("/{siteId}/{portalId}")
    public R<PortalDetailResOpenApiVo> getPortalDetail(@PathVariable(required = true) String siteId, @PathVariable(required = true) String portalId) {
        return R.ok(sysPortalService.getPortalDetail(siteId, portalId));
    }
}
