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

import com.skr.mdm.api.index.service.DeviceDistributionService;
import com.skr.mdm.dto.LoginAdminDTO;
import com.skr.mdm.result.ResponseResult;
import com.skr.mdm.bean.qo.controller.SelectDeviceQO;
import com.skr.mdm.bean.vo.DeviceDistributionVO;
import io.swagger.annotations.*;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @ProjectName: mdm_new
 * @Package: com.skr.mdm.largeScreenManagement.controller
 * @ClassName: DeviceDistributionController
 * @Author: Tty
 * @Description: 设备分布
 * @Date: 2020/9/16 16:35
 * @Version: 1.0
 */
@RestController
@RequestMapping("/deviceDistribution")
@Api(tags = "设备分布")
public class DeviceDistributionController {

	@Autowired
	private DeviceDistributionService deviceDistributionService;


	@PostMapping("distributionList")
	@ApiOperation("设备分布信息获取")
	@ApiResponses({
			@ApiResponse(code = 200, message = "成功", response = DeviceDistributionVO.class)
	})
	@ApiImplicitParams({
			@ApiImplicitParam(name = "onlineState",value = "设备在线状态 1：在线  3：离线"),
			@ApiImplicitParam(name = "deviceModel",value = "设备类型 1:手机 2:手环 3:记录 4:手表 5:其他"),
			@ApiImplicitParam(name = "searchType",value = "搜索类型 1:设备名 2:设备号"),
			@ApiImplicitParam(name = "searchValue",value = "搜索条件")
	})
	@PreAuthorize("hasAnyAuthority('sys:index')")
	public ResponseResult deviceDistributionList(@RequestBody SelectDeviceQO selectDeviceQO, @ApiIgnore Authentication authentication) throws Exception {
		LoginAdminDTO admin = (LoginAdminDTO) authentication.getPrincipal();
		return deviceDistributionService.deviceDistributionList(admin,selectDeviceQO);
	}

}
