package com.changhu.controller;

import com.changhu.common.annotation.JsonBody;
import com.changhu.service.WxService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author 20252
 * @createTime 2024/11/22 上午11:42
 * @desc WeChatController...
 */
@Tag(name = "微信相关")
@Controller
@RequestMapping("/wx")
public class WeChatController {

    @Autowired
    private WxService wxService;

    @JsonBody(value = false)
    @Operation(summary = "获取小程序页面二维码")
    @GetMapping(value = "/qrCode")
    public ResponseEntity<Resource> qrCode(@Schema(description = "要生成的路径") @RequestParam String path,
                                           @Schema(description = "生成二维码的宽度") @RequestParam(defaultValue = "430") Integer width) {
        return wxService.qrCode(path, width);
    }
}
