package com.goafanti.common.controller;

import com.goafanti.banners.enums.BannersType;
import com.goafanti.banners.service.BannersService;
import com.goafanti.common.model.Banners;
import com.goafanti.news.bo.NewsPortalList;
import com.goafanti.news.enums.NewsType;
import com.goafanti.news.service.NewsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class WebpageController extends BaseController {


	@Resource
	private BannersService bannersService;

	@Resource
	private NewsService newsService;



	@RequestMapping(value = "/user/account/index", method = RequestMethod.GET)
	public ModelAndView UserIndex(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/user/account/index");
		return modelview;
	}

	@RequestMapping(value = "/admin/account/evaluateInfo", method = RequestMethod.GET)
	public ModelAndView evaluateInfo(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/user/account/evaluateInfo");
		return modelview;
	}
	@RequestMapping(value = "/admin/account/services", method = RequestMethod.GET)
	public ModelAndView userServices(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/user/account/services");
		return modelview;
	}


	@RequestMapping(value = "/admin/login", method = RequestMethod.GET)
	public String adminLogin(HttpServletRequest request, ModelAndView modelview) {
		return "/admin/login";
	}
	@RequestMapping(value = "/admin/standard", method = RequestMethod.GET)
	public String adminStandard(HttpServletRequest request, ModelAndView modelview) {
		return "/admin/standard";
	}


	@RequestMapping(value = "/RD/admin/login", method = RequestMethod.GET)
	public String adminRDLogin(HttpServletRequest request, ModelAndView modelview) {
		return "/admin/RDlogin";
	}

	@RequestMapping(value = "/RD/admin/index", method = RequestMethod.GET)
	public ModelAndView adminRDindex(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/RDindex");
		return modelview;
	}

	@RequestMapping(value = "/admin/demand", method = RequestMethod.GET)
	public String adminDemand(HttpServletRequest request, ModelAndView modelview) {
		return "/admin/demand";
	}

	@RequestMapping(value = "/admin/achievement", method = RequestMethod.GET)
	public String adminAchievement(HttpServletRequest request, ModelAndView modelview) {
		return "/admin/achievement";
	}

	@RequestMapping(value = "/admin/legalAffairs", method = RequestMethod.GET)
	public String legalAffairs(HttpServletRequest request, ModelAndView modelview) {
		return "/admin/legalAffairs";
	}
	@RequestMapping(value = "/admin/set", method = RequestMethod.GET)
	public String adminSet(HttpServletRequest request, ModelAndView modelview) {
		return "/admin/set";
	}

	@RequestMapping(value = "/admin/userManage", method = RequestMethod.GET)
	public ModelAndView adminUserManage(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/userManage");
		return modelview;
	}

	@RequestMapping(value = "/admin/customer", method = RequestMethod.GET)
	public ModelAndView adminCustomer(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/customer");
		return modelview;
	}

	@RequestMapping(value = "/admin/customerService", method = RequestMethod.GET)
	public ModelAndView admincustomerService(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/customerService");
		return modelview;
	}

	@RequestMapping(value = "/admin/servicesManage/technology", method = RequestMethod.GET)
	public ModelAndView adminServicesManageTechnology(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/servicesManage/technology");
		return modelview;
	}

	@RequestMapping(value = "/admin/servicesManage/patent", method = RequestMethod.GET)
	public ModelAndView adminServicesManagePatent(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/servicesManage/patent");
		return modelview;
	}

	@RequestMapping(value = "/admin/servicesManage/contract", method = RequestMethod.GET)
	public ModelAndView adminServicesManageContract(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/servicesManage/contract");
		return modelview;
	}

	@RequestMapping(value = "/admin/servicesManage/highTech", method = RequestMethod.GET)
	public ModelAndView adminServicesManageHighTech(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/servicesManage/highTech");
		return modelview;
	}


	@RequestMapping(value = "/admin/servicesManage/copyright", method = RequestMethod.GET)
	public ModelAndView adminServicesManageCopyright(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/servicesManage/copyright");
		return modelview;
	}

	@RequestMapping(value = "/admin/servicesManage/projectOrder", method = RequestMethod.GET)
	public ModelAndView adminServiceManageProjectOrder(HttpServletRequest request, ModelAndView modelview){
		modelview.setViewName("/admin/servicesManage/projectOrder");
		return modelview;
	}

	@RequestMapping(value = "/admin/index", method = RequestMethod.GET)
	public ModelAndView adminHome(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/index");
		return modelview;
	}

	@RequestMapping(value = "/admin/amiba", method = RequestMethod.GET)
	public ModelAndView adminAmiba(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/amiba");
		return modelview;
	}

	@RequestMapping(value = "/admin/idea", method = RequestMethod.GET)
	public ModelAndView adminIdea(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/idea");
		return modelview;
	}

	@RequestMapping(value = "/admin/userOrder", method = RequestMethod.GET)
	public ModelAndView adminUserOrder(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/userOrder");
		return modelview;
	}

	@RequestMapping(value = "/admin/order", method = RequestMethod.GET)
	public ModelAndView adminOrder(HttpServletRequest request, ModelAndView modelview){
		modelview.setViewName("/admin/order");
		return modelview;
	}
	@RequestMapping(value = "/admin/project", method = RequestMethod.GET)
	public ModelAndView adminProject(HttpServletRequest request, ModelAndView modelview){
		modelview.setViewName("/admin/project");
		return modelview;
	}

	@RequestMapping(value = "/admin/operate", method = RequestMethod.GET)
	public ModelAndView adminOperate(HttpServletRequest request, ModelAndView modelview){
		modelview.setViewName("/admin/operate");
		return modelview;
	}

	@RequestMapping(value = "/admin/channelList", method = RequestMethod.GET)
	public ModelAndView adminChannelLis(HttpServletRequest request, ModelAndView modelview){
		modelview.setViewName("/admin/channelList");
		return modelview;
	}

	/**
	 * 首页
	 */
	@RequestMapping(value = "/portal/index", method = RequestMethod.GET)
	public ModelAndView portalIndex(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/login");
		/*List<Banners> banners = bannersService.findPortalBanners(BannersType.SHOU_YE.getKey());
		if (!banners.isEmpty()) {
			modelview.addObject("banner", banners.get(0));
		}
		//政策
		modelview.addObject("jtdt", newsService.findIndexNewsList(0, NewsType.JTDT.getCode(), 4));
		//服务项目
		/*List<BusinessProject> projectList=marketingManagementService.selectHotProject(5);

		List<MarketingManagementBo> achievementList = marketingManagementService.selectMarketList(request,
				MarketingPage.mainAchievement.getBoothType(),MarketingPage.mainAchievement.getBoothSize());
		List<MarketingManagementBo> demandList = marketingManagementService.selectMarketList(request,
				MarketingPage.mainDemand.getBoothType(),MarketingPage.mainDemand.getBoothSize());
		List<MarketingManagementBo> speciaList = marketingManagementService.selectMarketList(request,
				MarketingPage.specialist.getBoothType(), MarketingPage.specialist.getBoothSize());
		modelview.addObject("achievementList", achievementList);
		modelview.addObject("demandList", demandList);
		modelview.addObject("speciaList", speciaList);
		modelview.addObject("projectList", projectList);*/
		return modelview;
	}

	@RequestMapping(value = "/portal/technologyTrading/achievement", method = RequestMethod.GET)
	public ModelAndView portalSearchAchievement(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/technologyTrading/achievement");
		return modelview;
	}

	@RequestMapping(value = "/portal/membership", method = RequestMethod.GET)
	public ModelAndView membership(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/membership");
		return modelview;
	}

	@RequestMapping(value = "/portal/technologyTrading/demand", method = RequestMethod.GET)
	public ModelAndView portalSearchDemand(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/technologyTrading/demand");
		return modelview;
	}

	@RequestMapping(value = "/portal/search/subscriberUser", method = RequestMethod.GET)
	public ModelAndView portalSearchSubscriberUser(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/search/subscriberUser");
		return modelview;
	}

	@RequestMapping(value = "/portal/search/subscriberOrg", method = RequestMethod.GET)
	public ModelAndView portalSearchSubscriberOrg(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/search/subscriberOrg");
		return modelview;
	}

	/**
	 * 评估页
	 */
	@RequestMapping(value = "/portal/evaluation/index", method = RequestMethod.GET)
	public ModelAndView evaluation(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/evaluation/index");
		handleBanners(modelview, BannersType.JI_SHU_PING_GU);
		return modelview;
	}

	/**
	 * 服务汇
	 */
	@RequestMapping(value = "/portal/service/serviceIndex", method = RequestMethod.GET)
	public ModelAndView portalServiceServiceIndex(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/service/serviceIndex");
		handleBanners(modelview, BannersType.FU_WU_HUI);
		return modelview;
	}

	/**
	 * 知识产权
	 *
	 * @param request
	 * @param modelview
	 * @return
	 */
	@RequestMapping(value = "/portal/service/propertyRight", method = RequestMethod.GET)
	public ModelAndView propertyRight(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/service/propertyRight");
		return modelview;
	}

	/**
	 * 高企认定
	 *
	 * @param request
	 * @param modelview
	 * @return
	 */
	@RequestMapping(value = "/portal/service/highTechCognizance", method = RequestMethod.GET)
	public ModelAndView highTechCognizance(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/service/highTechCognizance");
		return modelview;
	}

	/**
	 * 技术交易
	 */
	@RequestMapping(value = "/portal/technologyTrading/index", method = RequestMethod.GET)
	public ModelAndView portalTechnologyTradingIndex(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/technologyTrading/index");
		handleBanners(modelview, BannersType.JI_SHU_JIAO_YI);
		List<NewsPortalList> newsPortalList=newsService.portalNewsPolicy();
		modelview.addObject("newsPortalList", newsPortalList);
		List<NewsPortalList> portalNewsQuestion=newsService.portalNewsQuestion();
		modelview.addObject("portalNewsQuestion", portalNewsQuestion);
		return modelview;
	}

	/**
	 *
	 * 智库咨询
	 *
	 * @param request
	 * @param modelview
	 * @return
	 */
	@RequestMapping(value = "/portal/thinkTank/index", method = RequestMethod.GET)
	public ModelAndView thinkTank(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/thinkTank/index");
		return modelview;
	}

	/**
	 * 政策列表
	 *
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/portal/thinkTank/policyList", method = RequestMethod.GET)
	public ModelAndView policyList(ModelAndView modelview) {
		modelview.setViewName("/portal/thinkTank/policyList");
		List<NewsPortalList> newsList = (List<NewsPortalList>) newsService.portalNewsList(5, 1, null, null, null, null)
				.getList();
		modelview.addObject("newsList", newsList);
		return modelview;
	}

	/**
	 * 会员介绍
	 *
	 * @param request
	 * @param modelview
	 * @return
	 */
	@RequestMapping(value = "/portal/member")
	public ModelAndView member(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/member");
		return modelview;
	}

	/**
	 *  营销管理
	 * @param request
	 * @param modelview
	 * @return
	 */
	/*@RequestMapping(value="/admin/marketing")
	public ModelAndView marketing(HttpServletRequest request, ModelAndView modelview){
		modelview.setViewName("/admin/marketing");
		return modelview;
	}*/

	/**
	 *  技术评估
	 * @param request
	 * @param modelview
	 * @return
	 */
	@RequestMapping(value="/portal/technologyTrading/assessMent")
	public ModelAndView assessMent(HttpServletRequest request, ModelAndView modelview){
		modelview.setViewName("/portal/technologyTrading/assessMent");
		modelview.addObject("zcfg", newsService.findIndexNewsList(0, NewsType.KJZX.getCode(), 4));
		return modelview;
	}

	@RequestMapping(value="/portal/websocket")
	public ModelAndView websocket(HttpServletRequest request, ModelAndView modelview){
		request.getSession().setAttribute("uid", "con");
		modelview.setViewName("/portal/websocket");
		return modelview;
	}

	/**
	 *  关于我们
	 * @param request
	 * @param modelview
	 * @return
	 */
	@RequestMapping(value="/portal/aboutUs" ,method = RequestMethod.GET)
	public ModelAndView aboutUs(HttpServletRequest request, ModelAndView modelview){
		modelview.setViewName("/portal/aboutUs");
		return modelview;
	}

	/**
	 * 联系我们
	 * @param request
	 * @param modelview
	 * @return
	 */
	@RequestMapping(value="/portal/contactUs"  ,method = RequestMethod.GET)
	public ModelAndView contactUs(HttpServletRequest request, ModelAndView modelview){
		modelview.setViewName("/portal/contactUs");
		return modelview;
	}
	private void handleBanners(ModelAndView modelview, BannersType bannersType) {
		List<Banners> banners = bannersService.findPortalBanners(bannersType.getKey());
		if (!banners.isEmpty()) {
			modelview.addObject("banners", banners);
		}
	}

	/**
	 * 服务-推荐
	 *
	 * @param request
	 * @param modelview
	 * @return
	 */
	@RequestMapping(value = "/portal/service/recommended")
	public ModelAndView recommended(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/service/recommended");
		return modelview;
	}

	@RequestMapping(value = "/admin/statistics", method = RequestMethod.GET)
	public ModelAndView adminStatistics(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/statistics");
		return modelview;
	}

	@RequestMapping(value = "/portal/websocket", method = RequestMethod.GET)
	public ModelAndView webSocket(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/websocket");
		return modelview;
	}

	@RequestMapping(value = "/open/index", method = RequestMethod.GET)
	public ModelAndView index(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/portal/index");
		return modelview;
	}
	@RequestMapping(value = "/admin/povertyInquiry", method = RequestMethod.GET)
	public ModelAndView povertyInquiry(HttpServletRequest request, ModelAndView modelview) {
		modelview.setViewName("/admin/povertyInquiry");
		return modelview;
	}


}
