package cn.stylefeng.team.meta.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.meta.modular.pojo.dictrouting.RoutingDict;
import cn.stylefeng.team.meta.modular.pojo.dictrouting.RoutingDictType;
import cn.stylefeng.team.meta.modular.service.DictRoutingService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@ApiResource(name = "字典路由接口")
public class DictRoutingController {

    @Resource
    private DictRoutingService dictRoutingService;

    @GetResource(name = "获取字典路由方式，true为用户字典", path = "/dictRouting/getDictUserTypeFlag")
    public ResponseData<Boolean> getDictUserTypeFlag() {
        return new SuccessResponseData<>(false);
    }

    @GetResource(name = "获取字典类型列表", path = "/dictRouting/getDictTypeList")
    public ResponseData<List<RoutingDictType>> getDictTypeList() {
        return new SuccessResponseData<>(dictRoutingService.getDictTypeList());
    }

    @GetResource(name = "获取字典项列表", path = "/dictRouting/getDictItemList")
    public ResponseData<List<RoutingDict>> getDictItemList(@RequestParam("dictTypeId") Long dictTypeId) {
        List<RoutingDict> dictList = dictRoutingService.getDictItemList(dictTypeId);
        return new SuccessResponseData<>(dictList);
    }

}
