package cn.pluss.platform.controller.systemConfig;

import cn.pluss.platform.api.PageInfo;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.entity.CommonSwitch;
import cn.pluss.platform.mswitch.CommonSwitchService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * 系统开关管理页面
 */
@Controller
@RequiredArgsConstructor
@RequestMapping("systemSwitch")
public class SystemSwitchController {

    private final CommonSwitchService commonSwitchService;

    @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "index")
    public String toList() {
        return "systemSwitch/list";
    }

    @GetMapping("/page")
    public Result<PageInfo<CommonSwitch>> page(Page<CommonSwitch> page , CommonSwitch commonSwitch) {
        PageInfo<CommonSwitch> pageInfo = commonSwitchService.pageData(page, commonSwitch);
        return ResultGenerator.genSuccessResult(pageInfo);
    }
}
