MiniProgramController.java 1.73 KB
package com.infoloop.tianting.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto;
import com.infoloop.tianting.model.dto.WxUserDto.WxUserPhoneResponseDto;
import com.infoloop.tianting.service.WxMiniProgramService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "小程序个人信息")
@ApiSupport(order = -1)
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class MiniProgramController {

  private final WxMiniProgramService wxMiniProgramService;

  @SaIgnore
  @ApiOperation(value = "小程序:根据code获取openId")
  @GetMapping("/wx/miniprogram/customers/openid/{code}")
  @ResponseStatus(HttpStatus.OK)
  public WxUserOpenIdDto getOpenIdByCode(@PathVariable String code) {
    return  wxMiniProgramService.getWxUserOpenIdByCode(code);
  }

  @SaIgnore
  @ApiOperation(value = "小程序:根据code获取手机号")
  @GetMapping("/wx/miniprogram/customers/phone/{code}")
  @ResponseStatus(HttpStatus.OK)
  public WxUserPhoneResponseDto getPhoneByCode(@PathVariable String code) {
    return  wxMiniProgramService.getUserPhoneInfoByCode(code);
  }

}