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

import com.skr.mdm.api.index.service.SecurityPostureService;
import com.skr.mdm.dto.LoginAdminDTO;
import com.skr.mdm.result.ResponseResult;
import com.skr.mdm.bean.vo.index.SecurityPostureVO;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @outher tty
 * @date 2020/7/7 18:45
 **/
@Slf4j
@RestController
@RequestMapping(value = "securityPosture")
@Api(tags = "安全态势分析")
public class SecurityPostureController {
    @Autowired
    private SecurityPostureService securityPostureService;

	@GetMapping(value = "getPostureList")
	@ApiOperation(value = "分析数据")
	@ApiResponses({
			@ApiResponse(code = 200,message = "成功",response = SecurityPostureVO.class)
	})
	@PreAuthorize("hasAnyAuthority('sys:index')")
	public ResponseResult getPostureList(@ApiParam("开始时间") String startTime,
										  @ApiParam("开始时间") String endTime,
										  @ApiIgnore Authentication authentication) {
		LoginAdminDTO admin = (LoginAdminDTO) authentication.getPrincipal();
		return securityPostureService.getViolatorMessage(startTime,endTime,admin);
	}

}