package com.sqx.modules.app.controller.app;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.app.service.AdService;
import com.sqx.modules.callback.service.UniAdCallbackRecordService;
import com.sqx.modules.sys.controller.AbstractController;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/ad")
public class AdController extends AbstractController {

    private final UniAdCallbackRecordService callbackRecordService;
    private final AdService adService;

    public AdController(UniAdCallbackRecordService callbackRecordService, AdService adService) {
        this.callbackRecordService = callbackRecordService;
        this.adService = adService;
    }

    @Login
    @GetMapping("/state")
    public Result getAdState(@RequestParam String extraKey, @RequestAttribute Long userId) {
        return Result.success(callbackRecordService.getStateByExtraKey(userId, extraKey));
    }

    @Login
    @GetMapping("/detail")
    public Result getAdDetail(@RequestAttribute Long userId) {
        return Result.success(adService.getDetail(userId));
    }
}
