响应参数新增微信头像,绑定手机号新增密码

This commit is contained in:
yiyan 2019-12-21 15:57:32 +08:00
parent 6259645d6c
commit cfd63d829d
4 changed files with 30 additions and 9 deletions

View File

@ -115,8 +115,8 @@ public class UsersAction {
* @return * @return
*/ */
@RequestMapping(value="/bindPhone",method=RequestMethod.GET) @RequestMapping(value="/bindPhone",method=RequestMethod.GET)
public JsonResult<?> bindPhone(String unionId, String phoneNum) { public JsonResult<?> bindPhone(String unionId, String phoneNum, String password) {
return userService.bindPhone(unionId, phoneNum); return userService.bindPhone(unionId, phoneNum, password);
} }
/** /**

View File

@ -137,6 +137,8 @@ public class User implements Serializable{
@Column(name = "wechat_unionid") @Column(name = "wechat_unionid")
private String wechatUnionid; private String wechatUnionid;
private String wechatImgUrl;
/** /**
* 修改时间 * 修改时间
*/ */
@ -302,4 +304,12 @@ public class User implements Serializable{
public void setWechatUnionid(String wechatUnionid) { public void setWechatUnionid(String wechatUnionid) {
this.wechatUnionid = wechatUnionid; this.wechatUnionid = wechatUnionid;
} }
public String getWechatImgUrl() {
return wechatImgUrl;
}
public void setWechatImgUrl(String wechatImgUrl) {
this.wechatImgUrl = wechatImgUrl;
}
} }

View File

@ -58,7 +58,7 @@ public interface UserService {
* @param phone * @param phone
* @return * @return
*/ */
public JsonResult<?> bindPhone(String unionId, String phone); public JsonResult<?> bindPhone(String unionId, String phone, String password);
/** /**
* 更多用户数据信息 * 更多用户数据信息

View File

@ -319,6 +319,8 @@ public class UserServiceImpl implements UserService {
if (wechatUserInfo == null || wechatUserInfo.size() == 2) { if (wechatUserInfo == null || wechatUserInfo.size() == 2) {
throw new IfishException(ResultEnum.error403); throw new IfishException(ResultEnum.error403);
} }
//微信头像
String headimgurl = wechatUserInfo.getString("headimgurl");
//用户信息 //用户信息
User user = userDao.findUniqueByProperty(Restrictions.eq("wechatUnionid",wechatUserInfo.getString("unionid"))); User user = userDao.findUniqueByProperty(Restrictions.eq("wechatUnionid",wechatUserInfo.getString("unionid")));
if (user == null) { if (user == null) {
@ -387,6 +389,8 @@ public class UserServiceImpl implements UserService {
/** /**
* 登录返回信息 * 登录返回信息
*/ */
//微信头像
user.setWechatImgUrl(headimgurl);
//用户信息 //用户信息
json.put("user", getUserInfo(user,gwellParam)); json.put("user", getUserInfo(user,gwellParam));
//用户资产 //用户资产
@ -484,7 +488,7 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public JsonResult<?> bindPhone(String unionId, String phone) { public JsonResult<?> bindPhone(String unionId, String phone, String password) {
if (unionId == null || phone == null) { if (unionId == null || phone == null) {
throw new IfishException(ResultEnum.error401); throw new IfishException(ResultEnum.error401);
} }
@ -495,7 +499,8 @@ public class UserServiceImpl implements UserService {
} }
User userPhone = userDao.findUniqueByProperty(Restrictions.eq("phoneNumber",phone)); User userPhone = userDao.findUniqueByProperty(Restrictions.eq("phoneNumber",phone));
if (userPhone == null) { if (userPhone == null) {
throw new IfishException(ResultEnum.fail101); userWechat.setPhoneNumber(phone);
userWechat.setUserPassword(password);
} }
List<DeviceUser> deviceUserListWechat = deviceUserDao.findByProperty(Restrictions.eq("priId.userId", userWechat.getUserId())); List<DeviceUser> deviceUserListWechat = deviceUserDao.findByProperty(Restrictions.eq("priId.userId", userWechat.getUserId()));
List<DeviceUser> deviceUserListPhone = deviceUserDao.findByProperty(Restrictions.eq("priId.userId", userPhone.getUserId())); List<DeviceUser> deviceUserListPhone = deviceUserDao.findByProperty(Restrictions.eq("priId.userId", userPhone.getUserId()));
@ -551,10 +556,15 @@ public class UserServiceImpl implements UserService {
// tbl_Camera_User_Mapper.updateCameraUserId(userPhone.getUserId(), Integer.valueOf(cameraUser.getCameraUserId().getCameraId())); // tbl_Camera_User_Mapper.updateCameraUserId(userPhone.getUserId(), Integer.valueOf(cameraUser.getCameraUserId().getCameraId()));
} }
} }
//修改手机账号的微信unionid if (userPhone != null) {
userPhone.setWechatUnionid(userWechat.getWechatUnionid()); //修改手机账号的微信unionid
userDao.update(userPhone); userPhone.setWechatUnionid(userWechat.getWechatUnionid());
userDao.delete(userWechat); userDao.update(userPhone);
userDao.delete(userWechat);
} else {
userDao.update(userWechat);
}
//用户资产信息 //用户资产信息
UserAssetDto userAssetDtoWechat = getUserAssetInfo(userWechat.getUserId()); UserAssetDto userAssetDtoWechat = getUserAssetInfo(userWechat.getUserId());
UserAssetDto userAssetDtoPhone = getUserAssetInfo(userPhone.getUserId()); UserAssetDto userAssetDtoPhone = getUserAssetInfo(userPhone.getUserId());
@ -1277,6 +1287,7 @@ public class UserServiceImpl implements UserService {
json.put("gwellUserID", user.getGwellUserID()); json.put("gwellUserID", user.getGwellUserID());
json.put("neteaseToken", user.getNeteaseToken()); json.put("neteaseToken", user.getNeteaseToken());
json.put("userType", user.getUserType()); json.put("userType", user.getUserType());
json.put("wechatImgUrl", user.getWechatImgUrl());
json.put("shopsUserId", user.getShopsUserId()); json.put("shopsUserId", user.getShopsUserId());
return json; return json;
} }