Merge branch 'master' into 'feature/REQ-3009'
Master See merge request universal/infrastructure/backend/axzo-log-plat!132
This commit is contained in:
commit
39139e9ba1
@ -41,6 +41,5 @@ public class LogAddReq {
|
|||||||
/**
|
/**
|
||||||
* 日志内容,需要是json格式
|
* 日志内容,需要是json格式
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "message is required")
|
|
||||||
private String message;
|
private String message;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import cn.axzo.framework.domain.web.result.ApiResult;
|
|||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
@ -29,4 +30,10 @@ public class ExceptionAdviceHandler {
|
|||||||
log.warn("业务异常", e);
|
log.warn("业务异常", e);
|
||||||
return ApiResult.err(e.getMessage());
|
return ApiResult.err(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler({MethodArgumentNotValidException.class})
|
||||||
|
public ApiResult<Void> exceptionHandler(MethodArgumentNotValidException e) {
|
||||||
|
log.error("参数异常", e);
|
||||||
|
return ApiResult.err(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,6 +78,9 @@ public class LogServiceImpl implements LogService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String addLog(LogAddReq req) {
|
public String addLog(LogAddReq req) {
|
||||||
|
if (StringUtils.isBlank(req.getMessage())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
LogEntity logEntity = buildToLogEntity(req);
|
LogEntity logEntity = buildToLogEntity(req);
|
||||||
logMapper.save(logEntity);
|
logMapper.save(logEntity);
|
||||||
return logEntity.getId();
|
return logEntity.getId();
|
||||||
@ -145,8 +148,12 @@ public class LogServiceImpl implements LogService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> batchAddLogs(LogBatchAddReq req) {
|
public List<String> batchAddLogs(LogBatchAddReq req) {
|
||||||
|
if (req.getLogs().stream().allMatch(l -> StringUtils.isBlank(l.getMessage()))) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
List<LogEntity> logEntities = req.getLogs()
|
List<LogEntity> logEntities = req.getLogs()
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(l -> StringUtils.isNotBlank(l.getMessage()))
|
||||||
.map(this::buildToLogEntity)
|
.map(this::buildToLogEntity)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
logMapper.saveAll(logEntities);
|
logMapper.saveAll(logEntities);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user