schangxiang@126.com
2024-09-04 9242d0da6005e070b0197a26b12ba24d1361466d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using Furion;
using Microsoft.Extensions.DependencyInjection;
using Yitter.IdGenerator;
 
namespace iWare.Wms.Web.Core
{
    /// <summary>
    /// 雪花id
    /// </summary>
    internal static class SnowflakeIdServiceExtension
    {
        public static void AddSnowflakeId(this IServiceCollection services)
        {
            // 设置雪花Id的workerId,确保每个实例workerId都应不同
            var workerId = ushort.Parse(App.Configuration["SnowId:WorkerId"] ?? "1");
            YitIdHelper.SetIdGenerator(new IdGeneratorOptions { WorkerId = workerId });
        }
    }
}