package com.ruoyi.wx; import com.ruoyi.system.mapper.Vo.WXResponse; import com.ruoyi.system.service.WXService; import com.ruoyi.utils.SimpleResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RequestMapping("/wx") @RestController public class WXController { @Autowired private WXService wxService; @GetMapping("/openid/{code}") public SimpleResult openid(@PathVariable("code") String code) { WXResponse wxResponse = wxService.getWXOpenId(code); if (wxResponse != null){ return SimpleResult.success(wxResponse, "获取openid成功"); } else { return SimpleResult.error("获取openid失败"); } } }