package com.miaxis.app.controller.gzpt;


import com.miaxis.common.constant.Constants;
import com.miaxis.common.core.controller.BaseController;
import com.miaxis.common.core.domain.Response;
import com.miaxis.common.core.domain.entity.SysDictData;
import com.miaxis.system.service.ISysConfigService;
import com.miaxis.system.service.ISysDictTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 学员基本信息表 前端控制器
 * </p>
 *
 * @since 2021-03-09
 */
@RestController
@Api(tags = "【app-字典信息查询】")
@RequestMapping(Constants.OPEN_PREFIX+"/gzpt/userInfo")
public class GzptDictDataController extends BaseController {


    @Autowired
    private ISysDictTypeService dictTypeService;

    @Autowired
    private ISysConfigService configService;

    /**
     * 根据字典类型查询字典数据信息
     */
    @GetMapping(value = "/type/{dictType}")
    @ApiOperation("根据字典类型查询字典数据信息")
    public Response<List<SysDictData>> dictType(
            @ApiParam(name = "dictType", value = "根据字典类型查询字典数据信息", required = true)
            @PathVariable("dictType") String dictType
    ){
        return Response.success(dictTypeService.selectDictDataByType(dictType));
    }


    /**
     * 根据参数键名查询参数值
     */
    @GetMapping(value = "/configKey/{configKey}")
    @ApiOperation("根据参数键名查询参数值")
    public Response<String> getConfigKey(
            @ApiParam(name = "configKey", value = "参数键名", required = true)
            @PathVariable("configKey") String configKey
    ){
        return Response.success(configService.selectConfigByKey(configKey));
    }


}

