1. 修改資料庫連線
2. 加入db schema 3. 修改權限
This commit is contained in:
parent
2185e4c3dd
commit
7e9614c6ad
5
SolarPower/.config/dotnet-tools.json
Normal file
5
SolarPower/.config/dotnet-tools.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"isRoot": true,
|
||||||
|
"tools": {}
|
||||||
|
}
|
||||||
@ -27,8 +27,6 @@ namespace SolarPower.Controllers
|
|||||||
this.companyRepository = companyRepository;
|
this.companyRepository = companyRepository;
|
||||||
this.roleRepository = roleRepository;
|
this.roleRepository = roleRepository;
|
||||||
|
|
||||||
var xxx = Directory.GetCurrentDirectory();
|
|
||||||
|
|
||||||
logoSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "company_logo");
|
logoSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "company_logo");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +46,16 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var companySelectItemLists = await companyRepository.GetCompanySelectOptionListAsync();
|
var companySelectItemLists = new List<CompanySelectItemList>();
|
||||||
|
|
||||||
|
if (myUser.IsGod != 1 && !IsPlatformLayer(myUser.Role.Layer))
|
||||||
|
{
|
||||||
|
companySelectItemLists = await companyRepository.GetCompanySelectOptionListAsync(myUser.CompanyId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
companySelectItemLists = await companyRepository.GetCompanySelectOptionListAsync(0);
|
||||||
|
}
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = companySelectItemLists;
|
apiResult.Data = companySelectItemLists;
|
||||||
@ -175,6 +182,16 @@ namespace SolarPower.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//替換logo src
|
||||||
|
if (!string.IsNullOrEmpty(company.Logo))
|
||||||
|
{
|
||||||
|
company.Logo = logoPath + company.Logo;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
company.Logo = logoPath + "default.png";
|
||||||
|
}
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = company;
|
apiResult.Data = company;
|
||||||
|
|
||||||
@ -515,6 +532,8 @@ namespace SolarPower.Controllers
|
|||||||
#region 新增公司權限池
|
#region 新增公司權限池
|
||||||
|
|
||||||
//找出要新增的
|
//找出要新增的
|
||||||
|
if (post.CheckAuths != null)
|
||||||
|
{
|
||||||
List<string> insertCompanyAuthStrs = post.CheckAuths.Where(x => !origCompanyAuths.Select(y => y.AuthCode).Contains(x)).ToList();
|
List<string> insertCompanyAuthStrs = post.CheckAuths.Where(x => !origCompanyAuths.Select(y => y.AuthCode).Contains(x)).ToList();
|
||||||
|
|
||||||
List<CompanyAuth> insertCompanyAuths = new List<CompanyAuth>();
|
List<CompanyAuth> insertCompanyAuths = new List<CompanyAuth>();
|
||||||
@ -537,7 +556,7 @@ namespace SolarPower.Controllers
|
|||||||
};
|
};
|
||||||
|
|
||||||
await companyRepository.AddCompanyAuthAsync(insertCompanyAuths, properties);
|
await companyRepository.AddCompanyAuthAsync(insertCompanyAuths, properties);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
|
|||||||
@ -93,6 +93,12 @@ namespace SolarPower.Controllers
|
|||||||
CreatedBy = myUser.Id,
|
CreatedBy = myUser.Id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
List<string> removeParam = new List<string>() { "ChangePassword" }; //移除不紀錄參數的actionName
|
||||||
|
if (removeParam.Any(x => actionName.Contains(x)))
|
||||||
|
{
|
||||||
|
operatorLog.Parameter = "{}";
|
||||||
|
}
|
||||||
|
|
||||||
List<string> properties = new List<string>()
|
List<string> properties = new List<string>()
|
||||||
{
|
{
|
||||||
"ControllerName",
|
"ControllerName",
|
||||||
|
|||||||
@ -69,6 +69,19 @@ namespace SolarPower.Controllers
|
|||||||
totalRecords = roles.Count();
|
totalRecords = roles.Count();
|
||||||
recFilter = roles.Count();
|
recFilter = roles.Count();
|
||||||
|
|
||||||
|
foreach(var role in roles)
|
||||||
|
{
|
||||||
|
if(role.Layer == (int)RoleLayerEnum.PlatformAdmin || role.Layer == (int)RoleLayerEnum.CompanyAdmin)
|
||||||
|
{ //管理階層的角色無法被刪除
|
||||||
|
role.Function = "<button class='btn btn-primary edit-btn'>修改</button>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
role.Function = @"<button class='btn btn-primary edit-btn'>修改</button>
|
||||||
|
<button class='btn btn-danger del-btn'>刪除</button>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = roles;
|
apiResult.Data = roles;
|
||||||
}
|
}
|
||||||
@ -156,15 +169,31 @@ namespace SolarPower.Controllers
|
|||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(myUser.IsGod != 1 && !IsPlatformLayer(myUser.Role.Layer) && myUser.CompanyId != post.SelectedCompanyId)
|
||||||
|
{ //非超級使用者或平台人員,就只能新增自己公司的角色
|
||||||
|
apiResult.Code = "9993";
|
||||||
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
#region 新增公司角色
|
#region 新增公司角色
|
||||||
role = new Role()
|
role = new Role()
|
||||||
{
|
{
|
||||||
CompanyId = post.SelectedCompanyId,
|
CompanyId = post.SelectedCompanyId,
|
||||||
Name = post.Name,
|
Name = post.Name,
|
||||||
Layer = 3,
|
|
||||||
CreatedBy = myUser.Id,
|
CreatedBy = myUser.Id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (IsPlatformLayer(myUser.Role.Layer))
|
||||||
|
{ //平台新增角色 Layer,為平台使用者階層
|
||||||
|
role.Layer = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ //公司新增角色 Layer,為公司使用者階層
|
||||||
|
role.Layer = 3;
|
||||||
|
}
|
||||||
|
|
||||||
List<string> properties = new List<string>()
|
List<string> properties = new List<string>()
|
||||||
{
|
{
|
||||||
"CompanyId",
|
"CompanyId",
|
||||||
@ -182,6 +211,14 @@ namespace SolarPower.Controllers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#region 修改公司角色
|
#region 修改公司角色
|
||||||
|
|
||||||
|
if (myUser.IsGod != 1 && !IsPlatformLayer(myUser.Role.Layer) && myUser.CompanyId != post.SelectedCompanyId)
|
||||||
|
{ //非超級使用者或平台人員,就只能修改自己公司的角色
|
||||||
|
apiResult.Code = "9993";
|
||||||
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateRole update = new UpdateRole()
|
UpdateRole update = new UpdateRole()
|
||||||
{
|
{
|
||||||
Id = post.Id,
|
Id = post.Id,
|
||||||
|
|||||||
@ -20,6 +20,7 @@ namespace SolarPower.Controllers
|
|||||||
{
|
{
|
||||||
|
|
||||||
private readonly IUserRepository userRepository;
|
private readonly IUserRepository userRepository;
|
||||||
|
private string logoPath = "/upload/company_logo/";
|
||||||
public UserController(IUserRepository userRepository) : base()
|
public UserController(IUserRepository userRepository) : base()
|
||||||
{
|
{
|
||||||
this.userRepository = userRepository;
|
this.userRepository = userRepository;
|
||||||
@ -175,7 +176,7 @@ namespace SolarPower.Controllers
|
|||||||
{
|
{
|
||||||
apiResult.Code = "9999";
|
apiResult.Code = "9999";
|
||||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
Logger.LogError("【" + controllerName + "/" + actionName + "】");
|
||||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,13 +294,21 @@ namespace SolarPower.Controllers
|
|||||||
#region 新增使用者
|
#region 新增使用者
|
||||||
EDFunction edFunction = new EDFunction();
|
EDFunction edFunction = new EDFunction();
|
||||||
|
|
||||||
|
//隨機產生亂數密碼
|
||||||
|
Random random = new Random((int)DateTime.Now.Ticks);
|
||||||
|
const string chars = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789";
|
||||||
|
string random_password = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(chars.Length)]).ToArray());
|
||||||
|
|
||||||
|
//TODO 新增的密碼要寄信
|
||||||
|
random_password = edFunction.GetSHA256Encryption(random_password);
|
||||||
|
|
||||||
user = new User()
|
user = new User()
|
||||||
{
|
{
|
||||||
CompanyId = post.CompanyId,
|
CompanyId = post.CompanyId,
|
||||||
Name = post.Name,
|
Name = post.Name,
|
||||||
Email = post.Email,
|
Email = post.Email,
|
||||||
Account = post.Account,
|
Account = post.Account,
|
||||||
Password = edFunction.GetSHA256Encryption(post.Account),
|
Password = random_password,
|
||||||
RoleId = post.RoleId,
|
RoleId = post.RoleId,
|
||||||
Phone = post.Phone,
|
Phone = post.Phone,
|
||||||
CreatedBy = myUser.Id,
|
CreatedBy = myUser.Id,
|
||||||
|
|||||||
240
SolarPower/DBSchema/solar_power_schema.sql
Normal file
240
SolarPower/DBSchema/solar_power_schema.sql
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
-- --------------------------------------------------------
|
||||||
|
-- 主機: 127.0.0.1
|
||||||
|
-- 伺服器版本: 10.5.6-MariaDB - mariadb.org binary distribution
|
||||||
|
-- 伺服器作業系統: Win64
|
||||||
|
-- HeidiSQL 版本: 11.2.0.6213
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET NAMES utf8 */;
|
||||||
|
/*!50503 SET NAMES utf8mb4 */;
|
||||||
|
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||||
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||||
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||||
|
|
||||||
|
|
||||||
|
-- 傾印 solar_power 的資料庫結構
|
||||||
|
CREATE DATABASE IF NOT EXISTS `solar_power` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */;
|
||||||
|
USE `solar_power`;
|
||||||
|
|
||||||
|
-- 傾印 資料表 solar_power.auth_page 結構
|
||||||
|
CREATE TABLE IF NOT EXISTS `auth_page` (
|
||||||
|
`AuthCode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||||
|
`MainName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '大項名稱',
|
||||||
|
`SubName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '功能名稱',
|
||||||
|
`ControlName` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`AuthCode`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='設定權限頁面';
|
||||||
|
|
||||||
|
-- 正在傾印表格 solar_power.auth_page 的資料:~-1 rows (近似值)
|
||||||
|
DELETE FROM `auth_page`;
|
||||||
|
|
||||||
|
|
||||||
|
-- 傾印 資料表 solar_power.company 結構
|
||||||
|
CREATE TABLE IF NOT EXISTS `company` (
|
||||||
|
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除,0:否 1:是',
|
||||||
|
`Status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '狀態,0:凍結 1:正常',
|
||||||
|
`Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '公司名稱',
|
||||||
|
`Logo` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '公司logo',
|
||||||
|
`TaxIDNumber` varchar(8) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '統一編號',
|
||||||
|
`Phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電話',
|
||||||
|
`Address` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址',
|
||||||
|
`RegisterUpperLimit` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '註冊上限',
|
||||||
|
`SPStationAmount` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '太陽能電站數量',
|
||||||
|
`RelationalDB` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '公司各自資料庫',
|
||||||
|
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
|
||||||
|
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
|
||||||
|
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者',
|
||||||
|
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '修改時間',
|
||||||
|
PRIMARY KEY (`Id`),
|
||||||
|
KEY `IDX_01` (`Deleted`,`Status`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='公司資料';
|
||||||
|
|
||||||
|
-- 正在傾印表格 solar_power.company 的資料:~-1 rows (近似值)
|
||||||
|
DELETE FROM `company`;
|
||||||
|
/*!40000 ALTER TABLE `company` DISABLE KEYS */;
|
||||||
|
/*!40000 ALTER TABLE `company` ENABLE KEYS */;
|
||||||
|
|
||||||
|
-- 傾印 資料表 solar_power.company_auth_page 結構
|
||||||
|
CREATE TABLE IF NOT EXISTS `company_auth_page` (
|
||||||
|
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`CompanyId` int(10) unsigned NOT NULL,
|
||||||
|
`AuthCode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
`CreatedBy` int(10) unsigned DEFAULT NULL,
|
||||||
|
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
PRIMARY KEY (`Id`),
|
||||||
|
KEY `IDX_01` (`CompanyId`,`AuthCode`) USING BTREE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='公司擁有的權限池';
|
||||||
|
|
||||||
|
-- 正在傾印表格 solar_power.company_auth_page 的資料:~-1 rows (近似值)
|
||||||
|
DELETE FROM `company_auth_page`;
|
||||||
|
/*!40000 ALTER TABLE `company_auth_page` DISABLE KEYS */;
|
||||||
|
/*!40000 ALTER TABLE `company_auth_page` ENABLE KEYS */;
|
||||||
|
|
||||||
|
-- 傾印 資料表 solar_power.operator_log 結構
|
||||||
|
CREATE TABLE IF NOT EXISTS `operator_log` (
|
||||||
|
`Id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`ControllerName` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
`ActionName` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
`Parameter` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
`CreatedBy` int(10) unsigned DEFAULT NULL,
|
||||||
|
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
PRIMARY KEY (`Id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='操作紀錄';
|
||||||
|
|
||||||
|
|
||||||
|
-- 傾印 資料表 solar_power.power_station 結構
|
||||||
|
CREATE TABLE IF NOT EXISTS `power_station` (
|
||||||
|
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除, 0:否 1:是',
|
||||||
|
`CompanyId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '公司編號',
|
||||||
|
`Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名稱',
|
||||||
|
`Code` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電站代碼,縣市+區域+流水號 ',
|
||||||
|
`IsEscrow` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否為代管,0:否 1:是',
|
||||||
|
`EscrowName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '代管名稱',
|
||||||
|
`ElectricityMeterAt` timestamp NULL DEFAULT NULL COMMENT '台電掛錶日',
|
||||||
|
`EstimatedRecoveryTime` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '預估回收時間',
|
||||||
|
`GeneratingCapacity` decimal(10,1) NOT NULL DEFAULT 0.0 COMMENT '電廠發電容量,單位(千瓦)',
|
||||||
|
`PowerRate` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '受電費率',
|
||||||
|
`Coordinate` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '座標',
|
||||||
|
`InverterBrand` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '逆變器廠牌',
|
||||||
|
`InverterProductModel` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '逆變器型號',
|
||||||
|
`InverterAmount` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '逆變器數量',
|
||||||
|
`PhotovoltaicPanelBrand` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '光電板廠牌',
|
||||||
|
`PhotovoltaicPanelProductModel` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '光電板型號',
|
||||||
|
`PhotovoltaicPanelSpecification` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '光電板規格',
|
||||||
|
`PhotovoltaicPanelAmount` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '光電板數量',
|
||||||
|
`BoEFile` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '能源局檔案',
|
||||||
|
`BoEDiscountRate` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '能源局折扣率',
|
||||||
|
`BoEDeviceRegisterNumber` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '能源局設備登記編號',
|
||||||
|
`BoERentRatio` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '能源局租金比率,單位(%)',
|
||||||
|
`TPCContractNumber` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '台電契約編號',
|
||||||
|
`TPCContractAt` timestamp NULL DEFAULT NULL COMMENT '台電簽約日期',
|
||||||
|
`TPCSellDeadline` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '台電售電期限,單位(年)',
|
||||||
|
`TPCMeterReading` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '台電每期抄錶日',
|
||||||
|
`TPCPurchaseElectricityAt` timestamp NULL DEFAULT NULL COMMENT '台電正式購電日',
|
||||||
|
`TPCSellElectricityAt` timestamp NULL DEFAULT NULL COMMENT '台電正式售電日',
|
||||||
|
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
|
||||||
|
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
|
||||||
|
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者',
|
||||||
|
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '修改時間',
|
||||||
|
PRIMARY KEY (`Id`),
|
||||||
|
KEY `IDX_01` (`Deleted`),
|
||||||
|
KEY `IDX_02` (`CompanyId`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='電站資料';
|
||||||
|
|
||||||
|
-- 正在傾印表格 solar_power.power_station 的資料:~-1 rows (近似值)
|
||||||
|
DELETE FROM `power_station`;
|
||||||
|
/*!40000 ALTER TABLE `power_station` DISABLE KEYS */;
|
||||||
|
/*!40000 ALTER TABLE `power_station` ENABLE KEYS */;
|
||||||
|
|
||||||
|
-- 傾印 資料表 solar_power.role 結構
|
||||||
|
CREATE TABLE IF NOT EXISTS `role` (
|
||||||
|
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除, 0:否 1:是',
|
||||||
|
`CompanyId` int(10) NOT NULL,
|
||||||
|
`Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '角色名稱',
|
||||||
|
`Layer` tinyint(4) NOT NULL DEFAULT -1 COMMENT '角色層級,0:平台(FIC)超級使用者 1:平台(FIC)使用者 2:公司管理員 3:公司一般人員',
|
||||||
|
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
|
||||||
|
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
|
||||||
|
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者',
|
||||||
|
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '修改時間',
|
||||||
|
PRIMARY KEY (`Id`),
|
||||||
|
KEY `IDX_01` (`Deleted`),
|
||||||
|
KEY `IDX_02` (`CompanyId`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='角色資料';
|
||||||
|
|
||||||
|
-- 正在傾印表格 solar_power.role 的資料:~-1 rows (近似值)
|
||||||
|
DELETE FROM `role`;
|
||||||
|
/*!40000 ALTER TABLE `role` DISABLE KEYS */;
|
||||||
|
/*!40000 ALTER TABLE `role` ENABLE KEYS */;
|
||||||
|
|
||||||
|
-- 傾印 資料表 solar_power.role_auth 結構
|
||||||
|
CREATE TABLE IF NOT EXISTS `role_auth` (
|
||||||
|
`Id` int(10) unsigned NOT NULL,
|
||||||
|
`AuthCode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||||
|
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
|
||||||
|
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
|
||||||
|
PRIMARY KEY (`Id`,`AuthCode`) USING BTREE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='角色權限';
|
||||||
|
|
||||||
|
-- 正在傾印表格 solar_power.role_auth 的資料:~-1 rows (近似值)
|
||||||
|
DELETE FROM `role_auth`;
|
||||||
|
/*!40000 ALTER TABLE `role_auth` DISABLE KEYS */;
|
||||||
|
/*!40000 ALTER TABLE `role_auth` ENABLE KEYS */;
|
||||||
|
|
||||||
|
-- 傾印 資料表 solar_power.user 結構
|
||||||
|
CREATE TABLE IF NOT EXISTS `user` (
|
||||||
|
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除, 0:否 1:是',
|
||||||
|
`Status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '狀態,0:凍結 1:正常',
|
||||||
|
`Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '姓名',
|
||||||
|
`Account` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '帳號',
|
||||||
|
`Password` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '密碼',
|
||||||
|
`IsGod` tinyint(3) unsigned NOT NULL DEFAULT 0 COMMENT '是否為超級使用者。1:是;0:否',
|
||||||
|
`CompanyId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '公司編號',
|
||||||
|
`DepartmentId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '部門編號',
|
||||||
|
`RoleId` int(10) unsigned DEFAULT 0 COMMENT '權限角色編號',
|
||||||
|
`JobTitle` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '職稱',
|
||||||
|
`Phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手機',
|
||||||
|
`Tel` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '市話',
|
||||||
|
`Email` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電子信箱',
|
||||||
|
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
|
||||||
|
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
|
||||||
|
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者',
|
||||||
|
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '修改時間',
|
||||||
|
PRIMARY KEY (`Id`) USING BTREE,
|
||||||
|
KEY `IDX_01` (`Deleted`,`Status`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='使用者資料表';
|
||||||
|
|
||||||
|
-- 正在傾印表格 solar_power.user 的資料:~-1 rows (近似值)
|
||||||
|
DELETE FROM `user`;
|
||||||
|
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
|
||||||
|
|
||||||
|
|
||||||
|
-- 傾印 資料表 solar_power.variable 結構
|
||||||
|
CREATE TABLE IF NOT EXISTS `variable` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '變數名稱',
|
||||||
|
`value` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '變數內容值',
|
||||||
|
`remark` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '備註',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `IDX_01` (`name`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='設定變數';
|
||||||
|
|
||||||
|
-- 正在傾印表格 solar_power.variable 的資料:~-1 rows (近似值)
|
||||||
|
DELETE FROM `variable`;
|
||||||
|
/*!40000 ALTER TABLE `variable` DISABLE KEYS */;
|
||||||
|
/*!40000 ALTER TABLE `variable` ENABLE KEYS */;
|
||||||
|
|
||||||
|
/*!40000 ALTER TABLE `auth_page` DISABLE KEYS */;
|
||||||
|
INSERT INTO `auth_page` (`AuthCode`, `MainName`, `SubName`, `ControlName`) VALUES
|
||||||
|
('A', '系統管理', '帳號管理', 'User,Role'),
|
||||||
|
('B', '系統管理', '公司管理', 'Company'),
|
||||||
|
('C', '系統管理', '電站資料管理', 'AAA'),
|
||||||
|
('D', '系統管理', '定時任務設定', 'Setting'),
|
||||||
|
('E', '系統管理', '功能清單', 'ASDA'),
|
||||||
|
('F', '總覽', '地圖總覽', 'BBB'),
|
||||||
|
('G', '總攬', '電占總覽', 'CCC'),
|
||||||
|
('H', '總覽', '運為總覽', 'HHH'),
|
||||||
|
('J', '即時告警', '即時告警', 'JJJ'),
|
||||||
|
('K', '交叉分析', '逆變器', 'KKK'),
|
||||||
|
('L', '交叉分析', '電站運轉效率', 'LLL');
|
||||||
|
/*!40000 ALTER TABLE `auth_page` ENABLE KEYS */;
|
||||||
|
|
||||||
|
INSERT INTO `user` (`Id`, `Deleted`, `Status`, `Name`, `Account`, `Password`, `IsGod`, `CompanyId`, `DepartmentId`, `RoleId`, `JobTitle`, `Phone`, `Tel`, `Email`, `CreatedBy`, `CreatedAt`, `UpdatedBy`, `UpdatedAt`) VALUES
|
||||||
|
(1, 0, 1, '野原新之助', 'admin', 'Ki4SV2TZiQbvDjdEVLNMmVkJfZC9VyTh88DmLSXP+Iw=', 1, 1, 0, 1, NULL, '0987987987', NULL, 'god@admin.com', 1, '2021-06-07 19:19:08', NULL, '2021-06-13 19:08:22');
|
||||||
|
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
|
||||||
|
|
||||||
|
-- 新增FIC平台公司
|
||||||
|
INSERT INTO `solar_power`.`company` (`Name`, `TaxIDNumber`, `Phone`, `Address`, `RegisterUpperLimit`, `CreatedBy`) VALUES ('大眾電腦', '20840777', '02-87518751', '臺北市內湖區陽光街300號1至9樓', '100', '1');
|
||||||
|
|
||||||
|
-- 新增平台管理員角色
|
||||||
|
INSERT INTO `solar_power`.`role` (`CompanyId`, `Name`, `Layer`, `CreatedBy`) VALUES ('1', '平台管理員', '0', '1');
|
||||||
|
|
||||||
|
|
||||||
|
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||||
|
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
|
||||||
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;
|
||||||
@ -31,20 +31,13 @@ namespace SolarPower.Helper
|
|||||||
{
|
{
|
||||||
EDFunction ed = new EDFunction();
|
EDFunction ed = new EDFunction();
|
||||||
|
|
||||||
var serverStr1 = ed.AESEncrypt(dbConfig.Server);
|
var serverStr = ed.AESDecrypt(dbConfig.Server);
|
||||||
var databaseStr1 = ed.DESEncrypt(dbConfig.Database);
|
var databaseStr = ed.DESDecrypt(dbConfig.Database);
|
||||||
var rootStr1 = ed.DESEncrypt(dbConfig.Root);
|
var rootStr = ed.DESDecrypt(dbConfig.Root);
|
||||||
var passwordStr1 = ed.DESEncrypt(dbConfig.Password);
|
var passwordStr = ed.DESDecrypt(dbConfig.Password);
|
||||||
|
|
||||||
var serverStr = ed.AESDecrypt(serverStr1);
|
var connStr = $"server={serverStr};database={databaseStr};user={rootStr};password={passwordStr};charset=utf8;";
|
||||||
var databaseStr = ed.DESDecrypt(databaseStr1);
|
//var connStr = @"server=127.0.0.1;database=solar_power;user=root;password=000000;charset=utf8;";
|
||||||
var rootStr = ed.DESDecrypt(rootStr1);
|
|
||||||
var passwordStr = ed.DESDecrypt(passwordStr1);
|
|
||||||
|
|
||||||
//var connStr = $"server={serverStr};database={databaseStr};user={rootStr};password={passwordStr};charset=utf8;";
|
|
||||||
var connStr = $"server=127.0.0.1;database=solar_power;user=root;password=000000;charset=utf8;";
|
|
||||||
|
|
||||||
//var connStr = @"data source=127.0.0.1;initial catalog=SolarPower;integrated security=true;";
|
|
||||||
|
|
||||||
this._connectionString = connStr;
|
this._connectionString = connStr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,10 +49,11 @@ namespace SolarPower.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class MyCompany
|
public class MyCompany
|
||||||
{
|
{
|
||||||
|
private string logo;
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public byte Status { get; set; } //狀態
|
public byte Status { get; set; } //狀態
|
||||||
public string Name { get; set; } //名稱
|
public string Name { get; set; } //名稱
|
||||||
public string Logo { get; set; }
|
public string Logo { get { return "/upload/company_logo/" + logo; } set { logo = value; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
//當前登入使用者的角色權限
|
//當前登入使用者的角色權限
|
||||||
|
|||||||
@ -29,6 +29,7 @@ namespace SolarPower.Models.Role
|
|||||||
{
|
{
|
||||||
public string CompanyName { get; set; }
|
public string CompanyName { get; set; }
|
||||||
public string CreatorName { get; set; }
|
public string CreatorName { get; set; }
|
||||||
|
public string Function { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -15,12 +15,12 @@ namespace SolarPower.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EDFunction
|
public class EDFunction
|
||||||
{
|
{
|
||||||
const string SHA256_KEY = "SHA256_KEY"; //自訂金鑰
|
const string SHA256_KEY = "REWOPRALOS"; //自訂金鑰
|
||||||
const string DES_KEY = "SUMT_KEY"; //DES_KEY金鑰(8位字元)
|
const string DES_KEY = "RALOSKEY"; //DES_KEY金鑰(8位字元)
|
||||||
const string DES_IV = "SUMMT_IV"; //DES_IV初始化向量字串(8位字元)
|
const string DES_IV = "RALOS_IV"; //DES_IV初始化向量字串(8位字元)
|
||||||
|
|
||||||
const string AES_KEY = "SUMT_KEY"; //AES_KEY金鑰
|
const string AES_KEY = "RALOSKEY"; //AES_KEY金鑰
|
||||||
const string AES_IV = "SUMMT_IV"; //AES_IV初始化向量字串
|
const string AES_IV = "RALOS_IV"; //AES_IV初始化向量字串
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 單向加密SHA256
|
/// 單向加密SHA256
|
||||||
|
|||||||
@ -26,7 +26,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<List<CompanySelectItemList>> GetCompanySelectOptionListAsync()
|
public async Task<List<CompanySelectItemList>> GetCompanySelectOptionListAsync(int companyId = 0)
|
||||||
{
|
{
|
||||||
List<CompanySelectItemList> result;
|
List<CompanySelectItemList> result;
|
||||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
@ -35,7 +35,12 @@ namespace SolarPower.Repository.Implement
|
|||||||
{
|
{
|
||||||
var sql = $"SELECT Id AS Value, Name AS Text FROM {tableName} WHERE Deleted = 0";
|
var sql = $"SELECT Id AS Value, Name AS Text FROM {tableName} WHERE Deleted = 0";
|
||||||
|
|
||||||
result = (await conn.QueryAsync<CompanySelectItemList>(sql)).ToList();
|
if(companyId > 0)
|
||||||
|
{
|
||||||
|
sql += " AND Id = @SelectedCompanyId";
|
||||||
|
}
|
||||||
|
|
||||||
|
result = (await conn.QueryAsync<CompanySelectItemList>(sql, new { SelectedCompanyId = companyId})).ToList();
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -30,7 +30,7 @@ namespace SolarPower.Repository.Interface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<CompanySelectItemList>> GetCompanySelectOptionListAsync();
|
Task<List<CompanySelectItemList>> GetCompanySelectOptionListAsync(int companyId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 透過搜尋條件,查詢過濾後的公司
|
/// 透過搜尋條件,查詢過濾後的公司
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<AssemblyName>SolarPower</AssemblyName>
|
<AssemblyName>SolarPower</AssemblyName>
|
||||||
<RootNamespace>SolarPower</RootNamespace>
|
<RootNamespace>SolarPower</RootNamespace>
|
||||||
|
<UserSecretsId>9c9a93c3-c4f5-4cc2-92ea-0ae0a51be5d3</UserSecretsId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
ViewData["SubNum"] = "2";
|
ViewData["SubNum"] = "2";
|
||||||
ViewData["Title"] = "客戶公司管理";
|
ViewData["Title"] = "客戶公司管理";
|
||||||
}
|
}
|
||||||
|
@using SolarPower.Models.Role
|
||||||
|
@model RoleLayerEnum
|
||||||
|
|
||||||
<ol class="breadcrumb page-breadcrumb">
|
<ol class="breadcrumb page-breadcrumb">
|
||||||
<li class="breadcrumb-item"><a href="javascript:void(0);">系統管理</a></li>
|
<li class="breadcrumb-item"><a href="javascript:void(0);">系統管理</a></li>
|
||||||
@ -52,10 +54,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-container show">
|
<div class="panel-container show">
|
||||||
<div class="panel-content">
|
<div class="panel-content">
|
||||||
|
@*只有超級使用者及平台人員可以新增公司*@
|
||||||
|
@if (ViewBag.myUser.IsGod == 1 || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser)
|
||||||
|
{
|
||||||
<button type="button" class="btn btn-success waves-effect waves-themed mb-3" onclick="AddCompany()">
|
<button type="button" class="btn btn-success waves-effect waves-themed mb-3" onclick="AddCompany()">
|
||||||
<span class="fal fa-plus mr-1"></span>
|
<span class="fal fa-plus mr-1"></span>
|
||||||
新增
|
新增
|
||||||
</button>
|
</button>
|
||||||
|
}
|
||||||
<div class="frame-wrap">
|
<div class="frame-wrap">
|
||||||
<table id="company_table" class="table table-bordered table-hover m-0 text-center">
|
<table id="company_table" class="table table-bordered table-hover m-0 text-center">
|
||||||
<thead class="thead-themed">
|
<thead class="thead-themed">
|
||||||
@ -153,7 +159,12 @@
|
|||||||
<table id="company_auth_table" class="table table-bordered text-center">
|
<table id="company_auth_table" class="table table-bordered text-center">
|
||||||
<thead class="thead-themed">
|
<thead class="thead-themed">
|
||||||
<tr>
|
<tr>
|
||||||
<th>選擇</th>
|
<th>
|
||||||
|
<div class="custom-control custom-checkbox">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="select-all-company-auth">
|
||||||
|
<label class="custom-control-label" for="select-all-company-auth">全選</label>
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
@*<th>編號</th>*@
|
@*<th>編號</th>*@
|
||||||
<th>功能大項</th>
|
<th>功能大項</th>
|
||||||
<th>功能名稱</th>
|
<th>功能名稱</th>
|
||||||
@ -300,8 +311,6 @@
|
|||||||
"info": true,
|
"info": true,
|
||||||
"autoWidth": false,
|
"autoWidth": false,
|
||||||
"responsive": true,
|
"responsive": true,
|
||||||
"deferLoading": 0,
|
|
||||||
"serverSide": true,
|
|
||||||
"order": [[1, "desc"]],
|
"order": [[1, "desc"]],
|
||||||
"columns": [{
|
"columns": [{
|
||||||
"data": "authCode"
|
"data": "authCode"
|
||||||
@ -376,6 +385,19 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region 公司權限池全選
|
||||||
|
$("#select-all-company-auth").change(function () {
|
||||||
|
|
||||||
|
var rows = companyAuthTable.rows({ 'search': 'applied' }).nodes();
|
||||||
|
|
||||||
|
if (this.checked) {
|
||||||
|
$('input[type="checkbox"]', rows).prop('checked', this.checked);
|
||||||
|
} else {
|
||||||
|
$('input[type="checkbox"]', rows).prop('checked', this.checked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
});
|
});
|
||||||
|
|
||||||
//#region 搜尋公司列表
|
//#region 搜尋公司列表
|
||||||
@ -384,7 +406,7 @@
|
|||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 新增系統管理員
|
//#region 新增公司基本資料
|
||||||
function AddCompany() {
|
function AddCompany() {
|
||||||
|
|
||||||
selected_id = 0;
|
selected_id = 0;
|
||||||
@ -460,18 +482,6 @@
|
|||||||
formData.append("LogoFile", logos[0])
|
formData.append("LogoFile", logos[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
@*$.post(url, formData, function (rel) {
|
|
||||||
if (rel.code != "0000") {
|
|
||||||
toast_error(rel.msg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
toast_ok(rel.msg);
|
|
||||||
$('#company-modal').modal('hide');
|
|
||||||
|
|
||||||
companyTable.ajax.reload();
|
|
||||||
}, 'json');*@
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: url,
|
url: url,
|
||||||
@ -530,6 +540,8 @@
|
|||||||
|
|
||||||
selected_id = $(this).parents('tr').attr('data-id');
|
selected_id = $(this).parents('tr').attr('data-id');
|
||||||
|
|
||||||
|
$("#select-all-company-auth").prop("checked", false);
|
||||||
|
|
||||||
companyAuthTable.ajax.reload();
|
companyAuthTable.ajax.reload();
|
||||||
|
|
||||||
$("#company-auth-modal").modal();
|
$("#company-auth-modal").modal();
|
||||||
@ -539,8 +551,9 @@
|
|||||||
//#region 儲存公司權限池
|
//#region 儲存公司權限池
|
||||||
function SaveComapnyAuth() {
|
function SaveComapnyAuth() {
|
||||||
|
|
||||||
|
var rows = companyAuthTable.rows({ 'search': 'applied' }).nodes();
|
||||||
//取得被選擇的權限
|
//取得被選擇的權限
|
||||||
var checkAuths = $("input[name='selectedAuthPage[]']:checked").map(function () {
|
var checkAuths = $("input[name='selectedAuthPage[]']:checked", rows).map(function () {
|
||||||
return $(this).val();
|
return $(this).val();
|
||||||
}).get();
|
}).get();
|
||||||
|
|
||||||
|
|||||||
@ -45,158 +45,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@*
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h3 class="card-title">搜尋條件</h3>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<form id="system-admin-filter-form">
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label>帳號:</label>
|
|
||||||
<input type="text" class="form-control" id="system_admin_account" name="system_admin_account">
|
|
||||||
</div>
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label>姓名:</label>
|
|
||||||
<input type="text" class="form-control" id="system_admin_name" name="system_admin_name">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label>電子信箱:</label>
|
|
||||||
<input type="text" class="form-control" id="system_admin_email" name="system_admin_email">
|
|
||||||
</div>
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label>手機號碼:</label>
|
|
||||||
<input type="text" class="form-control" id="system_admin_phone" name="system_admin_phone">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div class="card-footer text-right">
|
|
||||||
<button type="button" class="btn btn-default" onclick="ResetForm()">清除</button>
|
|
||||||
<button type="button" class="btn btn-primary" onclick="SearchSystemAdmin()">查詢</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h3 class="card-title">人員列表</h3>
|
|
||||||
<div class="card-tools">
|
|
||||||
<button class="btn btn-success" onclick="AddSystemAdmin()"><i class="fa fa-plus"></i> 新增</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- /.card-header -->
|
|
||||||
<div class="card-body">
|
|
||||||
<table id="system_admin_table" class="table table-bordered table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>帳號</th>
|
|
||||||
<th>姓名</th>
|
|
||||||
<th>電子信箱</th>
|
|
||||||
<th>手機號碼</th>
|
|
||||||
<th>狀態</th>
|
|
||||||
<th>建立時間</th>
|
|
||||||
<th>功能</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<!-- /.card-body -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 個人資料 -->
|
|
||||||
<div class="modal" tabindex="-1" id="system-admin-modal" role="dialog" data-backdrop="static" data-keyboard="false">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title">系統管理員</h5>
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
||||||
<span aria-hidden="true">×</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<form class="system-admin-form" id="system-admin-form">
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group col-md-12">
|
|
||||||
<label for="system_admin_name_modal">
|
|
||||||
<font class="text-danger">*</font>姓名:
|
|
||||||
</label>
|
|
||||||
<input type="text" class="form-control" id="system_admin_name_modal" name="system_admin_name_modal" autocomplete="off" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group col-md-12">
|
|
||||||
<label for="system_admin_account_modal">
|
|
||||||
帳號:
|
|
||||||
</label>
|
|
||||||
<input type="text" class="form-control" id="system_admin_account_modal" name="system_admin_account_modal" disabled>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-row system_admin_password_form_row">
|
|
||||||
<div class="form-group col-md-12">
|
|
||||||
<label>
|
|
||||||
密碼:等同帳號
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group col-md-12">
|
|
||||||
<label>狀態:</label>
|
|
||||||
<div class="custom-control custom-radio d-inline">
|
|
||||||
<input class="custom-control-input" type="radio" id="system_admin_status_normal_modal" name="system_admin_status_modal" value="0">
|
|
||||||
<label for="system_admin_status_normal_modal" class="custom-control-label">正常</label>
|
|
||||||
</div>
|
|
||||||
<div class="custom-control custom-radio d-inline">
|
|
||||||
<input class="custom-control-input" type="radio" id="system_admin_status_suspend_modal" name="system_admin_status_modal" value="1">
|
|
||||||
<label for="system_admin_status_suspend_modal" class="custom-control-label">停權</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group col-md-12">
|
|
||||||
<label for="system_admin_email_modal">
|
|
||||||
電子信箱:
|
|
||||||
</label>
|
|
||||||
<input type="email" class="form-control" id="system_admin_email_modal" name="system_admin_email_modal" autocomplete="off">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group col-md-12">
|
|
||||||
<label for="system_admin_phone_modal">
|
|
||||||
電話:
|
|
||||||
</label>
|
|
||||||
<input type="text" class="form-control" id="system_admin_phone_modal" name="system_admin_phone_modal" autocomplete="off">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-primary btn-save" onclick="SaveSystemAdmin()">儲存</button>
|
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- /.個人資料 -->
|
|
||||||
*@
|
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
<script>
|
<script>
|
||||||
var userTable; var roleTable; var roleAuthTable; var roleAuthNotJoinTable;
|
var userTable; var roleTable; var roleAuthTable; var roleAuthNotJoinTable;
|
||||||
@ -298,6 +146,11 @@
|
|||||||
|
|
||||||
//預設查詢第一個
|
//預設查詢第一個
|
||||||
$("#select_company_role_userManager_tab").val($("#select_company_role_userManager_tab option:first").val()).trigger('change');
|
$("#select_company_role_userManager_tab").val($("#select_company_role_userManager_tab option:first").val()).trigger('change');
|
||||||
|
|
||||||
|
//更新帳號管理DataTable
|
||||||
|
if (selected_tab == "#tab-user-manager") {
|
||||||
|
userTable.ajax.reload();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$("#select_company_role_userManager_tab").empty();
|
$("#select_company_role_userManager_tab").empty();
|
||||||
$("#select_company_role_userManager_tab").append('<option value="0" disabled>請先新增角色</option>');
|
$("#select_company_role_userManager_tab").append('<option value="0" disabled>請先新增角色</option>');
|
||||||
@ -334,6 +187,11 @@
|
|||||||
|
|
||||||
//預設查詢第一個
|
//預設查詢第一個
|
||||||
$("#select_roleId_roleAuth_tab").val($("#select_roleId_roleAuth_tab option:first").val()).trigger('change');
|
$("#select_roleId_roleAuth_tab").val($("#select_roleId_roleAuth_tab option:first").val()).trigger('change');
|
||||||
|
|
||||||
|
//更新角色權限DataTable
|
||||||
|
if (selected_tab == "#tab-role-auth") {
|
||||||
|
roleAuthTable.ajax.reload();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$("#select_roleId_roleAuth_tab").empty();
|
$("#select_roleId_roleAuth_tab").empty();
|
||||||
$("#select_roleId_roleAuth_tab").append('<option value="0" disabled>請先新增角色</option>');
|
$("#select_roleId_roleAuth_tab").append('<option value="0" disabled>請先新增角色</option>');
|
||||||
@ -341,6 +199,11 @@
|
|||||||
$("#select_roleId_roleAuth_tab").val($("#select_roleId_roleAuth_tab option:first").val()).trigger('change');
|
$("#select_roleId_roleAuth_tab").val($("#select_roleId_roleAuth_tab option:first").val()).trigger('change');
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//更新角色管理DataTable
|
||||||
|
if (selected_tab == "#tab-role-manager") {
|
||||||
|
roleTable.ajax.reload();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -470,8 +333,7 @@
|
|||||||
}, {
|
}, {
|
||||||
"data": "createdAt"
|
"data": "createdAt"
|
||||||
}, {
|
}, {
|
||||||
"data": null,
|
"data": "function",
|
||||||
"defaultContent": '<button class="btn btn-primary edit-btn">修改</button> <button class="btn btn-danger del-btn">刪除</button>'
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"language": {
|
"language": {
|
||||||
@ -536,7 +398,8 @@
|
|||||||
"deferLoading": 0,
|
"deferLoading": 0,
|
||||||
"order": [[5, "desc"]],
|
"order": [[5, "desc"]],
|
||||||
"columns": [{
|
"columns": [{
|
||||||
"data": "id"
|
"data": null,
|
||||||
|
"target": 0
|
||||||
}, {
|
}, {
|
||||||
"data": "companyName"
|
"data": "companyName"
|
||||||
}, {
|
}, {
|
||||||
@ -600,6 +463,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@*roleAuthTable.on('order.dt search.dt', function () {
|
||||||
|
roleAuthTable.column(0, {
|
||||||
|
search: 'applied',
|
||||||
|
order: 'applied'
|
||||||
|
}).nodes().each(function (cell, i) {
|
||||||
|
i = i + 1;
|
||||||
|
var page = roleAuthTable.page.info();
|
||||||
|
|
||||||
|
var pageno = page.page;
|
||||||
|
|
||||||
|
var length = page.length;
|
||||||
|
|
||||||
|
var columnIndex = (i + pageno * length);
|
||||||
|
cell.innerHTML = columnIndex;
|
||||||
|
})
|
||||||
|
});*@
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 角色未加入權限列表 DataTable
|
//#region 角色未加入權限列表 DataTable
|
||||||
@ -683,6 +563,19 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region 角色權限全選
|
||||||
|
$("#select-all-role-auth").change(function () {
|
||||||
|
|
||||||
|
var rows = roleAuthNotJoinTable.rows({ 'search': 'applied' }).nodes();
|
||||||
|
|
||||||
|
if (this.checked) {
|
||||||
|
$("input[name='selectedAuthPage[]']", rows).prop('checked', this.checked);
|
||||||
|
} else {
|
||||||
|
$("input[name='selectedAuthPage[]']", rows).prop('checked', this.checked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
});
|
});
|
||||||
|
|
||||||
//#region 帳號管理Tab
|
//#region 帳號管理Tab
|
||||||
@ -957,7 +850,7 @@
|
|||||||
|
|
||||||
var send_data = {
|
var send_data = {
|
||||||
Id: selected_role_id,
|
Id: selected_role_id,
|
||||||
CompanyId: $("#role_companyId_modal").val(),
|
SelectedCompanyId: $("#role_companyId_modal").val(),
|
||||||
Name: $("#role_name_modal").val(),
|
Name: $("#role_name_modal").val(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1013,6 +906,9 @@
|
|||||||
|
|
||||||
//#region 新增角色權限
|
//#region 新增角色權限
|
||||||
function AddRoleAuth() {
|
function AddRoleAuth() {
|
||||||
|
|
||||||
|
$("#select-all-company-auth").prop("checked", false);
|
||||||
|
|
||||||
roleAuthNotJoinTable.ajax.reload();
|
roleAuthNotJoinTable.ajax.reload();
|
||||||
|
|
||||||
$("#role-auth-modal").modal();
|
$("#role-auth-modal").modal();
|
||||||
@ -1022,8 +918,9 @@
|
|||||||
//#region 儲存角色權限
|
//#region 儲存角色權限
|
||||||
function SaveRoleAuth() {
|
function SaveRoleAuth() {
|
||||||
|
|
||||||
|
var rows = roleAuthNotJoinTable.rows({ 'search': 'applied' }).nodes();
|
||||||
//取得被選擇的角色權限
|
//取得被選擇的角色權限
|
||||||
var checkAuths = $("input[name='selectedAuthPage[]']:checked").map(function () {
|
var checkAuths = $("input[name='selectedAuthPage[]']:checked", rows).map(function () {
|
||||||
return $(this).val();
|
return $(this).val();
|
||||||
}).get();
|
}).get();
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,12 @@
|
|||||||
<table id="roleAuth_NotJoin_table" class="table table-bordered table-hover m-0 text-center">
|
<table id="roleAuth_NotJoin_table" class="table table-bordered table-hover m-0 text-center">
|
||||||
<thead class="thead-themed">
|
<thead class="thead-themed">
|
||||||
<tr>
|
<tr>
|
||||||
<th>選擇</th>
|
<th>
|
||||||
|
<div class="custom-control custom-checkbox">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="select-all-role-auth">
|
||||||
|
<label class="custom-control-label" for="select-all-role-auth">全選</label>
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
<th>功能大項</th>
|
<th>功能大項</th>
|
||||||
<th>功能名稱</th>
|
<th>功能名稱</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@ -8,16 +8,10 @@
|
|||||||
},
|
},
|
||||||
"LoginExpireMinute": 60, //登入到期時間,單位(分)
|
"LoginExpireMinute": 60, //登入到期時間,單位(分)
|
||||||
"DBConfig": {
|
"DBConfig": {
|
||||||
"Server": "172.16.251.248",
|
"Server": "LPp7aTdHGEFQJieGkSGl0g==",
|
||||||
"Database": "solar_power",
|
"Database": "k48iBBWXwJHPZF9zkF8UjreGN2uYWz6R",
|
||||||
"Root": "idafenweb",
|
"Root": "2TdWJL+VXK8xbnhD8iA0zNJMT95nSE5W",
|
||||||
"Password": "P@ssw0rd"
|
"Password": "BxXjVEJCYCyPmlt03xAKmUNEnXzHhw1j"
|
||||||
},
|
|
||||||
"JWTConfig": {
|
|
||||||
"Issuer": "SHH", //Token釋出者
|
|
||||||
"Audience": "EveryOne", //Token接受者
|
|
||||||
"IssuerSigningKey": "0dd6b2fa-ce1b-40e5-8ca9-e798a4c7bb23", //祕鑰可以構建伺服器認可的token;簽名祕鑰長度最少16
|
|
||||||
"AccessTokenExpiresMinutes": "600" //過期時間 分鐘
|
|
||||||
},
|
},
|
||||||
"SMTPConfig": {
|
"SMTPConfig": {
|
||||||
"Host": "smtp.gmail.com",
|
"Host": "smtp.gmail.com",
|
||||||
@ -26,5 +20,4 @@
|
|||||||
"Password": "wswgnluvoodfexrb",
|
"Password": "wswgnluvoodfexrb",
|
||||||
"EnableSsl": true
|
"EnableSsl": true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,5 +6,19 @@
|
|||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"LoginExpireMinute": 60, //登入到期時間,單位(分)
|
||||||
|
"DBConfig": {
|
||||||
|
"Server": "LPp7aTdHGEFQJieGkSGl0g==",
|
||||||
|
"Database": "k48iBBWXwJHPZF9zkF8UjreGN2uYWz6R",
|
||||||
|
"Root": "2TdWJL+VXK8xbnhD8iA0zNJMT95nSE5W",
|
||||||
|
"Password": "BxXjVEJCYCyPmlt03xAKmUNEnXzHhw1j"
|
||||||
|
},
|
||||||
|
"SMTPConfig": {
|
||||||
|
"Host": "smtp.gmail.com",
|
||||||
|
"Port": 25,
|
||||||
|
"UserName": "shanghohui@gmail.com",
|
||||||
|
"Password": "wswgnluvoodfexrb",
|
||||||
|
"EnableSsl": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
SolarPower/wwwroot/upload/company_logo/1.png
Normal file
BIN
SolarPower/wwwroot/upload/company_logo/1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 907 B After Width: | Height: | Size: 3.9 KiB |
Loading…
Reference in New Issue
Block a user