mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-09 15:51:52 +08:00
将 login_log、error_log 迁移到 yudao-core-service 项目中
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.infra.service.logger;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.iocoder.yudao.coreservice.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiAccessLogCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.service.logger.impl.InfApiAccessLogCoreServiceImpl;
|
||||
import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
/**
|
||||
* {@link InfApiAccessLogCoreServiceImpl} 单元测试
|
||||
*/
|
||||
@Import(InfApiAccessLogCoreServiceImpl.class)
|
||||
public class InfApiAccessLogCoreServiceTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private InfApiAccessLogCoreService apiAccessLogCoreService;
|
||||
|
||||
@Resource
|
||||
private InfApiAccessLogCoreMapper apiAccessLogCoreMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateApiAccessLogAsync() {
|
||||
// 准备参数
|
||||
ApiAccessLogCreateDTO createDTO = RandomUtils.randomPojo(ApiAccessLogCreateDTO.class,
|
||||
dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()));
|
||||
|
||||
// 调用
|
||||
apiAccessLogCoreService.createApiAccessLogAsync(createDTO);
|
||||
// 断言
|
||||
InfApiAccessLogDO infApiAccessLogDO = apiAccessLogCoreMapper.selectOne(null);
|
||||
assertNotNull(infApiAccessLogDO);
|
||||
assertPojoEquals(createDTO, infApiAccessLogDO);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.infra.service.logger;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.iocoder.yudao.coreservice.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiErrorLogCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.service.logger.impl.InfApiErrorLogCoreServiceImpl;
|
||||
import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
/**
|
||||
* {@link InfApiErrorLogCoreServiceImpl} 单元测试
|
||||
*/
|
||||
@Import(InfApiErrorLogCoreServiceImpl.class)
|
||||
public class InfApiErrorLogCoreServiceTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private InfApiErrorLogCoreService apiErrorLogCoreService;
|
||||
|
||||
@Resource
|
||||
private InfApiErrorLogCoreMapper infApiErrorLogCoreMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateApiErrorLogAsync() {
|
||||
// 准备参数
|
||||
ApiErrorLogCreateDTO createDTO = RandomUtils.randomPojo(ApiErrorLogCreateDTO.class,
|
||||
dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()));
|
||||
|
||||
// 调用
|
||||
apiErrorLogCoreService.createApiErrorLogAsync(createDTO);
|
||||
// 断言
|
||||
InfApiErrorLogDO infApiErrorLogDO = infApiErrorLogCoreMapper.selectOne(null);
|
||||
assertNotNull(infApiErrorLogDO);
|
||||
assertPojoEquals(createDTO, infApiErrorLogDO);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1 @@
|
||||
package cn.iocoder.yudao.coreservice.modules.infra.service;
|
@@ -1,4 +1,6 @@
|
||||
-- inf 开头的 DB
|
||||
DELETE FROM "inf_api_access_log";
|
||||
DELETE FROM "inf_api_error_log";
|
||||
|
||||
-- sys 开头的 DB
|
||||
DELETE FROM "sys_user_session";
|
||||
|
@@ -33,3 +33,58 @@ CREATE TABLE IF NOT EXISTS "sys_dict_data" (
|
||||
"deleted" bit NOT NULL DEFAULT FALSE,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '字典数据表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "inf_api_access_log" (
|
||||
"id" bigint not null GENERATED BY DEFAULT AS IDENTITY,
|
||||
"trace_id" varchar(64) not null default '',
|
||||
"user_id" bigint not null default '0',
|
||||
"user_type" tinyint not null default '0',
|
||||
"application_name" varchar(50) not null,
|
||||
"request_method" varchar(16) not null default '',
|
||||
"request_url" varchar(255) not null default '',
|
||||
"request_params" varchar(8000) not null default '',
|
||||
"user_ip" varchar(50) not null,
|
||||
"user_agent" varchar(512) not null,
|
||||
"begin_time" timestamp not null,
|
||||
"end_time" timestamp not null,
|
||||
"duration" integer not null,
|
||||
"result_code" integer not null default '0',
|
||||
"result_msg" varchar(512) default '',
|
||||
"creator" varchar(64) default '',
|
||||
"create_time" timestamp not null default current_timestamp,
|
||||
"updater" varchar(64) default '',
|
||||
"update_time" timestamp not null default current_timestamp,
|
||||
"deleted" bit not null default false,
|
||||
primary key ("id")
|
||||
) COMMENT 'API 访问日志表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "inf_api_error_log" (
|
||||
"id" integer not null GENERATED BY DEFAULT AS IDENTITY,
|
||||
"trace_id" varchar(64) not null,
|
||||
"user_id" bigint not null default '0',
|
||||
"user_type" tinyint not null default '0',
|
||||
"application_name" varchar(50) not null,
|
||||
"request_method" varchar(16) not null,
|
||||
"request_url" varchar(255) not null,
|
||||
"request_params" varchar(8000) not null,
|
||||
"user_ip" varchar(50) not null,
|
||||
"user_agent" varchar(512) not null,
|
||||
"exception_time" timestamp not null,
|
||||
"exception_name" varchar(128) not null default '',
|
||||
"exception_message" clob not null,
|
||||
"exception_root_cause_message" clob not null,
|
||||
"exception_stack_trace" clob not null,
|
||||
"exception_class_name" varchar(512) not null,
|
||||
"exception_file_name" varchar(512) not null,
|
||||
"exception_method_name" varchar(512) not null,
|
||||
"exception_line_number" integer not null,
|
||||
"process_status" tinyint not null,
|
||||
"process_time" timestamp default null,
|
||||
"process_user_id" bigint default '0',
|
||||
"creator" varchar(64) default '',
|
||||
"create_time" timestamp not null default current_timestamp,
|
||||
"updater" varchar(64) default '',
|
||||
"update_time" timestamp not null default current_timestamp,
|
||||
"deleted" bit not null default false,
|
||||
primary key ("id")
|
||||
) COMMENT '系统异常日志';
|
||||
|
Reference in New Issue
Block a user