package com.yihu.wlyy.web.third;

import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.archives.PatientEventService;
import com.yihu.wlyy.service.app.archives.PatientRecordService;
import com.yihu.wlyy.service.third.jw.JwSignService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

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

/**
 * 签约相关接口
 * @author hzp at 2016-12-19
 */
@Controller
@RequestMapping(value = "/third/sign")
@Api(description = "签约相关接口")
public class OpenApiSignController extends BaseController {

	@Autowired
	SignFamilyDao signFamilyDao;

	@Autowired
	JwSignService  jwSignService;

	@RequestMapping(value = "/sanshi", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取三师签约信息（基卫）")
	public String getSignSanshi(@ApiParam(name="idcard",value="身份证号",defaultValue = "360403195512282415")
								 @RequestParam(value="idcard",required = true) String idcard)
	{
		try {
			String response = jwSignService.getSignSanshi(idcard);
			return write(200, "获取三师签约信息成功！","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取三师签约信息失败！");
		}
	}

	@RequestMapping(value = "/family", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取家庭签约信息")
	public String getSignFamily(@ApiParam(name="idcard",value="身份证号",defaultValue = "350124198003255088")
								 @RequestParam(value="idcard",required = true) String idcard)
	{
		try {
			SignFamily sign =  signFamilyDao.getExpensesSignByIdcard(idcard);
			return write(200, "获取家庭签约信息成功！","data",sign);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取家庭签约信息失败！");
		}
	}


}
