Commit 3b69e6cb04295c74b92d0533c7bd935fed428c83
1 parent
fb5b5c8180
Exists in
master
提交代码
Showing 4 changed files with 205 additions and 17 deletions
- webApi/src/main/java/com/lyms/yimiao/web/controller/v1/FeedbackController.java
- webApi/src/main/java/com/lyms/yimiao/web/controller/v1/NotificationsController.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
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/FeedbackController.java
View file @
3b69e6c
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.base.TokenRequired; | |
5 | +import com.lymsh.mommybaby.basecommon.constant.ConstantInterface; | |
6 | +import com.lymsh.mommybaby.basecommon.context.MommyBobyContext; | |
7 | +import com.lymsh.mommybaby.basecommon.util.ContextHolder; | |
8 | +import com.lymsh.mommybaby.basecommon.util.ResultUtils; | |
9 | +import com.lymsh.yimiao.main.data.enumdata.YnEnum; | |
10 | +import com.lymsh.yimiao.main.data.model.YmFeedbacks; | |
11 | +import com.lymsh.yimiao.main.data.model.YmUsers; | |
12 | +import com.lymsh.yimiao.main.data.service.YmFeedbacksService; | |
13 | +import com.lymsh.yimiao.main.data.service.YmUsersService; | |
14 | +import com.lymsh.yimiao.main.data.util.JsonUtil; | |
15 | +import org.springframework.beans.factory.annotation.Autowired; | |
16 | +import org.springframework.stereotype.Controller; | |
17 | +import org.springframework.util.StringUtils; | |
18 | +import org.springframework.web.bind.annotation.RequestMapping; | |
19 | +import org.springframework.web.bind.annotation.RequestMethod; | |
20 | +import org.springframework.web.bind.annotation.RequestParam; | |
21 | + | |
22 | +import javax.servlet.http.HttpServletResponse; | |
23 | +import java.util.Date; | |
24 | +import java.util.HashMap; | |
25 | +import java.util.Map; | |
26 | + | |
3 | 27 | /** |
4 | - * 反馈 | |
28 | + * 反馈接口 | |
5 | 29 | * |
6 | 30 | * Created by Administrator on 2016/4/29 0029. |
7 | 31 | */ |
8 | -public class FeedbackController { | |
32 | +@Controller | |
33 | +@RequestMapping("/v1") | |
34 | +public class FeedbackController extends BaseController{ | |
35 | + | |
36 | + @Autowired | |
37 | + private YmUsersService usersService; | |
38 | + @Autowired | |
39 | + private YmFeedbacksService feedBacksService; | |
40 | + | |
41 | + /** | |
42 | + * 提交意见反馈 | |
43 | + * | |
44 | + * @return | |
45 | + */ | |
46 | + @RequestMapping(value = "/feedbacks", method = RequestMethod.POST) | |
47 | + @TokenRequired | |
48 | + public void submitFeedBack(@RequestParam("content") String content, | |
49 | + HttpServletResponse httpServletResponse) { | |
50 | + | |
51 | + if (StringUtils.isEmpty(content)) { | |
52 | + ResultUtils.buildParameterErrorResultAndWrite(httpServletResponse); | |
53 | + return; | |
54 | + } | |
55 | + | |
56 | + MommyBobyContext mommyBobyContext = ContextHolder.getContext(); | |
57 | + Integer userId = mommyBobyContext.getUserId(); | |
58 | + if (null != userId) { | |
59 | + | |
60 | + YmFeedbacks feedBacks = new YmFeedbacks(); | |
61 | + feedBacks.setYn(YnEnum.yes.getId()); | |
62 | + feedBacks.setCreated(new Date()); | |
63 | + feedBacks.setType(1);//默认是反馈 | |
64 | + feedBacks.setContent(content); | |
65 | + feedBacks.setPublishId(userId); | |
66 | + | |
67 | + YmUsers users = usersService.getYmUsers(userId); | |
68 | + if (null != users) { | |
69 | + feedBacks.setPublishName(users.getNickname()); | |
70 | + } | |
71 | + feedBacksService.addYmFeedbacks(feedBacks); | |
72 | + ResultUtils.buildSuccessResultAndWrite(httpServletResponse); | |
73 | + } else { | |
74 | + Map<String, Object> result = new HashMap<>(); | |
75 | + result.put("errorcode", ConstantInterface.SYSTEM_ERROR); | |
76 | + result.put("errormsg", "userId为空."); | |
77 | + writeJson(httpServletResponse, JsonUtil.obj2JsonString(result)); | |
78 | + } | |
79 | + } | |
80 | + | |
81 | + | |
9 | 82 | } |
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/NotificationsController.java
View file @
3b69e6c
1 | 1 | package com.lyms.yimiao.web.controller.v1; |
2 | 2 | |
3 | +import com.lymsh.mommybaby.basecommon.base.BaseController; | |
4 | +import org.springframework.stereotype.Controller; | |
5 | +import org.springframework.web.bind.annotation.RequestMapping; | |
6 | + | |
3 | 7 | /** |
4 | 8 | * |
5 | - * 消息 | |
9 | + * 消息接口 | |
6 | 10 | * |
7 | 11 | * Created by Administrator on 2016/4/29 0029. |
8 | 12 | */ |
9 | -public class NotificationsController { | |
13 | +@Controller | |
14 | +@RequestMapping("/v1") | |
15 | +public class NotificationsController extends BaseController{ | |
16 | + | |
17 | + //获取消息(1.系统消息2.接种消息) | |
18 | + | |
19 | + | |
20 | + //定时发送给当前登录用户接种通知 | |
21 | + /* | |
22 | + 查询当前登陆用户在当前时间距离下次接种时间3天和1天的时候,发送一条推送消息 | |
23 | + */ | |
24 | + | |
25 | + | |
10 | 26 | } |
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/OrganizationsController.java
View file @
3b69e6c
... | ... | @@ -3,8 +3,9 @@ |
3 | 3 | import com.lymsh.mommybaby.basecommon.base.BaseController; |
4 | 4 | import com.lymsh.mommybaby.basecommon.util.ResultUtils; |
5 | 5 | import com.lymsh.yimiao.main.data.model.MedOrganization; |
6 | -import com.lymsh.yimiao.main.data.service.MedAearService; | |
6 | +import com.lymsh.yimiao.main.data.service.MedAreaService; | |
7 | 7 | import com.lymsh.yimiao.main.data.service.MedOrganizationService; |
8 | +import com.lymsh.yimiao.main.data.util.JsonUtil; | |
8 | 9 | import org.springframework.beans.factory.annotation.Autowired; |
9 | 10 | import org.springframework.stereotype.Controller; |
10 | 11 | import org.springframework.web.bind.annotation.RequestMapping; |
... | ... | @@ -16,7 +17,7 @@ |
16 | 17 | import java.util.Map; |
17 | 18 | |
18 | 19 | /** |
19 | - * 机构 | |
20 | + * 机构信息 | |
20 | 21 | * |
21 | 22 | * Created by Administrator on 2016/4/29 0029. |
22 | 23 | */ |
... | ... | @@ -27,7 +28,7 @@ |
27 | 28 | @Autowired |
28 | 29 | private MedOrganizationService medOrganizationService; |
29 | 30 | @Autowired |
30 | - private MedAearService medAearService; | |
31 | + private MedAreaService medAreaService; | |
31 | 32 | |
32 | 33 | |
33 | 34 | @RequestMapping(value = "/organizations", method = RequestMethod.GET) |
34 | 35 | |
35 | 36 | |
36 | 37 | |
37 | 38 | |
38 | 39 | |
39 | 40 | |
... | ... | @@ -36,21 +37,56 @@ |
36 | 37 | |
37 | 38 | MedOrganization medOrganization = medOrganizationService.getMedOrganization(id); |
38 | 39 | if (medOrganization==null){ |
39 | - ResultUtils.buildParameterErrorResultAndWrite(response,"单位ID为空"); | |
40 | + ResultUtils.buildParameterErrorResultAndWrite(response,"单位ID为不存在"); | |
40 | 41 | return; |
41 | 42 | } |
42 | 43 | Map<String,Object> map = new HashMap<>(); |
43 | 44 | map.put("name",medOrganization.getoName()); |
44 | 45 | map.put("contactWay",medOrganization.getoContactWay()); |
45 | 46 | //省 |
46 | - map.put("ProvinceName",medAearService.getMedAear(medOrganization.getoProvinceNo()) == null ? null : medAearService.getMedAear(medOrganization.getoProvinceNo()).getAName()); | |
47 | + if (medOrganization.getoProvinceNo()!=null){ | |
48 | + map.put("province",medAreaService.getMedArea(medOrganization.getoProvinceNo()) == null ? null : medAreaService.getMedArea(medOrganization.getoProvinceNo()).getAName()); | |
49 | + }else { | |
50 | + map.put("province",null); | |
51 | + } | |
47 | 52 | //市 |
53 | + if (medOrganization.getoCityNo()!=null){ | |
54 | + map.put("city",medAreaService.getMedArea(medOrganization.getoCityNo()) == null ? null : medAreaService.getMedArea(medOrganization.getoCityNo()).getAName()); | |
55 | + }else { | |
56 | + map.put("city",null); | |
57 | + } | |
48 | 58 | //区 |
59 | + if (medOrganization.getoCityNo()!=null){ | |
60 | + map.put("city",medAreaService.getMedArea(medOrganization.getoCityNo()) == null ? null : medAreaService.getMedArea(medOrganization.getoCityNo()).getAName()); | |
61 | + }else { | |
62 | + map.put("city",null); | |
63 | + } | |
49 | 64 | //县 |
50 | - //街道 | |
65 | + if (medOrganization.getoCountyNo()!=null){ | |
66 | + map.put("county",medAreaService.getMedArea(medOrganization.getoCountyNo()) == null ? null : medAreaService.getMedArea(medOrganization.getoCountyNo()).getAName()); | |
67 | + }else { | |
68 | + map.put("county",null); | |
69 | + } | |
70 | + //乡镇 | |
71 | + if (medOrganization.getoTownshipNo()!=null){ | |
72 | + map.put("township",medAreaService.getMedArea(medOrganization.getoTownshipNo()) == null ? null : medAreaService.getMedArea(medOrganization.getoTownshipNo()).getAName()); | |
73 | + }else { | |
74 | + map.put("township",null); | |
75 | + } | |
51 | 76 | //村 |
77 | + if (medOrganization.getoVillageNo()!=null){ | |
78 | + map.put("village",medAreaService.getMedArea(medOrganization.getoVillageNo()) == null ? null : medAreaService.getMedArea(medOrganization.getoVillageNo()).getAName()); | |
79 | + }else { | |
80 | + map.put("village",null); | |
81 | + } | |
82 | + //街道 | |
83 | + if (medOrganization.getoAddress()!=null){ | |
84 | + map.put("address",medAreaService.getMedArea(medOrganization.getoAddress()) == null ? null : medAreaService.getMedArea(medOrganization.getoAddress()).getAName()); | |
85 | + }else { | |
86 | + map.put("address",null); | |
87 | + } | |
52 | 88 | |
53 | - | |
89 | + writeJson(response, JsonUtil.obj2JsonString(map)); | |
54 | 90 | |
55 | 91 | } |
56 | 92 |
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/UserController.java
View file @
3b69e6c
1 | 1 | package com.lyms.yimiao.web.controller.v1; |
2 | 2 | |
3 | 3 | import com.lymsh.mommybaby.basecommon.base.BaseController; |
4 | +import com.lymsh.mommybaby.basecommon.base.TokenRequired; | |
5 | +import com.lymsh.mommybaby.basecommon.context.MommyBobyContext; | |
6 | +import com.lymsh.mommybaby.basecommon.util.ContextHolder; | |
4 | 7 | import com.lymsh.mommybaby.basecommon.util.JsonUtil; |
8 | +import com.lymsh.mommybaby.basecommon.util.QiniuUtil; | |
5 | 9 | import com.lymsh.mommybaby.basecommon.util.ResultUtils; |
6 | 10 | import com.lymsh.yimiao.main.data.enumdata.YnEnum; |
7 | 11 | import com.lymsh.yimiao.main.data.model.YmUsers; |
... | ... | @@ -9,6 +13,7 @@ |
9 | 13 | import com.lymsh.yimiao.main.data.service.YmUsersService; |
10 | 14 | import com.lymsh.yimiao.main.data.util.LoginContext; |
11 | 15 | import com.lymsh.yimiao.main.data.util.LoginUtil; |
16 | +import com.lymsh.yimiao.main.data.util.PhoneUtil; | |
12 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
13 | 18 | import org.springframework.beans.factory.annotation.Value; |
14 | 19 | import org.springframework.http.MediaType; |
... | ... | @@ -39,7 +44,7 @@ |
39 | 44 | @Value("#{configProperties['yimiao.typeId']}") |
40 | 45 | private String typeId; |
41 | 46 | @Autowired |
42 | - private YmUsersService userService; | |
47 | + private YmUsersService usersService; | |
43 | 48 | |
44 | 49 | /** |
45 | 50 | * 发送验证码 |
... | ... | @@ -79,7 +84,7 @@ |
79 | 84 | YmUsersQuery query = new YmUsersQuery(); |
80 | 85 | query.setPhone(phone); |
81 | 86 | query.setYn(YnEnum.yes.getId()); |
82 | - List<YmUsers> usersList = userService.queryYmUsers(query); | |
87 | + List<YmUsers> usersList = usersService.queryYmUsers(query); | |
83 | 88 | if (usersList.size()==0){ |
84 | 89 | YmUsers users = new YmUsers(); |
85 | 90 | users.setPhone(phone); |
86 | 91 | |
... | ... | @@ -87,13 +92,13 @@ |
87 | 92 | users.setCreated(new Date()); |
88 | 93 | users.setLoginCenterId(result.getId()); |
89 | 94 | users.setLastLoginTime(new Date()); |
90 | - userService.addYmUsers(users); | |
95 | + usersService.addYmUsers(users); | |
91 | 96 | map.put("token", result.getToken()); |
92 | 97 | map.put("id", users.getId()); |
93 | 98 | }else { |
94 | 99 | YmUsers users = usersList.get(0); |
95 | 100 | users.setLastLoginTime(new Date()); |
96 | - userService.updateYmUsers(users); | |
101 | + usersService.updateYmUsers(users); | |
97 | 102 | map.put("token", result.getToken()); |
98 | 103 | map.put("id", users.getId()); |
99 | 104 | } |
... | ... | @@ -120,7 +125,7 @@ |
120 | 125 | YmUsersQuery query = new YmUsersQuery(); |
121 | 126 | query.setPhone(phone); |
122 | 127 | query.setYn(YnEnum.yes.getId()); |
123 | - List<YmUsers> usersList = userService.queryYmUsers(query); | |
128 | + List<YmUsers> usersList = usersService.queryYmUsers(query); | |
124 | 129 | if (usersList.size()==0){ |
125 | 130 | YmUsers user = new YmUsers(); |
126 | 131 | user.setId(result.getId()); |
127 | 132 | |
... | ... | @@ -128,12 +133,70 @@ |
128 | 133 | user.setCreated(new Date()); |
129 | 134 | user.setModified(new Date()); |
130 | 135 | user.setPhone(phone); |
131 | - userService.addYmUsers(user); | |
136 | + usersService.addYmUsers(user); | |
132 | 137 | } |
133 | 138 | } |
134 | 139 | writeJson(response, JsonUtil.obj2JsonString(map)); |
135 | 140 | } |
136 | 141 | |
142 | + /** | |
143 | + * 获取当前用户信息 | |
144 | + * @param response | |
145 | + */ | |
146 | + @RequestMapping(value = "/userInfo", method = RequestMethod.GET) | |
147 | + @TokenRequired | |
148 | + public void getUserInfo(HttpServletResponse response){ | |
149 | + //取到当前登陆用户的id | |
150 | + YmUsers users = usersService.getYmUsers(ContextHolder.getContext().getUserId()); | |
151 | + Map<String,Object> map = new HashMap<>(); | |
152 | + //如果没有昵称,返回手机 | |
153 | + map.put("nickname",users.getNickname()!=null ? users.getNickname() : users.getPhone()); | |
154 | + //如果没有头像,返回默认头像 | |
155 | + map.put("avatar", QiniuUtil.buildImg(users.getAvatar()!=null ? users.getAvatar() : "默认头像")); | |
156 | + | |
157 | + writeJson(response, JsonUtil.obj2JsonString(map)); | |
158 | + } | |
159 | + | |
160 | + /** | |
161 | + * 修改绑定手机号接口 | |
162 | + * @param response | |
163 | + * @param phone | |
164 | + */ | |
165 | + @RequestMapping(value = "/updatePhone", method = RequestMethod.PUT) | |
166 | + @TokenRequired | |
167 | + public void updateUserPhone(HttpServletResponse response, | |
168 | + @RequestParam("phone") String phone) { | |
169 | + //取到当前登陆用户的id | |
170 | + YmUsers users = usersService.getYmUsers(ContextHolder.getContext().getUserId()); | |
171 | + if (PhoneUtil.isMobileNO(phone)){ | |
172 | + users.setPhone(phone); | |
173 | + users.setModified(new Date()); | |
174 | + usersService.updateYmUsers(users); | |
175 | + ResultUtils.buildSuccessResultAndWrite(response); | |
176 | + }else { | |
177 | + ResultUtils.buildParameterErrorResultAndWrite(response,"手机号输入错误"); | |
178 | + } | |
179 | + } | |
180 | + | |
181 | + /** | |
182 | + * 修改当前登录用户头像和昵称 | |
183 | + * @param response | |
184 | + * @param avatar | |
185 | + * @param nickname | |
186 | + */ | |
187 | + @RequestMapping(value = "/updateUserInfo", method = RequestMethod.PUT) | |
188 | + @TokenRequired | |
189 | + public void updateUser(HttpServletResponse response, | |
190 | + @RequestParam(value = "avatar",required = false) String avatar, | |
191 | + @RequestParam(value = "nickname",required = false)String nickname) { | |
192 | + //取到当前登陆用户的id | |
193 | + YmUsers users = usersService.getYmUsers(ContextHolder.getContext().getUserId()); | |
194 | + users.setNickname(nickname); | |
195 | + users.setAvatar(avatar); | |
196 | + users.setModified(new Date()); | |
197 | + usersService.updateYmUsers(users); | |
198 | + ResultUtils.buildSuccessResultAndWrite(response); | |
199 | + } | |
137 | 200 | |
138 | 201 | } |