package com.yihu.wlyy.web.doctor.patient;

import com.yihu.wlyy.service.app.statistics.ServiceStatisticsService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
 * Created by lyr-pc on 2017/1/10.
 */
@RestController
@RequestMapping(value = "/doctor/patient/service")
public class ServiceStatisticsController extends BaseController {

    @Autowired
    ServiceStatisticsService serviceStatistics;

    /**
     * 居民服务统计查询
     *
     * @param patient 居民
     * @return
     */
    @RequestMapping(value = "/statistics", method = {RequestMethod.GET, RequestMethod.POST})
    @ApiOperation(value = "居民服务统计查询")
    public String statistics(@RequestParam @ApiParam(value = "居民code") String patient,
                             @RequestParam @ApiParam(value = "团队Code") Long teamCode) {
        try {
            JSONObject result = serviceStatistics.getServiceStatistics(patient, teamCode, getUID());
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

}
