package com.playlet.web.controller.tool;

import com.playlet.common.core.domain.Result;
import com.playlet.web.service.WxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * <p>微信服务端接口</p>
 * @author clunt
 */
@Controller
@Api(tags = "小程序*微信接口")
@RequestMapping("/tool/wx")
@CrossOrigin(origins = "*", maxAge = 3600)
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class WxController {

    private final WxService wxService;

    @ApiOperation(value = "获取openId", httpMethod = "POST")
    @PostMapping("/getOpenidByCode")
    @ResponseBody
    public Result<String> getOpenidByCode(@RequestParam(value = "code") String code){
        return Result.success(wxService.getOpenidByCode(code));
    }


}
