package com.ruoyi.web.controller.api;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.report.service.IRzlViewStatisticsInfoService;
import com.ruoyi.report.vo.PatentLastSumDTO;

@RestController
@RequestMapping("/private/patent")
public class PatentController extends PrivateApiController {
	@Autowired
	private IRzlViewStatisticsInfoService rzlViewStatisticsInfoService;

	@GetMapping("/lastSum")
	public AjaxResult list(HttpServletRequest req) {
		try {
			checkAuth(req);
		} catch (Exception e) {
			return AjaxResult.error(HttpStatus.UNAUTHORIZED,"权限验证不通过");
		}
		
		PatentLastSumDTO dto = rzlViewStatisticsInfoService.listForLast();
		return AjaxResult.success(dto);
	}
	
	

	public static void main(String[] args) {

//		String appid = PrivateApiController.APPID;
//		String secret = PrivateApiController.SECRET;
//		String url="http://127.0.0.1:8080/prod-api/private/geographical/lastSum?appid="+appid+"&secret="+secret;
		
		String appid = PrivateApiController.APPID;
		String secret = PrivateApiController.SECRET;
//		String url="http://127.0.0.1:8080/prod-api/private/geographical/lastSum?appid="+appid+"&secret="+secret;
		String url="http://root49.publicdi.com/prod-api/private/patent/lastSum?appid="+appid+"&secret="+secret;
		String res = HttpUtils.sendGet(url);
		System.out.println(res);
	}
	

}
