xlog-client相关调整
This commit is contained in:
parent
0bad641aa0
commit
3b49dea114
37
pom.xml
37
pom.xml
@ -1,10 +1,6 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<modules>
|
||||
<module>xlog-api</module>
|
||||
<module>xlog-server</module>
|
||||
</modules>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.axzo.infra</groupId>
|
||||
@ -20,6 +16,11 @@
|
||||
<name>xlog</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<modules>
|
||||
<module>xlog-client</module>
|
||||
<module>xlog-server</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<mapstruct.version>1.4.2.Final</mapstruct.version>
|
||||
@ -48,10 +49,36 @@
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<!-- spring framework -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- axzo -->
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-common</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- validation -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- for test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
package cn.axzo.xlog.api;
|
||||
|
||||
import cn.axzo.xlog.api.dto.OperateLogReq;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/***
|
||||
* @author: pepsi
|
||||
* @description: TODO
|
||||
* @date: 2022/9/16
|
||||
*/
|
||||
@FeignClient(name = "xlog", url = "http://xlog:10999")
|
||||
public interface OperateLogApi {
|
||||
|
||||
@PostMapping("/api/operateLog/create")
|
||||
CommonResponse<Boolean> operateLogCreate(@RequestBody OperateLogReq req);
|
||||
|
||||
|
||||
}
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>xlog-api</artifactId>
|
||||
<artifactId>xlog-client</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>xlog-api</name>
|
||||
@ -22,24 +22,19 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -47,6 +42,11 @@
|
||||
<artifactId>axzo-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@ -0,0 +1,38 @@
|
||||
package cn.axzo.xlog.client;
|
||||
|
||||
import cn.axzo.xlog.client.feign.XLogApi;
|
||||
import cn.axzo.xlog.client.model.OperateLogQueryReq;
|
||||
import cn.axzo.xlog.client.model.OperateLogQueryResp;
|
||||
import cn.axzo.xlog.client.model.OperateLogReq;
|
||||
import cn.azxo.framework.common.model.CommonPageResponse;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/17
|
||||
* @Description:
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class XLogClient {
|
||||
|
||||
private final XLogApi xLogApi;
|
||||
|
||||
public Boolean createOperateLog(@Valid OperateLogReq req) {
|
||||
CommonResponse<Boolean> apiResult = xLogApi.operateLogCreate(req);
|
||||
if (apiResult.getCode() == 200) {
|
||||
return apiResult.getData();
|
||||
}
|
||||
throw new RuntimeException(apiResult.getMsg());
|
||||
}
|
||||
|
||||
public CommonPageResponse<OperateLogQueryResp> queryForPage(@Valid OperateLogQueryReq req) {
|
||||
CommonResponse<CommonPageResponse<OperateLogQueryResp>> apiResult = xLogApi.queryForPage(req);
|
||||
if (apiResult.getCode() == 200) {
|
||||
return apiResult.getData();
|
||||
}
|
||||
throw new RuntimeException(apiResult.getMsg());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package cn.axzo.xlog.client.config;
|
||||
|
||||
import cn.axzo.xlog.client.XLogClient;
|
||||
import cn.axzo.xlog.client.feign.XLogApi;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/17
|
||||
* @Description:
|
||||
*/
|
||||
@Configuration
|
||||
public class XLogClientAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public XLogClient xLogClient(XLogApi xLogApi) {
|
||||
return new XLogClient(xLogApi);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package cn.axzo.xlog.client.feign;
|
||||
|
||||
import cn.axzo.xlog.client.model.OperateLogQueryReq;
|
||||
import cn.axzo.xlog.client.model.OperateLogQueryResp;
|
||||
import cn.axzo.xlog.client.model.OperateLogReq;
|
||||
import cn.azxo.framework.common.model.CommonPageResponse;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/***
|
||||
* @author: pepsi
|
||||
* @description: TODO
|
||||
* @date: 2022/9/16
|
||||
*/
|
||||
@FeignClient(name = "xlog", url = "http://xlog:10999", fallbackFactory = XLogApiFallback.class)
|
||||
public interface XLogApi {
|
||||
|
||||
@PostMapping(value = "/api/operateLog/create", consumes = APPLICATION_JSON_VALUE)
|
||||
CommonResponse<Boolean> operateLogCreate(@RequestBody OperateLogReq req);
|
||||
|
||||
@PostMapping(value = "api/unified/operateLog/queryForPage", consumes = APPLICATION_JSON_VALUE)
|
||||
CommonResponse<CommonPageResponse<OperateLogQueryResp>> queryForPage(@RequestBody @Valid OperateLogQueryReq req);
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package cn.axzo.xlog.client.feign;
|
||||
|
||||
import cn.axzo.xlog.client.model.OperateLogQueryReq;
|
||||
import cn.axzo.xlog.client.model.OperateLogQueryResp;
|
||||
import cn.axzo.xlog.client.model.OperateLogReq;
|
||||
import cn.azxo.framework.common.model.CommonPageResponse;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/17
|
||||
* @Description:
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class XLogApiFallback implements XLogApi{
|
||||
|
||||
@Override
|
||||
public CommonResponse<Boolean> operateLogCreate(OperateLogReq req) {
|
||||
log.error("创建操作日志失败,请求参数req={}", JSON.toJSONString(req));
|
||||
return CommonResponse.error("创建操作日志失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<CommonPageResponse<OperateLogQueryResp>> queryForPage(OperateLogQueryReq req) {
|
||||
log.error("分页查询操作日志失败,请求参数req={}", JSON.toJSONString(req));
|
||||
return CommonResponse.error("分页查询操作日志失败");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package cn.axzo.xlog.client.model;
|
||||
|
||||
import cn.axzo.core.domain.PageRequest;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : liuchuntao
|
||||
* @date : 2022/6/28 20:08
|
||||
* @description : 操作日志请求参数
|
||||
*/
|
||||
@Data
|
||||
public class OperateLogQueryReq extends PageRequest {
|
||||
|
||||
/**
|
||||
* 调用方服务名
|
||||
*/
|
||||
private String serviceName;
|
||||
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
private String operateUserName;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
private List<String> featureCodes;
|
||||
|
||||
/**
|
||||
* 功能name
|
||||
*/
|
||||
private String featureName;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 工作台Id
|
||||
*/
|
||||
@JsonIgnore
|
||||
private Long workspaceId;
|
||||
|
||||
/**
|
||||
* 单位Id
|
||||
*/
|
||||
@JsonIgnore
|
||||
private Long ouId;
|
||||
|
||||
/**
|
||||
* 身份Id
|
||||
*/
|
||||
@JsonIgnore
|
||||
private Long identityId;
|
||||
|
||||
/**
|
||||
* 身份类型
|
||||
*/
|
||||
@JsonIgnore
|
||||
private Integer identityType;
|
||||
|
||||
/**
|
||||
* 操作类型 1:add 2:add_batch 3:update 4:update_batch 5:delete 6:delete_batch
|
||||
*/
|
||||
private Integer operateType;
|
||||
|
||||
/**
|
||||
* 操作表名
|
||||
*/
|
||||
private String operateTable;
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package cn.axzo.xlog.client.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author : liuchuntao
|
||||
* @date : 2022/6/28 20:08
|
||||
* @description : 操作日志响应
|
||||
*/
|
||||
@Data
|
||||
public class OperateLogQueryResp {
|
||||
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
private String operateUserName;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
private String featureCode;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
private String featureName;
|
||||
|
||||
/**
|
||||
* 事件摘要
|
||||
*/
|
||||
private String contentSummary;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date operateTime;
|
||||
|
||||
/**
|
||||
* 操作人手机号
|
||||
*/
|
||||
private String operateUserPhone;
|
||||
|
||||
/**
|
||||
* 所属单位名称
|
||||
*/
|
||||
private String ouName;
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.xlog.api.dto;
|
||||
package cn.axzo.xlog.client.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -37,7 +37,7 @@ public class OperateLogReq {
|
||||
private String featureName;
|
||||
|
||||
/**
|
||||
* 日志等级 为空默认P4 请参照 {@link cn.axzo.xlog.api.enums.LogGradeEnum}
|
||||
* 日志等级 为空默认P4 请参照 {@link cn.axzo.xlog.client.enums.LogGradeEnum}
|
||||
*/
|
||||
private Integer logGrade = 4;
|
||||
|
||||
@ -55,7 +55,7 @@ public class OperateLogReq {
|
||||
|
||||
/**
|
||||
* 人员类型 1:工人 2:班组长 3:从业人员..实际情况拓展
|
||||
* 请参照 {@link cn.axzo.xlog.api.enums.IdentityType}
|
||||
* 请参照 {@link cn.axzo.xlog.client.enums.IdentityType}
|
||||
*/
|
||||
@NotNull(message = "人员类型身份不能为空")
|
||||
private Integer identityType;
|
||||
2
xlog-client/src/main/resources/META-INF/spring.factories
Normal file
2
xlog-client/src/main/resources/META-INF/spring.factories
Normal file
@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
cn.axzo.xlog.client.config.XLogClientAutoConfiguration
|
||||
@ -26,23 +26,11 @@
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- spring framework -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- validation -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
@ -53,13 +41,6 @@
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- axzo -->
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-common</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.xlog</groupId>
|
||||
<artifactId>xlog-api</artifactId>
|
||||
@ -80,12 +61,6 @@
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
@ -100,23 +75,14 @@
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>1.4.2.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>1.4.2.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- for test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.xlog.server.config;
|
||||
|
||||
import cn.axzo.xlog.api.dto.OperateLogReq;
|
||||
import cn.axzo.xlog.client.model.OperateLogReq;
|
||||
import cn.axzo.xlog.server.service.OperateLogService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.rabbitmq.client.Channel;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.xlog.server.controller.api;
|
||||
|
||||
import cn.axzo.xlog.api.dto.OperateLogReq;
|
||||
import cn.axzo.xlog.client.model.OperateLogReq;
|
||||
import cn.axzo.xlog.server.exception.ServiceException;
|
||||
import cn.axzo.xlog.server.service.OperateLogService;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.xlog.server.service;
|
||||
|
||||
import cn.axzo.xlog.api.dto.OperateLogReq;
|
||||
import cn.axzo.xlog.client.model.OperateLogReq;
|
||||
import cn.axzo.xlog.server.entity.OperateLogRecordEntity;
|
||||
|
||||
/***
|
||||
|
||||
@ -9,7 +9,7 @@ import cn.axzo.basics.organizational.api.vo.response.OrganizationalUnitVO;
|
||||
import cn.axzo.basics.profiles.api.UserProfileServiceApi;
|
||||
import cn.axzo.basics.profiles.dto.basic.IdentityProfileDto;
|
||||
import cn.axzo.pudge.core.service.ServiceException;
|
||||
import cn.axzo.xlog.api.dto.OperateLogReq;
|
||||
import cn.axzo.xlog.client.model.OperateLogReq;
|
||||
import cn.axzo.xlog.server.entity.OperateLogRecordEntity;
|
||||
import cn.axzo.xlog.server.enums.IdentityType;
|
||||
import cn.axzo.xlog.server.repository.OperateLogRepository;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.xlog.server.config;
|
||||
|
||||
import cn.axzo.xlog.api.dto.OperateLogReq;
|
||||
import cn.axzo.xlog.client.model.OperateLogReq;
|
||||
import cn.axzo.xlog.server.XlogApplicationTestBase;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.xlog.server.service;
|
||||
|
||||
import cn.axzo.xlog.api.dto.OperateLogReq;
|
||||
import cn.axzo.xlog.client.dto.OperateLogReq;
|
||||
import cn.axzo.xlog.server.XlogApplicationTestBase;
|
||||
import cn.axzo.xlog.server.entity.OperateLogRecordEntity;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user