package beilv.web.controller.system;

import beilv.common.core.domain.AjaxResult;
import beilv.common.core.domain.entity.SysDictData;
import beilv.system.service.ISysDictDataService;
import beilv.system.service.ISysDictTypeService;
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;

@RestController
@RequestMapping("/app-api/dict")
public class SysDictController {

    @Autowired
    private ISysDictTypeService dictTypeService;

    @Autowired
    private ISysDictDataService dictDataService;

    @GetMapping("/getType")
    public AjaxResult getType(String dictType) {
        return AjaxResult.success(dictTypeService.selectDictDataByType(dictType));
    }

    /**
     * 根据字典类型和字典键值查询字典数据信息
     *
     * @param dictType  字典类型
     * @param dictValue 字典键值
     * @return 字典标签
     */
    @GetMapping("/getLabel")
    public AjaxResult getLabel(String dictType, String dictValue) {
        return AjaxResult.success("success",dictDataService.selectDictLabel(dictType, dictValue));
    }
}
