Skip to content

Commit 4c9c247

Browse files
committed
#1445: API: Delete/Update user profile photo
1 parent 3543827 commit 4c9c247

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/usermanagement/UserController.java

+15
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,28 @@ public Mono<ResponseView<Boolean>> uploadProfilePhoto(@RequestPart("file") Mono<
114114
.map(ResponseView::success);
115115
}
116116

117+
@Override
118+
public Mono<ResponseView<Boolean>> uploadProfilePhotoById(@PathVariable String orgId, @PathVariable String userId, @RequestPart("file") Mono<Part> fileMono) {
119+
return orgApiService.checkVisitorAdminRole(orgId).flatMap(__ -> userService.findById(userId))
120+
.zipWith(fileMono)
121+
.flatMap(tuple -> userService.saveProfilePhoto(tuple.getT2(), tuple.getT1()))
122+
.map(ResponseView::success);
123+
}
124+
117125
@Override
118126
public Mono<ResponseView<Void>> deleteProfilePhoto() {
119127
return sessionUserService.getVisitor()
120128
.flatMap(visitor -> userService.deleteProfilePhoto(visitor)
121129
.map(ResponseView::success));
122130
}
123131

132+
@Override
133+
public Mono<ResponseView<Void>> deleteProfilePhotoById(@PathVariable String orgId, @PathVariable String userId) {
134+
return orgApiService.checkVisitorAdminRole(orgId).flatMap(__ -> userService.findById(userId))
135+
.flatMap(user -> userService.deleteProfilePhoto(user)
136+
.map(ResponseView::success));
137+
}
138+
124139
@Override
125140
public Mono<Void> getProfilePhoto(ServerWebExchange exchange) {
126141
return sessionUserService.getVisitorId()

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/usermanagement/UserEndpoints.java

+23-5
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,30 @@ public interface UserEndpoints
9595

9696
@Operation(
9797
tags = TAG_USER_PROFILE_PHOTO_MANAGEMENT,
98-
operationId = "deleteUserProfilePhoto",
99-
summary = "Delete current users profile photo",
100-
description = "Remove the profile Photo associated with the current User within Lowcoder."
98+
operationId = "uploadUserProfilePhotoById",
99+
summary = "Upload specific Users profile photo",
100+
description = "Upload or change specific profile photo within Lowcoder for personalization."
101101
)
102-
@DeleteMapping("/photo")
103-
public Mono<ResponseView<Void>> deleteProfilePhoto();
102+
@PostMapping(value = "/photo/{orgId}/{userId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
103+
public Mono<ResponseView<Boolean>> uploadProfilePhotoById(@PathVariable String orgId, @PathVariable String userId, @RequestPart("file") Mono<Part> fileMono);
104+
105+
@Operation(
106+
tags = TAG_USER_PROFILE_PHOTO_MANAGEMENT,
107+
operationId = "deleteUserProfilePhotoById",
108+
summary = "Delete specific users profile photo",
109+
description = "Remove the profile Photo associated with the specific User within Lowcoder."
110+
)
111+
112+
@DeleteMapping("/photo/{orgId}/{userId}")
113+
public Mono<ResponseView<Void>> deleteProfilePhotoById(@PathVariable String orgId, @PathVariable String userId);
114+
@Operation(
115+
tags = TAG_USER_PROFILE_PHOTO_MANAGEMENT,
116+
operationId = "deleteUserProfilePhoto",
117+
summary = "Delete current users profile photo",
118+
description = "Remove the profile Photo associated with the current User within Lowcoder."
119+
)
120+
@DeleteMapping("/photo")
121+
public Mono<ResponseView<Void>> deleteProfilePhoto();
104122

105123
@Operation(
106124
tags = TAG_USER_PROFILE_PHOTO_MANAGEMENT,

0 commit comments

Comments
 (0)