feat: 新增虚拟支付订单与网盘链接检测功能
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ruoyi.web.controller.app;
|
||||
|
||||
import com.ruoyi.app.domain.AppBlogArticle;
|
||||
import com.ruoyi.app.mapper.AppBlogArticleMapper;
|
||||
import com.ruoyi.app.service.ImageUrlService;
|
||||
import com.ruoyi.app.service.IAppBlogArticleService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
@@ -32,6 +33,9 @@ public class AppBlogArticleController extends BaseController {
|
||||
@Autowired
|
||||
private IAppBlogArticleService appBlogArticleService;
|
||||
|
||||
@Autowired
|
||||
private ImageUrlService imageUrlService;
|
||||
|
||||
@Resource
|
||||
private AppBlogArticleMapper appBlogArticleMapper;
|
||||
|
||||
@@ -45,6 +49,7 @@ public class AppBlogArticleController extends BaseController {
|
||||
public TableDataInfo list(AppBlogArticle appBlogArticle) {
|
||||
startPage();
|
||||
List<AppBlogArticle> list = appBlogArticleService.selectAppBlogArticleList(appBlogArticle);
|
||||
imageUrlService.decorateArticles(list);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@@ -72,6 +77,7 @@ public class AppBlogArticleController extends BaseController {
|
||||
@GetMapping(value = "/app/{id}")
|
||||
public AjaxResult appGetInfo(@PathVariable("id") Long id) {
|
||||
AppBlogArticle appBlogArticle = appBlogArticleService.selectAppBlogArticleById(id);
|
||||
imageUrlService.decorateArticle(appBlogArticle);
|
||||
List<String> list = new ArrayList<>();
|
||||
List<TtFile> picList = fileService.selectTtFileByCodeName(appBlogArticle.getTitle());
|
||||
for (TtFile ttFile : picList) {
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.ruoyi.app.domain.AppIntegralRecord;
|
||||
import com.ruoyi.app.domain.AppLotteryGoods;
|
||||
import com.ruoyi.app.domain.AppLotteryLog;
|
||||
import com.ruoyi.app.mapper.AppIntegralRecordMapper;
|
||||
import com.ruoyi.app.mapper.AppResourceMapper;
|
||||
import com.ruoyi.app.domain.AppResource;
|
||||
import com.ruoyi.app.service.IAppIntegralRecordService;
|
||||
import com.ruoyi.app.service.IAppLotteryGoodsService;
|
||||
import com.ruoyi.app.service.IAppLotteryLogService;
|
||||
@@ -42,6 +44,8 @@ public class AppIntegralRecordController extends BaseController
|
||||
private AppIntegralRecordMapper appIntegralRecordMapper;
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
@Resource
|
||||
private AppResourceMapper appResourceMapper;
|
||||
@Autowired
|
||||
private IAppLotteryGoodsService appLotteryGoodsService;
|
||||
@Autowired
|
||||
@@ -187,19 +191,38 @@ public class AppIntegralRecordController extends BaseController
|
||||
* 积分记录,增减用户积分通用
|
||||
*/
|
||||
@Transactional
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@PostMapping("/resource")
|
||||
public AjaxResult resource(@RequestBody AppIntegralRecord appIntegralRecord)
|
||||
{
|
||||
Date date = new Date();
|
||||
appIntegralRecord.setIntegralTime(date);
|
||||
appIntegralRecordService.insertAppIntegralRecord(appIntegralRecord);
|
||||
if (appIntegralRecord.getIsAdd() == 0){
|
||||
sysUserMapper.addIntegralByUserId(Math.toIntExact(appIntegralRecord.getIntegralNumber()), appIntegralRecord.getUserId());
|
||||
}else {
|
||||
sysUserMapper.delIntegralByUserId(Math.toIntExact(appIntegralRecord.getIntegralNumber()), appIntegralRecord.getUserId());
|
||||
Long userId = getUserId();
|
||||
AppResource resource = appResourceMapper.selectAppResourceById(appIntegralRecord.getResourceId());
|
||||
if (resource == null || resource.getIsAd() == null || resource.getIsAd() != 2L
|
||||
|| resource.getAdNumber() == null || resource.getAdNumber() <= 0)
|
||||
{
|
||||
return error("该资源不支持积分兑换");
|
||||
}
|
||||
|
||||
return toAjax(1);
|
||||
AppIntegralRecord exists = new AppIntegralRecord();
|
||||
exists.setUserId(userId);
|
||||
exists.setResourceId(resource.getId());
|
||||
if (appIntegralRecordMapper.selectAppIntegralRecordCount(exists) > 0)
|
||||
{
|
||||
return success("资源已解锁");
|
||||
}
|
||||
|
||||
int points = Math.toIntExact(resource.getAdNumber());
|
||||
if (sysUserMapper.delIntegralByUserId(points, userId) != 1)
|
||||
{
|
||||
return error("积分不足");
|
||||
}
|
||||
appIntegralRecord.setSource("资源兑换");
|
||||
appIntegralRecord.setIsAdd(1L);
|
||||
appIntegralRecord.setIntegralNumber(resource.getAdNumber());
|
||||
appIntegralRecord.setUserId(userId);
|
||||
appIntegralRecord.setIntegralTime(new Date());
|
||||
appIntegralRecordService.insertAppIntegralRecord(appIntegralRecord);
|
||||
return success("兑换成功");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.web.controller.app;
|
||||
|
||||
import com.ruoyi.app.domain.AppResource;
|
||||
import com.ruoyi.app.mapper.AppResourceMapper;
|
||||
import com.ruoyi.app.service.ImageUrlService;
|
||||
import com.ruoyi.app.service.IAppResourceService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
@@ -16,6 +17,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
|
||||
/**
|
||||
* 资源Controller
|
||||
@@ -30,6 +34,9 @@ public class AppResourceController extends BaseController
|
||||
@Autowired
|
||||
private IAppResourceService appResourceService;
|
||||
|
||||
@Autowired
|
||||
private ImageUrlService imageUrlService;
|
||||
|
||||
@Resource
|
||||
private AppResourceMapper appResourceMapper;
|
||||
|
||||
@@ -41,6 +48,7 @@ public class AppResourceController extends BaseController
|
||||
{
|
||||
startPage();
|
||||
List<AppResource> list = appResourceService.selectAppResourceList(appResource);
|
||||
imageUrlService.decorateResources(list);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@@ -70,16 +78,28 @@ public class AppResourceController extends BaseController
|
||||
@GetMapping(value = "/app/{id}")
|
||||
public AjaxResult getInfoApp(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(appResourceService.selectAppResourceById(id));
|
||||
return success(imageUrlService.decorateResource(
|
||||
appResourceMapper.selectAppResourceByIdAndUserId(id, currentUserId())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID获取资源详细信息
|
||||
*/
|
||||
@GetMapping(value = "/app/user/{id}/{userId}")
|
||||
public AjaxResult getResourceByUserId(@PathVariable("id") Long id, @PathVariable("userId") Long userId)
|
||||
public AjaxResult getResourceByUserId(@PathVariable("id") Long id, @PathVariable("userId") Long ignoredUserId)
|
||||
{
|
||||
return success(appResourceMapper.selectAppResourceByIdAndUserId(id, userId));
|
||||
return success(imageUrlService.decorateResource(
|
||||
appResourceMapper.selectAppResourceByIdAndUserId(id, currentUserId())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序资源详情。用户身份只从 JWT 读取,不接收客户端 userId。
|
||||
*/
|
||||
@GetMapping(value = "/app/user/{id}")
|
||||
public AjaxResult getResourceForCurrentUser(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(imageUrlService.decorateResource(
|
||||
appResourceMapper.selectAppResourceByIdAndUserId(id, currentUserId())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,4 +143,14 @@ public class AppResourceController extends BaseController
|
||||
{
|
||||
return toAjax( appResourceMapper.lookAddNumber(appResource.getId()));
|
||||
}
|
||||
|
||||
private Long currentUserId()
|
||||
{
|
||||
Authentication authentication = SecurityUtils.getAuthentication();
|
||||
if (authentication != null && authentication.getPrincipal() instanceof LoginUser)
|
||||
{
|
||||
return ((LoginUser) authentication.getPrincipal()).getUserId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.ruoyi.web.controller.app;
|
||||
|
||||
import com.ruoyi.app.domain.AppVirtualOrder;
|
||||
import com.ruoyi.app.service.IAppVirtualOrderService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 虚拟支付订单管理接口。
|
||||
*
|
||||
* 支付订单由微信回调和主动查单流程维护,管理端仅提供只读查询和导出。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/virtualOrder")
|
||||
public class AppVirtualOrderController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IAppVirtualOrderService appVirtualOrderService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('app:virtualOrder:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(AppVirtualOrder order)
|
||||
{
|
||||
startPage();
|
||||
List<AppVirtualOrder> list = appVirtualOrderService.selectAppVirtualOrderList(order);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('app:virtualOrder:query')")
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult getInfo(@PathVariable Long id)
|
||||
{
|
||||
return success(appVirtualOrderService.selectAppVirtualOrderById(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('app:virtualOrder:export')")
|
||||
@Log(title = "虚拟支付订单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, AppVirtualOrder order)
|
||||
{
|
||||
List<AppVirtualOrder> list = appVirtualOrderService.selectAppVirtualOrderList(order);
|
||||
ExcelUtil<AppVirtualOrder> util = new ExcelUtil<>(AppVirtualOrder.class);
|
||||
util.exportExcel(response, list, "虚拟支付订单数据");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.ruoyi.web.controller.app;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.ruoyi.app.domain.request.CreateVirtualOrderRequest;
|
||||
import com.ruoyi.app.service.IAppVirtualPayService;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
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.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/virtual-pay")
|
||||
public class AppVirtualPayController extends BaseController
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(AppVirtualPayController.class);
|
||||
|
||||
private final IAppVirtualPayService virtualPayService;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public AppVirtualPayController(IAppVirtualPayService virtualPayService, ObjectMapper objectMapper)
|
||||
{
|
||||
this.virtualPayService = virtualPayService;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@PostMapping("/resource-orders")
|
||||
public AjaxResult createOrder(@Validated @RequestBody CreateVirtualOrderRequest request)
|
||||
{
|
||||
return success(virtualPayService.createOrder(request));
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping("/resource-orders/{orderNo}")
|
||||
public AjaxResult queryOrder(@PathVariable String orderNo,
|
||||
@RequestParam(defaultValue = "false") boolean sync)
|
||||
{
|
||||
return success(virtualPayService.queryOrder(orderNo, sync));
|
||||
}
|
||||
|
||||
/**
|
||||
* 在小程序后台保存消息推送配置时使用。
|
||||
*/
|
||||
@GetMapping(value = "/callback", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public String verifyCallback(@RequestParam String signature,
|
||||
@RequestParam String timestamp,
|
||||
@RequestParam String nonce,
|
||||
@RequestParam String echostr)
|
||||
{
|
||||
if (!virtualPayService.verifyCallbackSignature(signature, timestamp, nonce))
|
||||
{
|
||||
log.warn("微信虚拟支付回调 URL 验证失败");
|
||||
return "";
|
||||
}
|
||||
return echostr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序消息推送请配置为 JSON 数据格式。
|
||||
*/
|
||||
@PostMapping("/callback")
|
||||
public Map<String, Object> callback(@RequestParam String signature,
|
||||
@RequestParam String timestamp,
|
||||
@RequestParam String nonce,
|
||||
@RequestBody String body)
|
||||
{
|
||||
if (!virtualPayService.verifyCallbackSignature(signature, timestamp, nonce))
|
||||
{
|
||||
log.warn("拒绝签名无效的微信虚拟支付回调");
|
||||
return callbackResponse(1, "invalid signature");
|
||||
}
|
||||
try
|
||||
{
|
||||
JsonNode json = objectMapper.readTree(body);
|
||||
virtualPayService.handleCallback(json);
|
||||
return callbackResponse(0, "success");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// 返回非零 ErrCode 让微信重试,异常详情只记录在服务端日志中。
|
||||
log.error("微信虚拟支付回调处理失败", e);
|
||||
return callbackResponse(1, "callback failed");
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String, Object> callbackResponse(int code, String message)
|
||||
{
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("ErrCode", code);
|
||||
response.put("ErrMsg", message);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import com.ruoyi.app.domain.ShuiYinVo;
|
||||
import com.ruoyi.app.mapper.AppPunlicMapper;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -21,20 +20,6 @@ public class PublicController extends BaseController {
|
||||
AppPunlicMapper appPunlicMapper;
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
/**
|
||||
* 获取微信openid信息
|
||||
*/
|
||||
@GetMapping(value = "/autoLoginWx/{code}")
|
||||
public AjaxResult autoLoginWx(@PathVariable("code") String code)
|
||||
{
|
||||
HttpUtils httpUtils = new HttpUtils();
|
||||
String appid = configService.selectConfigByKey("miniapp.wx.appId");
|
||||
String secret = configService.selectConfigByKey("miniapp.wx.secret");
|
||||
String param = "appid="+appid+"&secret="+secret+"&js_code="+code+"&grant_type=authorization_code";
|
||||
String s = httpUtils.httpGet("https://api.weixin.qq.com/sns/jscode2session", param);
|
||||
return success(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去水印 key 免费申请联系作者微信:yimoziyuan666
|
||||
* @return
|
||||
@@ -43,7 +28,7 @@ public class PublicController extends BaseController {
|
||||
private String delWatermarkKey;
|
||||
@PostMapping(value = "/delSHuiYin")
|
||||
public AjaxResult delSHuiYin(HttpServletRequest request, @RequestBody ShuiYinVo shuiYinVo) {
|
||||
HttpUtils httpUtils = new HttpUtils();
|
||||
com.ruoyi.common.utils.http.HttpUtils httpUtils = new com.ruoyi.common.utils.http.HttpUtils();
|
||||
String key = configService.selectConfigByKey("miniapp.shuiyin.key");
|
||||
String param = "key="+key+"&url="+shuiYinVo.getUrl();
|
||||
String s = httpUtils.httpGet("https://api.emoboy.vip/api/shuiyin/delWatermark", param);
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.ruoyi.web.controller.app;
|
||||
|
||||
import com.ruoyi.app.service.IAppPayOrderService;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.wx.*;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
@@ -26,20 +25,6 @@ import java.io.IOException;
|
||||
public class WxMiniappPayController extends BaseController {
|
||||
@Autowired
|
||||
private WxMiniappPayService wxMiniappPayService;
|
||||
@Autowired
|
||||
private IAppPayOrderService appPayOrderService;
|
||||
|
||||
/**
|
||||
* 预支付订单/统一下单
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/createOrder")
|
||||
public Response<PrepayWithRequestPaymentResponse> createOrder(@Validated @RequestBody CreateOrderReq req) {
|
||||
log.info("------预支付订单/统一下单------");
|
||||
//微信小程序登录用户openid,用户标识 说明:用户在商户appid下的唯一标识。
|
||||
return this.wxMiniappPayService.createOrder(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付回调
|
||||
@@ -65,6 +50,7 @@ public class WxMiniappPayController extends BaseController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/queryOrder")
|
||||
@PreAuthorize("@ss.hasPermi('app:order:query')")
|
||||
public Response queryOrder(@Validated @RequestBody QueryOrderReq req) {
|
||||
log.info("------根据支付订单号查询订单------");
|
||||
return this.wxMiniappPayService.queryOrder(req);
|
||||
@@ -81,6 +67,7 @@ public class WxMiniappPayController extends BaseController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/queryOrderByOutTradeNo")
|
||||
@PreAuthorize("@ss.hasPermi('app:order:query')")
|
||||
public Response queryOrderByOutTradeNo(@Validated @RequestBody QueryOrderReq req) {
|
||||
log.info("------根据商户订单号查询订单------");
|
||||
return this.wxMiniappPayService.queryOrderByOutTradeNo(req);
|
||||
@@ -93,6 +80,7 @@ public class WxMiniappPayController extends BaseController {
|
||||
*/
|
||||
|
||||
@PostMapping("/closeOrder")
|
||||
@PreAuthorize("@ss.hasPermi('app:order:edit')")
|
||||
public Response closeOrder(@Validated @RequestBody QueryOrderReq req) {
|
||||
log.info("------微信小程序支付关闭订单------");
|
||||
return this.wxMiniappPayService.closeOrder(req);
|
||||
@@ -104,6 +92,7 @@ public class WxMiniappPayController extends BaseController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/refund")
|
||||
@PreAuthorize("@ss.hasPermi('app:order:refund')")
|
||||
public Response refund(@Validated @RequestBody RefundOrderReq req) {
|
||||
log.info("------微信支付退款------");
|
||||
return this.wxMiniappPayService.refund(req);
|
||||
@@ -115,6 +104,7 @@ public class WxMiniappPayController extends BaseController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryByOutRefundNo")
|
||||
@PreAuthorize("@ss.hasPermi('app:order:query')")
|
||||
public Response queryByOutRefundNo(String outRefundNo) {
|
||||
log.info("------微信支付查询单笔退款------");
|
||||
return this.wxMiniappPayService.queryByOutRefundNo(outRefundNo);
|
||||
@@ -134,4 +124,4 @@ public class WxMiniappPayController extends BaseController {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.web.service.SysLoginService;
|
||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
import com.ruoyi.common.wx.WxCodeSession;
|
||||
import com.ruoyi.common.wx.WxCodeSessionService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@@ -36,6 +38,9 @@ public class SysLoginController
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
@Autowired
|
||||
private WxCodeSessionService wxCodeSessionService;
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
@@ -55,15 +60,13 @@ public class SysLoginController
|
||||
|
||||
|
||||
/**
|
||||
* 微信openID登陆
|
||||
* @param
|
||||
* @return
|
||||
* 使用微信临时 code 登录。OpenID 与 session_key 只在服务端获取。
|
||||
*/
|
||||
@PostMapping("/wxLogin")
|
||||
public AjaxResult wxLogin(@RequestBody LoginBody loginBody) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
// 生成令牌
|
||||
String token = loginService.wxLogin(loginBody.getOpenId(),loginBody.getOldUserId());
|
||||
WxCodeSession codeSession = wxCodeSessionService.exchange(loginBody.getCode());
|
||||
String token = loginService.wxLogin(codeSession.getOpenId(), loginBody.getOldUserId());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user