preface

This project is the dormitory management system, mainly including data monitoring market, dormitory management, dormitory management, dormitory member management, borrowing management, health management, payment management, warranty management, log management, user management, role management and the export function of each module. With enterprise-level development standards to complete the entire front and back end code, whether used as a graduation design or to learn, I believe that beginners will be of great help.

(Want source code and video tutorial students private message me ~~~)

Engineering structure

Application layer

The hierarchy above is taken from the Alibaba Java Development manual, and I have made some adjustments to it. The actual hierarchy is as follows:

The domain model

  • DO (DataObject) : Corresponds to the database table structure one by one, and transmits data source objects upward through the DAO layer

  • BO (BusinessObject) : BusinessObject. An object that encapsulates business logic output by the Service layer

  • VO (View Object) : Display layer Object, usually an Object transferred by the Web to the template rendering engine layer

    BO and VO domain models are divided into BoRequest (input model), BoResponse (output model), VoRequest (input model) and VoResponse (output model).

Technology stack

Front end: Vue + Element

Back-end: JDk1.8 + SpringBoot + Redis + mysql

The system design

Interface design

The interface of the whole project adopts the restful style design which is popular in the Internet at present, and each interface and each parameter have detailed documentation. Because development in the enterprise has to be team work, it has to be a separate development model, you have to define the interface first, and then the front end can be developed in sync with the back end. Another way is to provide interfaces externally. For example, your team next door wants to call the interface of your service, but your two schedules are in the same week. In this case, you need to define the interface to the other team first, and then everyone develops it synchronously.

Running effect

System login

dashboard

Home page data market, according to the pie chart proportion of the latest 7 days, the trend of the latest 30 days line chart, the bar chart analysis of the latest year, the proportion of each time period of the latest 7 days analysis of all-round visual analysis data.

Dormitory management

Dormitory management

Dormitory member Management

Borrowing management

Health management

The head of the dormitory can arrange the staff on duty in the dormitory. Each person is on duty for one day, which is convenient for health management.

Pay cost management

The warranty management

Excel export

All modules support data export to Excel to facilitate data analysis

Borrowing record export

Warranty export

Log management

By default, log management is configured for the administrator. All operations in the system are recorded, helping the administrator troubleshoot faults when the system is abnormal.

User management

By default, only the administrator has the user management menu permission, and can create or edit users, assign user roles, and disable or enable users

Editing user Information

Role management

Extremely flexible rights management, all buttons in the system can be independently assigned rights, you can assign only query and export rights to role A, you can assign query, edit and new rights to role B, and you can assign only query rights to role C. Almost all business needs can be met, and you are free to define the combination of permissions.

Default: ‘Administrator role’, ‘Dormitory leader role’, ‘Common user Role’

A message is displayed if the page does not exist

Modification of Personal Information

Password change

After the administrator creates a user, the default password is 123456. The user can log in to the system to change the password

Permission to design

Permissions are implemented based on security and spring-session. Permission can be divided into authentication and authorization. Authentication is actually login. When a user logs in, the account and password are verified. Authorization refers to whether a user has the permission to access back-end resources. After a new user is created, a role is assigned to a user. A role is a set of permissions.

The permission design here is very flexible, fine-grained to button level, such as add, delete, modify, query, borrow action, ordinary users may only have query permission, administrators have new, delete, modify permissions. Even if a common user directly accesses the back-end through the interface to modify or delete the interface, the back-end will return an authorization failure error, because each back-end interface that requires permission is marked with permission identifier. Only users with resource permission can access the interface.

For example, the following vehicle modification interface, only the user with the “CAR_UPDATE” permission identifier can access this interface, otherwise “unauthorized” error is returned.

@PutMapping("/{id}")
@PreAuthorize("hasAuthority(T(com.senior.book.console.api.security.Authority).BOOK_UPDATE.name())")
    public Result<Boolean> update(@PathVariable("id") Long id, @Valid @RequestBody BookUpdateVoRequest request) {}Copy the code

Logging solution

Log using Lombok annotation + SLF4J + Log4J2 implementation scheme, based on the profile to achieve multi-environment log configuration, because different environment log printing strategy is different, for example, I may need to print to the console development environment, need debug level log to facilitate local development debugging. Test environment may need to print to the log file, the online environment may need to print to a file at the same time send logs to the kafka and collected es, such as online deployed more machine after we check the log to a a machine to check the log, because all the es collection, we just need to log in to kibana to search, It’s very convenient. Here said kafka+ ES + Kibana such a log solution is also the Internet companies more commonly used a set of solutions. If you’re very practical, you can build a set of kafka, Es, and Kibana locally and implement an enterprise-class logging solution by adding a few lines of configuration files (the default is to output to a log file).

The following are some of the key configurations. To configure Kafka, you only need to configure the configurations in the tag

    
      
<Configuration status="WARN"  xmlns:xi="http://www.w3.org/2001/XInclude">
    <Properties>
        <Property name="LOG_FILE">system.log</Property>
        <Property name="LOG_PATH">./logs</Property>
        <Property name="PID">????</Property>
        <Property name="LOG_EXCEPTION_CONVERSION_WORD">%xwEx</Property>
        <Property name="LOG_LEVEL_PATTERN">%5p</Property>
        <Property name="LOG_DATE_FORMAT_PATTERN">yyyy-MM-dd HH:mm:ss.SSS</Property>
        <Property name="CONSOLE_LOG_PATTERN">%clr{%d{${LOG_DATE_FORMAT_PATTERN}}}{faint} %clr{${LOG_LEVEL_PATTERN}} %clr{${sys:PID}}{magenta} %clr{---}{faint} % the CLR {[% 15.15 t]} {abbreviation} % CLR {% - 40.40 - c {1}} {cyan} % CLR {that} {abbreviation} % m % n ${sys: LOG_EXCEPTION_CONVERSION_WORD}</Property>
        <Property name="FILE_LOG_PATTERN">% d {${LOG_DATE_FORMAT_PATTERN}} ${LOG_LEVEL_PATTERN} ${sys: PID} [t] % % - 40.40 c {1} : % L: %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
    </Properties>
    <Appenders>
        <xi:include href="log4j2/file-appender.xml"/>
    </Appenders>
    <Loggers>
        <logger name="com.senior.park" level="info"/>
        <Root level="info">
            <AppenderRef ref="FileAppender"/>
        </Root>
    </Loggers>
</Configuration>
Copy the code