Back to total directory: Abp+adminlte+bootstrap table Rights Management System Phase I
Many people say ABP is not suitable for high concurrency large, there is a certain truth, but I think it is possible to see the architect's ability, I before the company is ABP absolute million data-level projects, is an online education site, involving the platform, college, faculties, classes, courses, students, etc., a platform how many universities, A university how many faculties, a department how many classes how many classes, the degree of responsibility is not simple, do not say, it is the great God, than I see in the garden absolute majority of architects are strong. I waited for the object to look up. But this is not the reason to stop and watch, but it is our pursuit of stronger steps.
In software development There will be a lot of mechanical duplication of work, there are a lot of repetitive code, the user needs more and more high, we have to make a more complex response, which requires us to integrate more things to meet the needs of the work.
Whenever we want to develop a new system, we need to use the things we used before, such as MVC,IOC, log, database mapping, log management, Message Queuing components and so on. We prefer to spend more time dealing with business logic than in software architecture, logs, fault tolerance, and so on.
Many big companies have their own basic framework, their company encapsulates a lot of things, such as our company's date components, pop-up windows, table style, paging, etc. are already encapsulated, and then later development of the time we just need to call on it, do not need each control to spend their time and energy to encapsulate.
I'll just say this. The system of Adminlte+bootstrap table based on ABP Module-zero is considered as the summary and extension of the preceding 11 sections.
First we still go to the official website to create a solution from the ABP template. Tick on Module-zero, then create a database connection, restore the NuGet package, and Update-database create the database.
The next step is to create a script to update the database, these are mentioned in the previous chapters, I will not do the statement, I do not understand can go back to the first section.
Then build ActionResult login under the home controller and add an attempt page. Plus own landing page style JS and so on, here we do not use the form of MVC again to request the controller, We directly request Webapi's Landing method. Yes, well, that's the swagger. Then request the account interface for/swagger/ui/index.
Now that we've talked about the ABP encapsulation of JavaScript Ajax,
var Newperson = { name: ' Dougles Adams ', age:42};abp.ajax ({ URL: '/people/saveperson ', data:JSON.stringify (Newperson)}). Done (the function(data) { abp.notify.success (' created new person with id = ' + Data.personid);});
In fact, here we can also do some re-encapsulation, easy to use in the project, the landing as an example of the effect is as follows.
Abp.ui.block ($ (' #login ' )); var url = "/api/account" ; var login = function (para, Ajaxtype,posturl) {return abp.ajax ({ur L:posturl, Type:ajaxtype, Async:false , data: Json.stringify (Para)}); }; var Loginmodel = {"Tenancyname": "" , "usernameoremailaddress": $ ("#userName" ). Val (), "Password": $ (" #password "). Val ()}; Abp.ui.setBusy ($ (' #login ' ), login (Loginmodel, "post", url). Done (function (data) {Abp.auth.setToken (" Bearer "+ data); Window.location.href = "/admin/userinfo/index" });
Of course this is in the ABP original package effect added, careful you have found here more than two things, one is Abp.ui.block, the other is abp.ui.setBusy, this is actually a block user repeat commit, and is committing busy state,
is actually a mask layer.
Here is the ABP integrated jquery.blockUI.js plug-in, which uses a transparent coating (transparent overlay) to block the entire page or an element on the page. This way, the user's click is not valid. This is useful when saving a form or loading an area (a div or an entire page). Like what
In addition Abpjs also to Blockui do some common methods of encapsulation, set blocking abp.ui.block, unblock Abp.ui.unblock, set busy abp.ui.setBusy and lift busy state abp.ui.clearBusy
Abp.ui.block = function (elm) { Abp.log.warn (' Abp.ui.block is not implemented! ' ); }; Abp.ui.unblock = function (elm) { Abp.log.warn (' Abp.ui.unblock is not implemented! ' ); }; /* UI BUSY * ///defines UI BUSY API, not implements it abp.ui.setBusy = function (elm, Optionsorpromis e) {Abp.log.warn (' abp.ui.setBusy is not implemented! ' ); }; Abp.ui.clearBusy = function (elm) {Abp.log.warn (' abp.ui.clearBusy is not implemented! ' ); };
Abp.ui.block (); Block the entire page abp.ui.block ($ (' #MyDivElement ')); You can use the jquery selector: Abp.ui.block (' #MyDivElement '); //.. or directly using the selector abp.ui.unblock (); Unblock entire page abp.ui.unblock (' #MyDivElement '); Unblocking a specific element
The UI Block API is implemented by default with jquery's Blockui plugin. If it comes into effect, you should include its JavaScript file, and then include Abp.blockUI.js as the adapter in the page.
The other is busy. The API is used to make certain pages or elements in a busy state. For example, you might want to block a form and then show a busy indicator when submitting the form to the server. Example:
Abp.ui.setBusy (' #MyLoginForm '); Abp.ui.clearBusy (' #MyLoginForm ');
The effect is the busy effect above.
The parameter should be a selector (such as ' #MyLoginForm ') or a jquery selector (such as $ (' #MyLoginForm ')). To make the entire page busy, you can pass in null (or ' body ') as a selector. The second parameter of the SETBUSY function receives a promise (contract) that automatically clears the busy state when the contract is completed. Because Abp.ajax returns promise, we can pass it directly as a promise. To learn the habit of promise more things, check out the Deferredof jquery.
The UI Busy API is implemented using spin.js . For it to take effect, it should contain its JavaScript file and then include Abp.spin.js as the adapter in the page.
Through the above efforts, we have to land has been done. The only thing we have to do after the landing is a save token. The other is the redirection of the route.
Token is important in the ABP, and we ask /api/account to give back a token, and we store tokens in cookies when we log in to facilitate later use. such as the landing of the Abp.auth.setToken ("Bearer" + data); How does the ABP set up cookies, which are also encapsulated here.
Abp.auth.tokenCookieName = ' Abp.authtoken '; Abp.auth.setToken = function (AuthToken, expiredate) { abp.utils.setCookieValue (abp.auth.tokenCookieName, AuthToken, ExpireDate, Abp.apppath); }; Abp.auth.getToken = function () { return abp.utils.getCookieValue (abp.auth.tokenCookieName); } Abp.auth.clearToken = function () { abp.auth.setToken (); }
This includes the methods used to access and purge tokens.
We have already added the domain, so here the login is successful and direct the URL to/admin/userinfo/index. Of course in the/areas/common/views/layout inside we have adminlte layout, including the menu has been loaded out, in fact, now the service layer of the time to miss something, we make up here, ABP since is a framework
Then in the creation of the service, it is natural to include the base additions and deletions to change the method, then Iasynccrudappservice will come in handy. Here we talk about the template imodulesservice. First we create the model and the DTO.
Using abp.domain.entities;using system;using system.collections.generic;using System.componentmodel.dataannotations;using system.linq;using system.text;using System.threading.tasks;namespace jcms.meuns{public class meun:entity<int>, imayhavetenant {public int? ParentID {get; set;} [Required] [Stringlength] publicstring Name {get; set;} [Required] [Stringlength] publicstring Linkurl {get; set;} [Stringlength] publicstring Description {get, set,} public bool Ismenu {GET, set;} public int Cod e {get; set;} public bool Enabled {GET, set;} public DateTime updatedate {get; set;} public int? TenantId {get; set; }}}
Dto:
UsingAbp.application.services.dto;usingAbp.automapper;usingAbp.domain.entities;usingSystem;usingSystem.collections.generic;usingSystem.componentmodel;usingSystem.componentmodel.dataannotations;usingSystem.linq;usingSystem.text;usingSystem.threading.tasks;namespacejcms.meuns{//<summary>///menu//</summary>[Serializable] [Automapfrom (typeof(Meun))] public class Meundto:entitydto<int>{//<summary>///ID//</summary> public int ID {get; set; }///<summary>//Parent Module ID///</summary> public int? ParentID {get; set;} <summary>///</summary> [Required] [Stringlength ()] public string name {get; set
; }///<summary>///</summary>
[Required] [Stringlength ()] public string Linkurl {get; Set ;}///<summary>///Is menu///</summary> public bool Ismenu {get; set ;}//<summary> ; Module number///</summary> public int code {get; set ;}///<summary>//Description///</summary> [Stringl Ength (+ )] public string Description {get; set ;}///<summary>///Activate///</summary> public B Ool Enabled {get; set ;} public DateTime updatedate {get; set ;}//public virtual meundto parentmodule {get ; Set }//public list<meundto> childmodules {get; private set;} public list<meundto> Children {get; set ;} }}
It should be noted here that if the model integrates an interface, then the DTO will inherit the dto of this interface, or else inherit Iasynccrudappservice will error.
For example, the model inherits Entity<int>, so DTOs also inherit Entitydto<int>
Then let's take a look at the parameters Iasynccrudappservice need.
Here can be seen very clearly, including additions and deletions of the dto here I am lazy, all used one.
Interface:
public interface imodulesservice:iasynccrudappservice<meundto, int, pagedresultrequestdto, meundto, MeunDto>// Iapplicationservice { }
Realize
public class Modulesservice:asynccrudappservice<meun, meundto, int, pagedresultrequestdto, meundto, MeunDto> , Imodulesservice {Public Modulesservice (Irepository<meun, int> repository): Base(repository) { } }
Then we Add. Withconventionalverbs () under the Apijcmswebapimodule method so that we can see the specific HTTP prefix, otherwise all post,http verbs are determined by the prefix of the method name:
- Get: The method name starts with get.
- Put: The method name begins with a put or an update.
- Delete: The method name begins with delete or remove.
- Post: The method name begins with post or create.
- Otherwise, post is the default value for the HTTP verb.
We can override these conventions by using WITHVERB methods or HTTP features for specific methods.
In this way, we are commonly used in the business layer of additions and deletions to change the method was born.
Verify that the incoming parameters, the results are not defective, available. Of course, it is possible to rewrite these methods according to your own needs. Page and the previous page almost, nothing to say, here page additions and deletions have been implemented.
Now the user management and role management functions have been implemented, I will do menu management, authorization management, done basically finished, of course, the following is also the focus. Work together!
GitHub Address: Https://github.com/Jimmey-Jiang/JCMS
Back to total directory: Abp+adminlte+bootstrap table Rights Management System Phase I
ABP Module-zero +adminlte+bootstrap table+jquery Rights Management System section 12th-Summary, role management of Bootstrap Table