Former-commit-id: 980b60389514661fb4035e9305da6cd033e79f4e
TangShanKaiPing
wanggang 5 years ago
parent 49a209a836
commit a9f06980bd

@ -26,6 +26,7 @@ namespace Application.Models
public Guid? ApiId { get; set; }
[Display(Name = "命令名称")]
[MaxLength(24, ErrorMessage = "{0}最大长度为{1}")]
[Required(ErrorMessage = nameof(RequiredAttribute))]
public string Name { get; set; }

@ -24,6 +24,7 @@ namespace Application.Models
public string Name { get; set; }
[Display(Name = "显示名称")]
[MaxLength(24, ErrorMessage = "{0}最大长度为{1}")]
[Required]
public string DisplayName { get; set; }

@ -9,11 +9,11 @@ namespace Application.Models
{
[DataType("SelectList")]
[Display(Name = "场景节点")]
[MaxLength(24, ErrorMessage = "{0}最大长度为{1}")]
[Required(ErrorMessage = nameof(RequiredAttribute))]
public Guid? NodeId { get; set; }
[Display(Name = "场景名称")]
[MaxLength(24, ErrorMessage = "{0}最大长度为{1}")]
[Required(ErrorMessage = nameof(RequiredAttribute))]
public string Name { get; set; }

@ -36,6 +36,7 @@ namespace Application.Models
public string Condition { get; set; }
[Display(Name = "触发器名称")]
[MaxLength(24, ErrorMessage = "{0}最大长度为{1}")]
public string Name { get; set; }
[Display(Name = "禁用")]

@ -19,6 +19,7 @@ namespace Application.Models
public Guid SceneId { get; set; }
[Display(Name = "定时器名称")]
[MaxLength(24, ErrorMessage = "{0}最大长度为{1}")]
public string Name { get; set; }
[Display(Name = "定时器规则")]

@ -30,6 +30,11 @@ namespace IoT.Shared.Areas.Admin.Controllers
return query.Include(o => o.Category).ThenInclude(o => o.Parent);
}
public override IQueryable<Permission> Query(PagedListModel<EditPermissionModel> model, IQueryable<Permission> query)
{
return query.OrderBy(o => o.CategoryId).ThenBy(o => o.Name);
}
public override void ToEditModel(Permission entity, EditPermissionModel model)
{
this.ViewData.SelectList(o => model.CategoryId, () => this.GetPermissionCategorySelectList(model.CategoryId), model.CategoryId.HasValue);
@ -58,6 +63,7 @@ namespace IoT.Shared.Areas.Admin.Controllers
}
var list = this.Repo.ReadOnlyTable()
.Include(o => o.Category)
.OrderBy(o => o.CategoryId).ThenBy(o => o.Name)
.Select(o => new { o.Id, o.Name, Group = o.Category.Name })
.ToList();
return new MultiSelectList(list, "Id", "Name", selectedValues, "Group");

@ -15,6 +15,7 @@ namespace IoTCenter.Application.Models
public Guid SceneId { get; set; }
[Display(Name = "触发器名称")]
[MaxLength(24, ErrorMessage = "{0}最大长度为{1}")]
public string Name { get; set; }
[DataType("SelectList")]

@ -14,6 +14,7 @@ namespace IoTCenter.Application.Models
public Guid SceneId { get; set; }
[Display(Name = "平台定时器名称")]
[MaxLength(24, ErrorMessage = "{0}最大长度为{1}")]
public string Name { get; set; }
[Display(Name = "定时器规则")]

