소스 검색

chang message id data type from int to long

master
Savorboard 6 년 전
부모
커밋
1c0225e847
5개의 변경된 파일21개의 추가작업 그리고 17개의 파일을 삭제
  1. +5
    -1
      src/DotNetCore.CAP.MySql/MySqlStorage.cs
  2. +8
    -8
      src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs
  3. +2
    -2
      src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs
  4. +1
    -1
      src/DotNetCore.CAP/Dashboard/Monitoring/MessageDto.cs
  5. +5
    -5
      src/DotNetCore.CAP/IStorageConnection.cs

+ 5
- 1
src/DotNetCore.CAP.MySql/MySqlStorage.cs 파일 보기

@@ -81,7 +81,11 @@ CREATE TABLE IF NOT EXISTS `{prefix}.published` (
`ExpiresAt` datetime DEFAULT NULL,
`StatusName` varchar(40) NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `{prefix}.published` MODIFY Id BIGINT NOT NULL;
ALTER TABLE `{prefix}.received` MODIFY Id BIGINT NOT NULL;
";
return batchSql;
}



+ 8
- 8
src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs 파일 보기

@@ -30,7 +30,7 @@ namespace DotNetCore.CAP.MySql
return new MySqlStorageTransaction(this);
}

public async Task<CapPublishedMessage> GetPublishedMessageAsync(int id)
public async Task<CapPublishedMessage> GetPublishedMessageAsync(long id)
{
var sql = $@"SELECT * FROM `{_prefix}.published` WHERE `Id`={id};";

@@ -52,7 +52,7 @@ namespace DotNetCore.CAP.MySql
}
}

public Task StoreReceivedMessageAsync(CapReceivedMessage message)
public void StoreReceivedMessage(CapReceivedMessage message)
{
if (message == null)
{
@@ -60,16 +60,16 @@ namespace DotNetCore.CAP.MySql
}

var sql = $@"
INSERT INTO `{_prefix}.received`(`Name`,`Group`,`Content`,`Retries`,`Added`,`ExpiresAt`,`StatusName`)
VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";
INSERT INTO `{_prefix}.received`(`Id`,`Name`,`Group`,`Content`,`Retries`,`Added`,`ExpiresAt`,`StatusName`)
VALUES(@Id,@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";

using (var connection = new MySqlConnection(Options.ConnectionString))
{
return connection.ExecuteScalarAsync<int>(sql, message);
connection.Execute(sql, message);
}
}

public async Task<CapReceivedMessage> GetReceivedMessageAsync(int id)
public async Task<CapReceivedMessage> GetReceivedMessageAsync(long id)
{
var sql = $@"SELECT * FROM `{_prefix}.received` WHERE Id={id};";
using (var connection = new MySqlConnection(Options.ConnectionString))
@@ -89,7 +89,7 @@ VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";
}
}

public bool ChangePublishedState(int messageId, string state)
public bool ChangePublishedState(long messageId, string state)
{
var sql =
$"UPDATE `{_prefix}.published` SET `Retries`=`Retries`+1,`ExpiresAt`=NULL,`StatusName` = '{state}' WHERE `Id`={messageId}";
@@ -100,7 +100,7 @@ VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";
}
}

public bool ChangeReceivedState(int messageId, string state)
public bool ChangeReceivedState(long messageId, string state)
{
var sql =
$"UPDATE `{_prefix}.received` SET `Retries`=`Retries`+1,`ExpiresAt`=NULL,`StatusName` = '{state}' WHERE `Id`={messageId}";


+ 2
- 2
src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs 파일 보기

@@ -82,14 +82,14 @@ namespace DotNetCore.CAP.Dashboard

Routes.AddJsonResult("/published/message/(?<Id>.+)", x =>
{
var id = int.Parse(x.UriMatch.Groups["Id"].Value);
var id = long.Parse(x.UriMatch.Groups["Id"].Value);
var message = x.Storage.GetConnection().GetPublishedMessageAsync(id)
.GetAwaiter().GetResult();
return message.Content;
});
Routes.AddJsonResult("/received/message/(?<Id>.+)", x =>
{
var id = int.Parse(x.UriMatch.Groups["Id"].Value);
var id = long.Parse(x.UriMatch.Groups["Id"].Value);
var message = x.Storage.GetConnection().GetReceivedMessageAsync(id)
.GetAwaiter().GetResult();
return message.Content;


+ 1
- 1
src/DotNetCore.CAP/Dashboard/Monitoring/MessageDto.cs 파일 보기

@@ -7,7 +7,7 @@ namespace DotNetCore.CAP.Dashboard.Monitoring
{
public class MessageDto
{
public int Id { get; set; }
public long Id { get; set; }

public string Group { get; set; }



+ 5
- 5
src/DotNetCore.CAP/IStorageConnection.cs 파일 보기

@@ -19,7 +19,7 @@ namespace DotNetCore.CAP
/// Returns the message with the given id.
/// </summary>
/// <param name="id">The message's id.</param>
Task<CapPublishedMessage> GetPublishedMessageAsync(int id);
Task<CapPublishedMessage> GetPublishedMessageAsync(long id);

/// <summary>
/// Returns executed failed messages.
@@ -32,13 +32,13 @@ namespace DotNetCore.CAP
/// Stores the message.
/// </summary>
/// <param name="message">The message to store.</param>
Task StoreReceivedMessageAsync(CapReceivedMessage message);
void StoreReceivedMessage(CapReceivedMessage message);

/// <summary>
/// Returns the message with the given id.
/// </summary>
/// <param name="id">The message's id.</param>
Task<CapReceivedMessage> GetReceivedMessageAsync(int id);
Task<CapReceivedMessage> GetReceivedMessageAsync(long id);

/// <summary>
/// Returns executed failed message.
@@ -55,13 +55,13 @@ namespace DotNetCore.CAP
/// </summary>
/// <param name="messageId">Message id</param>
/// <param name="state">State name</param>
bool ChangePublishedState(int messageId, string state);
bool ChangePublishedState(long messageId, string state);

/// <summary>
/// Change specified message's state of received message
/// </summary>
/// <param name="messageId">Message id</param>
/// <param name="state">State name</param>
bool ChangeReceivedState(int messageId, string state);
bool ChangeReceivedState(long messageId, string state);
}
}

불러오는 중...
취소
저장