feat:免密支付
This commit is contained in:
1 parent
5b2463cba0
commit
5dc6a1ebbd
31 files changed
+776
-281
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
package com.bsd.pjcloud.app.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 支付宝支付配置
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "mini-ali-pay")
|
||||
@Data
|
||||
public class MiniAlipayConf {
|
||||
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 私钥
|
||||
*/
|
||||
private String privateKey;
|
||||
|
||||
/**
|
||||
* 公钥
|
||||
*/
|
||||
private String publicKey;
|
||||
|
||||
/**
|
||||
* 支付宝公钥
|
||||
*/
|
||||
private String alipayPublicKey;
|
||||
|
||||
/**
|
||||
* 回调地址
|
||||
*/
|
||||
private String callbackUrl;
|
||||
|
||||
}
|
||||
+68
-82
@@ -28,6 +28,8 @@ import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.HasPermission;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.common.security.util.SecurityUtils;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -45,95 +47,79 @@ import java.util.List;
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class AppSocialDetailsController {
|
||||
|
||||
private final AppSocialDetailsService appSocialDetailsService;
|
||||
private final AppSocialDetailsService appSocialDetailsService;
|
||||
|
||||
/**
|
||||
* 社交登录账户简单分页查询
|
||||
* @param page 分页对象
|
||||
* @param appSocialDetails 社交登录
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getSocialDetailsPage(Page page, AppSocialDetails appSocialDetails) {
|
||||
return R.ok(appSocialDetailsService.page(page, Wrappers.query(appSocialDetails)));
|
||||
}
|
||||
/**
|
||||
* 社交登录账户简单分页查询
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getSocialDetailsPage(Page page, AppSocialDetails appSocialDetails) {
|
||||
return R.ok(appSocialDetailsService.page(page, Wrappers.query(appSocialDetails)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getinfo(@PathVariable("id") Long id) {
|
||||
return R.ok(appSocialDetailsService.getById(id));
|
||||
}
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getinfo(@PathVariable("id") Long id) {
|
||||
return R.ok(appSocialDetailsService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* @param appSocialDetails
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("保存三方信息")
|
||||
@PostMapping
|
||||
@HasPermission("app_social_details_add")
|
||||
public R save(@Valid @RequestBody AppSocialDetails appSocialDetails) {
|
||||
return R.ok(appSocialDetailsService.save(appSocialDetails));
|
||||
}
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@SysLog("保存三方信息")
|
||||
@PostMapping
|
||||
@HasPermission("app_social_details_add")
|
||||
public R save(@Valid @RequestBody AppSocialDetails appSocialDetails) {
|
||||
return R.ok(appSocialDetailsService.save(appSocialDetails));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param appSocialDetails
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("修改三方信息")
|
||||
@PutMapping
|
||||
@HasPermission("app_social_details_edit")
|
||||
public R updateById(@Validated({ ValidGroup.Update.class }) @RequestBody AppSocialDetails appSocialDetails) {
|
||||
appSocialDetailsService.updateById(appSocialDetails);
|
||||
return R.ok(Boolean.TRUE);
|
||||
}
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@SysLog("修改三方信息")
|
||||
@PutMapping
|
||||
@HasPermission("app_social_details_edit")
|
||||
public R updateById(@Validated({ValidGroup.Update.class}) @RequestBody AppSocialDetails appSocialDetails) {
|
||||
appSocialDetailsService.updateById(appSocialDetails);
|
||||
return R.ok(Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param ids
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除三方信息")
|
||||
@DeleteMapping
|
||||
@HasPermission("app_social_details_del")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(appSocialDetailsService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@SysLog("删除三方信息")
|
||||
@DeleteMapping
|
||||
@HasPermission("app_social_details_del")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(appSocialDetailsService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过社交账号、手机号查询用户、角色信息
|
||||
* @param inStr appid@code
|
||||
* @return
|
||||
*/
|
||||
@Inner
|
||||
@GetMapping("/info/{inStr}")
|
||||
public R getUserInfo(@PathVariable String inStr) {
|
||||
return R.ok(appSocialDetailsService.getUserInfo(inStr));
|
||||
}
|
||||
/**
|
||||
* 通过社交账号、手机号查询用户、角色信息
|
||||
*/
|
||||
@Inner
|
||||
@GetMapping("/info/{inStr}")
|
||||
public R getUserInfo(@PathVariable String inStr) {
|
||||
return R.ok(appSocialDetailsService.getUserInfo(inStr));
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定社交账号
|
||||
* @param state 类型
|
||||
* @param code code
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/bind")
|
||||
public R bindSocial(String state, String code) {
|
||||
return R.ok(appSocialDetailsService.bindSocial(state, code));
|
||||
}
|
||||
/**
|
||||
* 绑定社交账号
|
||||
*/
|
||||
@PostMapping("/bind")
|
||||
public R bindSocial(String state, String code) {
|
||||
return R.ok(appSocialDetailsService.bindSocial(state, code));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
@ResponseExcel
|
||||
public List<AppSocialDetails> export(AppSocialDetails appSocialDetails) {
|
||||
return appSocialDetailsService.list(Wrappers.query(appSocialDetails));
|
||||
}
|
||||
/**
|
||||
* 导出
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
@ResponseExcel
|
||||
public List<AppSocialDetails> export(AppSocialDetails appSocialDetails) {
|
||||
return appSocialDetailsService.list(Wrappers.query(appSocialDetails));
|
||||
}
|
||||
|
||||
}
|
||||
+93
-147
@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.app.api.dto.AppUserDTO;
|
||||
import com.bsd.pjcloud.app.api.dto.AppUserInfo;
|
||||
import com.bsd.pjcloud.app.api.entity.AppUser;
|
||||
import com.bsd.pjcloud.app.api.feign.RemoteAppUserService;
|
||||
import com.bsd.pjcloud.app.api.vo.AppUserExcelVO;
|
||||
@@ -61,155 +62,100 @@ import java.util.List;
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class AppUserController {
|
||||
|
||||
private final AppUserService appUserService;
|
||||
|
||||
|
||||
@Inner
|
||||
@GetMapping("/info/{username}")
|
||||
public R info(@PathVariable String username) {
|
||||
AppUser user = appUserService.getOne(Wrappers.<AppUser>query()
|
||||
.lambda()
|
||||
.eq(AppUser::getUsername, username)
|
||||
.or()
|
||||
.eq(AppUser::getPhone, username));
|
||||
if (user == null) {
|
||||
return R.failed(MsgUtils.getMessage(ErrorCodes.APP_USER_USERINFO_EMPTY, username));
|
||||
}
|
||||
return R.ok(appUserService.findUserInfo(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户全部信息
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping(value = { "/info" })
|
||||
public R info() {
|
||||
String username = SecurityUtils.getUser().getUsername();
|
||||
AppUser user = appUserService.getOne(Wrappers.<AppUser>query().lambda().eq(AppUser::getUsername, username));
|
||||
if (user == null) {
|
||||
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_QUERY_ERROR));
|
||||
}
|
||||
return R.ok(appUserService.findUserInfo(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param appUserDTO app用户表
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
public R getAppUserPage(Page page, AppUserDTO appUserDTO) {
|
||||
return R.ok(appUserService.getUsersWithRolePage(page, appUserDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询app用户表
|
||||
* @param userId id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/details/{userId}")
|
||||
public R getById(@PathVariable("userId") Long userId) {
|
||||
return R.ok(appUserService.selectUserVoById(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过userName查询", description = "通过userName查询")
|
||||
@GetMapping("/details")
|
||||
public R getByUserName(AppUser user) {
|
||||
AppUser one = appUserService.getOne(Wrappers.query(user), false);
|
||||
return R.ok(one == null ? null : CommonConstants.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增app用户表
|
||||
* @param appUser app用户表
|
||||
* @return R
|
||||
*/
|
||||
// @Operation(summary = "新增app用户表", description = "新增app用户表")
|
||||
// @SysLog("新增app用户表")
|
||||
// @PostMapping
|
||||
// @HasPermission("app_appuser_add")
|
||||
// public R save(@RequestBody AppUserDTO appUser) {
|
||||
// appUserService.saveUser(appUser);
|
||||
// return R.ok();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 修改app用户表
|
||||
* @param appUser app用户表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改app用户表", description = "修改app用户表")
|
||||
@SysLog("修改app用户表")
|
||||
@PutMapping
|
||||
@HasPermission("app_appuser_edit")
|
||||
public R updateById(@RequestBody AppUserDTO appUser) {
|
||||
return R.ok(appUserService.updateUser(appUser));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除app用户表
|
||||
* @param ids userIds
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过ids删除app用户表", description = "通过ids删除app用户表")
|
||||
@SysLog("通过id删除app用户表")
|
||||
@DeleteMapping
|
||||
@HasPermission("app_appuser_del")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(appUserService.deleteAppUserByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
// * @param appUser 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
// @ResponseExcel
|
||||
// @GetMapping("/export")
|
||||
// @HasPermission("app_appuser_export")
|
||||
// public List<AppUserExcelVO> export(AppUserDTO appUser) {
|
||||
// return appUserService.listUser(appUser);
|
||||
// }
|
||||
|
||||
@SysLog("修改个人信息")
|
||||
@PutMapping("/edit")
|
||||
public R updateUserInfo(@Valid @RequestBody AppUserDTO userDto) {
|
||||
if (UserTypeEnum.TOC.getStatus().equals(SecurityUtils.getUser().getUserType())) {
|
||||
userDto.setUserId(SecurityUtils.getUser().getId());
|
||||
// TOC 以手机号为key
|
||||
userDto.setUsername(SecurityUtils.getUser().getUsername());
|
||||
}
|
||||
return appUserService.updateUserInfo(userDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入用户
|
||||
* @param excelVOList 用户列表
|
||||
* @param bindingResult 错误信息列表
|
||||
* @return R
|
||||
*/
|
||||
// @PostMapping("/import")
|
||||
// @HasPermission("app_appuser_export")
|
||||
// public R importUser(@RequestExcel List<AppUserExcelVO> excelVOList, BindingResult bindingResult) {
|
||||
// return appUserService.importUser(excelVOList, bindingResult);
|
||||
// }
|
||||
|
||||
// @Operation(summary = "注册app用户表", description = "注册app用户表")
|
||||
// @SysLog("注册app用户表")
|
||||
// @Inner(value = false)
|
||||
// @PostMapping("/register")
|
||||
// public R register(@RequestBody AppUserDTO appUser) {
|
||||
// return appUserService.registerAppUser(appUser);
|
||||
// }
|
||||
|
||||
private final AppUserService appUserService;
|
||||
|
||||
/* ************************************* start app start ************************************* */
|
||||
|
||||
/**
|
||||
* 获取当前用户全部信息
|
||||
*/
|
||||
@GetMapping(value = {"/info"})
|
||||
public R<AppUserInfo> info() {
|
||||
Long userId = SecurityUtils.getUser().getId();
|
||||
AppUser user = appUserService.getOne(Wrappers.<AppUser>query().lambda().eq(AppUser::getUserId, userId));
|
||||
if (user == null) {
|
||||
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_QUERY_ERROR));
|
||||
}
|
||||
return R.ok(appUserService.findUserInfo(user));
|
||||
}
|
||||
|
||||
/* ************************************* end app end ************************************* */
|
||||
|
||||
@Inner
|
||||
@GetMapping("/info/{username}")
|
||||
public R info(@PathVariable String username) {
|
||||
AppUser user = appUserService.getOne(Wrappers.<AppUser>query()
|
||||
.lambda()
|
||||
.eq(AppUser::getUsername, username)
|
||||
.or()
|
||||
.eq(AppUser::getPhone, username));
|
||||
if (user == null) {
|
||||
return R.failed(MsgUtils.getMessage(ErrorCodes.APP_USER_USERINFO_EMPTY, username));
|
||||
}
|
||||
return R.ok(appUserService.findUserInfo(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
public R getAppUserPage(Page page, AppUserDTO appUserDTO) {
|
||||
return R.ok(appUserService.getUsersWithRolePage(page, appUserDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询app用户表
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/details/{userId}")
|
||||
public R getById(@PathVariable("userId") Long userId) {
|
||||
return R.ok(appUserService.selectUserVoById(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过userName查询", description = "通过userName查询")
|
||||
@GetMapping("/details")
|
||||
public R getByUserName(AppUser user) {
|
||||
AppUser one = appUserService.getOne(Wrappers.query(user), false);
|
||||
return R.ok(one == null ? null : CommonConstants.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改app用户表
|
||||
*/
|
||||
@Operation(summary = "修改app用户表", description = "修改app用户表")
|
||||
@SysLog("修改app用户表")
|
||||
@PutMapping
|
||||
@HasPermission("app_appuser_edit")
|
||||
public R updateById(@RequestBody AppUserDTO appUser) {
|
||||
return R.ok(appUserService.updateUser(appUser));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除app用户表
|
||||
*/
|
||||
@Operation(summary = "通过ids删除app用户表", description = "通过ids删除app用户表")
|
||||
@SysLog("通过id删除app用户表")
|
||||
@DeleteMapping
|
||||
@HasPermission("app_appuser_del")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(appUserService.deleteAppUserByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
@SysLog("修改个人信息")
|
||||
@PutMapping("/edit")
|
||||
public R updateUserInfo(@Valid @RequestBody AppUserDTO userDto) {
|
||||
if (UserTypeEnum.TOC.getStatus().equals(SecurityUtils.getUser().getUserType())) {
|
||||
userDto.setUserId(SecurityUtils.getUser().getId());
|
||||
// TOC 以手机号为key
|
||||
userDto.setUsername(SecurityUtils.getUser().getUsername());
|
||||
}
|
||||
return appUserService.updateUserInfo(userDto);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
package com.bsd.pjcloud.app.handler;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.AlipayConfig;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
||||
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.bsd.pjcloud.app.api.dto.AppUserInfo;
|
||||
import com.bsd.pjcloud.app.api.entity.AppUser;
|
||||
import com.bsd.pjcloud.app.config.MiniAlipayConf;
|
||||
import com.bsd.pjcloud.app.mapper.AppSocialDetailsMapper;
|
||||
import com.bsd.pjcloud.app.service.AppUserService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 支付宝小程序
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("MINI_ALIPAY")
|
||||
@AllArgsConstructor
|
||||
public class MiniAlipayLoginHandler extends AbstractLoginHandler {
|
||||
|
||||
private final MiniAlipayConf miniAlipayConf;
|
||||
|
||||
private final AppUserService appUserService;
|
||||
|
||||
private final AppSocialDetailsMapper appSocialDetailsMapper;
|
||||
|
||||
static private AlipayClient alipayClient = null;
|
||||
|
||||
public AlipayClient getAlipay() {
|
||||
if (ObjectUtil.isNotEmpty(miniAlipayConf)) return getAlipayClient();
|
||||
return getAlipayClient();
|
||||
}
|
||||
|
||||
private synchronized AlipayClient getAlipayClient() {
|
||||
if (alipayClient == null) {
|
||||
try {
|
||||
alipayClient = new DefaultAlipayClient(getAlipayConfig());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("初始化支付宝客户端失败error:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
return alipayClient;
|
||||
}
|
||||
|
||||
private AlipayConfig getAlipayConfig() {
|
||||
AlipayConfig alipayConfig = new AlipayConfig();
|
||||
alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
|
||||
alipayConfig.setAppId(miniAlipayConf.getAppId());
|
||||
alipayConfig.setPrivateKey(miniAlipayConf.getPrivateKey());
|
||||
alipayConfig.setFormat("json");
|
||||
alipayConfig.setAlipayPublicKey(miniAlipayConf.getAlipayPublicKey());
|
||||
alipayConfig.setCharset("UTF-8");
|
||||
alipayConfig.setSignType("RSA2");
|
||||
return alipayConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付宝openId
|
||||
*/
|
||||
public AlipaySystemOauthTokenResponse getOpenId(String code, String refreshToken) {
|
||||
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
|
||||
// 设置刷新令牌
|
||||
if (ObjectUtil.isNotEmpty(refreshToken)) {
|
||||
request.setRefreshToken(refreshToken);
|
||||
request.setGrantType("refresh_token");
|
||||
}
|
||||
// 设置授权码
|
||||
if (ObjectUtil.isNotEmpty(code)) {
|
||||
request.setCode(code);
|
||||
request.setGrantType("authorization_code");
|
||||
}
|
||||
try {
|
||||
AlipaySystemOauthTokenResponse response = getAlipay().execute(request);
|
||||
if (!response.isSuccess()) {
|
||||
log.error("|获取支付宝openId|错误error:{}", response.getSubMsg());
|
||||
}
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("|获取支付宝openId|意外的错误error:{}", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户传入获取唯一标识
|
||||
*/
|
||||
@Override
|
||||
public String identify(String loginStr) {
|
||||
AlipaySystemOauthTokenResponse res = getOpenId(loginStr, null);
|
||||
if (ObjectUtil.isEmpty(res) || ObjectUtil.isEmpty(res.getOpenId())) {
|
||||
return null;
|
||||
}
|
||||
return res.getOpenId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
@Override
|
||||
public AppUserInfo info(String openId) {
|
||||
AppUser user = appUserService.getOne(Wrappers.<AppUser>query().lambda().eq(AppUser::getWxOpenid, openId));
|
||||
if (ObjectUtil.isEmpty(user)) {
|
||||
log.info("支付宝小程序openId:{},创建新的用户", openId);
|
||||
String name = "支付宝游客-" + openId;
|
||||
AppUser appUser = new AppUser();
|
||||
appUser.setWxOpenid(openId);
|
||||
appUser.setUsername(name);
|
||||
appUser.setName(name);
|
||||
appUser.setCreateBy(openId);
|
||||
appUser.setUpdateBy(openId);
|
||||
appUserService.saveOrUpdate(appUser);
|
||||
AppUserInfo appUserDTO = new AppUserInfo();
|
||||
appUserDTO.setAppUser(appUser);
|
||||
return appUserDTO;
|
||||
}
|
||||
return appUserService.findUserInfo(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定逻辑
|
||||
*/
|
||||
@Override
|
||||
public Boolean bind(AppUser user, String identify) {
|
||||
user.setWxOpenid(identify);
|
||||
appUserService.updateById(user);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+2
-5
@@ -36,15 +36,12 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2019年11月02日
|
||||
* <p>
|
||||
* 微信小程序
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("APP-MINI")
|
||||
@Component("MINI_WECHAT")
|
||||
@AllArgsConstructor
|
||||
public class MiniAppLoginHandler extends AbstractLoginHandler {
|
||||
public class MiniWechatLoginHandler extends AbstractLoginHandler {
|
||||
|
||||
private final AppUserService appUserService;
|
||||
|
||||
Reference in new issue
Block a user