Commit 5879c03e2ef250b6413a3fd9976481cca279daa2
1 parent
036dcd99ee
Exists in
master
提交代码
Showing 2 changed files with 57 additions and 23 deletions
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/KidsController.java
View file @
5879c03
| ... | ... | @@ -105,31 +105,35 @@ | 
| 105 | 105 | public void checkCode(HttpServletResponse response, | 
| 106 | 106 | @RequestParam("phone") String phone, | 
| 107 | 107 | @RequestParam("code") String code) { | 
| 108 | - | |
| 109 | 108 | Map<String, Object> resultMsgMap = new HashMap<>(); | 
| 110 | 109 | |
| 111 | - //通过手机拿到redis中的验证码,然后和用户输入的验证码做校验 | |
| 112 | - //从redis里面获取验证码 | |
| 113 | - Object verCodeObj = (Object) RedisUtils.getObj("c_" + phone); | |
| 114 | - if (verCodeObj == null) { | |
| 115 | - //参数错误 | |
| 116 | - resultMsgMap.put(ResultUtils.ERROR_CODE, ConstantInterface.VER_CODE_EXPIRE); | |
| 117 | - resultMsgMap.put(ResultUtils.ERROR_MSG, "验证码已过期,请重新获取."); | |
| 118 | - writeJson(response, JsonUtil.obj2JsonString(resultMsgMap));//把这个map转成一个json字符串输出到前台 | |
| 119 | - return; | |
| 120 | - } | |
| 121 | - | |
| 122 | - if (code.equals(verCodeObj)) { | |
| 110 | + //测试需要 | |
| 111 | + if (code.equals("123456")){ | |
| 123 | 112 | resultMsgMap.put("idRight", true); | 
| 124 | 113 | resultMsgMap.put(ResultUtils.ERROR_CODE, 0); | 
| 125 | 114 | resultMsgMap.put(ResultUtils.ERROR_MSG, "成功"); | 
| 126 | - writeJson(response, JsonUtil.obj2JsonString(resultMsgMap)); | |
| 127 | - } else { | |
| 128 | - resultMsgMap.put("idRight", false); | |
| 129 | - resultMsgMap.put(ResultUtils.ERROR_CODE, ConstantInterface.USER_PASSWORD_ERROR); | |
| 130 | - resultMsgMap.put(ResultUtils.ERROR_MSG, "验证码错误,请重新输入"); | |
| 131 | - writeJson(response, JsonUtil.obj2JsonString(resultMsgMap)); | |
| 115 | + }else { | |
| 116 | + //通过手机拿到redis中的验证码,然后和用户输入的验证码做校验 | |
| 117 | + //从redis里面获取验证码 | |
| 118 | + Object verCodeObj = (Object) RedisUtils.getObj("c_" + phone); | |
| 119 | + if (verCodeObj == null) { | |
| 120 | + //参数错误 | |
| 121 | + resultMsgMap.put(ResultUtils.ERROR_CODE, ConstantInterface.VER_CODE_EXPIRE); | |
| 122 | + resultMsgMap.put(ResultUtils.ERROR_MSG, "验证码已过期,请重新获取."); | |
| 123 | + writeJson(response, JsonUtil.obj2JsonString(resultMsgMap));//把这个map转成一个json字符串输出到前台 | |
| 124 | + return; | |
| 125 | + } | |
| 126 | + if (code.equals(verCodeObj)) { | |
| 127 | + resultMsgMap.put("idRight", true); | |
| 128 | + resultMsgMap.put(ResultUtils.ERROR_CODE, 0); | |
| 129 | + resultMsgMap.put(ResultUtils.ERROR_MSG, "成功"); | |
| 130 | + }else { | |
| 131 | + resultMsgMap.put("idRight", false); | |
| 132 | + resultMsgMap.put(ResultUtils.ERROR_CODE, ConstantInterface.USER_PASSWORD_ERROR); | |
| 133 | + resultMsgMap.put(ResultUtils.ERROR_MSG, "验证码错误,请重新输入"); | |
| 134 | + } | |
| 132 | 135 | } | 
| 136 | + writeJson(response, JsonUtil.obj2JsonString(resultMsgMap)); | |
| 133 | 137 | } | 
| 134 | 138 | |
| 135 | 139 | /** | 
| ... | ... | @@ -229,8 +233,8 @@ | 
| 229 | 233 | query.setKidId(id); | 
| 230 | 234 | query.setYn(YnEnum.yes.getId()); | 
| 231 | 235 | int count = ymUserKidMapsService.queryYmUserKidMapsCount(query); | 
| 232 | - if (count != 0) { | |
| 233 | - //已经关联了的版本就不需要在关联,直接返回成功 | |
| 236 | + if (count > 0) { | |
| 237 | + //已经关联了的宝宝就不需要再关联,直接返回成功 | |
| 234 | 238 | ResultUtils.buildSuccessResultAndWrite(response); | 
| 235 | 239 | } | 
| 236 | 240 | YmUserKidMaps userKidMaps = new YmUserKidMaps(); | 
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/UserController.java
View file @
5879c03
| ... | ... | @@ -8,8 +8,9 @@ | 
| 8 | 8 | import com.lymsh.mommybaby.basecommon.util.QiniuUtil; | 
| 9 | 9 | import com.lymsh.mommybaby.basecommon.util.ResultUtils; | 
| 10 | 10 | import com.lymsh.yimiao.main.data.enumdata.YnEnum; | 
| 11 | -import com.lymsh.yimiao.main.data.model.YmUsers; | |
| 12 | -import com.lymsh.yimiao.main.data.model.YmUsersQuery; | |
| 11 | +import com.lymsh.yimiao.main.data.model.*; | |
| 12 | +import com.lymsh.yimiao.main.data.service.MedKidsService; | |
| 13 | +import com.lymsh.yimiao.main.data.service.YmUserKidMapsService; | |
| 13 | 14 | import com.lymsh.yimiao.main.data.service.YmUsersService; | 
| 14 | 15 | import com.lymsh.yimiao.main.data.util.ImageUtil; | 
| 15 | 16 | import com.lymsh.yimiao.main.data.util.LoginContext; | 
| ... | ... | @@ -47,6 +48,10 @@ | 
| 47 | 48 | private YmUsersService usersService; | 
| 48 | 49 | @Autowired | 
| 49 | 50 | private TokenService tokenService; | 
| 51 | + @Autowired | |
| 52 | + private YmUserKidMapsService ymUserKidMapsService; | |
| 53 | + @Autowired | |
| 54 | + private MedKidsService medKidsService; | |
| 50 | 55 | |
| 51 | 56 | /** | 
| 52 | 57 | * 发送验证码 | 
| ... | ... | @@ -236,6 +241,31 @@ | 
| 236 | 241 | users.setModified(new Date()); | 
| 237 | 242 | usersService.updateYmUsers(users); | 
| 238 | 243 | ResultUtils.buildSuccessResultAndWrite(response); | 
| 244 | + } | |
| 245 | + | |
| 246 | + //获取用户所有关联的宝宝 | |
| 247 | + @RequestMapping(value = "/userBaby", method = RequestMethod.GET) | |
| 248 | + @TokenRequired | |
| 249 | + public void getUserBaby(HttpServletResponse response,HttpServletRequest request) { | |
| 250 | + LoginContext loginContext = (LoginContext) request.getAttribute("loginContext"); | |
| 251 | + YmUsers users = usersService.getYmUsers(loginContext.getId()); | |
| 252 | + | |
| 253 | + List<Map> list = new ArrayList<>(); | |
| 254 | + | |
| 255 | + YmUserKidMapsQuery query = new YmUserKidMapsQuery(); | |
| 256 | + query.setUserId(users.getId()); | |
| 257 | + query.setYn(YnEnum.yes.getId()); | |
| 258 | + List<YmUserKidMaps> userKidMapsList = ymUserKidMapsService.queryYmUserKidMaps(query); | |
| 259 | + if (CollectionUtils.isNotEmpty(userKidMapsList)){ | |
| 260 | + for (YmUserKidMaps data : userKidMapsList){ | |
| 261 | + Map<String,Object> map = new HashMap<>(); | |
| 262 | + map.put("id",data.getKidId()); | |
| 263 | + MedKids medKids = medKidsService.getMedKids(data.getKidId()); | |
| 264 | + map.put("name",medKids.getName()); | |
| 265 | + list.add(map); | |
| 266 | + } | |
| 267 | + } | |
| 268 | + ResultUtils.buildSuccessResultAndWrite(response,list); | |
| 239 | 269 | } | 
| 240 | 270 | |
| 241 | 271 | } |