SystemDictController.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.yihu.wlyy.web.common.system;
  2. import com.yihu.wlyy.entity.dict.SystemDict;
  3. import com.yihu.wlyy.service.system.SystemDictService;
  4. import com.yihu.wlyy.web.BaseController;
  5. import io.swagger.annotations.Api;
  6. import org.json.JSONArray;
  7. import org.json.JSONObject;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.http.MediaType;
  10. import org.springframework.stereotype.Controller;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import org.springframework.web.bind.annotation.RequestMethod;
  13. import org.springframework.web.bind.annotation.ResponseBody;
  14. import java.util.List;
  15. /**
  16. * Created by Administrator on 2016/8/13.
  17. */
  18. @Controller
  19. @RequestMapping(value = "/common", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  20. @Api(description = "系统字典")
  21. public class SystemDictController extends BaseController {
  22. @Autowired
  23. private SystemDictService systemDictService;
  24. /**
  25. * 根據dictname查找DictName
  26. * @param name
  27. * @return
  28. */
  29. @ResponseBody
  30. @RequestMapping(value = "/getDictByDictName")
  31. public String getDictByDictName(String name){
  32. try {
  33. List<SystemDict> list=systemDictService.getDictByDictName(name);
  34. JSONArray ja=new JSONArray();
  35. for (SystemDict systemDict:list){
  36. JSONObject jo=new JSONObject();
  37. jo.put("code",systemDict.getCode());
  38. jo.put("value",systemDict.getValue());
  39. ja.put(jo);
  40. }
  41. return write(200,"查询成功","list",ja);
  42. } catch (Exception e) {
  43. error(e);
  44. return error(-1, "验证码检查失败!");
  45. }
  46. }
  47. }