package com.inkasso.factoring.system.resource.controller;

import com.inkasso.adapter.response.ResponseData;
import com.inkasso.adapter.web.LoginUserHolder;
import com.inkasso.auth.interfaces.PermissionAndCheck;
import com.inkasso.auth.interfaces.Permissions;
import com.inkasso.factoring.system.resource.model.dto.ResourceTreeDTO;
import com.inkasso.factoring.system.resource.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 张超
 * @date  2023-08-19
 */
@RestController
@RequestMapping(path = "system")
@Permissions(name="资源",code = "resourceManage")
public class ResourceController {

    @Autowired
    private ResourceService resourceService;

    @GetMapping(path = "resourceTree")
    @PermissionAndCheck(name="获取资源tree",code="ResourceController:resourceTree")
    public ResponseData resourceTree() {
        Long tenantId = LoginUserHolder.get().getTenantId();
        List<ResourceTreeDTO> resourceTree = resourceService.getResourceTree(tenantId);
        return ResponseData.success(resourceTree);
    }

}