package com.seer.teach.mp.app.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.stp.StpUtil;
import com.seer.teach.common.ResultBean;
import com.seer.teach.common.annotation.DecryptionAnnotation;
import com.seer.teach.common.annotation.EncryptionAnnotation;
import com.seer.teach.common.annotation.LogPrint;
import com.seer.teach.mp.app.controller.req.AppMpAgentActivityQrCodeQueryReq;
import com.seer.teach.mp.app.controller.resp.AgentActivityParticipantResp;
import com.seer.teach.mp.app.service.IAppAgentActivityParticipantService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 代理商参与活动记录App控制器
 * </p>
 *
 * @author Lingma
 * @since 2025-12-29
 */
@Tag(name = "APP - 代理商参与活动")
@RestController
@RequestMapping("/app/agent/activity/participant")
@LogPrint
@EncryptionAnnotation
@DecryptionAnnotation
@RequiredArgsConstructor
public class AppAgentActivityParticipantController {

    private final IAppAgentActivityParticipantService agentActivityParticipantService;

    @Operation(summary = "获取代理商参加的活动列表")
    @GetMapping()
    @SaCheckPermission("mp:app:agent:participant:parents")
    public ResultBean<List<AgentActivityParticipantResp>> getParentsByAgentAndActivity(@RequestParam("agentId") Integer agentId) {
        Integer userId = StpUtil.getLoginIdAsInt();
        return ResultBean.success(agentActivityParticipantService.getParticipantsByActivityAndAgent(agentId,userId));
    }

    @Operation(summary = "获取代理参与活动的二维码")
    @PostMapping("/qrcode")
    @SaCheckPermission("mp:app:agent:activity:qrcode")
    public ResultBean<String> getQrCode(@RequestBody AppMpAgentActivityQrCodeQueryReq req) {
        Integer userId = StpUtil.getLoginIdAsInt();
        return ResultBean.success(agentActivityParticipantService.getQrCode(req,userId));
    }
}