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

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.PortalAppLinkCategory;
import cn.stylefeng.team.portal.modular.management.pojo.request.PortalAppLinkCategoryRequest;
import cn.stylefeng.team.portal.modular.management.service.PortalAppLinkCategoryService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@ApiResource(name = "应用链接的分类")
public class PortalAppLinkCategoryController {

    @Resource
    private PortalAppLinkCategoryService portalAppLinkCategoryService;

    @PostResource(name = "添加应用链接的分类", path = "/portalAppLinkCategory/add")
    public ResponseData<PortalAppLinkCategory> add(@RequestBody @Validated(PortalAppLinkCategoryRequest.add.class) PortalAppLinkCategoryRequest portalAppLinkCategoryRequest) {
        portalAppLinkCategoryService.add(portalAppLinkCategoryRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "删除应用链接的分类", path = "/portalAppLinkCategory/delete")
    public ResponseData<?> delete(@RequestBody @Validated(PortalAppLinkCategoryRequest.delete.class) PortalAppLinkCategoryRequest portalAppLinkCategoryRequest) {
        portalAppLinkCategoryService.del(portalAppLinkCategoryRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "批量删除应用链接的分类", path = "/portalAppLinkCategory/batchDelete")
    public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) PortalAppLinkCategoryRequest portalAppLinkCategoryRequest) {
        portalAppLinkCategoryService.batchDelete(portalAppLinkCategoryRequest);
        return new SuccessResponseData<>();
    }

    @PostResource(name = "编辑应用链接的分类", path = "/portalAppLinkCategory/edit")
    public ResponseData<?> edit(@RequestBody @Validated(PortalAppLinkCategoryRequest.edit.class) PortalAppLinkCategoryRequest portalAppLinkCategoryRequest) {
        portalAppLinkCategoryService.edit(portalAppLinkCategoryRequest);
        return new SuccessResponseData<>();
    }

    @GetResource(name = "查看应用链接的分类详情", path = "/portalAppLinkCategory/detail")
    public ResponseData<PortalAppLinkCategory> detail(@Validated(PortalAppLinkCategoryRequest.detail.class) PortalAppLinkCategoryRequest portalAppLinkCategoryRequest) {
        return new SuccessResponseData<>(portalAppLinkCategoryService.detail(portalAppLinkCategoryRequest));
    }

    @GetResource(name = "获取应用链接的分类列表", path = "/portalAppLinkCategory/list")
    public ResponseData<List<PortalAppLinkCategory>> list(PortalAppLinkCategoryRequest portalAppLinkCategoryRequest) {
        return new SuccessResponseData<>(portalAppLinkCategoryService.findList(portalAppLinkCategoryRequest));
    }

}
