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

import com.skr.mdm.api.common.service.MdmEquipmentService;
import com.skr.mdm.dto.LoginAdminDTO;
import com.skr.mdm.result.ResponseResult;
import com.skr.mdm.bean.qo.EquipmentIssuedQO;
import com.skr.mdm.bean.vo.equipment.EquipmentIssuedVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.validation.annotation.Validated;
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;

import javax.validation.Valid;

/**
 * @author nfq
 * @date 2022-07-18 18:42
 */
@Validated
@RestController
@RequestMapping("mdm/issued")
@Api(tags = "下发管理")
public class MdmEquipmentController {

    @Autowired
    private MdmEquipmentService mdmEquipmentService;


    @PostMapping("user")
    @ApiOperation("通用个人下发接口")
    @ApiResponses({
            @ApiResponse(code = 200, message = "", response = EquipmentIssuedVO.class)
    })
    public ResponseResult listEquipmentIssuedVO(@RequestBody @Valid EquipmentIssuedQO equipmentIssuedQO,
                                                @ApiIgnore Authentication authentication) {
        LoginAdminDTO loginAdminDTO = (LoginAdminDTO) authentication.getPrincipal();
        return mdmEquipmentService.listEquipmentIssuedVO(equipmentIssuedQO, loginAdminDTO);
    }
}
