Asp. Net Core project practice-permission management system (3) function and entity design, core permission management system

Source: Internet
Author: User

Asp. Net Core project practice-permission management system (3) function and entity design, core permission management system

0 Asp. Net Core: permission management system (0)

1 Asp. Net Core project practice-permission management system (1) Use AdminLTE to build a front-end

2 Asp. Net Core project practice-permission management system (2) function and entity Design

3. Asp. Net Core: permission management system (3) using PostgreSQL through EntityFramework Core

Github Source Code address

0 Function Design

The simplest and most basic permission management system includes organization management, role management, user management, function management, and Role authorization.

1. Function management includes two levels: function menu and function page button.

2. Role authorization.

3. Each user can have multiple roles. the user's actual permissions are obtained based on the union of multiple roles.

/// <Summary> /// generic Entity base class /// </summary> /// <typeparam name = "TPrimaryKey"> Primary Key type </typeparam> public abstract class Entity <TPrimaryKey >{/// <summary> /// primary key /// </summary> public virtual TPrimaryKey Id {get; set ;}//< summary> // defines the object base class with the default primary key type of Guid /// </summary> public abstract class Entity: entity <Guid> {}1.0 organizational entity

/// <Summary> /// Department entity /// </summary> public class Department: entity {// <summary> // Department Name // </summary> public string Name {get; set ;} /// <summary> /// department ID /// </summary> public string Code {get; set ;} /// <summary> /// department head /// </summary> public string Manager {get; set ;} /// <summary> /// contact number /// </summary> public string ContactNumber {get; set ;} /// <summary> /// remarks /// </summ Ary> public string Remarks {get; set ;}/// <summary> /// parent department ID /// </summary> public Guid ParentId {get; set ;} /// <summary> /// creator /// </summary> public Guid CreateUserId {get; set ;} /// <summary> /// creation time /// </summary> public DateTime? CreateTime {get; set ;}/// <summary >/// whether or not the object has been deleted /// </summary> public int IsDeleted {get; set ;} /// <summary> /// contains the User /// </summary> public virtual ICollection <User> Users {get; set ;} /// <summary> /// creator information /// </summary> public virtual User CreateUser {get; set ;}}
1.1 functional entities
/// <Summary> /// function Menu entity /// </summary> public class Menu: entity {// <summary> // parent ID /// </summary> public Guid ParentId {get; set ;} /// <summary> /// serial number /// </summary> public int SerialNumber {get; set ;} /// <summary> /// menu Name /// </summary> public string Name {get; set ;} /// <summary> /// menu encoding /// </summary> public string Code {get; set ;} /// <summary> /// menu address /// </summary> publi C string Url {get; set ;}/// <summary> // type: 0 navigation menu; 1 OPERATION button. /// </Summary> public int Type {get; set ;}/// <summary> // menu Icon /// </summary> public string Icon {get; set ;}//< summary> /// menu Remarks //</summary> public string Remarks {get; set ;}
}
1.2 role entity
public class Role : Entity{     public string Code { get; set; }     public string Name { get; set; }     public Guid CreateUserId { get; set; }     public DateTime? CreateTime { get; set; }     public string Remarks { get; set; }     public virtual User CreateUser { get; set; }     public virtual ICollection<User> Users { get; set; }     public virtual ICollection<Menu> Menus { get; set; }}
1.3 user entity
Public class User: Entity {// <summary> // User name // </summary> public string UserName {get; set ;} /// <summary> /// Password /// </summary> public string Password {get; set ;} /// <summary> /// user Name /// </summary> public string Name {get; set ;} /// <summary> /// EMail address /// </summary> public string EMail {get; set ;} /// <summary> /// mobile phone number /// </summary> public string MobileNumber {get; set ;}/// <Summary> // Remarks /// </summary> public string Remarks {get; set ;} /// <summary> /// creator /// </summary> public Guid CreateUserId {get; set ;} /// <summary> /// creation time /// </summary> public DateTime? CreateTime {get; set ;}/// <summary> /// last logon time /// </summary> public DateTime LastLoginTime {get; set ;} /// <summary> /// Number of logins /// </summary> public int LoginTimes {get; set ;} /// <summary> /// department ID /// </summary> public Guid DeptmentId {get; set ;} /// <summary> /// whether the object has been deleted /// </summary> public int IsDeleted {get; set ;} /// <summary> /// Department entity /// </summary> public virtual Department {get; set ;} /// <summary> /// creator object /// </summary> public virtual User CreateUser {get; set ;} /// <summary> /// Role set /// </summary> public virtual ICollection <Role> Roles {get; set ;}
}
2. Conclusion

This document mainly designs functions and entities for the simplest permission management system. related entity files are added to the project. The current solution structure is as follows:

Next, we will introduce how to use the PostgreSQL database through EntityFramework Core in Asp. Net Core.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.