As a complete project to build the support of the interface, here the front-end of the basic page has been completed, now the interface design

Interface requirements

  • Implement login function
  • Implement permission function

Design ideas

| | - the user table (user) - field contains: id primary key, user name, password, create, update time, signature, roles, the reserved field (role) | | - character table - field contains: id primary key, the role name, obligate field table (priv) | | - permissions field contains: Id primary key, permissions, name, permissions, value, the types of rights, the reserved field (userRoles) | | - user role relation table - field contains: userId, roleId - - - foreign key link (rolePrivs) | | - associated role authorization table - field contains: PrivId,roleId—————— Foreign key associationCopy the code

Interface ideas

| - login interface: validating the user name and password, return signature token, here will give token a time limit, by updating the time to compare | - query access interface: | - adding roles show permission list interface: adding roles and permissions | - can be configured to modify role interface: modify properties | - delete role interface: Batch delete to delete the specified role, here do | - query interface role: fuzzy queries all role attribute | - add user interface: add user basic information, and can give the role | - delete user interface: delete specified users, here do batch delete | - modify the user interface: modify the specified user attributes list | - queries the user interface: Fuzzy query user information list details | - queries the user interface: precise query a single user all attributes (basic attribute, role permissions)Copy the code

FindAndCountAll – Paging query

Compared with findAll, offset indicates the number of entries to be filtered and limit indicates the number of entries to be queried

Usage show

    await module.findAndCountAll({
        where: {
            subject:{
                [Op.like]:The '%' +subject + The '%'
            },
            type:{
                [Op.like]:The '%' +type + The '%'
            },
            category:{
                [Op.like]:The '%' +category + The '%'
            },
            score:{
                [Op.like]:The '%' +score + The '%'
            }
        },
        offset,
        limit
    });
Copy the code

Learn more about SequelizeClick here to