| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System.Linq;
- using WeApp.BaseInfo;
- using WeApp.EF;
- using IwbZero.Authorization.Base.SystemInfo;
- namespace WeApp.SeedData
- {
- public class DefaultAppGuidsCreator
- {
- private readonly WeAppDbContext _context;
- public DefaultAppGuidsCreator(WeAppDbContext context)
- {
- _context = context;
- }
- public void Create()
- {
- _context.TruncateTable("[dbo].[Sys_AppGuids]");
- AddAppGuidIfNotExists((short)AppGuidType.UserNo);
- AddAppGuidIfNotExists((short)AppGuidType.Guest);
- AddAppGuidIfNotExists((short)AppGuidType.DataLib, 1000);
- }
- private void AddAppGuidIfNotExists(short type, int start = 100000, short step = 1)
- {
- if (_context.SysAppGuids.Any(s => s.IdType == type))
- return;
- _context.SysAppGuids.Add(new SysAppGuid()
- {
- IdType = type,
- LastId = start,
- Step = step,
- });
- _context.SaveChanges();
- }
- }
- }
|