package com.goafanti.admin.controller;

import java.util.Calendar;

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.cognizance.service.OrgActivityService;
import com.goafanti.cognizance.service.OrgIntellectualPropertyService;
import com.goafanti.common.bo.Result;
import com.goafanti.common.constant.ErrorConstants;
import com.goafanti.common.controller.CertifyApiController;
import com.goafanti.common.utils.StringUtils;

@RestController
@RequestMapping(value = "/api/admin/summary")
public class AdminSummaryApiController extends CertifyApiController {

	private static final Integer			year	= Calendar.getInstance().get(Calendar.YEAR) - 1;
	@Resource
	private OrgIntellectualPropertyService	orgIntellectualPropertyService;
	@Resource
	private OrgActivityService				orgActivityService;

	/**
	 * 高企信息汇总导出--获得知识产权数量
	 * 
	 * @param uid
	 * @return
	 */
	@RequestMapping(value = "/intellectualProperty", method = RequestMethod.GET)
	public Result intellectualProperty(String uid) {
		Result res = new Result();
		if (StringUtils.isBlank(uid)) {
			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户ID"));
			return res;
		}

		res.setData(orgIntellectualPropertyService.selectIntellectualPropertyCount(year, uid));
		return res;
	}

	/**
	 * 高企信息汇总导出--知识产权列表
	 * 
	 * @param uid
	 * @return
	 */
	@RequestMapping(value = "/intellectualPropertyList", method = RequestMethod.GET)
	public Result intellectualPropertyList(String uid) {
		Result res = new Result();
		if (StringUtils.isBlank(uid)) {
			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户ID"));
			return res;
		}
		res.setData(orgIntellectualPropertyService.selectIntellectualPropertyList(year, uid));
		return res;
	}

	/**
	 * 高企信息汇总导出--企业研发活动列表
	 * 
	 * @param uid
	 * @return
	 */
	@RequestMapping(value = "/activity", method = RequestMethod.GET)
	public Result activity(String uid) {
		Result res = new Result();
		if (StringUtils.isBlank(uid)) {
			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户ID"));
			return res;
		}
		res.setData(orgActivityService.selectAcivityList(year, uid));
		return res;
	}

}
