package com.goafanti.app.controller;

import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


import com.goafanti.admin.service.AdminService;

import com.goafanti.app.bo.ServiceImages;
import com.goafanti.business.service.BusinessVarietiesService;
import com.goafanti.business.service.BusinessProjectService;
import com.goafanti.common.bo.Result;
import com.goafanti.common.constant.ErrorConstants;
import com.goafanti.common.controller.BaseApiController;
import com.goafanti.common.utils.StringUtils;

import com.goafanti.user.service.UserIdentityService;


@RestController
@RequestMapping(path = "/app/service", method = RequestMethod.GET)
public class AppServiceController extends BaseApiController {
	@Resource
	private BusinessVarietiesService	adminVarietiesService;
	@Resource
	private BusinessProjectService	businessProjectService;
	@Resource
	private AdminService			adminService;
	@Resource
	private UserIdentityService 	userIdentityService;

	/**
	 * 获取初级品类
	 */
	@RequestMapping(value = "/getVarieties", method = RequestMethod.GET)
	public Result getVarieties() {
		Result res = new Result();
		res.setData(adminVarietiesService.getVarieties());
		return res;
	}
	/**
	 * 获取服务轮播图
	 */
	@RequestMapping(value = "/getImagers", method = RequestMethod.GET)
	public Result getImagers() {
		Result res = new Result();
		ServiceImages	serviceImages=new ServiceImages();
		res.setData(serviceImages.getImagers());
		return res;
	}
	/**
	 * 获取品类下的项目
	 */
	@RequestMapping(value = "/getBusinessProject", method = RequestMethod.GET)
	public Result getBusinessProject(String id,Integer pNo,Integer pSize) {
		Result res = new Result();
		if (StringUtils.isBlank(id)) {
			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"品类必须指定","品类"));
			return res;
		}
		res.setData(businessProjectService.getBusinessProject(id,pNo, pSize));
		//res.setData(new Pagination<ProjectBo>());
		return res;
	}
	/**
	 * 项目详情
	 */
	@RequestMapping(value = "/ProjectDetail", method = RequestMethod.GET)
	public Result ProjectDetail(String id) {
		Result res = new Result();
		if (StringUtils.isBlank(id)) {
			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"项目必须指定","项目"));
			return res;
		}
		res.setData(businessProjectService.orgProject(id));
		return res;
	}
	/**
	 * 推荐列表
	 */
	@RequestMapping(value = "/recommendProjectList", method = RequestMethod.GET)
	public Result recommendProjectList(Integer pNo,Integer pSize) {
		Result res = new Result();
		res.setData(businessProjectService.recommendProjectList( pNo, pSize));
		return res;
	}
	/**
	 * 一对一
	 */
	@RequestMapping(value = "/consultantList", method = RequestMethod.GET)
	public Result consultantList(Integer pNo,Integer pSize) {
		Result res = new Result();
		res.setData(userIdentityService.consultantList( pNo, pSize));
		return res;
	}
	/**
	 * 咨询师详情
	 */
	@RequestMapping(value = "/consultantDetail", method = RequestMethod.GET)
	public Result consultantDetail(String id) {
		Result res = new Result();
		if (StringUtils.isBlank(id)) {
			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"咨询师必须指定","咨询师"));
			return res;
		}
		res.setData(userIdentityService.consultantDetail( id));
		return res;
	}
}
