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

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import com.seer.teach.common.PageListBean;
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.AgentActivityParentQueryReq;
import com.seer.teach.mp.app.controller.req.RecordContactCallReq;
import com.seer.teach.mp.app.controller.resp.AgentActivityParentInfoResp;
import com.seer.teach.mp.app.service.IAppAgentActivityParentInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
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 jakarta.validation.Valid;

/**
 * <p>
 * 代理商活动参与家长信息App控制器
 * </p>
 *
 * @author Lingma
 * @since 2025-12-30
 */
@Tag(name = "APP - 参与代理商活动家长信息")
@RestController
@RequestMapping("/app/agent/activity/parent-info")
@LogPrint
@EncryptionAnnotation
@DecryptionAnnotation
@RequiredArgsConstructor
public class AppAgentActivityParentInfoController {

    private final IAppAgentActivityParentInfoService agentActivityParentInfoService;

    @Operation(summary = "获取参加指定活动的家长列表")
    @PostMapping("/page-list")
    @SaCheckLogin
    public ResultBean<PageListBean<AgentActivityParentInfoResp>> getActivityParents(@RequestBody @Valid AgentActivityParentQueryReq queryReq) {
        Integer userId = StpUtil.getLoginIdAsInt();
        return ResultBean.success(agentActivityParentInfoService.getParentsByActivityAndAgent(userId, queryReq));
    }

    @Operation(summary = "记录代理商拨打电话联系家长的次数")
    @PostMapping("/record-contact-call")
    @SaCheckLogin
    public ResultBean<Boolean> recordContactCall(@RequestBody @Valid RecordContactCallReq req) {
        Integer userId = StpUtil.getLoginIdAsInt();
        return ResultBean.success(agentActivityParentInfoService.recordContactCall(req.getCollectionId(), req.getIncrementCount(),userId));
    }
}