Skip to content

Commit

Permalink
perf($i18n): update multi lingual message for uploading resources
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Aug 9, 2021
1 parent ac8222e commit 053fc0e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public LoginResponse login(@Valid LoginPayload payload) throws SecurityException
}
val jwt = this.jwtService.createJwt(payload.getRememberMe(), user.getId(), user.getUsername(), null, null);
val response = new LoginResponse();
response.setGreeting(this.messageSource.getMessage(("greeting"), null, LocaleContextHolder.getLocale()));
response.setGreeting(this.messageSource.getMessage("greeting", null, LocaleContextHolder.getLocale()));
response.setJwt(jwt);
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -28,12 +30,14 @@
@Api(tags = {"Write resource API"})
public class WriteResourceController {
private final WriteResourceService writeResourceService;
private final MessageSource messageSource;

@PostMapping("/upload/single")
@SneakyThrows({IOException.class, BizException.class})
@ApiOperation(value = "Upload single resource", notes = "Upload single resource")
public ResponseBodyBean<String> uploadSingleResource(@RequestParam("file") MultipartFile multipartFile) {
return ResponseBodyBean.ofSuccess(this.writeResourceService.uploadSingleResource(multipartFile),
"Succeed to upload");
this.messageSource.getMessage("uploaded", null,
LocaleContextHolder.getLocale()));
}
}
1 change: 1 addition & 0 deletions oss-center/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
greeting=Hello!
uploaded=Upload single resource successfully
1 change: 1 addition & 0 deletions oss-center/src/main/resources/messages_zh_CN.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
greeting=你好!
uploaded=成功上传单个资源

0 comments on commit 053fc0e

Please sign in to comment.