用户导入
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Const;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DataEncryption;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.JsonSerialization;
|
||||
@@ -7,7 +11,9 @@ using JNPF.Systems.Entitys.Permission;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Npgsql.TypeHandlers;
|
||||
using SqlSugar;
|
||||
using Tnb.ProductionMgr.Entities.Entity;
|
||||
|
||||
namespace JNPF.Systems.Common;
|
||||
|
||||
@@ -89,5 +95,60 @@ public class TestService : IDynamicApiController, ITransient
|
||||
{
|
||||
return "测试成功";
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<string> insertUser()
|
||||
{
|
||||
List<TempErpUser> users = _sugar.Queryable<TempErpUser>().ToList();
|
||||
List<UserEntity> insertUsers = new List<UserEntity>();
|
||||
List<UserRelationEntity> insertUserRelations = new List<UserRelationEntity>();
|
||||
List<ErpExtendField> insertErpExtendFields = new List<ErpExtendField>();
|
||||
foreach (var user in users)
|
||||
{
|
||||
UserEntity userEntity = new UserEntity();
|
||||
userEntity.Id = SnowflakeIdHelper.NextId();
|
||||
userEntity.Account = user.code;
|
||||
userEntity.RealName = user.name;
|
||||
userEntity.Gender = 1;
|
||||
userEntity.OrganizeId = "25193668006933";
|
||||
userEntity.RoleId = "30327535942933";
|
||||
userEntity.Secretkey = Guid.NewGuid().ToString();
|
||||
userEntity.Password = MD5Encryption.Encrypt(MD5Encryption.Encrypt(CommonConst.DEFAULTPASSWORD) + userEntity.Secretkey);
|
||||
userEntity.EntryDate = DateTime.Now;
|
||||
userEntity.EnabledMark = 1;
|
||||
userEntity.CreatorTime = DateTime.Now;
|
||||
insertUsers.Add(userEntity);
|
||||
|
||||
UserRelationEntity userRelationEntity = new UserRelationEntity();
|
||||
userRelationEntity.Id = SnowflakeIdHelper.NextId();
|
||||
userRelationEntity.UserId = userEntity.Id;
|
||||
userRelationEntity.ObjectType = "Role";
|
||||
userRelationEntity.ObjectId = "30327535942933";
|
||||
userRelationEntity.CreatorTime = DateTime.Now;
|
||||
insertUserRelations.Add(userRelationEntity);
|
||||
|
||||
ErpExtendField extendField = new ErpExtendField();
|
||||
extendField.id = SnowflakeIdHelper.NextId();
|
||||
extendField.org_id = "25398501929509";
|
||||
extendField.table_name = "base_user";
|
||||
extendField.table_id = userEntity.Id;
|
||||
extendField.user_id = user.id;
|
||||
insertErpExtendFields.Add(extendField);
|
||||
}
|
||||
|
||||
await _sugar.Insertable(insertUsers).ExecuteCommandAsync();
|
||||
await _sugar.Insertable(insertUserRelations).ExecuteCommandAsync();
|
||||
await _sugar.Insertable(insertErpExtendFields).ExecuteCommandAsync();
|
||||
return "测试成功";
|
||||
}
|
||||
|
||||
|
||||
[SugarTable("temp_erp_user")]
|
||||
public class TempErpUser : BaseEntity<string>
|
||||
{
|
||||
public string code { get; set; }
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user