Browse Source

超级API日志入库

2024年8月14日14:17:37
thing_master
lishuai 1 year ago
parent
commit
5a18b0532d
  1. 9
      modules/thing/src/main/java/com/thing/thing/api/entity/IotThingApiLogEntity.java
  2. 2
      modules/thing/src/main/java/com/thing/thing/api/service/IotThingApiLogService.java
  3. 5
      modules/thing/src/main/java/com/thing/thing/api/service/impl/IotThingApiServiceImpl.java

9
modules/thing/src/main/java/com/thing/thing/api/entity/IotThingApiLogEntity.java

@ -1,15 +1,12 @@
package com.thing.thing.api.entity;
import com.mybatisflex.annotation.Table;
import com.thing.common.core.validator.group.UpdateGroup;
import com.thing.common.orm.entity.BaseDateEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serial;
/**
@ -27,9 +24,9 @@ public class IotThingApiLogEntity extends BaseDateEntity {
private static final long serialVersionUID = 1L;
@Schema(description = "主键")
@NotNull(message = "API日志id不能为空",groups = UpdateGroup.class)
private Long id;
// @Schema(description = "主键")
// @NotNull(message = "API日志id不能为空",groups = UpdateGroup.class)
// private Long id;
/**
* 调用API的主键

2
modules/thing/src/main/java/com/thing/thing/api/service/IotThingApiLogService.java

@ -3,8 +3,6 @@ package com.thing.thing.api.service;
import com.thing.common.orm.service.IBaseService;
import com.thing.thing.api.entity.IotThingApiLogEntity;
;
/**
* 超级api
*

5
modules/thing/src/main/java/com/thing/thing/api/service/impl/IotThingApiServiceImpl.java

@ -29,6 +29,7 @@ import com.thing.sys.security.context.UserContext;
import com.thing.thing.api.controller.IotThingApiController;
import com.thing.thing.api.dto.*;
import com.thing.thing.api.entity.IotThingApiEntity;
import com.thing.thing.api.entity.IotThingApiLogEntity;
import com.thing.thing.api.excel.IotThingApiExcel;
import com.thing.thing.api.mapper.IotThingApiMapper;
import com.thing.thing.api.service.IotThingApiLogService;
@ -823,7 +824,7 @@ public class IotThingApiServiceImpl extends BaseServiceImpl<IotThingApiMapper, I
private void apiLog(IotThingApiEntity apiEntity, String caller) {
try {
IotThingApiLogDTO apiLogDTO = new IotThingApiLogDTO();
IotThingApiLogEntity apiLogDTO = new IotThingApiLogEntity();
apiLogDTO.setApiId(apiEntity.getId());
apiLogDTO.setCaller(caller);
apiLogDTO.setApiName(apiEntity.getName());
@ -842,7 +843,7 @@ public class IotThingApiServiceImpl extends BaseServiceImpl<IotThingApiMapper, I
//调用IP
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
apiLogDTO.setIp(IpUtils.getIpAddr(request));
apiLogService.saveDto(apiLogDTO);
apiLogService.saveOrUpdate(apiLogDTO);
} catch (Exception e) {
log.error(e.getMessage());
}

Loading…
Cancel
Save