Commit ba1966a2737287e456e8e6bd57bf15b7b95d8294
1 parent
f4cea12db6
Exists in
master
New changelist
Showing 12 changed files with 330 additions and 40 deletions
- .idea/artifacts/web_api_war_exploded.xml
- .idea/libraries/Maven__cn_jpush_api_jpush_client_3_2_9.xml
- .idea/libraries/Maven__com_google_code_gson_gson_2_3.xml
- mainData/pom.xml
- mainData/src/main/java/com/lymsh/yimiao/main/data/service/PushTaskService.java
- mainData/src/main/java/com/lymsh/yimiao/main/data/service/impl/PushTaskServiceImpl.java
- pom.xml
- webApi/src/main/java/com/lyms/yimiao/web/controller/v1/NotificationsController.java
- webApi/src/main/java/com/lyms/yimiao/web/controller/v1/UserController.java
- webApi/src/main/resources/config.properties
- webApi/src/main/resources/spring/applicationContext.xml
- webApi/web-api.iml
.idea/artifacts/web_api_war_exploded.xml
View file @
ba1966a
| ... | ... | @@ -33,6 +33,8 @@ |
| 33 | 33 | <element id="archive" name="main-data-e-1.0-SNAPSHOT.jar"> |
| 34 | 34 | <element id="module-output" name="main-data-e" /> |
| 35 | 35 | </element> |
| 36 | + <element id="library" level="project" name="Maven: cn.jpush.api:jpush-client:3.2.9" /> | |
| 37 | + <element id="library" level="project" name="Maven: com.google.code.gson:gson:2.3" /> | |
| 36 | 38 | <element id="library" level="project" name="Maven: org.springframework:spring-core:3.2.2.RELEASE" /> |
| 37 | 39 | <element id="library" level="project" name="Maven: commons-logging:commons-logging:1.1.1" /> |
| 38 | 40 | <element id="library" level="project" name="Maven: org.springframework:spring-expression:3.2.2.RELEASE" /> |
| ... | ... | @@ -107,7 +109,6 @@ |
| 107 | 109 | <element id="library" level="project" name="Maven: org.jboss.logging:jboss-logging:3.1.3.GA" /> |
| 108 | 110 | <element id="library" level="project" name="Maven: com.fasterxml:classmate:1.0.0" /> |
| 109 | 111 | <element id="library" level="project" name="Maven: com.qiniu:qiniu-java-sdk:7.0.9" /> |
| 110 | - <element id="library" level="project" name="Maven: com.google.code.gson:gson:2.3.1" /> | |
| 111 | 112 | <element id="library" level="project" name="Maven: com.squareup.okhttp:okhttp:2.7.1" /> |
| 112 | 113 | <element id="library" level="project" name="Maven: com.squareup.okio:okio:1.6.0" /> |
| 113 | 114 | <element id="library" level="project" name="Maven: redis.clients:jedis:2.1.0" /> |
.idea/libraries/Maven__cn_jpush_api_jpush_client_3_2_9.xml
View file @
ba1966a
| 1 | +<component name="libraryTable"> | |
| 2 | + <library name="Maven: cn.jpush.api:jpush-client:3.2.9"> | |
| 3 | + <CLASSES> | |
| 4 | + <root url="jar://$MAVEN_REPOSITORY$/cn/jpush/api/jpush-client/3.2.9/jpush-client-3.2.9.jar!/" /> | |
| 5 | + </CLASSES> | |
| 6 | + <JAVADOC> | |
| 7 | + <root url="jar://$MAVEN_REPOSITORY$/cn/jpush/api/jpush-client/3.2.9/jpush-client-3.2.9-javadoc.jar!/" /> | |
| 8 | + </JAVADOC> | |
| 9 | + <SOURCES> | |
| 10 | + <root url="jar://$MAVEN_REPOSITORY$/cn/jpush/api/jpush-client/3.2.9/jpush-client-3.2.9-sources.jar!/" /> | |
| 11 | + </SOURCES> | |
| 12 | + </library> | |
| 13 | +</component> |
.idea/libraries/Maven__com_google_code_gson_gson_2_3.xml
View file @
ba1966a
| 1 | +<component name="libraryTable"> | |
| 2 | + <library name="Maven: com.google.code.gson:gson:2.3"> | |
| 3 | + <CLASSES> | |
| 4 | + <root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.3/gson-2.3.jar!/" /> | |
| 5 | + </CLASSES> | |
| 6 | + <JAVADOC> | |
| 7 | + <root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.3/gson-2.3-javadoc.jar!/" /> | |
| 8 | + </JAVADOC> | |
| 9 | + <SOURCES> | |
| 10 | + <root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.3/gson-2.3-sources.jar!/" /> | |
| 11 | + </SOURCES> | |
| 12 | + </library> | |
| 13 | +</component> |
mainData/pom.xml
View file @
ba1966a
mainData/src/main/java/com/lymsh/yimiao/main/data/service/PushTaskService.java
View file @
ba1966a
mainData/src/main/java/com/lymsh/yimiao/main/data/service/impl/PushTaskServiceImpl.java
View file @
ba1966a
| 1 | +package com.lymsh.yimiao.main.data.service.impl; | |
| 2 | + | |
| 3 | +import cn.jpush.api.JPushClient; | |
| 4 | +import cn.jpush.api.push.PushResult; | |
| 5 | +import cn.jpush.api.push.model.Platform; | |
| 6 | +import cn.jpush.api.push.model.PushPayload; | |
| 7 | +import cn.jpush.api.push.model.audience.Audience; | |
| 8 | +import cn.jpush.api.push.model.notification.Notification; | |
| 9 | +import com.lymsh.mommybaby.basecommon.util.DateUtil; | |
| 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.*; | |
| 13 | +import com.lymsh.yimiao.main.data.util.JPushUtil; | |
| 14 | +import org.apache.commons.collections.CollectionUtils; | |
| 15 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | +import org.springframework.context.ApplicationContext; | |
| 17 | +import org.springframework.context.support.ClassPathXmlApplicationContext; | |
| 18 | +import org.springframework.stereotype.Service; | |
| 19 | + | |
| 20 | +import javax.annotation.Resource; | |
| 21 | +import java.util.Date; | |
| 22 | +import java.util.List; | |
| 23 | + | |
| 24 | +/** | |
| 25 | + * | |
| 26 | + * 定时推送接种消息 | |
| 27 | + * | |
| 28 | + * Created by Administrator on 2016/5/24 0024. | |
| 29 | + */ | |
| 30 | +@Service | |
| 31 | +public class PushTaskServiceImpl implements PushTaskService{ | |
| 32 | + | |
| 33 | + @Autowired | |
| 34 | + private JPushClient jPushClient; | |
| 35 | + @Autowired | |
| 36 | + private MedInoculateOrderService medInoculateOrderService; | |
| 37 | + @Autowired | |
| 38 | + private YmUserKidMapsService ymUserKidMapsService; | |
| 39 | + @Autowired | |
| 40 | + private YmUsersService ymUsersService; | |
| 41 | + @Autowired | |
| 42 | + private YmPushMessagesService ymPushMessagesService; | |
| 43 | + @Autowired | |
| 44 | + private MedKidsService medKidsService; | |
| 45 | + @Autowired | |
| 46 | + private MedVaccineNameService medVaccineNameService; | |
| 47 | + | |
| 48 | + private final static String isDelete = "1"; | |
| 49 | + | |
| 50 | + public static final int THREE_DAY_SECONDS = 86400 * 1000 * 3; | |
| 51 | + | |
| 52 | + public static final int ONE_DAY_SECONDS = 86400 * 1000; | |
| 53 | + | |
| 54 | + private static final String ALERT = "您有一条新的推送"; | |
| 55 | + | |
| 56 | + private static final String ALIAS = "yimiaoer"; | |
| 57 | + | |
| 58 | + @Override | |
| 59 | + public void pushTask() { | |
| 60 | + //距离三天 | |
| 61 | + MedInoculateOrderQuery orderQuery = new MedInoculateOrderQuery(); | |
| 62 | + orderQuery.setIoIsDelete(isDelete); | |
| 63 | + orderQuery.setIoInoculateDate(DateUtil.getyyyy_MM_dd(new Date(DateUtil.getStartTime() + THREE_DAY_SECONDS)).toString()); | |
| 64 | + List<MedInoculateOrder> orderList = medInoculateOrderService.queryMedInoculateOrder(orderQuery); | |
| 65 | + if (CollectionUtils.isNotEmpty(orderList)){ | |
| 66 | + //距离当前还有三天就要接种的小孩 | |
| 67 | + for (MedInoculateOrder data : orderList){ | |
| 68 | + | |
| 69 | + //接种的疫苗名称 | |
| 70 | + MedVaccineName medVaccineName = medVaccineNameService.getMedVaccineName(data.getIoVaccineId()); | |
| 71 | + | |
| 72 | + YmUserKidMapsQuery mapsQuery = new YmUserKidMapsQuery(); | |
| 73 | + mapsQuery.setYn(YnEnum.yes.getId()); | |
| 74 | + mapsQuery.setKidId(data.getIoKidId()); | |
| 75 | + List<YmUserKidMaps> mapsList = ymUserKidMapsService.queryYmUserKidMaps(mapsQuery); | |
| 76 | + //得到和小孩关联的账号 | |
| 77 | + if (CollectionUtils.isNotEmpty(mapsList)){ | |
| 78 | + for (YmUserKidMaps temp : mapsList){ | |
| 79 | + | |
| 80 | + //得到小孩的名字 | |
| 81 | + MedKids medKids = medKidsService.getMedKids(temp.getKidId()); | |
| 82 | + | |
| 83 | + YmUsersQuery usersQuery = new YmUsersQuery(); | |
| 84 | + usersQuery.setYn(YnEnum.yes.getId()); | |
| 85 | + usersQuery.setId(temp.getUserId()); | |
| 86 | + //拿到最后所有需要发推送的用户 | |
| 87 | + List<YmUsers> usersList = ymUsersService.queryYmUsers(usersQuery); | |
| 88 | + if (CollectionUtils.isNotEmpty(usersList)) { | |
| 89 | + YmUsers users = usersList.get(0); | |
| 90 | + PushPayload pushPayload = JPushUtil.buildPushObject_all_alias_alert(ALIAS + users.getPhone(), ALERT); | |
| 91 | + if (pushPayload != null) { | |
| 92 | + YmPushMessages messages = new YmPushMessages(); | |
| 93 | + messages.setCreated(new Date()); | |
| 94 | + messages.setContent((medKids == null ? "" : medKids.getName() == null ? "" : medKids.getName()) + "小朋友按计划3天后将会接种" + | |
| 95 | + (medVaccineName == null ? "" : medVaccineName.getVnName()) + ",请提前做好准备,准时到接种点接种疫苗。"); | |
| 96 | + messages.setReceptionId(users.getId()); | |
| 97 | + messages.setYn(YnEnum.yes.getId()); | |
| 98 | + ymPushMessagesService.addYmPushMessages(messages); | |
| 99 | + | |
| 100 | + //成功后推送提示消息 | |
| 101 | + try { | |
| 102 | + jPushClient.sendPush(pushPayload); | |
| 103 | + } catch (Exception e) { | |
| 104 | + | |
| 105 | + } | |
| 106 | + } | |
| 107 | + } | |
| 108 | + } | |
| 109 | + } | |
| 110 | + } | |
| 111 | + } | |
| 112 | + //距离一天 | |
| 113 | + MedInoculateOrderQuery orderQuery1 = new MedInoculateOrderQuery(); | |
| 114 | + orderQuery1.setIoIsDelete(isDelete); | |
| 115 | + orderQuery1.setIoInoculateDate(DateUtil.getyyyy_MM_dd(new Date(DateUtil.getStartTime() + ONE_DAY_SECONDS)).toString()); | |
| 116 | + List<MedInoculateOrder> orderList1 = medInoculateOrderService.queryMedInoculateOrder(orderQuery1); | |
| 117 | + if (CollectionUtils.isNotEmpty(orderList1)){ | |
| 118 | + for (MedInoculateOrder data : orderList1){ | |
| 119 | + | |
| 120 | + //接种的疫苗名称 | |
| 121 | + MedVaccineName medVaccineName = medVaccineNameService.getMedVaccineName(data.getIoVaccineId()); | |
| 122 | + | |
| 123 | + YmUserKidMapsQuery mapsQuery = new YmUserKidMapsQuery(); | |
| 124 | + mapsQuery.setYn(YnEnum.yes.getId()); | |
| 125 | + mapsQuery.setKidId(data.getIoKidId()); | |
| 126 | + List<YmUserKidMaps> mapsList = ymUserKidMapsService.queryYmUserKidMaps(mapsQuery); | |
| 127 | + //得到和小孩关联的账号 | |
| 128 | + if (CollectionUtils.isNotEmpty(mapsList)){ | |
| 129 | + for (YmUserKidMaps temp : mapsList){ | |
| 130 | + | |
| 131 | + //得到小孩的名字 | |
| 132 | + MedKids medKids = medKidsService.getMedKids(temp.getKidId()); | |
| 133 | + | |
| 134 | + YmUsersQuery usersQuery = new YmUsersQuery(); | |
| 135 | + usersQuery.setYn(YnEnum.yes.getId()); | |
| 136 | + usersQuery.setId(temp.getUserId()); | |
| 137 | + //拿到最后所有需要发推送的用户 | |
| 138 | + List<YmUsers> usersList = ymUsersService.queryYmUsers(usersQuery); | |
| 139 | + if (CollectionUtils.isNotEmpty(usersList)) { | |
| 140 | + YmUsers users = usersList.get(0); | |
| 141 | + PushPayload pushPayload = JPushUtil.buildPushObject_all_alias_alert(ALIAS + users.getPhone(), ALERT); | |
| 142 | + if (pushPayload != null) { | |
| 143 | + YmPushMessages messages = new YmPushMessages(); | |
| 144 | + messages.setCreated(new Date()); | |
| 145 | + messages.setContent((medKids == null ? "" : medKids.getName() == null ? "" : medKids.getName()) + "小朋友按计划1天后将会接种" + | |
| 146 | + (medVaccineName == null ? "" : medVaccineName.getVnName()) + ",请提前做好准备,准时到接种点接种疫苗。"); | |
| 147 | + messages.setReceptionId(users.getId()); | |
| 148 | + messages.setYn(YnEnum.yes.getId()); | |
| 149 | + ymPushMessagesService.addYmPushMessages(messages); | |
| 150 | + | |
| 151 | + //成功后推送提示消息 | |
| 152 | + try { | |
| 153 | + jPushClient.sendPush(pushPayload); | |
| 154 | + } catch (Exception e) { | |
| 155 | + | |
| 156 | + } | |
| 157 | + } | |
| 158 | + } | |
| 159 | + } | |
| 160 | + } | |
| 161 | + } | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + } | |
| 166 | + | |
| 167 | + | |
| 168 | + } | |
| 169 | + | |
| 170 | +} |
pom.xml
View file @
ba1966a
| ... | ... | @@ -44,6 +44,11 @@ |
| 44 | 44 | </repositories> |
| 45 | 45 | <dependencies> |
| 46 | 46 | <dependency> |
| 47 | + <groupId>cn.jpush.api</groupId> | |
| 48 | + <artifactId>jpush-client</artifactId> | |
| 49 | + <version>3.2.9</version> | |
| 50 | + </dependency> | |
| 51 | + <dependency> | |
| 47 | 52 | <groupId>org.springframework</groupId> |
| 48 | 53 | <artifactId>spring-core</artifactId> |
| 49 | 54 | <version>${org.springframework.version}</version> |
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/NotificationsController.java
View file @
ba1966a
| ... | ... | @@ -8,7 +8,11 @@ |
| 8 | 8 | import com.lymsh.yimiao.main.data.enumdata.YnEnum; |
| 9 | 9 | import com.lymsh.yimiao.main.data.model.YmNotifications; |
| 10 | 10 | import com.lymsh.yimiao.main.data.model.YmNotificationsQuery; |
| 11 | +import com.lymsh.yimiao.main.data.model.YmPushMessages; | |
| 12 | +import com.lymsh.yimiao.main.data.model.YmPushMessagesQuery; | |
| 11 | 13 | import com.lymsh.yimiao.main.data.service.YmNotificationsService; |
| 14 | +import com.lymsh.yimiao.main.data.service.YmPushMessagesService; | |
| 15 | +import com.lymsh.yimiao.main.data.util.LoginContext; | |
| 12 | 16 | import org.apache.commons.collections.CollectionUtils; |
| 13 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 14 | 18 | import org.springframework.stereotype.Controller; |
| 15 | 19 | |
| ... | ... | @@ -17,11 +21,9 @@ |
| 17 | 21 | import org.springframework.web.bind.annotation.RequestParam; |
| 18 | 22 | |
| 19 | 23 | import javax.management.Notification; |
| 24 | +import javax.servlet.http.HttpServletRequest; | |
| 20 | 25 | import javax.servlet.http.HttpServletResponse; |
| 21 | -import java.util.ArrayList; | |
| 22 | -import java.util.HashMap; | |
| 23 | -import java.util.List; | |
| 24 | -import java.util.Map; | |
| 26 | +import java.util.*; | |
| 25 | 27 | |
| 26 | 28 | /** |
| 27 | 29 | * |
| 28 | 30 | |
| 29 | 31 | |
| 30 | 32 | |
| ... | ... | @@ -35,17 +37,22 @@ |
| 35 | 37 | |
| 36 | 38 | @Autowired |
| 37 | 39 | private YmNotificationsService notificationsService; |
| 40 | + @Autowired | |
| 41 | + private YmPushMessagesService ymPushMessagesService; | |
| 38 | 42 | |
| 39 | 43 | //获取消息(1.系统消息2.接种消息) |
| 40 | 44 | @RequestMapping(value = "/notifications", method = RequestMethod.GET) |
| 41 | 45 | @TokenRequired |
| 42 | - public void getNotifications(HttpServletResponse response){ | |
| 43 | - | |
| 46 | + public void getNotifications(HttpServletResponse response, | |
| 47 | + HttpServletRequest request | |
| 48 | +// , @RequestParam(value = "time",required = false) long time | |
| 49 | + ){ | |
| 50 | + //系统消息 | |
| 44 | 51 | YmNotificationsQuery notificationsQuery = new YmNotificationsQuery(); |
| 45 | 52 | notificationsQuery.setYn(YnEnum.yes.getId()); |
| 46 | - | |
| 47 | 53 | notificationsQuery.setSort("created desc"); |
| 48 | 54 | |
| 55 | +// notificationsQuery.setCreated(new Date(time*1000)); | |
| 49 | 56 | List<YmNotifications> notificationsList = notificationsService.queryYmNotifications(notificationsQuery); |
| 50 | 57 | |
| 51 | 58 | List<Map> list = new ArrayList<>(); |
| 52 | 59 | |
| 53 | 60 | |
| ... | ... | @@ -55,18 +62,62 @@ |
| 55 | 62 | Map<String,Object> map = new HashMap<>(); |
| 56 | 63 | map.put("id",data.getId()); |
| 57 | 64 | map.put("created", DateUtil.getSecond(data.getCreated())); |
| 58 | - map.put("type",data.getType()); | |
| 65 | + map.put("type",1); | |
| 59 | 66 | map.put("content",data.getContent()); |
| 60 | 67 | list.add(map); |
| 61 | 68 | } |
| 62 | 69 | } |
| 70 | + | |
| 71 | + //接种通知 | |
| 72 | + List inculateList = getInculateList(request); | |
| 73 | +// List inculateList = getInculateList(request,time); | |
| 74 | + if (CollectionUtils.isNotEmpty(inculateList)){ | |
| 75 | + list.addAll(inculateList); | |
| 76 | + } | |
| 77 | + | |
| 78 | + //对所有结果集重新排序 | |
| 79 | + Collections.sort(list, new Comparator<Map>() { | |
| 80 | + private String key ="created"; | |
| 81 | + @Override | |
| 82 | + public int compare(Map o1, Map o2) { | |
| 83 | + if(o1.containsKey(key)&&o2.containsKey(key)){ | |
| 84 | + if((Integer)o1.get(key)==(Integer)o2.get(key)){ | |
| 85 | + return 0; | |
| 86 | + } | |
| 87 | + if((Integer)o1.get(key)>(Integer)o2.get(key)){ | |
| 88 | + return -1; | |
| 89 | + }else{ | |
| 90 | + return 1; | |
| 91 | + } | |
| 92 | + } | |
| 93 | + return 0; | |
| 94 | + } | |
| 95 | + }); | |
| 63 | 96 | ResultUtils.buildSuccessResultAndWrite(response,list); |
| 64 | 97 | } |
| 65 | 98 | |
| 66 | - //定时发送给当前登录用户接种通知 | |
| 67 | - /* | |
| 68 | - 查询当前登陆用户在当前时间距离下次接种时间3天和1天的时候,发送一条推送消息 | |
| 69 | - */ | |
| 99 | + private List getInculateList(HttpServletRequest request) { | |
| 100 | + List<Map> dataList = new ArrayList<>(); | |
| 101 | + | |
| 102 | + LoginContext loginContext = (LoginContext) request.getAttribute("loginContext"); | |
| 103 | + | |
| 104 | + YmPushMessagesQuery query = new YmPushMessagesQuery(); | |
| 105 | + query.setYn(YnEnum.yes.getId()); | |
| 106 | + query.setReceptionId(loginContext.getId()); | |
| 107 | +// query.setCreated(new Date(time * 1000)); | |
| 108 | + List<YmPushMessages> messagesList = ymPushMessagesService.queryYmPushMessages(query); | |
| 109 | + if (CollectionUtils.isNotEmpty(messagesList)){ | |
| 110 | + for (YmPushMessages data : messagesList){ | |
| 111 | + Map<String,Object> map = new HashMap<>(); | |
| 112 | + map.put("id",data.getId()); | |
| 113 | + map.put("content",data.getContent()); | |
| 114 | + map.put("created",DateUtil.getSecond(data.getCreated())); | |
| 115 | + map.put("type",2); | |
| 116 | + dataList.add(map); | |
| 117 | + } | |
| 118 | + } | |
| 119 | + return dataList; | |
| 120 | + } | |
| 70 | 121 | |
| 71 | 122 | |
| 72 | 123 | } |
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/UserController.java
View file @
ba1966a
| ... | ... | @@ -48,9 +48,9 @@ |
| 48 | 48 | private String typeId; |
| 49 | 49 | @Autowired |
| 50 | 50 | private YmUsersService usersService; |
| 51 | +// @Autowired | |
| 52 | +// private TokenService tokenService; | |
| 51 | 53 | @Autowired |
| 52 | - private TokenService tokenService; | |
| 53 | - @Autowired | |
| 54 | 54 | private YmUserKidMapsService ymUserKidMapsService; |
| 55 | 55 | @Autowired |
| 56 | 56 | private MedKidsService medKidsService; |
| ... | ... | @@ -86,8 +86,7 @@ |
| 86 | 86 | |
| 87 | 87 | LoginContext result = LoginUtil.login(phone, code, typeId, token); |
| 88 | 88 | Map<String, Object> map = new HashMap<>(); |
| 89 | - map.put("errorcode", result.getErrorcode()); | |
| 90 | - map.put("errormsg", result.getErrormsg()); | |
| 89 | + | |
| 91 | 90 | //登陆的同时,在数据库创建账号,对手机号唯一性判断 |
| 92 | 91 | if (result.getToken()!=null){ |
| 93 | 92 | YmUsersQuery query = new YmUsersQuery(); |
| 94 | 93 | |
| ... | ... | @@ -115,33 +114,38 @@ |
| 115 | 114 | map.put("token", result.getToken()); |
| 116 | 115 | map.put("id", users.getId()); |
| 117 | 116 | } |
| 117 | + map.put("errorcode", ConstantInterface.SUCCESS); | |
| 118 | + map.put("errormsg", "成功"); | |
| 119 | + }else { | |
| 120 | + map.put("errorcode",ConstantInterface.SYSTEM_ERROR); | |
| 121 | + map.put("errormsg", "登录失败"); | |
| 118 | 122 | } |
| 119 | 123 | writeJson(response, JsonUtil.obj2JsonString(map)); |
| 120 | 124 | } |
| 121 | 125 | |
| 122 | 126 | //暫時獲取token接口 |
| 123 | - @RequestMapping(value = "/userlogin", method = RequestMethod.POST) | |
| 124 | - public void userLogin(HttpServletResponse response, | |
| 125 | - @RequestParam("phone") String phone){ | |
| 126 | - YmUsersQuery query = new YmUsersQuery(); | |
| 127 | - query.setPhone(phone); | |
| 128 | - query.setYn(YnEnum.yes.getId()); | |
| 129 | - List<YmUsers> usersList = usersService.queryYmUsers(query); | |
| 130 | - Map<String, Object> map = new HashMap<>(); | |
| 131 | - if (CollectionUtils.isNotEmpty(usersList)){ | |
| 132 | - YmUsers users = usersList.get(0); | |
| 133 | - String token = tokenService.createToken(users.getId()); | |
| 134 | - map.put("token", token); | |
| 135 | - map.put("id", users.getId()); | |
| 136 | - users.setLastLoginTime(new Date()); | |
| 137 | - usersService.updateYmUsers(users); | |
| 138 | - map.put("errorcode", 0); | |
| 139 | - map.put("errormsg", "成功"); | |
| 140 | - writeJson(response,JsonUtil.obj2JsonString(map)); | |
| 141 | - }else { | |
| 142 | - ResultUtils.buildParameterErrorResultAndWrite(response,"该手机号不存在,请注册"); | |
| 143 | - } | |
| 144 | - } | |
| 127 | +// @RequestMapping(value = "/userlogin", method = RequestMethod.POST) | |
| 128 | +// public void userLogin(HttpServletResponse response, | |
| 129 | +// @RequestParam("phone") String phone){ | |
| 130 | +// YmUsersQuery query = new YmUsersQuery(); | |
| 131 | +// query.setPhone(phone); | |
| 132 | +// query.setYn(YnEnum.yes.getId()); | |
| 133 | +// List<YmUsers> usersList = usersService.queryYmUsers(query); | |
| 134 | +// Map<String, Object> map = new HashMap<>(); | |
| 135 | +// if (CollectionUtils.isNotEmpty(usersList)){ | |
| 136 | +// YmUsers users = usersList.get(0); | |
| 137 | +// String token = tokenService.createToken(users.getId()); | |
| 138 | +// map.put("token", token); | |
| 139 | +// map.put("id", users.getId()); | |
| 140 | +// users.setLastLoginTime(new Date()); | |
| 141 | +// usersService.updateYmUsers(users); | |
| 142 | +// map.put("errorcode", 0); | |
| 143 | +// map.put("errormsg", "成功"); | |
| 144 | +// writeJson(response,JsonUtil.obj2JsonString(map)); | |
| 145 | +// }else { | |
| 146 | +// ResultUtils.buildParameterErrorResultAndWrite(response,"该手机号不存在,请注册"); | |
| 147 | +// } | |
| 148 | +// } | |
| 145 | 149 | |
| 146 | 150 | /** |
| 147 | 151 | * 注册(暂时不需要注册接口) |
webApi/src/main/resources/config.properties
View file @
ba1966a
| ... | ... | @@ -42,4 +42,11 @@ |
| 42 | 42 | #---------ÒÚÃç¶ùappµÄtokenºÍtypeId-------- |
| 43 | 43 | yimiao.token=ce303762-b5b4-4156-84aa-e159d3241319 |
| 44 | 44 | yimiao.typeId=3 |
| 45 | + | |
| 46 | + | |
| 47 | +#jpush properties | |
| 48 | +jpush.AppKey=e3e9f9d33c13abc3f38db26e | |
| 49 | +jpush.MasterSecret=3c56e298d8e1bb90b94ccc30 | |
| 50 | +jpush.apnsProduction=0 | |
| 51 | +jpush.timeToLive=86400 |
webApi/src/main/resources/spring/applicationContext.xml
View file @
ba1966a
| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | <context:component-scan base-package="com.lymsh.yimiao.main.data.dao" /> |
| 15 | 15 | <context:component-scan base-package="com.lymsh.yimiao.main.data.service" /> |
| 16 | 16 | <context:component-scan base-package="com.lymsh.yimiao.main.data.util" /> |
| 17 | + <context:component-scan base-package="com.lymsh.yimiao.main.data.service.impl" /> | |
| 17 | 18 | |
| 18 | 19 | <bean id="configProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> |
| 19 | 20 | <property name="locations"> |
| ... | ... | @@ -88,5 +89,19 @@ |
| 88 | 89 | <property name="sqlSessionFactoryBeanName" value="mainSqlSessionFactory"></property> |
| 89 | 90 | <property name="basePackage" value="com.lymsh.yimiao.main.data.dao" /> |
| 90 | 91 | </bean> |
| 92 | + | |
| 93 | + | |
| 94 | + <!--JPush Client--> | |
| 95 | + <bean class="cn.jpush.api.JPushClient"> | |
| 96 | + <constructor-arg name="appKey" value="${jpush.AppKey}"/> | |
| 97 | + <constructor-arg name="masterSecret" value="${jpush.MasterSecret}"/> | |
| 98 | + <constructor-arg name="apnsProduction" value="${jpush.apnsProduction}"/> | |
| 99 | + <constructor-arg name="timeToLive" value="${jpush.timeToLive}"/> | |
| 100 | + </bean> | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 91 | 106 | </beans> |
webApi/web-api.iml
View file @
ba1966a
| ... | ... | @@ -46,6 +46,8 @@ |
| 46 | 46 | <orderEntry type="library" name="Maven: org.igniterealtime.smack:smack-extensions:4.1.3" level="project" /> |
| 47 | 47 | <orderEntry type="library" name="Maven: org.igniterealtime.smack:smack-im:4.1.3" level="project" /> |
| 48 | 48 | <orderEntry type="module" module-name="main-data-e" /> |
| 49 | + <orderEntry type="library" name="Maven: cn.jpush.api:jpush-client:3.2.9" level="project" /> | |
| 50 | + <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.3" level="project" /> | |
| 49 | 51 | <orderEntry type="library" name="Maven: org.springframework:spring-core:3.2.2.RELEASE" level="project" /> |
| 50 | 52 | <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" /> |
| 51 | 53 | <orderEntry type="library" name="Maven: org.springframework:spring-expression:3.2.2.RELEASE" level="project" /> |
| ... | ... | @@ -139,7 +141,6 @@ |
| 139 | 141 | <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.1.3.GA" level="project" /> |
| 140 | 142 | <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.0.0" level="project" /> |
| 141 | 143 | <orderEntry type="library" name="Maven: com.qiniu:qiniu-java-sdk:7.0.9" level="project" /> |
| 142 | - <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.3.1" level="project" /> | |
| 143 | 144 | <orderEntry type="library" name="Maven: com.squareup.okhttp:okhttp:2.7.1" level="project" /> |
| 144 | 145 | <orderEntry type="library" name="Maven: com.squareup.okio:okio:1.6.0" level="project" /> |
| 145 | 146 | <orderEntry type="library" name="Maven: redis.clients:jedis:2.1.0" level="project" /> |