加上必要的注释

This commit is contained in:
巴拉迪维 2021-09-08 14:55:54 +08:00
parent 9b5c05fec0
commit 16d38beea2
1 changed files with 13 additions and 4 deletions

View File

@ -36,17 +36,26 @@ public class NotificationController {
* @param receiver
* @return
*/
@GetMapping(value = "/{type}")
public ResponseData index(@PathVariable(name = "type", required = true) String type,
@GetMapping(value = "/{platform}/{type}")
public ResponseData index(@PathVariable(name = "platform", required = true) String platform,
@PathVariable(name = "type", required = true) String type,
@RequestParam(name = "receiver", required = true) Integer receiver,
@RequestParam(name = "page", required = false, defaultValue = "1") Integer pageNum,
@RequestParam(name = "size", required = false, defaultValue = "20") Integer pageSize) {
//验证 {platform} 参数合法性以判断请求来源
if (!platform.trim().toLowerCase().equals(PLATFORM_CODE_GITLINK)) {
logger.debug("------>输入参数 {platform} 的值 {" + platform + "} 无效");
DataPacketUtil.jsonFailResult("参数 {platform} 非法");
}
//验证 {receiver} 参数合法性
if (receiver <= 0 || receiver >= Integer.MAX_VALUE) {
logger.debug("------>输入参数 {receiver} 的值 {" + receiver + "} 超出约定范围");
DataPacketUtil.jsonFailResult("参数 {receiver} 非法");
}
//判断 {type} 参数合法性正确的值只能是 listcount
if (type.trim().toLowerCase().equals("list")) {
//用户请求的是 list
logger.debug("------>{type} 参数是 list");
@ -54,7 +63,7 @@ public class NotificationController {
//TODO: 获取约定的必要参数
//调用业务逻辑获取数据结果
List<SysNotification> foundList = notificationService.getUnreadSysNotificationsList(PLATFORM_CODE_GITLINK, receiver, pageSize);
List<SysNotification> foundList = notificationService.getUnreadSysNotificationsList(platform, receiver, pageSize);
//拼装约定的 json 格式并返回
return DataPacketUtil.jsonSuccessResult(foundList);
@ -65,7 +74,7 @@ public class NotificationController {
//TODO: 获取必要的参数
//调用业务逻辑获取数据结果
Integer foundCount = notificationService.getSysNotificationNumberByType(PLATFORM_CODE_GITLINK, receiver, 1);
Integer foundCount = notificationService.getSysNotificationNumberByType(platform, receiver, 1);
//拼装约定的 json 格式并返回
return DataPacketUtil.jsonSuccessResult(foundCount);