package cn.stylefeng.team.portal.modular.management.controller;

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.team.portal.modular.management.entity.PortalDesign;
import cn.stylefeng.team.portal.modular.management.pojo.request.PortalDesignRequest;
import cn.stylefeng.team.portal.modular.management.service.PortalDesignService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@ApiResource(name = "门户设计")
public class PortalDesignController {

    @Resource
    private PortalDesignService portalDesignService;

    @GetResource(name = "获取门户设计详情", path = "/portalDesign/getDesignConfig")
    public ResponseData<PortalDesign> getDesignConfig(PortalDesignRequest portalDesignRequest) {
        return new SuccessResponseData<>(portalDesignService.detail(portalDesignRequest));
    }

    @PostResource(name = "更新门户配置", path = "/portalDesign/updateDesign")
    public ResponseData<PortalDesign> updateDesign(@RequestBody @Validated(PortalDesignRequest.updateDesign.class) PortalDesignRequest portalDesignRequest) {
        portalDesignService.updateDesign(portalDesignRequest);
        return new SuccessResponseData<>();
    }

}
