Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
Yygh Parent
提交
340ff5eb
Y
Yygh Parent
项目概览
别团等shy哥发育
/
Yygh Parent
9 个月 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
Yygh Parent
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
340ff5eb
编写于
1月 07, 2022
作者:
别团等shy哥发育
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
生成微信登录的二维码
上级
3c91ba48
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
87 addition
and
2 deletion
+87
-2
service/service_user/src/main/java/com/atguigu/yygh/user/api/WeixinApiController.java
...n/java/com/atguigu/yygh/user/api/WeixinApiController.java
+35
-0
service/service_user/src/main/java/com/atguigu/yygh/user/utils/ConstantWxPropertiesUtils.java
...om/atguigu/yygh/user/utils/ConstantWxPropertiesUtils.java
+36
-0
service/service_user/src/main/resources/application.properties
...ce/service_user/src/main/resources/application.properties
+9
-2
service_gateway/src/main/resources/application.properties
service_gateway/src/main/resources/application.properties
+7
-0
未找到文件。
service/service_user/src/main/java/com/atguigu/yygh/user/api/WeixinApiController.java
0 → 100644
浏览文件 @
340ff5eb
package
com.atguigu.yygh.user.api
;
import
com.atguigu.yygh.user.utils.ConstantWxPropertiesUtils
;
import
com.atguigu.yygu.common.result.Result
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.Map
;
@Controller
@RequestMapping
(
"/api/ucenter/wx"
)
public
class
WeixinApiController
{
//1、生成微信扫描的二维码
//返回生成二维码需要参数
@GetMapping
(
"getLoginParam"
)
@ResponseBody
public
Result
genQrConnect
()
throws
UnsupportedEncodingException
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"appid"
,
ConstantWxPropertiesUtils
.
WX_OPEN_APP_ID
);
map
.
put
(
"scope"
,
"snsapi_login"
);
String
wxOpenRedirectUrl
=
ConstantWxPropertiesUtils
.
WX_OPEN_REDIRECT_URL
;
wxOpenRedirectUrl
=
URLEncoder
.
encode
(
wxOpenRedirectUrl
,
"utf-8"
);
map
.
put
(
"redirect_uri"
,
wxOpenRedirectUrl
);
map
.
put
(
"state"
,
System
.
currentTimeMillis
()+
""
);
return
Result
.
ok
(
map
);
}
//2、回调的方法,得到扫描人信息
}
service/service_user/src/main/java/com/atguigu/yygh/user/utils/ConstantWxPropertiesUtils.java
0 → 100644
浏览文件 @
340ff5eb
package
com.atguigu.yygh.user.utils
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
@Component
public
class
ConstantWxPropertiesUtils
implements
InitializingBean
{
@Value
(
"${wx.open.app_id}"
)
private
String
appId
;
@Value
(
"${wx.open.app_secret}"
)
private
String
appSecret
;
@Value
(
"${wx.open.redirect_url}"
)
private
String
redirectUrl
;
@Value
(
"${yygh.baseUrl}"
)
private
String
yyghBaseUrl
;
public
static
String
WX_OPEN_APP_ID
;
public
static
String
WX_OPEN_APP_SECRET
;
public
static
String
WX_OPEN_REDIRECT_URL
;
public
static
String
YYGH_BASE_URL
;
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
WX_OPEN_APP_ID
=
appId
;
WX_OPEN_APP_SECRET
=
appSecret
;
WX_OPEN_REDIRECT_URL
=
redirectUrl
;
YYGH_BASE_URL
=
yyghBaseUrl
;
}
}
service/service_user/src/main/resources/application.properties
浏览文件 @
340ff5eb
# 服务端口
# 服务端口
server.port
=
8
203
server.port
=
8
160
# 服务名
# 服务名
spring.application.name
=
service-user
spring.application.name
=
service-user
...
@@ -16,6 +16,7 @@ spring.datasource.password=123456
...
@@ -16,6 +16,7 @@ spring.datasource.password=123456
spring.jackson.date-format
=
yyyy-MM-dd HH:mm:ss
spring.jackson.date-format
=
yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone
=
GMT+8
spring.jackson.time-zone
=
GMT+8
# redis配置
spring.redis.host
=
192.168.159.33
spring.redis.host
=
192.168.159.33
spring.redis.port
=
6379
spring.redis.port
=
6379
spring.redis.database
=
0
spring.redis.database
=
0
...
@@ -30,4 +31,10 @@ spring.redis.lettuce.pool.min-idle=0
...
@@ -30,4 +31,10 @@ spring.redis.lettuce.pool.min-idle=0
spring.cloud.nacos.discovery.server-addr
=
127.0.0.1:8848
spring.cloud.nacos.discovery.server-addr
=
127.0.0.1:8848
#配置mapper xml文件的路径
#配置mapper xml文件的路径
mybatis-plus.mapper-locations
=
classpath:com/atguigu/yygh/user/mapper/xml/*.xml
mybatis-plus.mapper-locations
=
classpath:com/atguigu/yygh/user/mapper/xml/*.xml
\ No newline at end of file
# 微信登录参数
wx.open.app_id
=
wxed9954c01bb89b47
wx.open.app_secret
=
a7482517235173ddb4083788de60b90e
wx.open.redirect_url
=
http://localhost:8160/api/ucenter/wx/callback
yygh.baseUrl
=
http://localhost:3000
service_gateway/src/main/resources/application.properties
浏览文件 @
340ff5eb
...
@@ -36,3 +36,10 @@ spring.cloud.gateway.routes[3].id=service-msm
...
@@ -36,3 +36,10 @@ spring.cloud.gateway.routes[3].id=service-msm
spring.cloud.gateway.routes[3]
.uri
=
lb://service-msm
spring.cloud.gateway.routes[3]
.uri
=
lb://service-msm
#设置路由断言,代理servicerId为auth-service的/auth/路径
#设置路由断言,代理servicerId为auth-service的/auth/路径
spring.cloud.gateway.routes[3]
.predicates
=
Path=/*/msm/**
spring.cloud.gateway.routes[3]
.predicates
=
Path=/*/msm/**
#设置路由id
spring.cloud.gateway.routes[4]
.id
=
service-user
#设置路由的uri
spring.cloud.gateway.routes[4]
.uri
=
lb://service-user
#设置路由断言,代理servicerId为auth-service的/auth/路径
spring.cloud.gateway.routes[4]
.predicates
=
Path=/*/ucenter/**
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录