package com.landtool.lanbase.modules.api.controller; import java.io.IOException; import javax.servlet.http.HttpServletResponse; 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.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.serializer.SimplePropertyPreFilter; import com.landtool.lanbase.modules.sys.service.SysFieldService; import com.landtool.lanbase.modules.sys.service.SysFieldvalueService; /** * @Description: 字典管理模块提供的api * @Author: bing.guo * @Date: 2018/2/01 * */ @Controller @RequestMapping(path = "/api/sys/field/") @Api(value = "", tags = {"字典管理相关接口"}) public class SysFieldApiController { @Autowired private SysFieldService sysFieldService; @Autowired private SysFieldvalueService sysFieldvalueService; /** * 查询所有字典key * @return */ @GetMapping("/queryList") @ApiOperation( value = "查询所有字典key", notes = "" ) public void queryList(HttpServletResponse response) throws IOException { SimplePropertyPreFilter filter = new SimplePropertyPreFilter(); filter.getExcludes().add("rcreateuser"); filter.getExcludes().add("rcreatedate"); filter.getExcludes().add("rlasteditdate"); System.out.println(JSONObject.toJSONString(sysFieldService.queryAllList(),filter)); response.setHeader("Content-Type","application/json;charset=UTF-8"); response.getWriter().write(JSONObject.toJSONString(sysFieldService.queryAllList(),filter)); } /** * 根据字典key获取对应字典值 * @param key * @return */ @GetMapping("/queryListByKey/{key}") @ApiOperation( value = "根据字典key获取对应字典值", notes = "" ) public void queryListByKey(@ApiParam(name="key",value="字典key",required=true) @PathVariable(name = "key")String key, HttpServletResponse response) throws IOException { SimplePropertyPreFilter filter = new SimplePropertyPreFilter(); filter.getExcludes().add("valueid"); filter.getExcludes().add("fkey"); filter.getExcludes().add("remark"); filter.getExcludes().add("rorder"); filter.getExcludes().add("rcreateuser"); filter.getExcludes().add("rcreatedate"); filter.getExcludes().add("rlasteditdate"); response.setHeader("Content-Type","application/json;charset=UTF-8"); response.getWriter().write(JSONObject.toJSONString(sysFieldvalueService.queryListByKey(key),filter)); } }