diff --git a/udf-api/pom.xml b/udf-api/pom.xml
index b72adb6..3f0b106 100644
--- a/udf-api/pom.xml
+++ b/udf-api/pom.xml
@@ -26,6 +26,7 @@
udf-api-server
udf-api-common
+ udf-api-general
@@ -38,6 +39,12 @@
pom
import
+
+
+ org.itkk.udf
+ udf-api-general
+ ${udf-api.version}
+
org.itkk.udf
diff --git a/udf-api/udf-api-common/pom.xml b/udf-api/udf-api-common/pom.xml
index eed3f78..5f17fe8 100644
--- a/udf-api/udf-api-common/pom.xml
+++ b/udf-api/udf-api-common/pom.xml
@@ -30,6 +30,16 @@
org.itkk.udf
udf-starter-datasource-dynamic
+
+
+ org.itkk.udf
+ udf-starter-cache-db
+
+
+
+ org.itkk.udf
+ udf-starter-queue-db
+
@@ -42,16 +52,7 @@
-
-
-
-
-
-
-
-
-
-
+
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/CommonConfiguration.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/CommonConfiguration.java
index 9108b7a..4c7c880 100644
--- a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/CommonConfiguration.java
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/CommonConfiguration.java
@@ -1,5 +1,7 @@
package org.itkk.udf.api.common;
+import org.itkk.udf.starter.cache.db.DbCacheServiceRegistration;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -9,4 +11,14 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class CommonConfiguration implements WebMvcConfigurer {
+ /**
+ * dbCacheServiceRegistration
+ *
+ * @return DbCacheServiceRegistration
+ */
+ @Bean(destroyMethod = "shutdown")
+ public DbCacheServiceRegistration dbCacheServiceRegistration() {
+ return new DbCacheServiceRegistration();
+ }
+
}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/CommonConstant.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/CommonConstant.java
index 8b23afc..f17408a 100644
--- a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/CommonConstant.java
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/CommonConstant.java
@@ -4,6 +4,67 @@ package org.itkk.udf.api.common;
* 常量类
*/
public class CommonConstant {
+
+ /**
+ * web根路径
+ */
+ public static final String URL_ROOT_WEB = "/api/udf/web";
+
+ /**
+ * 需认证的web根路径
+ */
+ public static final String URL_ROOT_WEB_PRIVATE = URL_ROOT_WEB + "/private";
+
+ /**
+ * 无需认证的web根路径
+ */
+ public static final String URL_ROOT_WEB_PUBLIC = URL_ROOT_WEB + "/public";
+
+ /**
+ * 默认时间格式
+ */
+ public static final String DEF_DATA_FMT = "yyyy-MM-dd HH:mm:ss";
+
+ /**
+ * 默认锁失败信息
+ */
+ public static final String DEF_LOCK_FAIL_MSG = "该数据正在被处理中,请稍后再试";
+
+ /**
+ * token参数名
+ */
+ public static final String PARAMETER_NAME_TOKEN = "token";
+
+ /**
+ * token信息参数名
+ */
+ public static final String PARAMETER_NAME_TOKEN_INFO = "tokenInfo";
+
+ /**
+ * token超时时间
+ */
+ public static final long TOKEN_CACHE_TTL = 30 * 60 * 1000L;
+
+ /**
+ * 刷新token时间
+ */
+ public static final long REFRESH_TOKEN_CACHE_TTL = 15 * 60 * 1000L;
+
+ /**
+ * 锁超时时间
+ */
+ public static final Long LOCK_EXPAIR = 5 * 60 * 1000L;
+
+ /**
+ * 发送邮件队列名
+ */
+ public static final String SEND_EMAIL_QUEUE = "SEND_EMAIL_QUEUE";
+
+ /**
+ * 发送邮件队列处理器
+ */
+ public static final String SEND_EMAIL_QUEUE_HANDLE = "SEND_EMAIL_QUEUE_HANDLE";
+
/**
* 私有化构造函数
*/
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/CommonProperties.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/CommonProperties.java
index 8317752..7c91078 100644
--- a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/CommonProperties.java
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/CommonProperties.java
@@ -5,6 +5,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
+import javax.validation.constraints.NotNull;
+
/**
* 属性类
*/
@@ -17,4 +19,15 @@ public class CommonProperties {
* 配置文件前缀
*/
protected static final String UDF_API_PROPERTIES = "org.itkk.udf.api.common.properties";
+
+ /**
+ * 追踪日志保留天数
+ */
+ @NotNull(message = UDF_API_PROPERTIES + ".traceLogKeepDays不能为空")
+ private Integer traceLogKeepDays = 5;
+
+ /**
+ * 发送邮件队列并发数
+ */
+ private Integer sendEmailQueueMaxConcurrency = 1;
}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/component/DbLogImpl.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/component/DbLogImpl.java
new file mode 100644
index 0000000..8a4664b
--- /dev/null
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/component/DbLogImpl.java
@@ -0,0 +1,72 @@
+package org.itkk.udf.api.common.component;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.itkk.udf.api.common.service.DataHisService;
+import org.itkk.udf.api.common.service.TraceInfoService;
+import org.itkk.udf.starter.core.exception.SystemRuntimeException;
+import org.itkk.udf.starter.core.exception.handle.IExceptionAlert;
+import org.itkk.udf.starter.core.trace.IDataHis;
+import org.itkk.udf.starter.core.trace.ITraceAlert;
+import org.itkk.udf.starter.core.trace.TraceDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+@Component
+@Slf4j
+public class DbLogImpl implements ITraceAlert, IExceptionAlert, IDataHis {
+
+ /**
+ * traceInfoService
+ */
+ @Autowired
+ private TraceInfoService traceInfoService;
+
+ /**
+ * dataHisService
+ */
+ @Autowired
+ private DataHisService dataHisService;
+
+ /**
+ * internalObjectMapper
+ */
+ @Autowired
+ @Qualifier("internalObjectMapper")
+ private ObjectMapper internalObjectMapper;
+
+ @Override
+ public void save(String traceId, String name, String pk, Object content, String userId) {
+ try {
+ dataHisService.save(traceId, name, pk, internalObjectMapper.writeValueAsString(content), userId);
+ } catch (JsonProcessingException ex) {
+ throw new SystemRuntimeException(ex);
+ }
+ }
+
+ @Override
+ @Async
+ public void alert(String traceId, Exception e) {
+ try {
+ final String type = "IExceptionAlert";
+ traceInfoService.save(traceId, type, internalObjectMapper.writeValueAsString(ExceptionUtils.getStackTrace(e)));
+ } catch (JsonProcessingException ex) {
+ log.warn(traceId + " (IExceptionAlert)记录trace日志失败,错误信息为 : " + ex.getMessage());
+ }
+ }
+
+ @Override
+ @Async
+ public void alert(TraceDto traceDto) {
+ try {
+ final String type = "ITraceAlert";
+ traceInfoService.save(traceDto.getTraceId(), type, internalObjectMapper.writeValueAsString(traceDto));
+ } catch (JsonProcessingException e) {
+ log.warn(traceDto.getTraceId() + " (ITraceAlert)记录trace日志失败,错误信息为 : " + e.getMessage());
+ }
+ }
+}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/component/DbQueueLockImpl.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/component/DbQueueLockImpl.java
new file mode 100644
index 0000000..d731798
--- /dev/null
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/component/DbQueueLockImpl.java
@@ -0,0 +1,27 @@
+package org.itkk.udf.api.common.component;
+
+import org.itkk.udf.starter.cache.db.service.DbCacheService;
+import org.itkk.udf.starter.queue.db.IDbQueueLock;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class DbQueueLockImpl implements IDbQueueLock {
+
+ /**
+ * dbCacheService
+ */
+ @Autowired
+ private DbCacheService dbCacheService;
+
+ @Override
+ public boolean lock(String key) {
+ final long expire = 30 * 60 * 1000L;
+ return dbCacheService.setNx(key, key, expire);
+ }
+
+ @Override
+ public void unlock(String key) {
+ dbCacheService.delete(key);
+ }
+}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/dto/SendMailDto.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/dto/SendMailDto.java
new file mode 100644
index 0000000..d4ad3dc
--- /dev/null
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/dto/SendMailDto.java
@@ -0,0 +1,25 @@
+package org.itkk.udf.api.common.dto;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+
+@Data
+@Accessors(chain = true)
+@NoArgsConstructor
+@ToString
+@EqualsAndHashCode(callSuper = false)
+public class SendMailDto implements Serializable {
+ private static final long serialVersionUID = 6443090530533741230L; //ID
+ private String emailSubject; //标题
+ private String emailContent; //主题
+ private Set addres; //地址列表
+ private Map fileMap; //附件列表
+}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/entity/DataHisEntity.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/entity/DataHisEntity.java
new file mode 100644
index 0000000..e96535d
--- /dev/null
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/entity/DataHisEntity.java
@@ -0,0 +1,54 @@
+package org.itkk.udf.api.common.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+@Data
+@Accessors(chain = true)
+@ToString
+@EqualsAndHashCode(callSuper = false)
+@TableName("TF_DATA_HIS")
+public class DataHisEntity {
+ /**
+ * 主键
+ */
+ @TableId("ID")
+ private String id;
+ /**
+ * 追踪ID
+ */
+ @TableField("TRACE_ID")
+ private String traceId;
+ /**
+ * 表名
+ */
+ @TableField("TABLE_NAME")
+ private String TABLE_NAME;
+ /**
+ * 表主键
+ */
+ @TableField("TABLE_PK")
+ private String TABLE_PK;
+ /**
+ * 表内容
+ */
+ @TableField("CONTENT")
+ private String content;
+ /**
+ * 创建时间
+ */
+ @TableField("CREATE_DATE")
+ private Date createDate;
+ /**
+ * 创建人
+ */
+ @TableField("CREATE_BY")
+ private String createBy;
+}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/entity/ParameterEntity.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/entity/ParameterEntity.java
new file mode 100644
index 0000000..8addd6f
--- /dev/null
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/entity/ParameterEntity.java
@@ -0,0 +1,68 @@
+package org.itkk.udf.api.common.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+@Data
+@Accessors(chain = true)
+@ToString
+@EqualsAndHashCode(callSuper = false)
+@TableName("TM_PARAMETER")
+public class ParameterEntity {
+
+ /**
+ * 代码
+ */
+ @TableId("CODE")
+ private String code;
+
+ /**
+ * 类别
+ */
+ @TableField("TYPE")
+ private String type;
+
+ /**
+ * 名称
+ */
+ @TableField("NAME")
+ private String name;
+
+ /**
+ * 内容
+ */
+ @TableField("CONTENT")
+ private String content;
+
+ /**
+ * 创建人
+ */
+ @TableField("CREATE_BY")
+ private String createBy;
+
+ /**
+ * 创建时间
+ */
+ @TableField("CREATE_DATE")
+ private Date createDate;
+
+ /**
+ * 更新人
+ */
+ @TableField("UPDATE_BY")
+ private String updateBy;
+
+ /**
+ * 更新时间
+ */
+ @TableField("UPDATE_DATE")
+ private Date updateDate;
+
+}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/entity/TraceInfoEntity.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/entity/TraceInfoEntity.java
new file mode 100644
index 0000000..a15d532
--- /dev/null
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/entity/TraceInfoEntity.java
@@ -0,0 +1,44 @@
+package org.itkk.udf.api.common.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+@Data
+@Accessors(chain = true)
+@ToString
+@EqualsAndHashCode(callSuper = false)
+@TableName("TF_TRACE_INFO")
+public class TraceInfoEntity {
+ /**
+ * 主键
+ */
+ @TableId("ID")
+ private String ID;
+ /**
+ * 追踪ID
+ */
+ @TableField("TRACE_ID")
+ private String traceId;
+ /**
+ * 类型
+ */
+ @TableField("TYPE")
+ private String type;
+ /**
+ * 追踪消息体
+ */
+ @TableField("CONTENT")
+ private String content;
+ /**
+ * 创建时间
+ */
+ @TableField("CREATE_DATE")
+ private Date createDate;
+}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/repository/IDataHisRepository.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/repository/IDataHisRepository.java
new file mode 100644
index 0000000..d08202d
--- /dev/null
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/repository/IDataHisRepository.java
@@ -0,0 +1,9 @@
+package org.itkk.udf.api.common.repository;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.itkk.udf.api.common.entity.DataHisEntity;
+
+@Mapper
+public interface IDataHisRepository extends BaseMapper {
+}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/repository/IParameterRepository.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/repository/IParameterRepository.java
new file mode 100644
index 0000000..2af8871
--- /dev/null
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/repository/IParameterRepository.java
@@ -0,0 +1,10 @@
+package org.itkk.udf.api.common.repository;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.itkk.udf.api.common.entity.ParameterEntity;
+
+@Mapper
+public interface IParameterRepository extends BaseMapper {
+
+}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/repository/ITraceInfoRepository.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/repository/ITraceInfoRepository.java
new file mode 100644
index 0000000..2f6e400
--- /dev/null
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/repository/ITraceInfoRepository.java
@@ -0,0 +1,16 @@
+package org.itkk.udf.api.common.repository;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.itkk.udf.api.common.entity.TraceInfoEntity;
+
+@Mapper
+public interface ITraceInfoRepository extends BaseMapper {
+ /**
+ * 清理追踪日志
+ *
+ * @param traceLogKeepDays traceLogKeepDays
+ */
+ void clearTraceInfo(@Param("traceLogKeepDays") Integer traceLogKeepDays);
+}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/service/DataHisService.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/service/DataHisService.java
new file mode 100644
index 0000000..8c02a50
--- /dev/null
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/service/DataHisService.java
@@ -0,0 +1,42 @@
+package org.itkk.udf.api.common.service;
+
+import lombok.extern.slf4j.Slf4j;
+import org.itkk.udf.api.common.entity.DataHisEntity;
+import org.itkk.udf.api.common.repository.IDataHisRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.UUID;
+
+@Service
+@Slf4j
+public class DataHisService {
+
+ /**
+ * iDataHisRepository
+ */
+ @Autowired
+ private IDataHisRepository iDataHisRepository;
+
+ /**
+ * 保存
+ *
+ * @param traceId traceId
+ * @param name name
+ * @param pk pk
+ * @param content content
+ * @param userId userId
+ */
+ public void save(String traceId, String name, String pk, String content, String userId) {
+ DataHisEntity entity = new DataHisEntity();
+ entity.setId(UUID.randomUUID().toString());
+ entity.setTraceId(traceId);
+ entity.setTABLE_NAME(name);
+ entity.setTABLE_PK(pk);
+ entity.setContent(content);
+ entity.setCreateDate(new Date());
+ entity.setCreateBy(userId);
+ iDataHisRepository.insert(entity);
+ }
+}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/service/ParameterService.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/service/ParameterService.java
new file mode 100644
index 0000000..8e1baf2
--- /dev/null
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/service/ParameterService.java
@@ -0,0 +1,113 @@
+package org.itkk.udf.api.common.service;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.itkk.udf.api.common.entity.ParameterEntity;
+import org.itkk.udf.api.common.repository.IParameterRepository;
+import org.itkk.udf.starter.core.exception.ParameterValidException;
+import org.itkk.udf.starter.core.exception.SystemRuntimeException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Service
+public class ParameterService {
+
+ /**
+ * iParameterRepository
+ */
+ @Autowired
+ private IParameterRepository iParameterRepository;
+
+ /**
+ * internalObjectMapper
+ */
+ @Autowired
+ @Qualifier("internalObjectMapper")
+ private ObjectMapper internalObjectMapper;
+
+ /**
+ * 批量返回String类型的内容
+ *
+ * @param codes codes
+ * @return
+ */
+ public Map getStringBatch(List codes) {
+ //定义返回值
+ final Map rv = new HashMap<>();
+ //判空
+ if (CollectionUtils.isNotEmpty(codes)) {
+ //去重
+ codes = codes.stream().distinct().collect(Collectors.toList());
+ //遍历
+ codes.forEach(code -> {
+ try {
+ rv.put(code, this.getString(code));
+ } catch (Exception e) {
+ rv.put(code, e.getMessage());
+ }
+ });
+ }
+ //返回
+ return rv;
+ }
+
+ /**
+ * 返回String类型的内容
+ *
+ * @param code code
+ * @return String
+ */
+ public String getString(String code) {
+ return this.getContent(code);
+ }
+
+ /**
+ * 返回json类型的内容
+ *
+ * @param code code
+ * @param
+ * @return T
+ * @throws IOException IOException
+ */
+ public T getJson(String code, TypeReference typeReference) {
+ try {
+ //获得内容
+ String content = this.getContent(code);
+ //判空
+ if (StringUtils.isBlank(code)) {
+ return null;
+ }
+ //转换 & 返回
+ return internalObjectMapper.readValue(content, typeReference);
+ } catch (Exception e) {
+ throw new SystemRuntimeException(e);
+ }
+ }
+
+ /**
+ * 获得内容
+ *
+ * @param code code
+ * @return String
+ */
+ private String getContent(String code) {
+ //获得数据
+ ParameterEntity parameterEntity = iParameterRepository.selectById(code);
+ //判空
+ if (parameterEntity == null) {
+ throw new ParameterValidException("代码为" + code + "的变量不存在");
+ }
+ //返回
+ return parameterEntity.getContent();
+ }
+
+}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/service/TraceInfoService.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/service/TraceInfoService.java
new file mode 100644
index 0000000..bce7d46
--- /dev/null
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/service/TraceInfoService.java
@@ -0,0 +1,64 @@
+package org.itkk.udf.api.common.service;
+
+
+import lombok.extern.slf4j.Slf4j;
+import org.itkk.udf.api.common.CommonProperties;
+import org.itkk.udf.api.common.entity.TraceInfoEntity;
+import org.itkk.udf.api.common.repository.ITraceInfoRepository;
+import org.itkk.udf.starter.cache.db.service.DbCacheService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.UUID;
+
+@Service
+@Slf4j
+public class TraceInfoService {
+ /**
+ * iTraceInfoRepository
+ */
+ @Autowired
+ private ITraceInfoRepository iTraceInfoRepository;
+
+ /**
+ * dbCacheService
+ */
+ @Autowired
+ private DbCacheService dbCacheService;
+
+ /**
+ * commonProperties
+ */
+ @Autowired
+ private CommonProperties commonProperties;
+
+ /**
+ * 定时清理追踪日志
+ */
+ public void clearTraceInfo() {
+ iTraceInfoRepository.clearTraceInfo(commonProperties.getTraceLogKeepDays());
+ }
+
+ /**
+ * 保存log(异步)
+ *
+ * @param traceId traceId
+ * @param type type
+ * @param content content
+ */
+ @Async
+ @Transactional(propagation = Propagation.NOT_SUPPORTED)
+ public void save(String traceId, String type, String content) {
+ TraceInfoEntity traceInfoEntity = new TraceInfoEntity();
+ traceInfoEntity.setID(UUID.randomUUID().toString());
+ traceInfoEntity.setTraceId(traceId);
+ traceInfoEntity.setType(type);
+ traceInfoEntity.setContent(content);
+ traceInfoEntity.setCreateDate(new Date());
+ iTraceInfoRepository.insert(traceInfoEntity);
+ }
+}
diff --git a/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/web/ParameterBaseController.java b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/web/ParameterBaseController.java
new file mode 100644
index 0000000..421a2ae
--- /dev/null
+++ b/udf-api/udf-api-common/src/main/java/org/itkk/udf/api/common/web/ParameterBaseController.java
@@ -0,0 +1,69 @@
+package org.itkk.udf.api.common.web;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import org.itkk.udf.api.common.service.ParameterService;
+import org.itkk.udf.starter.core.RestResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.List;
+import java.util.Map;
+
+public abstract class ParameterBaseController {
+
+ /**
+ * parameterService
+ */
+ @Autowired
+ private ParameterService parameterService;
+
+ /**
+ * 批量返回String类型的内容
+ *
+ * @param codes codes
+ * @return RestResponse