Commit f0d40d3e13f567a293da09a40329dc021b1d3b67
1 parent
58fba639a0
Exists in
master
提交亿苗儿接口
Showing 5 changed files with 202 additions and 46 deletions
- mainData/src/main/java/com/lymsh/yimiao/main/data/service/impl/MedGuardianServiceImpl.java
- mainData/src/main/java/com/lymsh/yimiao/main/data/service/impl/MedKidsServiceImpl.java
- webApi/src/main/java/com/lyms/yimiao/web/controller/v1/KidsController.java
- webApi/src/main/java/com/lyms/yimiao/web/controller/v1/OrganizationsController.java
- webApi/src/main/java/com/lyms/yimiao/web/controller/v1/UserController.java
mainData/src/main/java/com/lymsh/yimiao/main/data/service/impl/MedGuardianServiceImpl.java
View file @
f0d40d3
| ... | ... | @@ -23,7 +23,7 @@ |
| 23 | 23 | @Override |
| 24 | 24 | public void deleteMedGuardian (Integer id){medGuardianMapper.deleteMedGuardian(id);} |
| 25 | 25 | @Override |
| 26 | -public MedGuardian getMedGuardian (Integer id){return medGuardianMapper.getMedGuardian(id);} | |
| 26 | +public MedGuardian getMedGuardian (String id){return medGuardianMapper.getMedGuardian(id);} | |
| 27 | 27 | @Override |
| 28 | 28 | public int queryMedGuardianCount (MedGuardianQuery query){return medGuardianMapper.queryMedGuardianCount(query);} |
| 29 | 29 | @Override |
mainData/src/main/java/com/lymsh/yimiao/main/data/service/impl/MedKidsServiceImpl.java
View file @
f0d40d3
| ... | ... | @@ -23,7 +23,7 @@ |
| 23 | 23 | @Override |
| 24 | 24 | public void deleteMedKids (Integer id){medKidsMapper.deleteMedKids(id);} |
| 25 | 25 | @Override |
| 26 | -public MedKids getMedKids (Integer id){return medKidsMapper.getMedKids(id);} | |
| 26 | +public MedKids getMedKids (String id){return medKidsMapper.getMedKids(id);} | |
| 27 | 27 | @Override |
| 28 | 28 | public int queryMedKidsCount (MedKidsQuery query){return medKidsMapper.queryMedKidsCount(query);} |
| 29 | 29 | @Override |
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/KidsController.java
View file @
f0d40d3
| ... | ... | @@ -4,14 +4,14 @@ |
| 4 | 4 | import com.lymsh.mommybaby.basecommon.base.TokenRequired; |
| 5 | 5 | import com.lymsh.mommybaby.basecommon.cache.redis.RedisUtils; |
| 6 | 6 | import com.lymsh.mommybaby.basecommon.constant.ConstantInterface; |
| 7 | +import com.lymsh.mommybaby.basecommon.context.MommyBobyContext; | |
| 8 | +import com.lymsh.mommybaby.basecommon.util.ContextHolder; | |
| 7 | 9 | import com.lymsh.mommybaby.basecommon.util.ResultUtils; |
| 8 | -import com.lymsh.yimiao.main.data.model.MedKids; | |
| 9 | -import com.lymsh.yimiao.main.data.model.MedKidsQuery; | |
| 10 | -import com.lymsh.yimiao.main.data.service.MedKidsService; | |
| 10 | +import com.lymsh.yimiao.main.data.enumdata.YnEnum; | |
| 11 | +import com.lymsh.yimiao.main.data.model.*; | |
| 12 | +import com.lymsh.yimiao.main.data.service.*; | |
| 11 | 13 | import com.lymsh.yimiao.main.data.util.JsonUtil; |
| 12 | -import com.lymsh.yimiao.main.data.util.LoginUtil; | |
| 13 | 14 | import org.apache.commons.collections.CollectionUtils; |
| 14 | -import org.apache.commons.lang.StringUtils; | |
| 15 | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 16 | 16 | import org.springframework.beans.factory.annotation.Value; |
| 17 | 17 | import org.springframework.http.MediaType; |
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | |
| ... | ... | @@ -39,35 +39,46 @@ |
| 39 | 39 | |
| 40 | 40 | @Autowired |
| 41 | 41 | private MedKidsService medKidsService; |
| 42 | + @Autowired | |
| 43 | + private YmUsersService usersService; | |
| 44 | + @Autowired | |
| 45 | + private YmUserKidMapsService ymUserKidMapsService; | |
| 46 | + @Autowired | |
| 47 | + private MedInoculateorderService medInoculateorderService; | |
| 48 | + @Autowired | |
| 49 | + private MedVaccineinfoService medVaccineinfoService; | |
| 50 | + @Autowired | |
| 51 | + private MedOrganizationService medOrganizationService; | |
| 42 | 52 | |
| 43 | - /** | |
| 44 | - * 发送验证码 | |
| 45 | - * @param response | |
| 46 | - * @param phone 手机号 | |
| 47 | - */ | |
| 48 | - @RequestMapping(value = "/sendCode", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8") | |
| 49 | - @TokenRequired | |
| 50 | - public void sendVercode(HttpServletResponse response,@RequestParam("phone") String phone) { | |
| 51 | 53 | |
| 52 | - if (StringUtils.isNotBlank(phone)){ | |
| 53 | - //对手机号是否存在做校验 | |
| 54 | - MedKidsQuery query = new MedKidsQuery(); | |
| 55 | - query.setPhone(phone); | |
| 56 | - List<MedKids> medKidsList = medKidsService.queryMedKids(query); | |
| 57 | - if (medKidsList.size()==0){ | |
| 58 | - ResultUtils.buildParameterErrorResultAndWrite(response,"您预留的手机号不存在,请重新输入"); | |
| 59 | - return; | |
| 60 | - } | |
| 54 | +// /** | |
| 55 | +// * 发送验证码 | |
| 56 | +// * @param response | |
| 57 | +// * @param phone 手机号 | |
| 58 | +// */ | |
| 59 | +// @RequestMapping(value = "/sendCode", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8") | |
| 60 | +// @TokenRequired | |
| 61 | +// public void sendVercode(HttpServletResponse response,@RequestParam("phone") String phone) { | |
| 62 | +// | |
| 63 | +// if (StringUtils.isNotBlank(phone)){ | |
| 64 | +// //对手机号是否存在做校验 | |
| 65 | +// MedKidsQuery query = new MedKidsQuery(); | |
| 66 | +// query.setPhone(phone); | |
| 67 | +// List<MedKids> medKidsList = medKidsService.queryMedKids(query); | |
| 68 | +// if (medKidsList.size()==0){ | |
| 69 | +// ResultUtils.buildParameterErrorResultAndWrite(response,"您预留的手机号不存在,请重新输入"); | |
| 70 | +// return; | |
| 71 | +// } | |
| 72 | +// | |
| 73 | +// Boolean result = LoginUtil.sendVerCode(phone, typeId, token); | |
| 74 | +// if (result){ | |
| 75 | +// ResultUtils.buildSuccessResultAndWrite(response); | |
| 76 | +// }else { | |
| 77 | +// ResultUtils.buildParameterErrorResultAndWrite(response,"发送失败"); | |
| 78 | +// } | |
| 79 | +// } | |
| 80 | +// } | |
| 61 | 81 | |
| 62 | - Boolean result = LoginUtil.sendVerCode(phone, typeId, token); | |
| 63 | - if (result){ | |
| 64 | - ResultUtils.buildSuccessResultAndWrite(response); | |
| 65 | - }else { | |
| 66 | - ResultUtils.buildParameterErrorResultAndWrite(response,"发送失败"); | |
| 67 | - } | |
| 68 | - } | |
| 69 | - } | |
| 70 | - | |
| 71 | 82 | /** |
| 72 | 83 | * 校验验证码 |
| 73 | 84 | * @param response |
| 74 | 85 | |
| ... | ... | @@ -112,9 +123,9 @@ |
| 112 | 123 | * @param barCode |
| 113 | 124 | * @param phone |
| 114 | 125 | */ |
| 115 | - @RequestMapping(value = "/queryKids", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8") | |
| 126 | + @RequestMapping(value = "/queryKidsId", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8") | |
| 116 | 127 | @TokenRequired |
| 117 | - public void getKids(HttpServletResponse response, | |
| 128 | + public void getKidsId(HttpServletResponse response, | |
| 118 | 129 | @RequestParam("birthday") String birthday, |
| 119 | 130 | @RequestParam(value = "barCode",required = false) String barCode, |
| 120 | 131 | @RequestParam(value = "phone",required = false) String phone) { |
| 121 | 132 | |
| ... | ... | @@ -123,11 +134,14 @@ |
| 123 | 134 | medKidsQuery.setBirthday(birthday); |
| 124 | 135 | medKidsQuery.setBarCode(barCode); |
| 125 | 136 | medKidsQuery.setPhone(phone); |
| 137 | + //medKidsQuery.setSort("");//时间排序 | |
| 138 | + medKidsQuery.setIsDelete("1"); | |
| 126 | 139 | List<MedKids> medKidsList = medKidsService.queryMedKids(medKidsQuery); |
| 127 | 140 | |
| 128 | 141 | List<Map> list = new ArrayList<>(); |
| 129 | 142 | |
| 130 | 143 | if (CollectionUtils.isNotEmpty(medKidsList)){ |
| 144 | + //TODO 查出来的数据,可能会多条一样的和不一样的,有多条一样的情况下,取最新的一条,不一样的正常返回 | |
| 131 | 145 | for (MedKids data :medKidsList){ |
| 132 | 146 | Map<String,Object> map = new HashMap<>(); |
| 133 | 147 | map.put("id",data.getId()); |
| 134 | 148 | |
| 135 | 149 | |
| 136 | 150 | |
| ... | ... | @@ -138,12 +152,102 @@ |
| 138 | 152 | ResultUtils.buildSuccessResultAndWrite(response,list); |
| 139 | 153 | } |
| 140 | 154 | |
| 141 | - //获取宝宝信息 | |
| 142 | - @RequestMapping(value = "/queryKids", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8") | |
| 155 | + //添加宝宝接口(当前登陆用户与小孩子进行关联) | |
| 156 | + @RequestMapping(value = "/relateKids", method = RequestMethod.POST) | |
| 143 | 157 | @TokenRequired |
| 144 | - public void getKids(HttpServletResponse response){ | |
| 158 | + public void UserRelateKids(HttpServletResponse response, | |
| 159 | + @RequestParam("id")String id){ | |
| 145 | 160 | |
| 161 | + //取到当前登陆用户的id | |
| 162 | + MommyBobyContext mommyBobyContext= ContextHolder.getContext(); | |
| 163 | + YmUsers users = usersService.getYmUsers(mommyBobyContext.getUserId()); | |
| 164 | + //把查询到的宝宝id与登陆用户关联 | |
| 165 | + YmUserKidMapsQuery query = new YmUserKidMapsQuery(); | |
| 166 | + query.setUserId(users.getId()); | |
| 167 | + query.setKidId(id); | |
| 168 | + query.setYn(YnEnum.yes.getId()); | |
| 169 | + int count = ymUserKidMapsService.queryYmUserKidMapsCount(query); | |
| 170 | + if (count!=0){ | |
| 171 | + ResultUtils.buildParameterErrorResultAndWrite(response,"这个宝宝已经和用户关联"); | |
| 172 | + return; | |
| 173 | + } | |
| 174 | + YmUserKidMaps userKidMaps = new YmUserKidMaps(); | |
| 175 | + userKidMaps.setUserId(users.getId()); | |
| 176 | + userKidMaps.setKidId(id); | |
| 177 | + userKidMaps.setCreated(new Date()); | |
| 178 | + userKidMaps.setYn(YnEnum.yes.getId()); | |
| 179 | + ymUserKidMapsService.addYmUserKidMaps(userKidMaps); | |
| 180 | + ResultUtils.buildSuccessResultAndWrite(response); | |
| 146 | 181 | } |
| 182 | + | |
| 183 | + /** | |
| 184 | + * 获取宝宝信息 | |
| 185 | + * | |
| 186 | + * @param response | |
| 187 | + * @param id 宝宝id | |
| 188 | + */ | |
| 189 | + @RequestMapping(value = "/kids", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8") | |
| 190 | + @TokenRequired | |
| 191 | + public void getKids(HttpServletResponse response, | |
| 192 | + @RequestParam("id")String id) { | |
| 193 | + if (id == null) { | |
| 194 | + ResultUtils.buildIdIsNull(response); | |
| 195 | + return; | |
| 196 | + } | |
| 197 | + MedKids kids = medKidsService.getMedKids(id); | |
| 198 | + if (kids == null) { | |
| 199 | + ResultUtils.buildParameterErrorResultAndWrite(response, "宝宝信息不存在"); | |
| 200 | + return; | |
| 201 | + } | |
| 202 | + Map<String, Object> map = new HashMap<>(); | |
| 203 | + map.put("id", kids.getId()); | |
| 204 | + map.put("name", kids.getName()); | |
| 205 | + //TODO 这里需要把这个字符串转换成时间戳 | |
| 206 | + map.put("birthday", kids.getBirthday()); | |
| 207 | + | |
| 208 | + MedInoculateorderQuery inoculateorderQuery = new MedInoculateorderQuery(); | |
| 209 | + inoculateorderQuery.setIoKidId(id); | |
| 210 | + //时间倒序 | |
| 211 | + inoculateorderQuery.setIoInoculateTime("ioInoculateTime desc"); | |
| 212 | + List<MedInoculateorder> inoculateorderList = medInoculateorderService.queryMedInoculateorder(inoculateorderQuery); | |
| 213 | + if (CollectionUtils.isNotEmpty(inoculateorderList)) { | |
| 214 | + //取出离现在日期最近的一个预约接种 | |
| 215 | + MedInoculateorder medInoculateorder = inoculateorderList.get(0); | |
| 216 | + //下次接种时间 | |
| 217 | + map.put("ioInoculateTime", medInoculateorder.getIoInoculateTime()); | |
| 218 | + //下次接种疫苗 | |
| 219 | + map.put("vaccineId", medInoculateorder.getIoVaccineId()); | |
| 220 | + MedVaccineinfo medVaccineinfo = medVaccineinfoService.getMedVaccineinfo(medInoculateorder.getIoVaccineId()); | |
| 221 | + map.put("vaccineName", medVaccineinfo == null ? "" : medVaccineinfo.getViName()); | |
| 222 | + //接种地点 | |
| 223 | + map.put("organizationId", medInoculateorder.getIoOrganizationId()); | |
| 224 | + MedOrganization medOrganization = medOrganizationService.getMedOrganization(medInoculateorder.getIoOrganizationId()); | |
| 225 | + map.put("organizationName", medOrganization == null ? "" : medOrganization.getoName()); | |
| 226 | + }else { | |
| 227 | + map.put("ioInoculateTime", null); | |
| 228 | + map.put("vaccineId", null); | |
| 229 | + map.put("vaccineName", null); | |
| 230 | + map.put("organizationId", null); | |
| 231 | + map.put("organizationName", null); | |
| 232 | + } | |
| 233 | + writeJson(response, JsonUtil.obj2JsonString(map)); | |
| 234 | + } | |
| 235 | + | |
| 236 | + /** | |
| 237 | + * 根据月龄获取宝宝该月龄预约接种的疫苗(分为免费疫苗和收费疫苗两个模块) | |
| 238 | + * | |
| 239 | + * @param response | |
| 240 | + * @param mouthAge 月龄 | |
| 241 | + */ | |
| 242 | + @RequestMapping(value = "/kidsVaccines", method = RequestMethod.GET) | |
| 243 | + @TokenRequired | |
| 244 | + public void getKidVaccines(HttpServletResponse response, | |
| 245 | + @RequestParam("mouthAge")String mouthAge) { | |
| 246 | + | |
| 247 | + } | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 147 | 251 | |
| 148 | 252 | |
| 149 | 253 | } |
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/OrganizationsController.java
View file @
f0d40d3
| 1 | 1 | package com.lyms.yimiao.web.controller.v1; |
| 2 | 2 | |
| 3 | +import com.lymsh.mommybaby.basecommon.base.BaseController; | |
| 4 | +import com.lymsh.mommybaby.basecommon.util.ResultUtils; | |
| 5 | +import com.lymsh.yimiao.main.data.model.MedOrganization; | |
| 6 | +import com.lymsh.yimiao.main.data.service.MedAearService; | |
| 7 | +import com.lymsh.yimiao.main.data.service.MedOrganizationService; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.stereotype.Controller; | |
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 11 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 12 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 13 | + | |
| 14 | +import javax.servlet.http.HttpServletResponse; | |
| 15 | +import java.util.HashMap; | |
| 16 | +import java.util.Map; | |
| 17 | + | |
| 3 | 18 | /** |
| 4 | 19 | * 机构 |
| 5 | 20 | * |
| 6 | 21 | * Created by Administrator on 2016/4/29 0029. |
| 7 | 22 | */ |
| 8 | -public class OrganizationsController { | |
| 23 | +@Controller | |
| 24 | +@RequestMapping("/v1") | |
| 25 | +public class OrganizationsController extends BaseController{ | |
| 26 | + | |
| 27 | + @Autowired | |
| 28 | + private MedOrganizationService medOrganizationService; | |
| 29 | + @Autowired | |
| 30 | + private MedAearService medAearService; | |
| 31 | + | |
| 32 | + | |
| 33 | + @RequestMapping(value = "/organizations", method = RequestMethod.GET) | |
| 34 | + public void getOrganizations(HttpServletResponse response, | |
| 35 | + @RequestParam("id") String id){ | |
| 36 | + | |
| 37 | + MedOrganization medOrganization = medOrganizationService.getMedOrganization(id); | |
| 38 | + if (medOrganization==null){ | |
| 39 | + ResultUtils.buildParameterErrorResultAndWrite(response,"单位ID为空"); | |
| 40 | + return; | |
| 41 | + } | |
| 42 | + Map<String,Object> map = new HashMap<>(); | |
| 43 | + map.put("name",medOrganization.getoName()); | |
| 44 | + map.put("contactWay",medOrganization.getoContactWay()); | |
| 45 | + //省 | |
| 46 | + map.put("ProvinceName",medAearService.getMedAear(medOrganization.getoProvinceNo()) == null ? null : medAearService.getMedAear(medOrganization.getoProvinceNo()).getAName()); | |
| 47 | + //市 | |
| 48 | + //区 | |
| 49 | + //县 | |
| 50 | + //街道 | |
| 51 | + //村 | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + } | |
| 56 | + | |
| 9 | 57 | } |
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/UserController.java
View file @
f0d40d3
| ... | ... | @@ -69,12 +69,13 @@ |
| 69 | 69 | @RequestParam("code") String code) { |
| 70 | 70 | |
| 71 | 71 | LoginContext result = LoginUtil.login(phone, code, typeId, token); |
| 72 | - Map<String, Object> map = new HashMap<>(); | |
| 73 | - map.put("errorcode", result.getErrorcode()); | |
| 74 | - map.put("errormsg", result.getErrormsg()); | |
| 75 | 72 | |
| 76 | 73 | //登陆的同时,在数据库创建账号,对手机号唯一性判断 |
| 77 | 74 | if (result.getToken()!=null){ |
| 75 | + Map<String, Object> map = new HashMap<>(); | |
| 76 | + map.put("errorcode", result.getErrorcode()); | |
| 77 | + map.put("errormsg", result.getErrormsg()); | |
| 78 | + | |
| 78 | 79 | YmUsersQuery query = new YmUsersQuery(); |
| 79 | 80 | query.setPhone(phone); |
| 80 | 81 | query.setYn(YnEnum.yes.getId()); |
| 81 | 82 | |
| 82 | 83 | |
| ... | ... | @@ -93,9 +94,13 @@ |
| 93 | 94 | YmUsers users = usersList.get(0); |
| 94 | 95 | users.setLastLoginTime(new Date()); |
| 95 | 96 | userService.updateYmUsers(users); |
| 97 | + map.put("token", result.getToken()); | |
| 98 | + map.put("id", users.getId()); | |
| 96 | 99 | } |
| 100 | + writeJson(response, JsonUtil.obj2JsonString(map)); | |
| 101 | + }else { | |
| 102 | + ResultUtils.buildParameterErrorResultAndWrite(response,"登陆失败,异常"); | |
| 97 | 103 | } |
| 98 | - writeJson(response, JsonUtil.obj2JsonString(map)); | |
| 99 | 104 | } |
| 100 | 105 | |
| 101 | 106 | /** |
| ... | ... | @@ -123,7 +128,6 @@ |
| 123 | 128 | user.setCreated(new Date()); |
| 124 | 129 | user.setModified(new Date()); |
| 125 | 130 | user.setPhone(phone); |
| 126 | - //user.setLoginCenterId(a) | |
| 127 | 131 | userService.addYmUsers(user); |
| 128 | 132 | } |
| 129 | 133 | } |