1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- package com.yihu.wlyy.web.common.data;
- import java.util.List;
- import io.swagger.annotations.Api;
- import org.json.JSONArray;
- import org.json.JSONObject;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.MediaType;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.ResponseBody;
- import com.yihu.wlyy.entity.dict.Disease;
- import com.yihu.wlyy.service.common.data.DataService;
- import com.yihu.wlyy.web.BaseController;
- @RequestMapping(value = "/common/data", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- @Controller
- @Api(description = "疾病与社区")
- public class DataController extends BaseController {
- @Autowired
- private DataService dataService;
- @RequestMapping(value = "diseases")
- @ResponseBody
- public String diseases() {
- try {
- JSONArray array = new JSONArray();
- List<Disease> list = dataService.findAllDisease();
- for (Disease temp : list) {
- if (temp == null) {
- continue;
- }
- JSONObject json = new JSONObject();
- json.put("code", temp.getCode());
- json.put("name", temp.getName());
- array.put(json);
- }
- return write(200, "获取疾病成功!", "list", array);
- } catch (Exception e) {
- error(e);
- return error(-1, "获取疾病失败!");
- }
- }
- @RequestMapping(value = "diseases_community")
- @ResponseBody
- public String diseasesCommunity() {
- try {
- JSONArray array = new JSONArray();
- List<Disease> list = dataService.findAllDisease();
- for (Disease temp : list) {
- if (temp == null) {
- continue;
- }
- JSONObject json = new JSONObject();
- json.put("code", temp.getCode());
- json.put("name", temp.getName() + "社区");
- array.put(json);
- }
- return write(200, "获取疾病社区成功!", "list", array);
- } catch (Exception e) {
- error(e);
- return error(-1, "获取疾病社区失败!");
- }
- }
- }
|