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.organization.model.CreateSiteEntity;
import org.wfc.omada.api.organization.model.SiteEntity;
import org.wfc.omada.api.organization.model.UpdateSiteEntity;
import org.wfc.system.service.ISysSiteService;

/**
 * @description: site controller
 * @author: cyc
 * @since: 2025-02-18
 */
@RestController
@RequestMapping("/site")
public class SysSiteController extends BaseController {

    @Autowired
    private ISysSiteService siteService;

    @GetMapping("/page")
    public TableDataInfo getSiteList(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) {
        return siteService.getSiteList(pageNum, pageSize);
    }

    @GetMapping("/{siteId}")
    public R<SiteEntity> getSiteInfo(@PathVariable(required = true) String siteId) {
        return R.ok(siteService.getSiteEntity(siteId));
    }

    @PostMapping
    public R<Boolean> createNewSite(@RequestBody(required = false) CreateSiteEntity createSiteEntity) {
        return R.ok(siteService.createNewSite(createSiteEntity));
    }

    @PutMapping("/{siteId}")
    public R<Boolean> updateSite(@PathVariable(required = true) String siteId, @RequestBody(required = false) UpdateSiteEntity updateSiteEntity) {
        return R.ok(siteService.updateSiteEntity(siteId, updateSiteEntity));
    }

    @DeleteMapping("/{siteId}")
    public R<Boolean> deleteSite(@PathVariable(required = true) String siteId) {
        return R.ok(siteService.deleteSite(siteId));
    }
}
