syntax = "proto3";
option go_package = "./pb";

package pb;

import "models/rpc_messages.proto";
import "models/model_log.proto";

service LogService {
	// 创建日志
	rpc createLog (CreateLogRequest) returns (CreateLogResponse);

	// 计算日志数量
	rpc countLogs (CountLogRequest) returns (RPCCountResponse);

	// 列出单页日志
	rpc listLogs (ListLogsRequest) returns (ListLogsResponse);

	// 删除单条
	rpc deleteLogPermanently (DeleteLogPermanentlyRequest) returns (RPCSuccess);

	// 批量删除
	rpc deleteLogsPermanently (DeleteLogsPermanentlyRequest) returns (RPCSuccess);

	// 清理
	rpc cleanLogsPermanently (CleanLogsPermanentlyRequest) returns (RPCSuccess);

	// 计算日志容量大小
	rpc sumLogsSize (SumLogsSizeRequest) returns (SumLogsResponse);
}

// 创建日志
message CreateLogRequest {
	string level = 1;
	string description = 2;
	string action = 3;
	string ip = 4;
}

message CreateLogResponse {

}

// 计算日志数量
message CountLogRequest {
	string dayFrom = 1;
	string dayTo = 2;
	string keyword = 3;
	string userType = 4; // admin|user
}

// 列出单页日志
message ListLogsRequest {
	int64 offset = 1;
	int64 size = 2;
	string dayFrom = 3;
	string dayTo = 4;
	string keyword = 5;
	string userType = 6;
}

message ListLogsResponse {
	repeated Log logs = 1;
}

// 删除单条
message DeleteLogPermanentlyRequest {
	int64 logId = 1;
}

// 批量删除
message DeleteLogsPermanentlyRequest {
	repeated int64 logIds = 1;
}

// 清理
message CleanLogsPermanentlyRequest {
	int32 days = 1;
	bool clearAll = 2;
}

// 计算日志容量大小
message SumLogsSizeRequest {

}

message SumLogsResponse {
	int64 sizeBytes = 1;
}