package cn.stylefeng.team.portal.modular.front.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.front.pojo.appcenter.AppCenterCategory;
import cn.stylefeng.team.portal.modular.front.pojo.appcenter.AppCenterLink;
import cn.stylefeng.team.portal.modular.front.pojo.request.AppCenterRequest;
import cn.stylefeng.team.portal.modular.front.service.AppCenterService;
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 ComponentQuickAccessController {

    @Resource
    private AppCenterService appCenterService;

    @GetResource(name = "获取当前用户快捷入口的应用链接列表", path = "/component/quickAccess/getCurrentUserLinkList")
    public ResponseData<List<AppCenterLink>> getCurrentUserLinkList() {
        List<AppCenterLink> list = appCenterService.getCurrentUserLinkList();
        return new SuccessResponseData<>(list);
    }

    @GetResource(name = "获取用户自定义配置列表", path = "/component/quickAccess/getUserConfigList")
    public ResponseData<List<AppCenterCategory>> getUserConfigList() {
        List<AppCenterCategory> list = appCenterService.getUserConfigList();
        return new SuccessResponseData<>(list);
    }

    @PostResource(name = "配置当前用户快捷入口", path = "/component/quickAccess/updateUserConfigList")
    public ResponseData<?> updateUserConfigList(@RequestBody @Validated(AppCenterRequest.add.class) AppCenterRequest appCenterRequest) {
        appCenterService.updateUserConfigList(appCenterRequest);
        return new SuccessResponseData<>();
    }

}
