获取openId接口修改

This commit is contained in:
张松
2025-03-07 18:37:10 +08:00
parent 7f8b65a711
commit 2370abaa59
2 changed files with 19 additions and 2 deletions

View File

@@ -2,6 +2,8 @@ package com.czg.controller.user;
import com.czg.account.dto.auth.LoginTokenDTO;
import com.czg.account.dto.auth.UserAuthorizationLoginDTO;
import com.czg.account.entity.ShopInfo;
import com.czg.account.service.ShopInfoService;
import com.czg.account.service.UserAuthorizationService;
import com.czg.resp.CzgResult;
import com.czg.sa.MyStpLogic;
@@ -21,6 +23,8 @@ import java.util.Map;
public class UserAuthorizationController {
@Resource
private UserAuthorizationService userAuthorizationService;
@Resource
private ShopInfoService shopInfoService;
/**
* 小程序登录
@@ -39,8 +43,17 @@ public class UserAuthorizationController {
* @return 返回openId
*/
@GetMapping("/openId")
public CzgResult<String> getOpenId(@RequestParam String code, @RequestParam String source) {
return CzgResult.success(userAuthorizationService.getOpenId(code, source));
public CzgResult<Map<String, String>> getOpenId(@RequestParam String code, @RequestParam String source, @RequestParam Long shopId) {
String openId = userAuthorizationService.getOpenId(code, source);
ShopInfo shopInfo = shopInfoService.getById(shopId);
if (shopInfo == null){
return CzgResult.failure("店铺信息不存在");
}
return CzgResult.success(Map.of(
"openId", openId,
"shopImage", shopInfo.getLogo(),
"shopName", shopInfo.getShopName()
));
}
/**