package cn.stylefeng.team.view.modular.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.team.form.api.entity.FormModel;
import cn.stylefeng.team.view.api.entity.View;
import cn.stylefeng.team.view.api.pojo.ViewColumnField;
import cn.stylefeng.team.view.modular.pojo.request.ViewRequest;
import cn.stylefeng.team.view.modular.service.ViewService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@ApiResource(name = "通用接口业务视图的控制器")
public class CommonViewController {

    @Resource
    private ViewService viewService;

    @GetResource(name = "获取视图下拉列表", path = "/customView/selectList")
    public ResponseData<List<View>> selectList(ViewRequest viewRequest) {
        return new SuccessResponseData<>(viewService.findList(viewRequest));
    }

    @GetResource(name = "获取视图展示列的配置", path = "/customView/getViewFieldList")
    public ResponseData<List<ViewColumnField>> getViewFieldList(@Validated(ViewRequest.detail.class) ViewRequest viewRequest) {
        return new SuccessResponseData<>(viewService.getViewFieldList(viewRequest));
    }

    @GetResource(name = "获取视图对应的业务下的表单列表", path = "/commonView/getViewBusinessFormList")
    public ResponseData<List<FormModel>> getViewBusinessFormList(@Validated(ViewRequest.detail.class) ViewRequest viewRequest) {
        List<FormModel> formList = viewService.getViewBusinessFormList(viewRequest);
        return new SuccessResponseData<>(formList);
    }

}
