package com.skr.mdm.api.index.controller;

import com.skr.mdm.api.index.service.SecurityPolicyService;
import com.skr.mdm.dto.LoginAdminDTO;
import com.skr.mdm.result.ResponseResult;
import com.skr.mdm.bean.vo.index.StrategyStatisticsVO;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;


/**
 * @outher tty
 * @date 2020/7/6 15:16
 **/
@RestController
@RequestMapping("security")
@Api(tags = "安全策略")
@Slf4j
public class SecurityPolicyController {


	@Autowired
	private SecurityPolicyService securityPolicyService;

	/**
	 * @param authentication
	 * @return java.lang.Object
	 * @Description
	 * @outher Tty
	 * @date 2020/9/8
	 **/
	@GetMapping("/strategyData")
	@ApiOperation("获取安全策略模块信息")
	@ApiResponses({
			@ApiResponse(code = 200, message = "ok", response = StrategyStatisticsVO.class)
	})
	@PreAuthorize("hasAnyAuthority('sys:index')")
	public ResponseResult strategyData(@ApiParam("开始时间") String startTime,
									   @ApiParam("开始时间") String endTime,
									   @ApiIgnore Authentication authentication) throws Exception {
		LoginAdminDTO admin = (LoginAdminDTO) authentication.getPrincipal();
		return securityPolicyService.queryStrategyData(admin, startTime, endTime);
	}

}
