Merge branch 'master' into dev_gitlink_model

This commit is contained in:
万佳 2021-09-08 15:09:10 +08:00
commit 8633647df1
3 changed files with 18 additions and 9 deletions

View File

@ -15,11 +15,11 @@ import javax.servlet.http.HttpServletRequest;
/**
* web请求异常全局处理类在使用的模块内继承此类然后加上ControllerAdvice注解example:
* @ControllerAdvice
* public class ReaderExceptionInterceptor extends ExceptionInterceptor {}
*
* @author zengwei
* @ControllerAdvice public class ReaderExceptionInterceptor extends ExceptionInterceptor {}
* @date 2021/09/07
* */
*/
public class ExceptionInterceptor {
private static final Logger logger = LoggerFactory.getLogger(ExceptionInterceptor.class);
private static String logTemplate = "request page url{}, error:{}";
@ -37,6 +37,6 @@ public class ExceptionInterceptor {
@ExceptionHandler({Exception.class})
public ResponseData handle(HttpServletRequest request, Exception e) {
logger.error(logTemplate, request.getRequestURI(), e);
return DataPacketUtil.jsonFailResult("服务器异常,请联系管理员处理!", e);
return DataPacketUtil.jsonFailResult(e.getMessage());
}
}

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);

View File

@ -21,7 +21,7 @@
</encoder>
</appender>
<root level="info">
<root level="debug">
<appender-ref ref="console"/>
<appender-ref ref="file"/>
</root>