From 7480fee9df22bf8e541adfd155312506591814b5 Mon Sep 17 00:00:00 2001 From: Kai Date: Sun, 13 Jun 2021 18:46:10 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9myUser=20=E8=B3=87?= =?UTF-8?q?=E6=96=99=202.=20=E5=85=AC=E5=8F=B8=E7=AE=A1=E7=90=86=E4=B8=8A?= =?UTF-8?q?=E5=82=B3=E5=9C=96=E7=89=87=203.=20=E5=8A=A0=E5=85=A5=E9=9B=BB?= =?UTF-8?q?=E7=AB=99=E8=B3=87=E8=A8=8A=E9=A0=81=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Controllers/CompanyController.cs | 179 +++++++++- SolarPower/Controllers/MyBaseController.cs | 19 +- .../Controllers/PowerStationController.cs | 21 ++ SolarPower/Models/Company.cs | 18 +- SolarPower/Models/MyBaseModel.cs | 4 +- SolarPower/Models/Role.cs | 8 + SolarPower/Models/Share.cs | 4 +- .../Repository/Implement/CompanyRepository.cs | 123 ++++++- .../Repository/Implement/RoleRepository.cs | 41 ++- .../Interface/ICompanyRepository.cs | 23 +- .../Repository/Interface/IRoleRepository.cs | 10 +- SolarPower/Views/Company/Index.cshtml | 88 ++++- SolarPower/Views/PowerStation/Index.cshtml | 324 ++++++++++++++++++ .../PowerStation/PowerStationEdit.cshtml | 84 +++++ .../Views/PowerStation/_DeviceSetting.cshtml | 72 ++++ .../Views/PowerStation/_Operation.cshtml | 64 ++++ .../Views/PowerStation/_StationInfo.cshtml | 256 ++++++++++++++ .../Views/PowerStation/_UploadImage.cshtml | 182 ++++++++++ SolarPower/Views/Shared/_Layout.cshtml | 14 +- SolarPower/Views/User/Index.cshtml | 9 +- SolarPower/Views/User/_RoleManager.cshtml | 4 +- SolarPower/Views/User/_UserManager.cshtml | 2 +- SolarPower/appsettings.Development.json | 8 +- SolarPower/wwwroot/css/site.css | 7 - .../wwwroot/css/themes/cust-theme-15.css | 4 +- .../wwwroot/css/themes/cust-theme-15.css.map_ | 1 + SolarPower/wwwroot/css/vendors.bundle.css | 6 +- SolarPower/wwwroot/img/blank.gif | Bin 0 -> 2997 bytes .../img/card-backgrounds/cover-3-lg.png | Bin 39414 -> 36410 bytes .../img/demo/avatars/avatar-admin-lg.png | Bin 10715 -> 2684 bytes .../wwwroot/img/demo/avatars/avatar-admin.png | Bin 2968 -> 1167 bytes .../{20210611090212.png => 2.png} | Bin .../wwwroot/upload/company_logo/default.png | Bin 0 -> 2650 bytes 33 files changed, 1508 insertions(+), 67 deletions(-) create mode 100644 SolarPower/Controllers/PowerStationController.cs create mode 100644 SolarPower/Views/PowerStation/Index.cshtml create mode 100644 SolarPower/Views/PowerStation/PowerStationEdit.cshtml create mode 100644 SolarPower/Views/PowerStation/_DeviceSetting.cshtml create mode 100644 SolarPower/Views/PowerStation/_Operation.cshtml create mode 100644 SolarPower/Views/PowerStation/_StationInfo.cshtml create mode 100644 SolarPower/Views/PowerStation/_UploadImage.cshtml create mode 100644 SolarPower/wwwroot/css/themes/cust-theme-15.css.map_ create mode 100644 SolarPower/wwwroot/img/blank.gif rename SolarPower/wwwroot/upload/company_logo/{20210611090212.png => 2.png} (100%) create mode 100644 SolarPower/wwwroot/upload/company_logo/default.png diff --git a/SolarPower/Controllers/CompanyController.cs b/SolarPower/Controllers/CompanyController.cs index 7773f67..7296b44 100644 --- a/SolarPower/Controllers/CompanyController.cs +++ b/SolarPower/Controllers/CompanyController.cs @@ -5,6 +5,7 @@ using SolarPower.Models.Company; using SolarPower.Repository.Interface; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Threading.Tasks; @@ -13,10 +14,16 @@ namespace SolarPower.Controllers public class CompanyController : MyBaseController { private readonly ICompanyRepository companyRepository; + private string logoPath = "/upload/company_logo/"; + private string logoSaveAsPath = ""; public CompanyController(ICompanyRepository companyRepository) : base() { this.companyRepository = companyRepository; + + var xxx = Directory.GetCurrentDirectory(); + + logoSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "company_logo"); } public IActionResult Index() @@ -70,8 +77,18 @@ namespace SolarPower.Controllers companies = await companyRepository.GetAllByFilterAsync(post); - foreach(var company in companies) + foreach (var company in companies) { + //替換logo src + if (!string.IsNullOrEmpty(company.Logo)) + { + company.Logo = logoPath + company.Logo; + } + else + { + company.Logo = logoPath + "default.png"; + } + //找出當前狀態正常使用者人數 var registerNumber = await companyRepository.GetNormalUserNumberByCompanyIdAsync(company.Id); @@ -79,8 +96,8 @@ namespace SolarPower.Controllers //if(mySimpleCompany.Id == 1) //{ - company.Function = @" - 權限池 + company.Function = @" + "; //} @@ -159,7 +176,7 @@ namespace SolarPower.Controllers /// /// [HttpPost] - public async Task> SaveCompany(PostCompany post) + public async Task> SaveCompany([FromForm] PostCompany post) { ApiResult apiResult = new ApiResult(); @@ -184,21 +201,22 @@ namespace SolarPower.Controllers //先檢查統編是否已被使用 var exist = await companyRepository.GetOneNormalSimpleCompanyByTaxIDNumber(post.TaxIDNumber); - if(exist != null) + if (exist != null) { apiResult.Code = "9995"; apiResult.Msg = errorCode.GetString(apiResult.Code); return apiResult; } + + company = new Company() { Name = post.Name, - //Logo = post.Logo, TaxIDNumber = post.TaxIDNumber, Phone = post.Phone, Address = post.Address, - RegisterUpperLimit= post.RegisterUpperLimit, + RegisterUpperLimit = post.RegisterUpperLimit, CreatedBy = myUser.Id }; @@ -212,7 +230,36 @@ namespace SolarPower.Controllers "CreatedBy", }; - await companyRepository.AddAsync(company, properties); + var id = await companyRepository.AddAsync(company, properties); + + //處裡公司Logo圖片 + if (post.LogoFile != null) + { + var split = post.LogoFile.FileName.Split("."); + var fileName = id + "." + split[split.Length - 1]; + + var fullPath = Path.Combine(logoSaveAsPath, fileName); + + using (var stream = new FileStream(fullPath, FileMode.Create)) + { + post.LogoFile.CopyTo(stream); + } + + UpdateCompany updateCompany = new UpdateCompany() + { + Id = id, + Logo = fileName + }; + + properties = new List() + { + "Id", + "Logo" + }; + + await companyRepository.UpdateCompany(updateCompany, properties); + } + apiResult.Code = "0000"; apiResult.Msg = "儲存成功"; #endregion @@ -223,7 +270,7 @@ namespace SolarPower.Controllers //先檢查統編是否已被使用 var exist = await companyRepository.GetOneNormalSimpleCompanyByTaxIDNumber(post.TaxIDNumber); - if(exist != null && exist.Id != company.Id) + if (exist != null && exist.Id != company.Id) { apiResult.Code = "9995"; apiResult.Msg = errorCode.GetString(apiResult.Code); @@ -242,7 +289,6 @@ namespace SolarPower.Controllers UpdatedBy = myUser.Id, }; - List properties = new List() { "Id", @@ -256,6 +302,34 @@ namespace SolarPower.Controllers await companyRepository.UpdateCompany(update, properties); + //處裡公司Logo圖片 + if (post.LogoFile != null) + { + var split = post.LogoFile.FileName.Split("."); + var fileName = company.Id + "." + split[split.Length - 1]; + + var fullPath = Path.Combine(logoSaveAsPath, fileName); + + using (var stream = new FileStream(fullPath, FileMode.Create)) + { + post.LogoFile.CopyTo(stream); + } + + update = new UpdateCompany() + { + Id = company.Id, + Logo = fileName + }; + + properties = new List() + { + "Id", + "Logo" + }; + + await companyRepository.UpdateCompany(update, properties); + } + apiResult.Code = "0000"; apiResult.Msg = "儲存成功"; #endregion @@ -319,16 +393,15 @@ namespace SolarPower.Controllers /// public async Task GetCompanyAuthByCompanyId(int id) { - ApiResult> apiResult = new ApiResult>(); + ApiResult> apiResult = new ApiResult>(); int totalRecords = 0; //總資料筆數 int recFilter = 0; //過濾後資料筆數 - List companyAuths = null; + List companyAuths = null; try { - companyAuths = await companyRepository.GetCompanyAuthByCompanyId(id); totalRecords = companyAuths.Count(); @@ -355,6 +428,86 @@ namespace SolarPower.Controllers return result; } + public async Task> SaveCompanyAuth(PostCompanyAuth post) + { + ApiResult apiResult = new ApiResult(); + + Company company = null; + + try + { + company = await companyRepository.GetOneAsync(post.SelectedCompanyId); + + if (company == null) + { + apiResult.Code = "9996"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + + List origCompanyAuths = null; //原先的公司權限池 + + origCompanyAuths = await companyRepository.GetCompanyAuthByCompanyId(post.SelectedCompanyId); + + origCompanyAuths = origCompanyAuths.Where(x => x.CheckAuth == 1).ToList(); + + //判斷新進來的資料是否要歸類到新增 or 刪除 + #region 刪除公司權限池 + + //找出要刪除的 + List deletedCompanyAuthStrs = origCompanyAuths.Where(x => !post.CheckAuths.Contains(x.AuthCode)).Select(x => new CompanyAuth { CompanyId = company.Id, AuthCode = x.AuthCode }).ToList(); + + //刪除權限池 + await companyRepository.PurgeCompanyAuth(deletedCompanyAuthStrs); + + //同時刪除該公司底下擁有這些權限的角色 + await companyRepository.PurgeCompanyRoleAuth(company.Id, deletedCompanyAuthStrs); + + #endregion + + #region 新增公司權限池 + + //找出要新增的 + List insertCompanyAuthStrs = post.CheckAuths.Where(x => !origCompanyAuths.Select(y => y.AuthCode).Contains(x)).ToList(); + + List insertCompanyAuths = new List(); + + foreach (var checkAuth in insertCompanyAuthStrs) + { + CompanyAuth companyAuth = new CompanyAuth(); + companyAuth.CompanyId = company.Id; + companyAuth.AuthCode = checkAuth; + companyAuth.CreatedBy = myUser.Id; + + insertCompanyAuths.Add(companyAuth); + } + + List properties = new List() + { + "CompanyId", + "AuthCode", + "CreatedBy", + }; + + await companyRepository.AddCompanyAuthAsync(insertCompanyAuths, properties); + + #endregion + + apiResult.Code = "0000"; + apiResult.Msg = "儲存成功"; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + string json = System.Text.Json.JsonSerializer.Serialize(post); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + json); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + /// /// 透過公司編號,取得該公司剩餘可註冊的人數 /// diff --git a/SolarPower/Controllers/MyBaseController.cs b/SolarPower/Controllers/MyBaseController.cs index 00357ff..b151f80 100644 --- a/SolarPower/Controllers/MyBaseController.cs +++ b/SolarPower/Controllers/MyBaseController.cs @@ -30,6 +30,7 @@ namespace SolarPower.Controllers protected ILogger Logger => _logger ?? (_logger = HttpContext?.RequestServices.GetService>()); private IUserRepository userRepository => HttpContext?.RequestServices.GetService(); private ICompanyRepository companyRepository => HttpContext?.RequestServices.GetService(); + private IRoleRepository roleRepository => HttpContext?.RequestServices.GetService(); private IOperatorLogRepository operatorLogRepository => HttpContext?.RequestServices.GetService(); protected MyUser myUser = null; @@ -62,10 +63,26 @@ namespace SolarPower.Controllers //取得當前登入使用者資訊 myUser = userRepository.GetMyUserInfoByAccount(myAccount); myUser.Company = companyRepository.GetMyCompanyInfoById(myUser.CompanyId); + myUser.Role = roleRepository.GetMyRoleInfoById(myUser.RoleId); + + List auth_arr = new List(); + if (myUser.IsGod != 1 || myUser.Role.Layer != 0) //判斷是否神級使用者或平台管理員 + { + foreach (var auth in myUser.Role.Auths) + { + var per_auch_arr = auth.Split(','); + foreach (var x in per_auch_arr) + { + auth_arr.Add(x); + } + } + + ViewBag.auths = auth_arr; + } ViewBag.myUser = myUser; - #region 記錄人員操作紀錄 + #region 記錄人員操作記錄 var content = JsonConvert.SerializeObject(filterContext.ActionArguments); OperatorLog operatorLog = new OperatorLog() diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs new file mode 100644 index 0000000..cd93cba --- /dev/null +++ b/SolarPower/Controllers/PowerStationController.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace SolarPower.Controllers +{ + public class PowerStationController : Controller + { + public IActionResult Index() + { + return View(); + } + + public IActionResult Edit() + { + return View("~/Views/PowerStation/PowerStationEdit.cshtml"); + } + } +} diff --git a/SolarPower/Models/Company.cs b/SolarPower/Models/Company.cs index 2f80274..a54fd59 100644 --- a/SolarPower/Models/Company.cs +++ b/SolarPower/Models/Company.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.AspNetCore.Http; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -79,12 +80,13 @@ namespace SolarPower.Models.Company public string Phone { get; set; } //手機 public string Address { get; set; } //地址 public int RegisterUpperLimit { get; set; } //註冊上限 + public IFormFile LogoFile { get; set; } //公司logo } /// /// 公司權限池 /// - public class CompanyAuth + public class CompanyAuthDataTable { public string AuthCode { get; set; } public string MainName { get; set; } @@ -92,4 +94,16 @@ namespace SolarPower.Models.Company public string ControlName { get; set; } public byte CheckAuth { get; set; } } + + public class PostCompanyAuth + { + public int SelectedCompanyId { get; set; } + public List CheckAuths { get; set; } + } + + public class CompanyAuth : Created + { + public int CompanyId { get; set; } + public string AuthCode { get; set; } + } } diff --git a/SolarPower/Models/MyBaseModel.cs b/SolarPower/Models/MyBaseModel.cs index 1eda4e8..72cee8f 100644 --- a/SolarPower/Models/MyBaseModel.cs +++ b/SolarPower/Models/MyBaseModel.cs @@ -41,6 +41,7 @@ namespace SolarPower.Models public int RoleId { get; set; } //角色編號 public string Email { get; set; } public MyCompany Company { get; set; } //公司資訊 + public MyRole Role { get; set; } //角色資訊 } /// @@ -59,6 +60,7 @@ namespace SolarPower.Models { public int Id { get; set; } public string Name { get; set; } //名稱 - public List Auth { get; set; } //可操作頁面 + public byte Layer { get; set; } //角色層級 + public List Auths { get; set; } //可操作頁面 } } diff --git a/SolarPower/Models/Role.cs b/SolarPower/Models/Role.cs index e857cf4..dcf78bd 100644 --- a/SolarPower/Models/Role.cs +++ b/SolarPower/Models/Role.cs @@ -5,6 +5,14 @@ using System.Threading.Tasks; namespace SolarPower.Models.Role { + public enum RoleLayerEnum : byte + { + PlatformAdmin = 0, //平台管理員 + PlatformUser = 1, //平台使用者 + CompanyAdmin = 2, //公司管理員 + CompanyUser = 3 //公司使用者 + } + public class Role : Created { public int Id { get; set; } diff --git a/SolarPower/Models/Share.cs b/SolarPower/Models/Share.cs index 928534d..a08b94c 100644 --- a/SolarPower/Models/Share.cs +++ b/SolarPower/Models/Share.cs @@ -186,11 +186,11 @@ namespace SolarPower.Models /// 回傳結果 /// /// 資料型別 - public class ApiResult + public class ApiResult { public string Code { get; set; } public string Msg { get; set; } - public T Data { get; set; } + public S1 Data { get; set; } } public class DapperConnection diff --git a/SolarPower/Repository/Implement/CompanyRepository.cs b/SolarPower/Repository/Implement/CompanyRepository.cs index 14e9023..d458c77 100644 --- a/SolarPower/Repository/Implement/CompanyRepository.cs +++ b/SolarPower/Repository/Implement/CompanyRepository.cs @@ -2,6 +2,7 @@ using SolarPower.Helper; using SolarPower.Models; using SolarPower.Models.Company; +using SolarPower.Models.Role; using SolarPower.Models.User; using SolarPower.Repository.Interface; using System; @@ -264,9 +265,14 @@ namespace SolarPower.Repository.Implement } } - public async Task> GetCompanyAuthByCompanyId(int companyId) + /// + /// 透過公司編號,取得該公司的權限池 + /// + /// + /// + public async Task> GetCompanyAuthByCompanyId(int companyId) { - List result; + List result; using (IDbConnection conn = this._databaseHelper.GetConnection()) { conn.Open(); @@ -274,13 +280,12 @@ namespace SolarPower.Repository.Implement { var sql = @$"SELECT ap.*, - CASE WHEN cap_id.ComapnyId IS NOT NULL THEN 1 ELSE 0 END AS CheckAuth + CASE WHEN cap_id.CompanyId IS NOT NULL THEN 1 ELSE 0 END AS CheckAuth FROM auth_page ap - LEFT JOIN (SELECT * FROM company_auth_page WHERE ComapnyId = @ComapnyId) - cap_id ON ap.AuthCode = cap_id.AuthCode + LEFT JOIN (SELECT * FROM company_auth_page WHERE CompanyId = @CompanyId) cap_id ON ap.AuthCode = cap_id.AuthCode "; - result = (await conn.QueryAsync(sql, new { CompanyId = companyId })).ToList(); + result = (await conn.QueryAsync(sql, new { CompanyId = companyId })).ToList(); } catch (Exception exception) { @@ -293,5 +298,111 @@ namespace SolarPower.Repository.Implement return result; } } + + /// + /// 實際刪除公司權限池 + /// + /// + /// + public async Task PurgeCompanyAuth(List companyAuths) + { + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + var sql = $"DELETE FROM company_auth_page WHERE CompanyId = @CompanyId AND AuthCode = @AuthCode"; + + await conn.ExecuteAsync(sql, companyAuths, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + } + } + + /// + /// 實際刪除公司權限池 + /// + /// + /// + public async Task PurgeCompanyRoleAuth(int companyId, List companyAuths) + { + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + //找出該公司底下有該權限的角色 + var auths = companyAuths.Select(x => x.AuthCode).ToList(); + + var sqlRole = @$"SELECT ra.Id, ra.AuthCode FROM role_auth ra + LEFT JOIN role r ON ra.Id = r.Id + WHERE r.CompanyId = @CompanyId AND ra.AuthCode IN @AuthCode"; + + var roles = (await conn.QueryAsync(sqlRole, new { CompanyId = companyId, AuthCode = auths }, trans)).ToList(); + + var sql = $"DELETE FROM role_auth WHERE Id = @Id AND AuthCode = @AuthCode"; + + await conn.ExecuteAsync(sql, roles, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + } + } + + /// + /// 新增公司權限池 + /// + /// + /// + /// + public async Task AddCompanyAuthAsync(List entity, List properties) + { + int count; + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + try + { + string sql = $"INSERT INTO company_auth_page (CompanyId, AuthCode, CreatedBy) VALUES (@CompanyId, @AuthCode, @CreatedBy)"; + + count = await conn.ExecuteAsync(sql, entity); + } + catch (Exception exception) + { + throw exception; + } + finally + { + conn.Close(); + } + + return count; + } + } } } diff --git a/SolarPower/Repository/Implement/RoleRepository.cs b/SolarPower/Repository/Implement/RoleRepository.cs index f29fb83..6e0a291 100644 --- a/SolarPower/Repository/Implement/RoleRepository.cs +++ b/SolarPower/Repository/Implement/RoleRepository.cs @@ -1,5 +1,6 @@ using Dapper; using SolarPower.Helper; +using SolarPower.Models; using SolarPower.Models.Role; using SolarPower.Repository.Interface; using System; @@ -41,6 +42,42 @@ namespace SolarPower.Repository.Implement } } + /// + /// 取得當前使用者的角色資訊 + /// + /// + /// + public MyRole GetMyRoleInfoById(int id) + { + MyRole result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + conn.Open(); + try + { + var sql = $"SELECT * FROM {tableName} WHERE Deleted = 0 AND Id = @Id"; + + result = conn.QueryFirstOrDefault(sql, new { Id = id }); + + //查詢該角色可使用的權限 + var sql_auth = @"SELECT ControlName FROM role_auth ra + LEFT JOIN auth_page ap ON ra.AuthCode = ap.AuthCode + WHERE ra.Id = @Id"; + + result.Auths = conn.Query(sql_auth, new { Id = id }).ToList(); + } + catch (Exception exception) + { + throw exception; + } + finally + { + conn.Close(); + } + return result; + } + } + /// /// 取得單一公司角色,須為Deleted: 0 /// @@ -223,10 +260,10 @@ namespace SolarPower.Repository.Implement var sql = @$"SELECT ap2.AuthCode, ap2.MainName, ap2.SubName FROM ( - SELECT cap.ComapnyId, cap.AuthCode, ap.MainName, ap.SubName, ap.ControlName + SELECT cap.CompanyId, cap.AuthCode, ap.MainName, ap.SubName, ap.ControlName FROM company_auth_page cap LEFT JOIN auth_page ap ON cap.AuthCode = ap.AuthCode - WHERE cap.ComapnyId = @CompanyId + WHERE cap.CompanyId = @CompanyId ) ap2 LEFT JOIN role_auth ra ON ap2.AuthCode = ra.AuthCode AND ra.Id = @RoleId WHERE ra.AuthCode IS NULL diff --git a/SolarPower/Repository/Interface/ICompanyRepository.cs b/SolarPower/Repository/Interface/ICompanyRepository.cs index 496c984..2ce4dc5 100644 --- a/SolarPower/Repository/Interface/ICompanyRepository.cs +++ b/SolarPower/Repository/Interface/ICompanyRepository.cs @@ -72,6 +72,27 @@ namespace SolarPower.Repository.Interface /// /// /// - Task> GetCompanyAuthByCompanyId(int companyId); + Task> GetCompanyAuthByCompanyId(int companyId); + + /// + /// 實際刪除公司權限池 + /// + /// + /// + Task PurgeCompanyAuth(List companyAuths); + + /// + /// 實際刪除公司角色擁有的權限 + /// + /// + /// + Task PurgeCompanyRoleAuth(int companyId, List companyAuths); + + /// + /// 新增公司權限池 + /// + /// + /// + Task AddCompanyAuthAsync(List entity, List properties); } } diff --git a/SolarPower/Repository/Interface/IRoleRepository.cs b/SolarPower/Repository/Interface/IRoleRepository.cs index 95e5fd6..dd27801 100644 --- a/SolarPower/Repository/Interface/IRoleRepository.cs +++ b/SolarPower/Repository/Interface/IRoleRepository.cs @@ -1,4 +1,5 @@ -using SolarPower.Models.Role; +using SolarPower.Models; +using SolarPower.Models.Role; using System; using System.Collections.Generic; using System.Linq; @@ -8,6 +9,13 @@ namespace SolarPower.Repository.Interface { public interface IRoleRepository : IRepositoryBase { + /// + /// 取得當前使用者的角色資訊 + /// + /// + /// + MyRole GetMyRoleInfoById(int id); + /// /// 取得下拉式公司角色選單,須為Deleted: 0 /// diff --git a/SolarPower/Views/Company/Index.cshtml b/SolarPower/Views/Company/Index.cshtml index 4fc5edd..4670445 100644 --- a/SolarPower/Views/Company/Index.cshtml +++ b/SolarPower/Views/Company/Index.cshtml @@ -121,6 +121,11 @@ + +
+ + +
@@ -146,7 +151,6 @@ + \ No newline at end of file diff --git a/SolarPower/Views/PowerStation/_Operation.cshtml b/SolarPower/Views/PowerStation/_Operation.cshtml new file mode 100644 index 0000000..cf9f2f3 --- /dev/null +++ b/SolarPower/Views/PowerStation/_Operation.cshtml @@ -0,0 +1,64 @@ +
+

運維資料

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
廠商類別廠商聯絡人電話email建立日期建立人功能
施工台達電林先生0928-123456lin@tdd.com.tw2021/06/02周杰倫 + +
清洗潔寶暴風女0928-654321storm@mavel.com2021/06/03周杰倫 + +
維運華碩雷神索爾0937-123123thor@asus.com2021/06/04周杰倫 + +
+
+
\ No newline at end of file diff --git a/SolarPower/Views/PowerStation/_StationInfo.cshtml b/SolarPower/Views/PowerStation/_StationInfo.cshtml new file mode 100644 index 0000000..4b3b997 --- /dev/null +++ b/SolarPower/Views/PowerStation/_StationInfo.cshtml @@ -0,0 +1,256 @@ +
+
+ +
+ +
電站基本資料
+ +
+
+
+
+

電站代碼 

+

PEP-NTP001

+
+
+

電站名稱:

+

新竹巨城站

+
+
+

是否為代管 :

+

+

+ + +
+

+
+
+

台電掛錶日 

+

2018-12-26

+
+
+

預計回收年限:

+

20

+
+
+

資料建立:

+

蜘蛛人

+
+
+ +
+
+

電廠發電容量 
(kW)

+

362.7

+
+
+

運維人員:

+

美國隊長
鋼鐵人

+
+
+

被代管公司 :

+

台達電

+
+
+

授電費率:

+

PM060MW2_305

+
+
+

座標:

+

25.0726625,
121.5725953

+
+
+

建立時間:

+

2018-10-01 12:00

+
+
+ +
+
+
逆變器
+
+
+

廠牌:AUO

+
+
+

型號 :PM060MW2_305

+
+
+

數量:400

+
+
+
+
+
光電板
+
+
+

廠牌:ABLYTEK

+
+
+

規格 :1640×992×40

+
+
+

數量:1116

+
+
+

型號 :6MN6A295

+
+
+
+
+ +
+
+ + +
+
+
+ +
+ +
經濟部能源局與台電資訊
+ +
+
+
+
+
經濟部能源局
+
+
+

能源局同意檔案:台北市內湖區中山路一段1001號

+
+
+

折扣率 :2018-01-01

+
+
+

能源局設備登記編號:25.0726625,121.5725953

+
+
+

租金比例 (%) 10

+
+
+
+
+
台電資訊
+
+
+

契約編號 鋼鐵人

+
+
+

售電期限(年) 20

+
+
+

正式購電日 2018-10-01

+
+
+

簽約日期 0828-123456

+
+
+

每期抄錶日 10日

+
+
+

正式售電日 2018-10-01



+

資料建立:蜘蛛人

+

建立時間:2018-10-01 12:00

+
+
+
+
+
+
+ + +
+
+
+ +
+ +
土地房屋資料
+ +
+
+
+
+

地址 台北市內湖區中山路一段1001號

+

經緯度 25.0726625,121.5725953

+
+
+

租約公證日期 新竹巨城站

+

租金比例 (%) 10

+
+
+

地主姓名 鋼鐵人

+

電話 0828-123456

+
+
+

房屋用途 工廠

+
+
+

資料建立 蜘蛛人

+

建立時間 2018-10-01 12:00

+
+
+
+
+
+
+
+

地址 台北市內湖區中山路一段1001號

+

經緯度 25.0726625,121.5725953

+
+
+

租約公證日期 新竹巨城站

+

租金比例 (%) 10

+
+
+

地主姓名 鋼鐵人

+

電話 0828-123456

+
+
+

房屋用途 工廠

+
+
+

資料建立 蜘蛛人

+

建立時間 2018-10-01 12:00

+
+
+
+
+
+
+ +
+
+ +
+ + +
\ No newline at end of file diff --git a/SolarPower/Views/PowerStation/_UploadImage.cshtml b/SolarPower/Views/PowerStation/_UploadImage.cshtml new file mode 100644 index 0000000..347e177 --- /dev/null +++ b/SolarPower/Views/PowerStation/_UploadImage.cshtml @@ -0,0 +1,182 @@ +
+
+ +
+ +
圖片上傳
+ +
+
+
+
+
+ ... + + + +
+
+ + +
+
+
+
+
+
+ ... +
+
+ + +
+
+
+
+
+
+ ... +
+
+ + +
+
+
+
+
+
+ ... +
+
+ + +
+
+
+
+
+
+ ... +
+
+ + +
+
+
+
+ +
+
+ +
+
+
+
+
+ Drop files here or click to upload. +
+ This is just a demo dropzone. Selected files are not actually uploaded. +
+
+
+ +
+
+ +
+
+ +
+ +
單線圖
+ +
+
+
+
+
+ ... + + + +
+
+ + +
+
+
+
+
+
+ ... +
+
+ + +
+
+
+
+
+
+ ... +
+
+ + +
+
+
+
+
+
+ ... +
+
+ + +
+
+
+
+
+
+ ... +
+
+ + +
+
+
+
+ +
+
+ +
+
+
+
+
+ Drop files here or click to upload. +
+ This is just a demo dropzone. Selected files are not actually uploaded. +
+
+
+ +
+ +
\ No newline at end of file diff --git a/SolarPower/Views/Shared/_Layout.cshtml b/SolarPower/Views/Shared/_Layout.cshtml index d6a111c..02c0d7d 100644 --- a/SolarPower/Views/Shared/_Layout.cshtml +++ b/SolarPower/Views/Shared/_Layout.cshtml @@ -27,6 +27,8 @@ + + @@ -39,7 +41,7 @@