@ -9,6 +9,7 @@ namespace IoTCenter.Application.Models
public class EditNodeCategoryModel : EditModel
{
[Display(Name = "分类名称")]
[MaxLength(24, ErrorMessage = "{0}最大长度为{1}")]
[Required(ErrorMessage = nameof(RequiredAttribute))]
public string Name { get; set; }

@ -9,6 +9,7 @@ namespace IoTCenter.Application.Models
public class EditOrganModel : EditModel
{
[Display(Name = "机构名称")]
[MaxLength(24, ErrorMessage = "{0}最大长度为{1}")]
[Required(ErrorMessage = nameof(RequiredAttribute))]
public string Name { get; set; }

@ -7,6 +7,7 @@ using IoT.Shared;
using IoTCenter.Application.Domain;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
namespace IoTCenter
{
@ -44,12 +45,12 @@ namespace IoTCenter
var saRole = new Role { Name = "超级管理员", IsReadOnly = true };
var adminRole = new Role { Name = "管理员", IsReadOnly = true };
//var skips = new string[] { "添加节点", "删除节点", "添加设备", "删除设备" };
var skips = new string[] { "添加Api", "修改Api", "添加分类", "修改分类", "添加参数", "修改参数", "添加产品", "修改产品", "添加节点", "添加权限", "修改权限", "添加权限分类", "修改权限分类", "添加设备" };
foreach (var item in db.Set<Permission>())
{
saRole.RolePermissions.Add(new RolePermission { Permission = item, IsReadOnly = true });
if (!item.Name.Contains("删除"))// && !skips.Contains(item.Name))
if (!item.Name.Contains("删除") && !skips.Contains(item.Name))
{
adminRole.RolePermissions.Add(new RolePermission { Permission = item, IsReadOnly = true });
}

@ -6,6 +6,7 @@ using Infrastructure.Security;
using IoT.Shared;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
namespace IoTNode
{
@ -33,12 +34,12 @@ namespace IoTNode
var saRole = new Role { Name = "超级管理员", IsReadOnly = true };
var adminRole = new Role { Name = "管理员", IsReadOnly = true };
//var skips = new string[] { "添加节点", "删除节点", "添加设备", "删除设备" };
var skips = new string[] { "添加Api", "修改Api", "添加分类", "修改分类", "添加参数", "修改参数", "添加产品", "修改产品", "添加节点", "添加权限", "修改权限", "添加权限分类", "修改权限分类", "添加设备" };
foreach (var item in db.Set<Permission>())
{
saRole.RolePermissions.Add(new RolePermission { Permission = item, IsReadOnly = true });
if (!item.Name.Contains("删除"))// && !skips.Contains(item.Name))
if (!item.Name.Contains("删除") && !skips.Contains(item.Name))
{
adminRole.RolePermissions.Add(new RolePermission { Permission = item, IsReadOnly = true });
}

@ -47,6 +47,7 @@ namespace IoTCenter.Areas.Admin.Controllers
}
var list = this._permissionRepo.Table()
.Include(o => o.Category)
.OrderBy(o => o.CategoryId).ThenBy(o => o.Name)
.Select(o => new { o.Id, o.Name, Group = o.Category.Name })
.ToList();
return new MultiSelectList(list, "Id", "Name", selectedValues, "Group");

@ -0,0 +1,13 @@
using Infrastructure.Domain;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Application.Domain.Entities
{
[Display(Name = "机构")]
public class Organ : BaseTreeEntity<Organ>
{
public string Contact { get; set; }
public List<OrganUser> OrganUsers { get; set; } = new List<OrganUser>();
}
}

@ -0,0 +1,15 @@
using Infrastructure.Domain;
using System;
using System.ComponentModel.DataAnnotations;
namespace Application.Domain.Entities
{
[Display(Name = "机构用户")]
public class OrganUser : BaseEntity
{
public Guid UserId { get; set; }
public Guid OrganId { get; set; }
public User User { get; set; }
public Organ Organ { get; set; }
}
}

@ -81,6 +81,7 @@ namespace Application.Domain.Entities
public string RowVersion { get; set; }
public List<UserRole> UserRoles { get; set; } = new List<UserRole>();
public List<OrganUser> OrganUsers { get; set; } = new List<OrganUser>();
public List<UserDepartment> UserDepartments { get; set; } = new List<UserDepartment>();
}
}

@ -42,6 +42,14 @@ namespace Application.Models
[DataType(DataType.ImageUrl)]
public string Avatar { get; set; }
[Display(Name = "真实姓名")]
[RegularExpression("[\u4E00-\u9FA5]{2,4}", ErrorMessage = "")]
public string RealName { get; set; }
[Display(Name = "身份证号")]
[RegularExpression(@"^(\d{15}|\d{17}(x|X|\d))$", ErrorMessage = "身份证号格式错。")]
public string IdCardNumber { get; set; }
[Display(Name = "性别")]
[UIHint("RadioButtonList")]
[Required(ErrorMessage = nameof(RequiredAttribute))]

@ -55,6 +55,7 @@ namespace UserCenter.Areas.Admin.Controllers
}
var list = this._permissionRepo.Table()
.Include(o => o.Category)
.OrderBy(o => o.CategoryId).ThenBy(o => o.Name)
.Select(o => new { o.Id, o.Name, Group = o.Category.Name })
.ToList();
return new MultiSelectList(list, "Id", "Name", selectedValues, "Group");
@ -63,6 +64,7 @@ namespace UserCenter.Areas.Admin.Controllers
#endregion Permission
#region PermissionCategory
public SelectList GetPermissionCategorySelectList(Guid? selected)
{
var list = this._permissionCategoryRepo.ReadOnlyTable()
@ -70,6 +72,7 @@ namespace UserCenter.Areas.Admin.Controllers
.ToList();
return new SelectList(list, "Id", "Name", selected);
}
#endregion
#endregion PermissionCategory
}
}

