package com.tuoheng.miniprogram.controller;

import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.miniprogram.dao.UserMapper;
import com.tuoheng.miniprogram.entity.wx.WxMessageRequest;
import com.tuoheng.miniprogram.service.IWxService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author ChengWang
 * @Date 2023/6/23
 */
@RestController
@Slf4j
@RequestMapping("/weiXin")
public class WxController {

    @Autowired
    private IWxService iWxService;

    //根据code获取openId
    @GetMapping("/getOpenId/{code}")
    public JsonResult getOpenId(@PathVariable("code") String code){
        log.info("进入获取openId接口");
        return iWxService.openid(code);
    }

    @PostMapping("/send/message")
    public JsonResult sendMessage(@RequestBody WxMessageRequest wxMessageRequest){
        log.info("进入发送消息接口,WxMessageRequest={}",wxMessageRequest);
        return iWxService.sendMessage(wxMessageRequest);
    }






}
