Commit 2b72dc2f authored by liuyang's avatar liuyang

update

parent c0656b16
...@@ -10,7 +10,9 @@ import com.qiankun.config.WxMaProperties; ...@@ -10,7 +10,9 @@ import com.qiankun.config.WxMaProperties;
import com.qiankun.entity.User; import com.qiankun.entity.User;
import com.qiankun.service.UserService; import com.qiankun.service.UserService;
import com.qiankun.utils.JwtTokenUtil; import com.qiankun.utils.JwtTokenUtil;
import com.qiankun.utils.UserUtils;
import com.qiankun.vo.PaperIdLoginVo; import com.qiankun.vo.PaperIdLoginVo;
import com.qiankun.vo.UserVo;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -55,7 +57,7 @@ public class MdpController { ...@@ -55,7 +57,7 @@ public class MdpController {
if (userInfo != null){ if (userInfo != null){
String sKey = tokenUtil.generateToken(userInfo.getOpenid()); String sKey = tokenUtil.generateToken(userInfo.getOpenid());
result.put("sKey",sKey); result.put("sKey",sKey);
result.put("userInfo",userInfo); result.put("userInfo", UserUtils.converToVo(userInfo));
}else { }else {
result.put("sKey",""); result.put("sKey","");
result.put("userInfo",""); result.put("userInfo","");
...@@ -82,7 +84,7 @@ public class MdpController { ...@@ -82,7 +84,7 @@ public class MdpController {
user.setOpenid(vo.getOpenid()); user.setOpenid(vo.getOpenid());
userService.save(user); userService.save(user);
result.put("sKey",tokenUtil.generateToken(user.getOpenid())); result.put("sKey",tokenUtil.generateToken(user.getOpenid()));
result.put("userInfo",user); result.put("userInfo",UserUtils.converToVo(user));
} }
result.put("isExist",true); result.put("isExist",true);
} }
...@@ -91,13 +93,13 @@ public class MdpController { ...@@ -91,13 +93,13 @@ public class MdpController {
@Auth(verifyLogin = false,verifyURL = false) @Auth(verifyLogin = false,verifyURL = false)
@RequestMapping(value = "/userInfo",method = RequestMethod.GET) @RequestMapping(value = "/userInfo",method = RequestMethod.GET)
public User getUserInfo(@RequestHeader String sKey){ public UserVo getUserInfo(@RequestHeader String sKey){
if (Strings.isNullOrEmpty(sKey)){ if (Strings.isNullOrEmpty(sKey)){
throw new IllegalArgumentException("请求参数错误"); throw new IllegalArgumentException("请求参数错误");
} }
String openid = tokenUtil.getUsernameFromToken(sKey); String openid = tokenUtil.getUsernameFromToken(sKey);
User user = userService.findByOpenid(openid); User user = userService.findByOpenid(openid);
return user; return UserUtils.converToVo(user);
} }
} }
...@@ -139,7 +139,7 @@ public class RainbowPlanController { ...@@ -139,7 +139,7 @@ public class RainbowPlanController {
} }
@Auth(verifyLogin = false,verifyURL = false) @Auth(verifyLogin = false,verifyURL = false)
@RequestMapping(value = "/userInfo",method = RequestMethod.POST) @RequestMapping(value = "/userInfo",method = RequestMethod.POST)
public String updateUserInfo(@RequestBody UserInfo info,@RequestHeader String sKey) throws Exception { public @ResponseBody RainbowPlanUser updateUserInfo(@RequestBody UserInfo info,@RequestHeader String sKey) throws Exception {
if (Strings.isNullOrEmpty(sKey)){ if (Strings.isNullOrEmpty(sKey)){
throw new IllegalArgumentException("请求参数错误"); throw new IllegalArgumentException("请求参数错误");
} }
...@@ -160,12 +160,12 @@ public class RainbowPlanController { ...@@ -160,12 +160,12 @@ public class RainbowPlanController {
throw new Exception("保存失败,请求用户不存在"); throw new Exception("保存失败,请求用户不存在");
} }
return "OK"; return user;
} }
@Auth(verifyLogin = false,verifyURL = false) @Auth(verifyLogin = false,verifyURL = false)
@RequestMapping(value = "/userInfoWithAvatar",method = RequestMethod.POST) @RequestMapping(value = "/userInfoWithAvatar",method = RequestMethod.POST)
public String updateUserInfoWithAvatar(UserInfo info, @RequestHeader String sKey) throws Exception { public @ResponseBody RainbowPlanUser updateUserInfoWithAvatar(UserInfo info, @RequestHeader String sKey) throws Exception {
if (Strings.isNullOrEmpty(sKey)){ if (Strings.isNullOrEmpty(sKey)){
throw new IllegalArgumentException("请求参数错误"); throw new IllegalArgumentException("请求参数错误");
} }
...@@ -194,7 +194,7 @@ public class RainbowPlanController { ...@@ -194,7 +194,7 @@ public class RainbowPlanController {
}else { }else {
throw new Exception("保存失败,请求用户不存在"); throw new Exception("保存失败,请求用户不存在");
} }
return "OK"; return user;
} }
@Auth(verifyLogin = false,verifyURL = false) @Auth(verifyLogin = false,verifyURL = false)
@RequestMapping(value = "/publishWish",method = RequestMethod.POST) @RequestMapping(value = "/publishWish",method = RequestMethod.POST)
......
package com.qiankun.utils;
import com.qiankun.entity.Contacts;
import com.qiankun.entity.User;
import com.qiankun.vo.UserVo;
import org.springframework.beans.BeanUtils;
import java.util.Iterator;
import java.util.Set;
public class UserUtils {
public static UserVo converToVo(User user){
UserVo vo = null;
if (user != null){
vo = new UserVo();
BeanUtils.copyProperties(user,vo);
Set<Contacts> contacts = user.getContacts();
if (contacts != null){
Iterator<Contacts> its = contacts.iterator();
Integer count = 0;
while (its.hasNext()) {
Contacts c = its.next();
if (count == 0) {
vo.setContactsAddr1(c.getAddr());
vo.setContactsName1(c.getName());
vo.setContactsMobile1(c.getMobile());
vo.setContactsRelation1(c.getRelation());
vo.setContactsWeixin1(c.getWeixin());
vo.setContactsQQ1(c.getQq());
count ++;
} else {
vo.setContactsAddr2(c.getAddr());
vo.setContactsName2(c.getName());
vo.setContactsMobile2(c.getMobile());
vo.setContactsRelation2(c.getRelation());
vo.setContactsWeixin2(c.getWeixin());
vo.setContactsQQ2(c.getQq());
}
}
}
}
return vo;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment