Location>code7788 >text

PasteForm best CRUD practices, real cases PasteTemplate detailed explanation of the 3000 questions (four)

Popularity:487 ℃/2024-10-09 22:01:27
Whether 100 tables or 30 tables, in the use of PasteForm mode, the management side of the page is the same, about 4 pages.
The use of different modes of operation under different dto data model, through the back-end modification of the corresponding dto can be done to control the front-end UI, in the absence of special special needs can be done to quickly realize the CRUD!
Eliminate version compatibility issues , eliminating inconsistencies between the front and back end , eliminating the problem of inconsistent styles !
Based on the idea of PasteForm, you can also use other languages to achieve , such as java + vue, or php + angluar and so on!

image

So many days have passed since last time, and in that time I've continued to use PasteForm to develop new projects, and found new problems, or shortcomings, so I've made some additions to the original!

Tables are displayed differently by authority

For example, you can set up for the account with a certain permission to return to the menu three, and do not have this permission does not return this permission, the case here is in the form of data, so we find the corresponding ReadListModel interface, in accordance with the following operation can be

        /// <summary>
        /// retrieveListDtodata model
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ReadListModel()
        {
            var _model = <StoreInfoListDto>(new StoreInfoListDto());
            var _query_model = (new InputQueryStore());
            if (_query_model != null)
            {
                _model.QueryProperties = _query_model.Properties;
            }
            var _isroot = ();
            if (!_isroot)
            {
                var prost = _model.(x => == "Menu3" || == "Menu4").ToList();
                if(prost!=null && > 0)
                {
                    foreach(var ii in prost)
                    {
                        _model.(ii);
                    }
                }
            }
            return _model;
        }

As shown above, said that if there is no super privilege (IsSuper()), then remove the object Menu3 and Menu4, these two fields are my customized menu, so that, for example, Zhang San logged in to see these two menus, while Li Si logged in to see these two menus! Changes to the interface after the upgrade of the front-end immediate effect, to avoid the problem of version transition!
Similarly, you can specialize some fields based on different permissions!

Problems with customized file uploads

Before the use of the file attribute, the definition of the file upload, the default args1 parameter is a custom path, the back due to other needs, reference to the definition of the menu, the introduction of args3, you can customize the function, such as mine!

        /// <summary>
        /// User Data
        /// </summary> /// User data.
        [ColumnDataType("file", "", "", "global_upload_media(this);")]
        public string UploadMedia { get; set; } = "Click to upload a data file (*.mp3)";

Note that ColumnDataType has a total of six parameters, respectively, name, args1, args2, args3, args4, error, the default is null!

Customized styles in forms

Sometimes we need to add some style to a form item, that is, css style="xxxx"; this time you can mark the field style, as follows

        /// <summary>
        /// note
        /// </summary>
        [ColumnDataType("textarea")]
        [ColumnDataType("style", "height:90px;")]
        public string Mark { get; set; } = "";

For example, the above, defines 2 properties, the current field is displayed using textarea, and then configures the height of this to be 90px; the
image

Redefinition of query

For example, sometimes we open a page and pass in the parameter
typical example

pasteform/?path=roleInfo&gradeId=5

The meaning is that I want to show the permission roleInfo list, the incoming parameter is gradeId=5, so in the page, after obtaining the parameter gradeId, the search item in the gradeId carrying the field will be hidden, and at the same time assigned the value of 5, if the search item gradeId corresponding to the field does not get the value from the query parameter, then the search item will not be hidden, of course, you can mark it hidden to hide it!
Hidden fields in the search item, pay attention to the default value, such as orderby, if you do not give the default value, it will cause the search based on the empty sort, this time will not report an error?

id redefinition in form

Sometimes we need to customize the new data when the primary key Id, general Id is hidden by default, this time it is a little embarrassing, but also due to the type of Int, for example, sometimes allowed to not write, that is, the value of 0, this time required is not quite applicable, so change the rules for the description of the field to have a field for the display, otherwise in accordance with the default hidden processing

        ///<summary>
        ////ID Mandatory (note the comments here, separated by a space, with the name in front of the space, followed by the comment)
        ///</summary> ///ID Required.
        [Required]
        [MaxLength(32)]
        public string Id { get; set; } = "";

Adjustment of image in form

If the image is in single-image mode, it takes up half a line of the form, and the old version took up one line for IMAGE!
image

The switch attribute adds support for args1.

Sometimes we want to show swtich, and sometimes do not want to show, such as the list of permissions in the IsEnable state, when the current mode for the model = bind, we often want to read the IsEnable==true data, and then extendBind for whether the bound field, this time you need to configure the IsEnable in the view only when the switch is displayed, the other modes for true/false display, that is, non-operable mode, so there!

        ////<summary>
        //// Status
        ///</summary>
        [ColumnDataType("switch", "view")]
        public bool IsEnable { get; set; }

        /// <summary>
        /// Binds whether the extension has this permission based on the role.
        /// </summary> /// Bind.
        [ColumnDataType("switch")]]
        [ColumnDataType("hidden", "bind")]]
        public bool ExtendBind { get; set; }

Note the code above!!!
hidden means that it is not hidden when it is currently bind, but not when it is bind.
switch means that it shows switch mode when it is currently bind, but does not show switch when it is not bind, i.e., it shows true/false mode, and it does not show switch mode when it is not bind.
If switch's args1 is not filled in, i.e., left empty, it means that any mode shows switch mode
ps: the model mentioned above refers to the presentation of the pasteform/, there are view, select, bind three modes
The default mode of view is to display tabular data.
select indicates that the display mode of the object is selected when using the attribute outer.
bind mode, such as binding permissions for roles, this time you need to list all the permissions that have been bound to the switch is open!
image
The image above shows binding permissions for a role, you can see that the status is shown as true/false for non-interactive, and extendBind is shown as switch for interactive!
In the default view, the state is in interactive switch mode, and the bindings are hidden, as follows
image

[[In the use of PasteForm mode, do you have any other questions, you can leave a message in the comments, we will see you next issue]]]]