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.CommonAppLinkCategory;
import cn.stylefeng.team.portal.modular.management.pojo.request.CommonAppLinkCategoryRequest;
import cn.stylefeng.team.portal.modular.management.service.CommonAppLinkCategoryService;
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 CommonAppLinkCategoryController {

    @Resource
    private CommonAppLinkCategoryService commonAppLinkCategoryService;

    @PostResource(name = "添加通用应用链接的分类", path = "/commonAppLinkCategory/add")
    public ResponseData<CommonAppLinkCategory> add(@RequestBody @Validated(CommonAppLinkCategoryRequest.add.class) CommonAppLinkCategoryRequest commonAppLinkCategoryRequest) {
        commonAppLinkCategoryService.add(commonAppLinkCategoryRequest);
        return new SuccessResponseData<>();
    }

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

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

    @PostResource(name = "编辑通用应用链接的分类", path = "/commonAppLinkCategory/edit")
    public ResponseData<?> edit(@RequestBody @Validated(CommonAppLinkCategoryRequest.edit.class) CommonAppLinkCategoryRequest commonAppLinkCategoryRequest) {
        commonAppLinkCategoryService.edit(commonAppLinkCategoryRequest);
        return new SuccessResponseData<>();
    }

    @GetResource(name = "查看通用应用链接的分类详情", path = "/commonAppLinkCategory/detail")
    public ResponseData<CommonAppLinkCategory> detail(@Validated(CommonAppLinkCategoryRequest.detail.class) CommonAppLinkCategoryRequest commonAppLinkCategoryRequest) {
        return new SuccessResponseData<>(commonAppLinkCategoryService.detail(commonAppLinkCategoryRequest));
    }

    @GetResource(name = "获取通用应用链接的分类列表", path = "/commonAppLinkCategory/list")
    public ResponseData<List<CommonAppLinkCategory>> list(CommonAppLinkCategoryRequest commonAppLinkCategoryRequest) {
        return new SuccessResponseData<>(commonAppLinkCategoryService.findList(commonAppLinkCategoryRequest));
    }

}
