Compare commits
No commits in common. "c65f5ac7935e6ac02569598d860a80101ed86492" and "a204ebf9c809b3cf649a825ddb31c8d06a781c9d" have entirely different histories.
c65f5ac793
...
a204ebf9c8
@ -1,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.jx.controller.admin;
|
package cn.iocoder.yudao.module.jx.controller.admin;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
@ -8,14 +7,12 @@ import cn.iocoder.yudao.module.jx.domain.DriveSchoolCoach;
|
|||||||
import cn.iocoder.yudao.module.jx.domain.DriveSchoolInfo;
|
import cn.iocoder.yudao.module.jx.domain.DriveSchoolInfo;
|
||||||
import cn.iocoder.yudao.module.jx.mapper.DriveSchoolCoachMapper;
|
import cn.iocoder.yudao.module.jx.mapper.DriveSchoolCoachMapper;
|
||||||
import cn.iocoder.yudao.module.jx.service.IDriveSchoolInfoService;
|
import cn.iocoder.yudao.module.jx.service.IDriveSchoolInfoService;
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
||||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -26,8 +23,6 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 认证")
|
@Tag(name = "管理后台 - 认证")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/jx/auth")
|
@RequestMapping("/jx/auth")
|
||||||
@ -80,27 +75,4 @@ public class JxAuthController {
|
|||||||
return CommonResult.success(result);
|
return CommonResult.success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取App用户信息
|
|
||||||
*
|
|
||||||
* @return 用户信息
|
|
||||||
*/
|
|
||||||
@GetMapping("/getAppInfo")
|
|
||||||
public CommonResult getAppInfo()
|
|
||||||
{
|
|
||||||
LoginUser user = SecurityFrameworkUtils.getLoginUser();
|
|
||||||
// 获取当前登录用户角色编码
|
|
||||||
Set<String> roles = permissionService.getRolePermission(user.getId());
|
|
||||||
Map<String,Object> result = new HashMap<>();
|
|
||||||
result.put("user", user);
|
|
||||||
result.put("role", roles);
|
|
||||||
// ShopConfig shopConfig = configService.selectShopConfigById(1L);
|
|
||||||
// if (StringUtils.isEmpty(shopConfig.getOpenRz())||shopConfig.getOpenRz().equals("0")){
|
|
||||||
// ajax.put("openRz", "0");
|
|
||||||
// }else {
|
|
||||||
// ajax.put("openRz", "1");
|
|
||||||
// }
|
|
||||||
return success(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -470,45 +470,52 @@ public class SysLoginController {
|
|||||||
// return AjaxResult.success(menuService.buildMenus(menus));
|
// return AjaxResult.success(menuService.buildMenus(menus));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@PostMapping("/wxLogin")
|
// @ApiOperation("微信登录")
|
||||||
public CommonResult wxLogin(@RequestBody WxLoginBody wxLoginBody) {
|
// @ApiImplicitParams({
|
||||||
String code = wxLoginBody.getCode();
|
// @ApiImplicitParam(name = "WxLoginBody",dataType = "WxLoginBody", value = "jscode", required = true, paramType = "body")
|
||||||
//秘钥
|
// })
|
||||||
String encryptedIv = wxLoginBody.getEncryptedIv();
|
// @PostMapping("/wxLogin")
|
||||||
//加密数据
|
// public AjaxResult wxLogin(@RequestBody WxLoginBody wxLoginBody) {
|
||||||
String encryptedData = wxLoginBody.getEncryptedData();
|
// String code = wxLoginBody.getCode();
|
||||||
|
// //秘钥
|
||||||
|
// String encryptedIv = wxLoginBody.getEncryptedIv();
|
||||||
//想微信服务器发送请求获取用户信息
|
// //加密数据
|
||||||
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getJxAppId() + "&secret=" + wxConfig.getJxAppSecret() + "&js_code=" + code + "&grant_type=authorization_code";
|
// String encryptedData = wxLoginBody.getEncryptedData();
|
||||||
System.out.println(url);
|
//
|
||||||
String res = restTemplate.getForObject(url, String.class);
|
//
|
||||||
JSONObject jsonObject = JSONObject.parseObject(res);
|
// //想微信服务器发送请求获取用户信息
|
||||||
|
// String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getAppSecret() + "&js_code=" + code + "&grant_type=authorization_code";
|
||||||
//获取session_key和openid
|
// System.out.println(url);
|
||||||
String sessionKey = jsonObject.getString("session_key");
|
// String res = restTemplate.getForObject(url, String.class);
|
||||||
String openId = jsonObject.getString("openid");
|
// JSONObject jsonObject = JSONObject.parseObject(res);
|
||||||
//解密
|
//
|
||||||
String decryptResult = "";
|
// //获取session_key和openid
|
||||||
try {
|
// String sessionKey = jsonObject.getString("session_key");
|
||||||
//如果没有绑定微信开放平台,解析结果是没有unionid的。
|
// String openId = jsonObject.getString("openid");
|
||||||
decryptResult = decrypt(sessionKey, encryptedIv, encryptedData);
|
//
|
||||||
} catch (Exception e) {
|
// System.out.println(sessionKey);
|
||||||
e.printStackTrace();
|
// System.out.println(openId);
|
||||||
return error(500, "微信登录失败!");
|
// //解密
|
||||||
}
|
// String decryptResult = "";
|
||||||
|
// try {
|
||||||
if (StringUtils.hasText(decryptResult)) {
|
// //如果没有绑定微信开放平台,解析结果是没有unionid的。
|
||||||
//如果解析成功,获取token
|
// decryptResult = decrypt(sessionKey, encryptedIv, encryptedData);
|
||||||
AuthLoginRespVO loginVO = loginService.wxLogin(decryptResult,openId,wxLoginBody.getInviteId());
|
// } catch (Exception e) {
|
||||||
Map<String, Object> map = new HashMap<>();
|
// e.printStackTrace();
|
||||||
map.put("token", loginVO.getAccessToken());
|
// return AjaxResult.error("微信登录失败!");
|
||||||
return success(map);
|
// }
|
||||||
} else {
|
//
|
||||||
return error(500, "微信登录失败!");
|
// if (StringUtils.hasText(decryptResult)) {
|
||||||
}
|
// //如果解析成功,获取token
|
||||||
}
|
// String token = loginService.wxLogin(decryptResult,openId,wxLoginBody.getInviteId());
|
||||||
|
// AjaxResult ajax = AjaxResult.success();
|
||||||
|
// ajax.put(Constants.TOKEN, token);
|
||||||
|
// return ajax;
|
||||||
|
// } else {
|
||||||
|
// return AjaxResult.error("微信登录失败!");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
// @PostMapping("/wxLoginJc")
|
// @PostMapping("/wxLoginJc")
|
||||||
// public AjaxResult wxLoginJc(@RequestBody WxLoginBody wxLoginBody) {
|
// public AjaxResult wxLoginJc(@RequestBody WxLoginBody wxLoginBody) {
|
||||||
// String code = wxLoginBody.getCode();
|
// String code = wxLoginBody.getCode();
|
||||||
|
|||||||
@ -19,6 +19,6 @@ public class WxLoginBody {
|
|||||||
*/
|
*/
|
||||||
private String encryptedData;
|
private String encryptedData;
|
||||||
|
|
||||||
//邀请码
|
// //邀请码
|
||||||
private Long inviteId;
|
// private Long inviteId;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,9 +75,6 @@ public class WechatPayConfig {
|
|||||||
*/
|
*/
|
||||||
private String baseUrl;
|
private String baseUrl;
|
||||||
|
|
||||||
private String jxAppId = "wx684fc832e96cee65";
|
|
||||||
private String jxAppSecret = "d1fecac806c5f3cd9aca9f3d5c3759c7";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -130,11 +130,7 @@ public class YudaoWebSecurityConfigurerAdapter {
|
|||||||
// 1.1 静态资源,可匿名访问
|
// 1.1 静态资源,可匿名访问
|
||||||
.antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll()
|
.antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll()
|
||||||
|
|
||||||
.antMatchers(HttpMethod.POST, "/admin-api/rescue/login",
|
.antMatchers(HttpMethod.POST, "/admin-api/rescue/login", "/admin-api/rescue/loginApp","/admin-api/system/auth/loginApp", "/admin-api/rescue/driverLogin").anonymous()
|
||||||
"/admin-api/rescue/loginApp",
|
|
||||||
"/admin-api/rescue/wxLogin",
|
|
||||||
"/admin-api/system/auth/loginApp",
|
|
||||||
"/admin-api/rescue/driverLogin").anonymous()
|
|
||||||
// 1.2 设置 @PermitAll 无需认证
|
// 1.2 设置 @PermitAll 无需认证
|
||||||
.antMatchers(HttpMethod.GET, permitAllUrls.get(HttpMethod.GET).toArray(new String[0])).permitAll()
|
.antMatchers(HttpMethod.GET, permitAllUrls.get(HttpMethod.GET).toArray(new String[0])).permitAll()
|
||||||
.antMatchers(HttpMethod.POST, permitAllUrls.get(HttpMethod.POST).toArray(new String[0])).permitAll()
|
.antMatchers(HttpMethod.POST, permitAllUrls.get(HttpMethod.POST).toArray(new String[0])).permitAll()
|
||||||
|
|||||||
@ -132,49 +132,6 @@ public class AuthController {
|
|||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @PostMapping("/wxLoginJc")
|
|
||||||
// public AjaxResult wxLoginJc(@RequestBody WxLoginBody wxLoginBody) {
|
|
||||||
// String code = wxLoginBody.getCode();
|
|
||||||
// //秘钥
|
|
||||||
// String encryptedIv = wxLoginBody.getEncryptedIv();
|
|
||||||
// //加密数据
|
|
||||||
// String encryptedData = wxLoginBody.getEncryptedData();
|
|
||||||
//
|
|
||||||
// //想微信服务器发送请求获取用户信息
|
|
||||||
// String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getAppSecret() + "&js_code=" + code + "&grant_type=authorization_code";
|
|
||||||
// System.out.println(url);
|
|
||||||
// String res = restTemplate.getForObject(url, String.class);
|
|
||||||
// JSONObject jsonObject = JSONObject.parseObject(res);
|
|
||||||
//
|
|
||||||
// //获取session_key和openid
|
|
||||||
// String sessionKey = jsonObject.getString("session_key");
|
|
||||||
// String openId = jsonObject.getString("openid");
|
|
||||||
//
|
|
||||||
// System.out.println(sessionKey);
|
|
||||||
// System.out.println(openId);
|
|
||||||
// //解密
|
|
||||||
// String decryptResult = "";
|
|
||||||
// try {
|
|
||||||
// //如果没有绑定微信开放平台,解析结果是没有unionid的。
|
|
||||||
// decryptResult = decrypt(sessionKey, encryptedIv, encryptedData);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// return AjaxResult.error("微信登录失败!");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (StringUtils.hasText(decryptResult)) {
|
|
||||||
// //如果解析成功,获取token
|
|
||||||
// String token = loginService.wxLoginJc(decryptResult,openId,wxLoginBody.getInviteId());
|
|
||||||
// AjaxResult ajax = AjaxResult.success();
|
|
||||||
// ajax.put(Constants.TOKEN, token);
|
|
||||||
// return ajax;
|
|
||||||
// } else {
|
|
||||||
// return AjaxResult.error("微信登录失败!");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/refresh-token")
|
@PostMapping("/refresh-token")
|
||||||
@PermitAll
|
@PermitAll
|
||||||
@Operation(summary = "刷新令牌")
|
@Operation(summary = "刷新令牌")
|
||||||
|
|||||||
@ -109,6 +109,5 @@ public class AdminUserDO extends TenantBaseDO {
|
|||||||
|
|
||||||
private String jcOpenId;
|
private String jcOpenId;
|
||||||
|
|
||||||
private String openId;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,6 +53,4 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
|
|||||||
Integer getStudentNumberByUserId(Long jlId);
|
Integer getStudentNumberByUserId(Long jlId);
|
||||||
|
|
||||||
List<String> getStudentNumber(Long id);
|
List<String> getStudentNumber(Long id);
|
||||||
|
|
||||||
AdminUserDO selectUserByPhone(String phone);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,6 +70,4 @@ public interface AdminAuthService {
|
|||||||
*/
|
*/
|
||||||
AuthLoginRespVO refreshToken(String refreshToken);
|
AuthLoginRespVO refreshToken(String refreshToken);
|
||||||
|
|
||||||
AuthLoginRespVO wxLogin(String decryptResult,String openId,Long inviteId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import cn.iocoder.yudao.module.system.service.member.MemberService;
|
|||||||
import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService;
|
import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService;
|
||||||
import cn.iocoder.yudao.module.system.service.social.SocialUserService;
|
import cn.iocoder.yudao.module.system.service.social.SocialUserService;
|
||||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.xingyuv.captcha.model.common.ResponseModel;
|
import com.xingyuv.captcha.model.common.ResponseModel;
|
||||||
import com.xingyuv.captcha.model.vo.CaptchaVO;
|
import com.xingyuv.captcha.model.vo.CaptchaVO;
|
||||||
@ -66,7 +65,6 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
@Resource
|
@Resource
|
||||||
private SmsCodeApi smsCodeApi;
|
private SmsCodeApi smsCodeApi;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码的开关,默认为 true
|
* 验证码的开关,默认为 true
|
||||||
*/
|
*/
|
||||||
@ -209,63 +207,6 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
return AuthConvert.INSTANCE.convert(accessTokenDO);
|
return AuthConvert.INSTANCE.convert(accessTokenDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AuthLoginRespVO wxLogin(String decryptResult, String openId, Long inviteId) {
|
|
||||||
//字符串转json
|
|
||||||
JSONObject jsonObject = JSONObject.parseObject(decryptResult);
|
|
||||||
System.out.println(jsonObject);
|
|
||||||
System.out.println("openId"+openId);
|
|
||||||
String phoneNumber = jsonObject.getString("phoneNumber");
|
|
||||||
//还可以获取其他信息
|
|
||||||
//根据openid判断数据库中是否有该用户
|
|
||||||
//根据openid查询用户信息
|
|
||||||
AdminUserDO wxUser = userService.selectUserByPhone(phoneNumber);
|
|
||||||
//如果查不到,则新增,查到了,则更新
|
|
||||||
// SysUser user = new SysUser();
|
|
||||||
// if (wxUser == null) {
|
|
||||||
// // 新增
|
|
||||||
// user.setUserName(phoneNumber);
|
|
||||||
// user.setNickName(phoneNumber);
|
|
||||||
// user.setPhonenumber(phoneNumber);
|
|
||||||
// user.setOpenId(openId);
|
|
||||||
// user.setCreateTime(DateUtils.getNowDate());
|
|
||||||
// user.setPassword(SecurityUtils.encryptPassword("654321"));
|
|
||||||
// if (null!=inviteId){
|
|
||||||
//
|
|
||||||
// //绑定上级
|
|
||||||
// user.setInviteId(inviteId);
|
|
||||||
// //给上级进行积分奖励
|
|
||||||
// userBalanceService.inviteRewards(inviteId);
|
|
||||||
// }
|
|
||||||
// //新增 用户
|
|
||||||
// userService.insertUser(user);
|
|
||||||
// }else {
|
|
||||||
// //更新
|
|
||||||
// user = wxUser;
|
|
||||||
// user.setNickName(phoneNumber);
|
|
||||||
// user.setPhonenumber(phoneNumber);
|
|
||||||
// user.setUpdateTime(DateUtils.getNowDate());
|
|
||||||
// user.setOpenId(openId);
|
|
||||||
// if (ObjectUtil.isEmpty(user.getInviteId())){
|
|
||||||
// if (null!=inviteId){
|
|
||||||
// //绑定上级
|
|
||||||
// user.setInviteId(inviteId);
|
|
||||||
// //给上级进行积分奖励
|
|
||||||
// userBalanceService.inviteRewards(inviteId);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// userMapper.updateUser(user);
|
|
||||||
// }
|
|
||||||
//组装token信息
|
|
||||||
// LoginUser loginUser = new LoginUser();
|
|
||||||
// loginUser.setOpenId(openId);
|
|
||||||
// //如果有的话设置
|
|
||||||
// loginUser.setUser(user);
|
|
||||||
// loginUser.setUserId(user.getUserId());
|
|
||||||
// 生成token
|
|
||||||
return createTokenAfterLoginSuccess(wxUser.getId(), wxUser.getUsername(), LoginLogTypeEnum.LOGIN_SOCIAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logout(String token, Integer logType) {
|
public void logout(String token, Integer logType) {
|
||||||
// 删除访问令牌
|
// 删除访问令牌
|
||||||
|
|||||||
@ -215,6 +215,4 @@ public interface AdminUserService {
|
|||||||
Integer getStudentNumberByUserId(Long jlId);
|
Integer getStudentNumberByUserId(Long jlId);
|
||||||
|
|
||||||
List<String> getStudentNumber(Long id);
|
List<String> getStudentNumber(Long id);
|
||||||
|
|
||||||
AdminUserDO selectUserByPhone(String phone);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -520,11 +520,6 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
return userMapper.getStudentNumber(id);
|
return userMapper.getStudentNumber(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AdminUserDO selectUserByPhone(String phone) {
|
|
||||||
return userMapper.selectUserByPhone(phone);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对密码进行加密
|
* 对密码进行加密
|
||||||
*
|
*
|
||||||
|
|||||||
@ -30,8 +30,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="getStudentNumber" resultType="String">
|
<select id="getStudentNumber" resultType="String">
|
||||||
select distinct phone from drive_school_pay where jxId = #{deptId} and state = '3'
|
select distinct phone from drive_school_pay where jxId = #{deptId} and state = '3'
|
||||||
</select>
|
</select>
|
||||||
<select id="selectUserByPhone" resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
|
|
||||||
select su.*
|
|
||||||
from system_users su where su.mobile = #{phone} and su.deleted = '0'
|
|
||||||
</select>
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user