package com.izouma.nineth.web;

import com.izouma.nineth.repo.UserPropertyRepo;
import com.izouma.nineth.service.EventMgmtService;
import com.izouma.nineth.service.UserService;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/eventMgmt")
@AllArgsConstructor
public class EventMgmtController {

    private final EventMgmtService eventMgmtService;

    @GetMapping("/clearUserProperty")
    @PreAuthorize("hasRole('ADMIN')")
    public void clearUserProperty() {
        eventMgmtService.clearUserProperty();
    }

    @PostMapping("/importUserProperty")
    @PreAuthorize("hasRole('ADMIN')")
    public void importUserProperty(MultipartFile file) throws IOException {
        eventMgmtService.importUserProperty(file);
    }

    @GetMapping("/clearVipPoint")
    @PreAuthorize("hasRole('ADMIN')")
    public void clearVipPoint() {
        eventMgmtService.clearVipPoint();
    }

    @PostMapping("/importVipPoint")
    @PreAuthorize("hasRole('ADMIN')")
    public void importVipPoint(MultipartFile file) throws IOException {
        eventMgmtService.importVipPoint(file);
    }
}
