1. 新增公司與公司管理員時加入所有權限

This commit is contained in:
Kai 2021-07-15 10:46:06 +08:00
parent 2b40a22615
commit ae76f8eb68

View File

@ -328,9 +328,58 @@ namespace SolarPower.Controllers
"CreatedBy",
};
await roleRepository.AddAsync(role, roleProperties);
var roleId = await roleRepository.AddOneAsync(role, roleProperties);
#endregion
#region
var companyAuths = (await companyRepository.GetCompanyAuthByCompanyId(id)).Where(x=> x.CheckAuth == 0).Select(x => x.AuthCode).ToList();
List<CompanyAuth> insertCompanyAuths = new List<CompanyAuth>();
foreach (var checkAuth in companyAuths)
{
CompanyAuth companyAuth = new CompanyAuth();
companyAuth.CompanyId = id;
companyAuth.AuthCode = checkAuth;
companyAuth.CreatedBy = myUser.Id;
insertCompanyAuths.Add(companyAuth);
}
List<string> companyAuthProperties = new List<string>()
{
"CompanyId",
"AuthCode",
"CreatedBy",
};
await companyRepository.AddCompanyAuthAsync(insertCompanyAuths, companyAuthProperties);
#endregion
#region
List<RoleAuth> roleAuths = new List<RoleAuth>();
foreach (var checkAuth in companyAuths)
{
RoleAuth roleAuth = new RoleAuth();
roleAuth.Id = roleId;
roleAuth.AuthCode = checkAuth;
roleAuth.CreatedBy = myUser.Id;
roleAuths.Add(roleAuth);
}
List<string> roleAuthProperties = new List<string>()
{
"Id",
"AuthCode",
"CreatedBy",
};
await roleRepository.AddRoleAuthAsync(roleAuths, roleAuthProperties);
#endregion
#region DB及TableDB編號規則 solar_com_()exsolar_com0001
var siteDBFormat = "solar_com{0}_test";