|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
using Furion.DataEncryption;
|
|
|
|
|
using Furion.Logging;
|
|
|
|
|
using Furion.TaskScheduler;
|
|
|
|
|
using Myshipping.Core.Const;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using SqlSugar;
|
|
|
|
@ -25,7 +26,7 @@ namespace Myshipping.Core.Job
|
|
|
|
|
Log.Information($"UserSyncWorker {DateTime.Now}");
|
|
|
|
|
|
|
|
|
|
var tenantId = 349708986646597L;
|
|
|
|
|
var roleId = 355651062833221L;//普通用户
|
|
|
|
|
//var roleId = 355651062833221L;//普通用户
|
|
|
|
|
var _sugerClient = App.GetService<ISqlSugarClient>();
|
|
|
|
|
_sugerClient.QueryFilter.Clear();
|
|
|
|
|
var _repPingTaiUser = App.GetService<SqlSugarRepository<PingTaiUser>>();
|
|
|
|
@ -35,7 +36,11 @@ namespace Myshipping.Core.Job
|
|
|
|
|
var _repOrg = App.GetService<SqlSugarRepository<SysOrg>>();
|
|
|
|
|
var _repPos = App.GetService<SqlSugarRepository<SysPos>>();
|
|
|
|
|
var _repEmpPos = App.GetService<SqlSugarRepository<SysEmpPos>>();
|
|
|
|
|
var _repUserRole = App.GetService<SqlSugarRepository<SysUserRole>>();
|
|
|
|
|
|
|
|
|
|
var _sysRoleService = App.GetService<ISysRoleService>();
|
|
|
|
|
var _sysUserRoleService = App.GetService<ISysUserRoleService>();
|
|
|
|
|
var _sysDataUserMenu = App.GetService<ISysDataUserMenu>();
|
|
|
|
|
|
|
|
|
|
var users = _repPingTaiUser.Where(u => u.CompId == "5913ab4b-ff5e-4d31-8b6c-09911bdfc0d4").ToList();
|
|
|
|
|
var sysUsers = _repUser.AsQueryable().Filter(null, true).Where(x => x.TenantId == tenantId).ToList();
|
|
|
|
|
Log.Information($"准备同步用户数据,共{users.Count}条");
|
|
|
|
@ -103,11 +108,31 @@ namespace Myshipping.Core.Job
|
|
|
|
|
empPos.SysPosId = pos.Id;
|
|
|
|
|
_repEmpPos.Insert(empPos);
|
|
|
|
|
|
|
|
|
|
//var userrole = new SysUserRole();
|
|
|
|
|
//userrole.SysRoleId = roleId;
|
|
|
|
|
//userrole.SysUserId = sysUser.Id;
|
|
|
|
|
//_repUserRole.Insert(userrole);
|
|
|
|
|
|
|
|
|
|
// 绑定角色:普通员工
|
|
|
|
|
long? roleId = _sysRoleService.GetRoleIdByRoleCode(CommonConst.ROLE_COMMON_EMPLOYEE).Result;
|
|
|
|
|
if (roleId != null)
|
|
|
|
|
{
|
|
|
|
|
_sysUserRoleService.GrantRole(new UpdateUserInput()
|
|
|
|
|
{
|
|
|
|
|
Id = sysUser.Id,
|
|
|
|
|
GrantRoleIdList = new List<long>() { (long)roleId }
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var userrole = new SysUserRole();
|
|
|
|
|
userrole.SysRoleId = roleId;
|
|
|
|
|
userrole.SysUserId = sysUser.Id;
|
|
|
|
|
_repUserRole.Insert(userrole);
|
|
|
|
|
// 授权"订舱台账"菜单的数据范围
|
|
|
|
|
var userMenuDto = new Service.User.Dto.SysDataUserMenuDto()
|
|
|
|
|
{
|
|
|
|
|
UserId = sysUser.Id,
|
|
|
|
|
childrens = new List<Service.User.Dto.children>() {
|
|
|
|
|
new(MenuConst.MenuBookingOrder, DataScopeType.DEPT_WITH_CHILD, true)
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
_sysDataUserMenu.GrantData(userMenuDto);
|
|
|
|
|
|
|
|
|
|
Log.Information($"新用户,插入:{sysUser.Name}");
|
|
|
|
|
}
|
|
|
|
|