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

import cn.dev33.satoken.annotation.SaCheckPermission;
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.JsapiSignatureReq;
import com.seer.teach.mp.app.controller.resp.JsapiSignatureResp;
import com.seer.teach.mp.app.service.IAppMpSignatureService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
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;

@EncryptionAnnotation
@DecryptionAnnotation
@Tag(name = "APP - 微信JS-SDK签名")
@RestController
@RequestMapping("/app/signature")
@LogPrint
@RequiredArgsConstructor
public class AppMpSignatureController {

    private final IAppMpSignatureService appMpSignatureService;

    @Operation(summary = "生成JS-SDK签名")
    @PostMapping("/jsapi")
    @SaCheckPermission("mp:app:signature:jsapi")
    public ResultBean<JsapiSignatureResp> generateJsapiSignature(@Valid @RequestBody JsapiSignatureReq req) {
        JsapiSignatureResp resp = appMpSignatureService.generateJsapiSignature(req);
        return ResultBean.success(resp);
    }
}