Skip to content

Commit 23b4402

Browse files
committed
添加清除位置信息功能
1 parent 6c57eff commit 23b4402

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

webchat-backend-message/src/main/java/com/ywzlp/webchat/msg/controller/UserController.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ public WebChatResponse<?> getNearbyPeoples(@RequestBody Point location) {
106106
List<CoordinateEntity> nearbyPeoples = userService.getNearbyPeoples(location);
107107
return WebChatResponse.success(nearbyPeoples);
108108
}
109-
109+
110+
@PostMapping("/clearLocation")
111+
public WebChatResponse<?> clearLocation() {
112+
userService.clearLocation();
113+
return WebChatResponse.success();
114+
}
115+
110116
@GetMapping("/getProfilePhoto/{username}")
111117
public void getProfilePhoto(@PathVariable("username") String username, HttpServletRequest httpServletRequest,
112118
HttpServletResponse httpServletResponse) throws IOException {

webchat-backend-message/src/main/java/com/ywzlp/webchat/msg/repository/CoordinateRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ public interface CoordinateRepository extends CrudRepository<CoordinateEntity, S
88

99
CoordinateEntity findByUsername(String username);
1010

11+
int deleteByUsername(String username);
12+
1113
}

webchat-backend-message/src/main/java/com/ywzlp/webchat/msg/service/UserService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,12 @@ public List<CoordinateEntity> getNearbyPeoples(Point location) {
235235

236236
}
237237

238+
/**
239+
* 清除位置信息
240+
*/
241+
public void clearLocation() {
242+
String username = UserService.getCurrentUsername();
243+
coordinateRepository.deleteByUsername(username);
244+
}
245+
238246
}

0 commit comments

Comments
 (0)