Commit 8dbd6143bf60613c802fb79663f2c6f940244349
1 parent
038c0b87
增加微信小程序的登陆的测试代码
Showing
26 changed files
with
381 additions
and
20 deletions
mini-program-test/.eslintrc.js
0 → 100755
| 1 | +/* | |
| 2 | + * Eslint config file | |
| 3 | + * Documentation: https://eslint.org/docs/user-guide/configuring/ | |
| 4 | + * Install the Eslint extension before using this feature. | |
| 5 | + */ | |
| 6 | +module.exports = { | |
| 7 | + env: { | |
| 8 | + es6: true, | |
| 9 | + browser: true, | |
| 10 | + node: true, | |
| 11 | + }, | |
| 12 | + ecmaFeatures: { | |
| 13 | + modules: true, | |
| 14 | + }, | |
| 15 | + parserOptions: { | |
| 16 | + ecmaVersion: 2018, | |
| 17 | + sourceType: 'module', | |
| 18 | + }, | |
| 19 | + globals: { | |
| 20 | + wx: true, | |
| 21 | + App: true, | |
| 22 | + Page: true, | |
| 23 | + getCurrentPages: true, | |
| 24 | + getApp: true, | |
| 25 | + Component: true, | |
| 26 | + requirePlugin: true, | |
| 27 | + requireMiniProgram: true, | |
| 28 | + }, | |
| 29 | + // extends: 'eslint:recommended', | |
| 30 | + rules: {}, | |
| 31 | +} | ... | ... |
mini-program-test/README.md
0 → 100644
| 1 | +临时项目,作为测试微信小程序登陆之用 | ... | ... |
mini-program-test/app.js
0 → 100755
| 1 | +// app.js | |
| 2 | +App({ | |
| 3 | + onLaunch() { | |
| 4 | + // 展示本地存储能力 | |
| 5 | + const logs = wx.getStorageSync('logs') || [] | |
| 6 | + logs.unshift(Date.now()) | |
| 7 | + wx.setStorageSync('logs', logs) | |
| 8 | + | |
| 9 | + // 登录 | |
| 10 | + wx.login({ | |
| 11 | + success: res => { | |
| 12 | + // 发送 res.code 到后台换取 openId, sessionKey, unionId | |
| 13 | + } | |
| 14 | + }) | |
| 15 | + }, | |
| 16 | + globalData: { | |
| 17 | + userInfo: null | |
| 18 | + } | |
| 19 | +}) | ... | ... |
mini-program-test/app.json
0 → 100755
| 1 | +{ | |
| 2 | + "pages":[ | |
| 3 | + "pages/index/index", | |
| 4 | + "pages/logs/logs" | |
| 5 | + ], | |
| 6 | + "window":{ | |
| 7 | + "backgroundTextStyle":"light", | |
| 8 | + "navigationBarBackgroundColor": "#fff", | |
| 9 | + "navigationBarTitleText": "Weixin", | |
| 10 | + "navigationBarTextStyle":"black" | |
| 11 | + }, | |
| 12 | + "style": "v2", | |
| 13 | + "sitemapLocation": "sitemap.json" | |
| 14 | +} | ... | ... |
mini-program-test/app.wxss
0 → 100755
mini-program-test/pages/index/index.js
0 → 100755
| 1 | +// index.js | |
| 2 | + | |
| 3 | +const common=require('../../utils/common.js') | |
| 4 | +// 获取应用实例 | |
| 5 | +const app = getApp() | |
| 6 | + | |
| 7 | +Page({ | |
| 8 | + data: { | |
| 9 | + motto: 'Hello World', | |
| 10 | + userInfo: {}, | |
| 11 | + hasUserInfo: false, | |
| 12 | + canIUse: wx.canIUse('button.open-type.getUserInfo'), | |
| 13 | + canIUseGetUserProfile: false, | |
| 14 | + canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName'), // 如需尝试获取用户信息可改为false | |
| 15 | + holderText: 'to be auth' | |
| 16 | + }, | |
| 17 | + // 事件处理函数 | |
| 18 | + bindViewTap() { | |
| 19 | + wx.navigateTo({ | |
| 20 | + url: '../logs/logs' | |
| 21 | + }) | |
| 22 | + }, | |
| 23 | + onLoad() { | |
| 24 | + if (wx.getUserProfile) { | |
| 25 | + this.setData({ | |
| 26 | + canIUseGetUserProfile: true | |
| 27 | + }) | |
| 28 | + } | |
| 29 | + }, | |
| 30 | + getUserProfile(e) { | |
| 31 | + // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 | |
| 32 | + wx.getUserProfile({ | |
| 33 | + desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 | |
| 34 | + success: (res) => { | |
| 35 | + console.log(res) | |
| 36 | + this.setData({ | |
| 37 | + userInfo: res.userInfo, | |
| 38 | + hasUserInfo: true | |
| 39 | + }) | |
| 40 | + } | |
| 41 | + }) | |
| 42 | + }, | |
| 43 | + getUserInfo(e) { | |
| 44 | + // 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息 | |
| 45 | + console.log(e) | |
| 46 | + this.setData({ | |
| 47 | + userInfo: e.detail.userInfo, | |
| 48 | + hasUserInfo: true | |
| 49 | + }) | |
| 50 | + }, | |
| 51 | + // 小程序登录 https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html | |
| 52 | + wxLogin(e){ | |
| 53 | + let page=this; | |
| 54 | + wx.login({ | |
| 55 | + success (res) { | |
| 56 | + console.log("res:") | |
| 57 | + console.log(res) | |
| 58 | + if (res.code) { | |
| 59 | + //发起网络请求 | |
| 60 | + console.log('发起网络请求'+common.baseurl) | |
| 61 | + wx.request({ | |
| 62 | + url: common.baseurl+'/api/social-login2', | |
| 63 | + method: "POST", | |
| 64 | + data: { | |
| 65 | + code: res.code, | |
| 66 | + state: 'empty', | |
| 67 | + type: 33, | |
| 68 | + username: '15601691300', | |
| 69 | + password: 'admin123' | |
| 70 | + }, | |
| 71 | + header: { | |
| 72 | + 'content-type': 'application/json' // 默认值 | |
| 73 | + }, | |
| 74 | + success: function(res) { | |
| 75 | + console.log(res.data) | |
| 76 | + let holder="auth success, token:"+res.data.data.token | |
| 77 | + page.setData({holderText: holder}) | |
| 78 | + }, | |
| 79 | + fail: function(data){ | |
| 80 | + console.error("请求出错"); | |
| 81 | + console.error(data) | |
| 82 | + } | |
| 83 | + | |
| 84 | + }) | |
| 85 | + } else { | |
| 86 | + console.log('登录失败!' + res.errMsg) | |
| 87 | + } | |
| 88 | + } | |
| 89 | + }) | |
| 90 | + } | |
| 91 | +}) | ... | ... |
mini-program-test/pages/index/index.json
0 → 100755
mini-program-test/pages/index/index.wxml
0 → 100755
| 1 | +<!--index.wxml--> | |
| 2 | +<view class="container"> | |
| 3 | + <view class="userinfo"> | |
| 4 | + <block wx:if="{{canIUseOpenData}}"> | |
| 5 | + | |
| 6 | + | |
| 7 | + </block> | |
| 8 | + <block wx:elif="{{!hasUserInfo}}"> | |
| 9 | + <button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 获取头像昵称 </button> | |
| 10 | + <button wx:elif="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button> | |
| 11 | + <view wx:else> 请使用1.4.4及以上版本基础库 </view> | |
| 12 | + </block> | |
| 13 | + <block wx:else> | |
| 14 | + <image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image> | |
| 15 | + <text class="userinfo-nickname">{{userInfo.nickName}}</text> | |
| 16 | + </block> | |
| 17 | + </view> | |
| 18 | + <view class="usermotto"> | |
| 19 | + | |
| 20 | + </view> | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + <text style="position: relative; left: 1rpx; top: -476rpx">授权登录测试1024</text> | |
| 25 | + | |
| 26 | + <button style="position: relative; left: 0rpx; top: -361rpx" type="primary" id="login-button" bindtap="wxLogin">点击授权登录</button> | |
| 27 | + | |
| 28 | + <text style="position: relative; left: 1rpx; top: -272rpx" id="login-user-id">{{holderText}}</text> | |
| 29 | +</view> | ... | ... |
mini-program-test/pages/index/index.wxss
0 → 100755
| 1 | +/**index.wxss**/ | |
| 2 | +.userinfo { | |
| 3 | + display: flex; | |
| 4 | + flex-direction: column; | |
| 5 | + align-items: center; | |
| 6 | + color: #aaa; | |
| 7 | +} | |
| 8 | + | |
| 9 | +.userinfo-avatar { | |
| 10 | + overflow: hidden; | |
| 11 | + width: 128rpx; | |
| 12 | + height: 128rpx; | |
| 13 | + margin: 20rpx; | |
| 14 | + border-radius: 50%; | |
| 15 | +} | |
| 16 | + | |
| 17 | +.usermotto { | |
| 18 | + margin-top: 200px; | |
| 19 | +} | |
| 0 | 20 | \ No newline at end of file | ... | ... |
mini-program-test/pages/logs/logs.js
0 → 100755
| 1 | +// logs.js | |
| 2 | +const util = require('../../utils/util.js') | |
| 3 | + | |
| 4 | +Page({ | |
| 5 | + data: { | |
| 6 | + logs: [] | |
| 7 | + }, | |
| 8 | + onLoad() { | |
| 9 | + this.setData({ | |
| 10 | + logs: (wx.getStorageSync('logs') || []).map(log => { | |
| 11 | + return { | |
| 12 | + date: util.formatTime(new Date(log)), | |
| 13 | + timeStamp: log | |
| 14 | + } | |
| 15 | + }) | |
| 16 | + }) | |
| 17 | + } | |
| 18 | +}) | ... | ... |
mini-program-test/pages/logs/logs.json
0 → 100755
mini-program-test/pages/logs/logs.wxml
0 → 100755
mini-program-test/pages/logs/logs.wxss
0 → 100755
mini-program-test/project.config.json
0 → 100755
| 1 | +{ | |
| 2 | + "description": "项目配置文件", | |
| 3 | + "packOptions": { | |
| 4 | + "ignore": [ | |
| 5 | + { | |
| 6 | + "type": "file", | |
| 7 | + "value": ".eslintrc.js" | |
| 8 | + } | |
| 9 | + ] | |
| 10 | + }, | |
| 11 | + "setting": { | |
| 12 | + "bundle": false, | |
| 13 | + "userConfirmedBundleSwitch": false, | |
| 14 | + "urlCheck": true, | |
| 15 | + "scopeDataCheck": false, | |
| 16 | + "coverView": true, | |
| 17 | + "es6": true, | |
| 18 | + "postcss": true, | |
| 19 | + "compileHotReLoad": false, | |
| 20 | + "lazyloadPlaceholderEnable": false, | |
| 21 | + "preloadBackgroundData": false, | |
| 22 | + "minified": true, | |
| 23 | + "autoAudits": false, | |
| 24 | + "newFeature": false, | |
| 25 | + "uglifyFileName": false, | |
| 26 | + "uploadWithSourceMap": true, | |
| 27 | + "useIsolateContext": true, | |
| 28 | + "nodeModules": false, | |
| 29 | + "enhance": true, | |
| 30 | + "useMultiFrameRuntime": true, | |
| 31 | + "useApiHook": true, | |
| 32 | + "useApiHostProcess": true, | |
| 33 | + "showShadowRootInWxmlPanel": true, | |
| 34 | + "packNpmManually": false, | |
| 35 | + "enableEngineNative": false, | |
| 36 | + "packNpmRelationList": [], | |
| 37 | + "minifyWXSS": true, | |
| 38 | + "showES6CompileOption": false, | |
| 39 | + "minifyWXML": true | |
| 40 | + }, | |
| 41 | + "compileType": "miniprogram", | |
| 42 | + "libVersion": "2.19.4", | |
| 43 | + "appid": "wx44d047d87e6284d8", | |
| 44 | + "appid1": "wx63c280fe3248a3e7", | |
| 45 | + "projectname": "mini-program-test", | |
| 46 | + "debugOptions": { | |
| 47 | + "hidedInDevtools": [] | |
| 48 | + }, | |
| 49 | + "scripts": {}, | |
| 50 | + "staticServerOptions": { | |
| 51 | + "baseURL": "", | |
| 52 | + "servePath": "" | |
| 53 | + }, | |
| 54 | + "isGameTourist": false, | |
| 55 | + "condition": { | |
| 56 | + "search": { | |
| 57 | + "list": [] | |
| 58 | + }, | |
| 59 | + "conversation": { | |
| 60 | + "list": [] | |
| 61 | + }, | |
| 62 | + "game": { | |
| 63 | + "list": [] | |
| 64 | + }, | |
| 65 | + "plugin": { | |
| 66 | + "list": [] | |
| 67 | + }, | |
| 68 | + "gamePlugin": { | |
| 69 | + "list": [] | |
| 70 | + }, | |
| 71 | + "miniprogram": { | |
| 72 | + "list": [] | |
| 73 | + } | |
| 74 | + } | |
| 75 | +} | |
| 0 | 76 | \ No newline at end of file | ... | ... |
mini-program-test/sitemap.json
0 → 100755
mini-program-test/utils/common.js
0 → 100755
mini-program-test/utils/util.js
0 → 100755
| 1 | +const formatTime = date => { | |
| 2 | + const year = date.getFullYear() | |
| 3 | + const month = date.getMonth() + 1 | |
| 4 | + const day = date.getDate() | |
| 5 | + const hour = date.getHours() | |
| 6 | + const minute = date.getMinutes() | |
| 7 | + const second = date.getSeconds() | |
| 8 | + | |
| 9 | + return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}` | |
| 10 | +} | |
| 11 | + | |
| 12 | +const formatNumber = n => { | |
| 13 | + n = n.toString() | |
| 14 | + return n[1] ? n : `0${n}` | |
| 15 | +} | |
| 16 | + | |
| 17 | +module.exports = { | |
| 18 | + formatTime | |
| 19 | +} | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/auth/SysAuthSocialUnbindReqVO.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.system.controller.auth.vo.auth; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.adminserver.modules.system.enums.social.SysSocialTypeEnum; | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.system.enums.social.SysSocialTypeEnum; | |
| 4 | 4 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 5 | 5 | import io.swagger.annotations.ApiModel; |
| 6 | 6 | import io.swagger.annotations.ApiModelProperty; | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/user/SysUserProfileController.java
| ... | ... | @@ -8,15 +8,16 @@ import cn.iocoder.yudao.adminserver.modules.system.convert.user.SysUserConvert; |
| 8 | 8 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; |
| 9 | 9 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; |
| 10 | 10 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysRoleDO; |
| 11 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social.SysSocialUserDO; | |
| 12 | 11 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; |
| 13 | 12 | import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysPostService; |
| 14 | 13 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; |
| 15 | 14 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysRoleService; |
| 16 | -import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialService; | |
| 17 | 15 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 16 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.social.SysSocialUserDO; | |
| 18 | 17 | import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; |
| 18 | +import cn.iocoder.yudao.coreservice.modules.system.service.social.SysSocialService; | |
| 19 | 19 | import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService; |
| 20 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | |
| 20 | 21 | import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; |
| 21 | 22 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 22 | 23 | import io.swagger.annotations.Api; |
| ... | ... | @@ -77,7 +78,7 @@ public class SysUserProfileController { |
| 77 | 78 | resp.setPosts(SysUserConvert.INSTANCE.convertList02(posts)); |
| 78 | 79 | } |
| 79 | 80 | // 获得社交用户信息 |
| 80 | - List<SysSocialUserDO> socialUsers = socialService.getSocialUserList(user.getId()); | |
| 81 | + List<SysSocialUserDO> socialUsers = socialService.getSocialUserList(user.getId(), UserTypeEnum.ADMIN); | |
| 81 | 82 | resp.setSocialUsers(SysUserConvert.INSTANCE.convertList03(socialUsers)); |
| 82 | 83 | return success(resp); |
| 83 | 84 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/convert/user/SysUserConvert.java
| ... | ... | @@ -7,7 +7,7 @@ import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.*; |
| 7 | 7 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; |
| 8 | 8 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; |
| 9 | 9 | import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysRoleDO; |
| 10 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social.SysSocialUserDO; | |
| 10 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.social.SysSocialUserDO; | |
| 11 | 11 | import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; |
| 12 | 12 | import org.mapstruct.Mapper; |
| 13 | 13 | import org.mapstruct.factory.Mappers; | ... | ... |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/system/service/auth/SysAuthServiceImplTest.java
| ... | ... | @@ -7,11 +7,11 @@ import cn.iocoder.yudao.adminserver.modules.system.enums.logger.SysLoginResultEn |
| 7 | 7 | import cn.iocoder.yudao.adminserver.modules.system.service.auth.impl.SysAuthServiceImpl; |
| 8 | 8 | import cn.iocoder.yudao.adminserver.modules.system.service.common.SysCaptchaService; |
| 9 | 9 | import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; |
| 10 | -import cn.iocoder.yudao.adminserver.modules.system.service.social.SysSocialService; | |
| 11 | 10 | import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; |
| 12 | 11 | import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; |
| 13 | 12 | import cn.iocoder.yudao.coreservice.modules.system.service.auth.SysUserSessionCoreService; |
| 14 | 13 | import cn.iocoder.yudao.coreservice.modules.system.service.logger.SysLoginLogCoreService; |
| 14 | +import cn.iocoder.yudao.coreservice.modules.system.service.social.SysSocialService; | |
| 15 | 15 | import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService; |
| 16 | 16 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 17 | 17 | import cn.iocoder.yudao.framework.security.core.LoginUser; | ... | ... |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/system/service/social/SysSocialServiceTest.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.system.service.social; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.adminserver.BaseDbAndRedisUnitTest; |
| 4 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.social.SysSocialUserDO; | |
| 5 | -import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.social.SysSocialUserMapper; | |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.dal.redis.social.SysSocialAuthUserRedisDAO; | |
| 7 | -import cn.iocoder.yudao.adminserver.modules.system.enums.social.SysSocialTypeEnum; | |
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.service.social.impl.SysSocialServiceImpl; | |
| 4 | +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.social.SysSocialUserDO; | |
| 5 | +import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.social.SysSocialUserMapper; | |
| 6 | +import cn.iocoder.yudao.coreservice.modules.system.dal.redis.social.SysSocialAuthUserRedisDAO; | |
| 7 | +import cn.iocoder.yudao.coreservice.modules.system.enums.social.SysSocialTypeEnum; | |
| 8 | +import cn.iocoder.yudao.coreservice.modules.system.service.social.impl.SysSocialServiceImpl; | |
| 9 | 9 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 10 | 10 | import com.xkcoding.justauth.AuthRequestFactory; |
| 11 | 11 | import me.zhyd.oauth.model.AuthUser; |
| ... | ... | @@ -23,6 +23,7 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId |
| 23 | 23 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; |
| 24 | 24 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 25 | 25 | |
| 26 | +// TODO @timfruit:这个单元测试,挪到 yudao-core-service | |
| 26 | 27 | /** |
| 27 | 28 | * {@link SysSocialServiceImpl} 的单元测试类 |
| 28 | 29 | * |
| ... | ... | @@ -53,7 +54,7 @@ public class SysSocialServiceTest extends BaseDbAndRedisUnitTest { |
| 53 | 54 | // mock 方法 |
| 54 | 55 | |
| 55 | 56 | // 调用 |
| 56 | - socialService.bindSocialUser(userId, type, authUser); | |
| 57 | + socialService.bindSocialUser(userId, type, authUser, UserTypeEnum.ADMIN); | |
| 57 | 58 | // 断言 |
| 58 | 59 | List<SysSocialUserDO> socialUsers = socialUserMapper.selectList("user_id", userId); |
| 59 | 60 | assertEquals(1, socialUsers.size()); |
| ... | ... | @@ -78,7 +79,7 @@ public class SysSocialServiceTest extends BaseDbAndRedisUnitTest { |
| 78 | 79 | // mock 方法 |
| 79 | 80 | |
| 80 | 81 | // 调用 |
| 81 | - socialService.bindSocialUser(userId, type, authUser); | |
| 82 | + socialService.bindSocialUser(userId, type, authUser, UserTypeEnum.ADMIN); | |
| 82 | 83 | // 断言 |
| 83 | 84 | List<SysSocialUserDO> socialUsers = socialUserMapper.selectList("user_id", userId); |
| 84 | 85 | assertEquals(1, socialUsers.size()); |
| ... | ... | @@ -103,7 +104,7 @@ public class SysSocialServiceTest extends BaseDbAndRedisUnitTest { |
| 103 | 104 | // mock 方法 |
| 104 | 105 | |
| 105 | 106 | // 调用 |
| 106 | - socialService.bindSocialUser(userId, type, authUser); | |
| 107 | + socialService.bindSocialUser(userId, type, authUser, UserTypeEnum.ADMIN); | |
| 107 | 108 | // 断言 |
| 108 | 109 | List<SysSocialUserDO> socialUsers = socialUserMapper.selectList("user_id", userId); |
| 109 | 110 | assertEquals(1, socialUsers.size()); |
| ... | ... | @@ -140,7 +141,7 @@ public class SysSocialServiceTest extends BaseDbAndRedisUnitTest { |
| 140 | 141 | String newUnionId = oldSocialUser.getUnionId(); |
| 141 | 142 | |
| 142 | 143 | // 调用 |
| 143 | - socialService.unbindOldSocialUser(userId, type, newUnionId); | |
| 144 | + socialService.unbindOldSocialUser(userId, type, newUnionId, UserTypeEnum.ADMIN); | |
| 144 | 145 | // 断言 |
| 145 | 146 | assertEquals(1L, socialUserMapper.selectCount(null).longValue()); |
| 146 | 147 | } |
| ... | ... | @@ -163,7 +164,7 @@ public class SysSocialServiceTest extends BaseDbAndRedisUnitTest { |
| 163 | 164 | String newUnionId = randomString(10); |
| 164 | 165 | |
| 165 | 166 | // 调用 |
| 166 | - socialService.unbindOldSocialUser(userId, type, newUnionId); | |
| 167 | + socialService.unbindOldSocialUser(userId, type, newUnionId, UserTypeEnum.ADMIN); | |
| 167 | 168 | // 断言 |
| 168 | 169 | assertEquals(0L, socialUserMapper.selectCount(null).longValue()); |
| 169 | 170 | } | ... | ... |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/social/SysSocialService.java
| ... | ... | @@ -59,7 +59,7 @@ public interface SysSocialService { |
| 59 | 59 | * @param userId 用户编号 |
| 60 | 60 | * @return 社交用户列表 |
| 61 | 61 | */ |
| 62 | - List<SysSocialUserDO> getSocialUserList(Long userId,UserTypeEnum userTypeEnum); | |
| 62 | + List<SysSocialUserDO> getSocialUserList(Long userId, UserTypeEnum userTypeEnum); | |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * 绑定社交用户 | ... | ... |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/system/service/social/impl/SysSocialServiceImpl.java
| ... | ... | @@ -87,7 +87,7 @@ public class SysSocialServiceImpl implements SysSocialService { |
| 87 | 87 | |
| 88 | 88 | @Override |
| 89 | 89 | @Transactional |
| 90 | - public void bindSocialUser(Long userId, Integer type, AuthUser authUser,UserTypeEnum userTypeEnum) { | |
| 90 | + public void bindSocialUser(Long userId, Integer type, AuthUser authUser, UserTypeEnum userTypeEnum) { | |
| 91 | 91 | // 获得 unionId 对应的 SysSocialUserDO 列表 |
| 92 | 92 | String unionId = getAuthUserUnionId(authUser); |
| 93 | 93 | List<SysSocialUserDO> socialUsers = this.getAllSocialUserList(type, unionId, userTypeEnum); | ... | ... |
yudao-user-server/src/main/resources/application-local.yaml
| ... | ... | @@ -156,7 +156,6 @@ yudao: |
| 156 | 156 | pay-notify-url: http://niubi.natapp1.cc/api/pay/order/notify |
| 157 | 157 | refund-notify-url: http://niubi.natapp1.cc/api/pay/refund/notify |
| 158 | 158 | |
| 159 | - | |
| 160 | 159 | justauth: |
| 161 | 160 | enabled: true |
| 162 | 161 | type: |
| ... | ... | @@ -169,10 +168,12 @@ justauth: |
| 169 | 168 | extend: |
| 170 | 169 | enum-class: cn.iocoder.yudao.coreservice.modules.system.compent.justauth.AuthExtendSource |
| 171 | 170 | config: |
| 172 | - WECHAT_MINI_PROGRAM: # 微信小程序 扩展 | |
| 171 | + WECHAT_MINI_PROGRAM: # 微信小程序 https://www.yuque.com/docs/share/88e3d30a-6830-45fc-8c25-dae485aef3aa?#%20%E3%80%8A%E5%B0%8F%E7%A8%8B%E5%BA%8F%E6%8E%88%E6%9D%83%E7%99%BB%E5%BD%95%E3%80%8B | |
| 173 | 172 | request-class: cn.iocoder.yudao.coreservice.modules.system.compent.justauth.AuthWeChatMiniProgramRequest |
| 174 | 173 | client-id: wx44d047d87e6284d8 |
| 175 | 174 | client-secret: 21c3b7a8a51ee1b8f5cf875848ed4466 |
| 175 | +# client-id: wx63c280fe3248a3e7 # TODO 芋艿:自己的测试,后续可以删除 | |
| 176 | +# client-secret: 6f270509224a7ae1296bbf1c8cb97aed | |
| 176 | 177 | ignore-check-redirect-uri: true |
| 177 | 178 | ignore-check-state: true |
| 178 | 179 | cache: | ... | ... |