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

import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
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.pojo.response.PortalDesignVo;
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 PortalDesignManageController {

    @Resource
    private PortalDesignService portalDesignService;

    @GetResource(name = "获取门户列表（分页）", path = "/portalDesignManage/page")
    public ResponseData<PageResult<PortalDesignVo>> page(PortalDesignRequest portalDesignRequest) {
        return new SuccessResponseData<>(portalDesignService.findPage(portalDesignRequest));
    }

    @PostResource(name = "添加门户设计配置", path = "/portalDesignManage/add")
    public ResponseData<PortalDesign> add(@RequestBody @Validated(PortalDesignRequest.add.class) PortalDesignRequest portalDesignRequest) {
        portalDesignService.add(portalDesignRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "删除门户设计配置", path = "/portalDesignManage/delete")
    public ResponseData<?> delete(@RequestBody @Validated(PortalDesignRequest.delete.class) PortalDesignRequest portalDesignRequest) {
        portalDesignService.del(portalDesignRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "批量删除门户设计配置", path = "/portalDesignManage/batchDelete")
    public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) PortalDesignRequest portalDesignRequest) {
        portalDesignService.batchDelete(portalDesignRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "编辑门户设计配置", path = "/portalDesignManage/edit")
    public ResponseData<?> edit(@RequestBody @Validated(PortalDesignRequest.edit.class) PortalDesignRequest portalDesignRequest) {
        portalDesignService.edit(portalDesignRequest);
        return new SuccessResponseData<>();
    }

    @GetResource(name = "查看门户设计配置详情", path = "/portalDesignManage/detail")
    public ResponseData<PortalDesign> detail(@Validated(PortalDesignRequest.detail.class) PortalDesignRequest portalDesignRequest) {
        return new SuccessResponseData<>(portalDesignService.detail(portalDesignRequest));
    }

}
