package com.backendsys.modules.cms.page.controller;

import com.backendsys.entity.Cms.CmsPageDTO;
import com.backendsys.entity.PageDTO;
import com.backendsys.modules.cms.page.entity.Page;
import com.backendsys.modules.cms.page.service.PageService;
import com.backendsys.modules.common.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Validated
@RestController
@Tag(name = "单页管理")
public class PageController {

    @Autowired
    private PageService pageService;

    @Operation(summary = "获取单页列表")
    @PreAuthorize("@sr.hasPermission('10.3')")
    @GetMapping("/api/cms/page/getPage")
    public Result getPage(@Validated Page page) {
        return Result.success().put("data", pageService.selectPageList(page));
    }

    @Operation(summary = "获取单页详情")
    @PreAuthorize("@sr.hasPermission('12.2')")
    @GetMapping("/api/cms/page/getPageDetail")
    public Result getPageDetail(@Validated(Page.Detail.class) Page page) {
        return Result.success().put("data", pageService.selectPageDetail(page));
    }

}
