package com.yihu.figure.controller;

import com.yihu.figure.model.suggest.Suggest;
import com.yihu.figure.service.SuggestService;
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.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by chenweida on 2017/3/7.
 */
@RestController
@RequestMapping(value = "/suggest", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "建议")
public class SuggestController extends BaseController {
    @Autowired
    private SuggestService suggestService;

    @ApiOperation(value = "获取患者建议")
    @RequestMapping(value = "getPatientSuggest", method = RequestMethod.GET)
    public String getPatientInfo(
            @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode) {
        try {
            Map<String, List<Suggest>> patientInfo = suggestService.getPatientSuggest(patientCode);
            return write(200, "获取成功！", "suggest", patientInfo);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
}
