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

import com.skr.mdm.api.app.service.MdmAppStoreInstallService;
import com.skr.mdm.bean.qo.app.MdmAppStoreInstallQO;
import com.skr.mdm.bean.vo.app.MdmAppStoreInstallVO;
import com.skr.mdm.dto.LoginAdminDTO;
import com.skr.mdm.result.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
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-11-29 11:06
 */
@Validated
@RestController
@RequestMapping("app/store/install")
@Api(tags = "应用商店安装记录")
public class MdmAppStoreInstallController {

    @Autowired
    private MdmAppStoreInstallService appStoreInstallService;

    @ApiOperation(value = "列表", response = MdmAppStoreInstallVO.class)
    @PostMapping(value = "list")
    @PreAuthorize("hasAnyAuthority('sys:app:publish:install:record')")
    public ResponseResult listApp(@RequestBody @Valid MdmAppStoreInstallQO mdmAppStoreInstallQO,
                                  @ApiIgnore Authentication authentication) {
        LoginAdminDTO loginAdminDTO = (LoginAdminDTO) authentication.getPrincipal();
        return appStoreInstallService.listAppStoreInstall(mdmAppStoreInstallQO, loginAdminDTO);
    }
}
