Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities

This article also participated in the “Digitalstar Project” to win a creative gift package and creative incentive money

Logic to delete

Physical delete: Directly remove from the database

Logical deletion: not removed from the database, but invalidated by a variable! deleted = 0 => deleted = 1

Administrators can view deleted records! Prevent data loss, similar to the recycle bin!

Test it out:

1, add a deleted field to the table

2. Annotate entity classes

// Logical deletion @TABLelogic private Integer deleted;Copy the code

3, configuration! (Higher versions do not require configuration.)

@bean public ISqlInjector (){return new LogicSqlInjector(); }Copy the code
Mybatis - plus: # configure mybatis - plus log configuration: log - impl: org. Apache. Ibatis. Logging. Stdout. StdOutImpl global - config: db-config: logic-delete-value: 1 logic-not-delete-value: 0Copy the code

4. Test it out

Performance analysis plug-in

In our daily development, we encounter some slow SQL

Mp provides a performance analysis plugin that will stop the phone if it is exceeded

1. Import the plug-in

@bean@profile ({"dev","test"}) public PerformanceInterceptor PerformanceInterceptor (){ PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor(); / / set the SQL's biggest time, more than 1 ms does not perform performanceInterceptor. SetMaxTime (100); / / format support performanceInterceptor setFormat (true); return performanceInterceptor; }Copy the code

Start testing or production in Spring

  profiles:
    active: dev
Copy the code

2. Test use

An exception occurs when the set time is exceeded