@ -27,6 +27,11 @@ namespace UserCenter.Areas.Admin.Controllers
return query.Include(o => o.Category).ThenInclude(o => o.Parent);
}
public override IQueryable<Permission> Query(PagedListModel<EditPermissionModel> model, IQueryable<Permission> query)
{
return query.OrderBy(o => o.CategoryId).ThenBy(o => o.Name);
}
public override void ToEditModel(Permission entity, EditPermissionModel model)
{
this.ViewData.SelectList(o => model.CategoryId, () => this._ajax.GetPermissionCategorySelectList(model.CategoryId), model.CategoryId.HasValue);

@ -96,6 +96,10 @@ namespace UserCenter.Areas.Admin.Controllers
{
ModelState.AddModelError(o => model.UserName, "邮箱已经存在");
}
if (this.Repo.ReadOnlyTable().Any(o => o.NickName == model.NickName))
{
ModelState.AddModelError(o => model.UserName, "昵称已经存在");
}
return base.Add(model);
}

@ -46,6 +46,11 @@ namespace UserCenter
modelBuilder.Entity<Department>().HasOne(o => o.Parent).WithMany(o => o.Children).HasForeignKey(o => o.ParentId);
modelBuilder.Entity<Department>().Property(o => o.Number).IsRequired();
modelBuilder.Entity<Department>().HasIndex(o => o.Number).IsUnique();
modelBuilder.Entity<Organ>().Property(o => o.Number).IsRequired();
modelBuilder.Entity<Organ>().HasIndex(o => o.Number).IsUnique();
modelBuilder.Entity<OrganUser>().HasOne(o => o.User).WithMany(o => o.OrganUsers).HasForeignKey(o => o.UserId);
modelBuilder.Entity<OrganUser>().HasOne(o => o.Organ).WithMany(o => o.OrganUsers).HasForeignKey(o => o.OrganId);
modelBuilder.Entity<OrganUser>().HasIndex(o => new { o.UserId, o.OrganId }).IsUnique();
modelBuilder.Entity<UserDepartment>().HasOne(o => o.User).WithMany(o => o.UserDepartments).HasForeignKey(o => o.UserId);
modelBuilder.Entity<UserDepartment>().HasOne(o => o.Department).WithMany(o => o.UserDepartments).HasForeignKey(o => o.DepartmentId);
modelBuilder.Entity<UserDepartment>().HasIndex(o => new { o.UserId, o.DepartmentId }).IsUnique();
@ -100,10 +105,12 @@ namespace UserCenter
var saRole = new Role { Name = "超级管理员", IsReadOnly = true };
var adminRole = new Role { Name = "管理员", IsReadOnly = true };
var skips = new string[] { "添加权限", "修改权限", "添加权限分类", "修改权限分类" };
foreach (var item in dbContext.Set<Permission>())
{
saRole.RolePermissions.Add(new RolePermission { Permission = item, IsReadOnly = true });
if (!item.Name.Contains("删除"))
if (!item.Name.Contains("删除") && !skips.Contains(item.Name))
{
adminRole.RolePermissions.Add(new RolePermission { Permission = item, IsReadOnly = true });
}

@ -8,6 +8,17 @@ CREATE TABLE "uc_Department" (
CONSTRAINT "FK_uc_Department_uc_Department_ParentId" FOREIGN KEY ("ParentId") REFERENCES "uc_Department" ("Id") ON DELETE RESTRICT
);
CREATE TABLE "uc_Organ" (
"Id" TEXT NOT NULL CONSTRAINT "PK_uc_Organ" PRIMARY KEY,
"IsDeleted" TEXT NULL,
"Name" TEXT NULL,
"Number" TEXT NOT NULL,
"Path" TEXT NULL,
"ParentId" TEXT NULL,
"Contact" TEXT NULL,
CONSTRAINT "FK_uc_Organ_uc_Organ_ParentId" FOREIGN KEY ("ParentId") REFERENCES "uc_Organ" ("Id") ON DELETE RESTRICT
);
CREATE TABLE "uc_PermissionCategory" (
"Id" TEXT NOT NULL CONSTRAINT "PK_uc_PermissionCategory" PRIMARY KEY,
"IsDeleted" TEXT NULL,
@ -84,6 +95,15 @@ CREATE TABLE "uc_Permission" (
CONSTRAINT "FK_uc_Permission_uc_PermissionCategory_CategoryId" FOREIGN KEY ("CategoryId") REFERENCES "uc_PermissionCategory" ("Id") ON DELETE SET NULL
);
CREATE TABLE "uc_OrganUser" (
"Id" TEXT NOT NULL CONSTRAINT "PK_uc_OrganUser" PRIMARY KEY,
"IsDeleted" TEXT NULL,
"UserId" TEXT NOT NULL,
"OrganId" TEXT NOT NULL,
CONSTRAINT "FK_uc_OrganUser_uc_Organ_OrganId" FOREIGN KEY ("OrganId") REFERENCES "uc_Organ" ("Id") ON DELETE CASCADE,
CONSTRAINT "FK_uc_OrganUser_uc_User_UserId" FOREIGN KEY ("UserId") REFERENCES "uc_User" ("Id") ON DELETE CASCADE
);
CREATE TABLE "uc_UserDepartment" (
"Id" TEXT NOT NULL CONSTRAINT "PK_uc_UserDepartment" PRIMARY KEY,
"IsDeleted" TEXT NULL,
@ -116,6 +136,14 @@ CREATE UNIQUE INDEX "IX_uc_Department_Number" ON "uc_Department" ("Number");
CREATE INDEX "IX_uc_Department_ParentId" ON "uc_Department" ("ParentId");
CREATE UNIQUE INDEX "IX_uc_Organ_Number" ON "uc_Organ" ("Number");
CREATE INDEX "IX_uc_Organ_ParentId" ON "uc_Organ" ("ParentId");
CREATE INDEX "IX_uc_OrganUser_OrganId" ON "uc_OrganUser" ("OrganId");
CREATE UNIQUE INDEX "IX_uc_OrganUser_UserId_OrganId" ON "uc_OrganUser" ("UserId", "OrganId");
CREATE INDEX "IX_uc_Permission_CategoryId" ON "uc_Permission" ("CategoryId");
CREATE UNIQUE INDEX "IX_uc_Permission_Number" ON "uc_Permission" ("Number");

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.0.0.*")]
[assembly: AssemblyInformationalVersion("1.0.0.513")]
[assembly: AssemblyInformationalVersion("1.0.0.514")]
Loading…
Cancel
Save