package com.ifish.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ifish.dto.JsonResult;
import com.ifish.entity.IfishDoctor;
import com.ifish.enums.ResultEnum;
import com.ifish.exception.IfishException;
import com.ifish.service.IfishDoctorService;

/**
 * 
 * @author ggw
 *
 */
@Controller
@RequestMapping("/ifishDoctor")
@ResponseBody
public class IfishDoctorAction {
	
	@Autowired
	private IfishDoctorService ifishDoctorService;
	
	/**
	 * 提交问题
	 * @param ifishDoctor
	 * @return
	 */
	@RequestMapping(value="/v3/saveIfishDoctor.do",method=RequestMethod.POST)
	public Object saveIfishDoctor(IfishDoctor ifishDoctor) {
		return ifishDoctorService.saveIfishDoctor(ifishDoctor);
	}
	
	/**
	 * 金币打赏提交问题
	 * @param ifishDoctor
	 * @param result
	 * @return
	 */
	@RequestMapping(value="/payTourQuestion",method=RequestMethod.POST)
	public JsonResult<?> payTourSubmitQuestion(String payTourType,@Validated IfishDoctor ifishDoctor,BindingResult result){
		if(result.hasErrors()){
			throw new IfishException(ResultEnum.error401);
		}
		return ifishDoctorService.payTourSubmitQuestion(ifishDoctor,payTourType);
	}
	
}