package rd.controller.activity;

import rd.data.db.table.Activity;
import rd.data.model.response.PaginationWrapper;
import rd.data.model.response.Response;
import rd.service.activity.ActivityService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/activity")
public class ActivityController {

    private final ActivityService activityService;

    public ActivityController(ActivityService activityService) {
        this.activityService = activityService;
    }

    @RequestMapping("/current")
    public Response<Activity> current() {
        var result = activityService.getCurrentActivity();

        return Response.success(result);
    }

    @RequestMapping("/list")
    public Response<PaginationWrapper<List<Activity>>> list(
            @RequestParam(value = "page", required = false, defaultValue = "1") int page,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize
    ) {
        var result = activityService.list(page, pageSize);
        return Response.success(result);
    }

    @RequestMapping("/info")
    public Response<Activity> info(@RequestParam(value = "id") Long id) {
        var result = activityService.getById(id);
        return Response.success(result);
    }
}
