|
@@ -16,6 +16,7 @@ import com.kym.entity.miniapp.Account;
|
|
|
import com.kym.entity.miniapp.Cars;
|
|
import com.kym.entity.miniapp.Cars;
|
|
|
import com.kym.entity.miniapp.User;
|
|
import com.kym.entity.miniapp.User;
|
|
|
import com.kym.entity.miniapp.WxPhoneNum;
|
|
import com.kym.entity.miniapp.WxPhoneNum;
|
|
|
|
|
+import com.kym.entity.miniapp.params.WxLoginParams;
|
|
|
import com.kym.entity.miniapp.vo.UserVo;
|
|
import com.kym.entity.miniapp.vo.UserVo;
|
|
|
import com.kym.mapper.miniapp.UserMapper;
|
|
import com.kym.mapper.miniapp.UserMapper;
|
|
|
import com.kym.service.miniapp.AccountService;
|
|
import com.kym.service.miniapp.AccountService;
|
|
@@ -62,12 +63,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
|
@Override
|
|
@Override
|
|
|
- public R wxlogin(String code, String phoneCode, String avatar, String nickname) {
|
|
|
|
|
|
|
+ public R wxlogin(WxLoginParams params) {
|
|
|
// 微信登录
|
|
// 微信登录
|
|
|
var json = HttpUtil.getJson(WxApi.WX_MP_LOGIN.getApi(), Map.of(
|
|
var json = HttpUtil.getJson(WxApi.WX_MP_LOGIN.getApi(), Map.of(
|
|
|
"appid", wxConfig.getAppid(),
|
|
"appid", wxConfig.getAppid(),
|
|
|
"secret", wxConfig.getSecret(),
|
|
"secret", wxConfig.getSecret(),
|
|
|
- "js_code", code
|
|
|
|
|
|
|
+ "js_code", params.getCode()
|
|
|
));
|
|
));
|
|
|
|
|
|
|
|
var errorCode = json.getIntValue("errcode");
|
|
var errorCode = json.getIntValue("errcode");
|
|
@@ -92,11 +93,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
// access_token获取
|
|
// access_token获取
|
|
|
var accessTokenJson = HttpUtil.getJson(WxApi.WX_GET_ACCESS_TOKEN.getApi(), Map.of("appid", wxConfig.getAppid(), "secret", wxConfig.getSecret()));
|
|
var accessTokenJson = HttpUtil.getJson(WxApi.WX_GET_ACCESS_TOKEN.getApi(), Map.of("appid", wxConfig.getAppid(), "secret", wxConfig.getSecret()));
|
|
|
var accessToken = accessTokenJson.getString("access_token");
|
|
var accessToken = accessTokenJson.getString("access_token");
|
|
|
- var wxPhoneNum = HttpUtil.post(WxApi.WX_MP_GET_PHONE.getApi().replace("ACCESS_TOKEN", accessToken), Map.of("code", code), WxPhoneNum.class);
|
|
|
|
|
|
|
+ var wxPhoneNum = HttpUtil.post(WxApi.WX_MP_GET_PHONE.getApi().replace("ACCESS_TOKEN", accessToken), Map.of("code", params.getCode()), WxPhoneNum.class);
|
|
|
var mobilePhone = wxPhoneNum.getPhone_info().getPurePhoneNumber();
|
|
var mobilePhone = wxPhoneNum.getPhone_info().getPurePhoneNumber();
|
|
|
newUser.setMobilePhone(mobilePhone);
|
|
newUser.setMobilePhone(mobilePhone);
|
|
|
- newUser.setAvatar(avatar);
|
|
|
|
|
- newUser.setNickname(nickname);
|
|
|
|
|
|
|
+ newUser.setAvatar(params.getAvatar());
|
|
|
|
|
+ newUser.setNickname(params.getNickname());
|
|
|
userMapper.insert(newUser);
|
|
userMapper.insert(newUser);
|
|
|
// 创建用户账户
|
|
// 创建用户账户
|
|
|
var account = new Account();
|
|
var account = new Account();
|