|  | 
| 1 | 1 | # mybatis-dynamic-sql-integration-demo | 
| 2 |  | -a sample code integration mybatis generator, mybatis dynamic sql, spring-boot | 
|  | 2 | + | 
|  | 3 | +## Description | 
|  | 4 | + | 
|  | 5 | +A sample code integration mybatis generator, mybatis dynamic sql, spring-boot. | 
|  | 6 | + | 
|  | 7 | +**integration features** | 
|  | 8 | + | 
|  | 9 | +- Generate Entity from database by run Gradle Task `dao:mybatisGenerate` | 
|  | 10 | +- Auto migration database DDL or DML by flyway | 
|  | 11 | +- Integration Lombok and MapStruct to simplify the code | 
|  | 12 | +- Integration Mybatis-Dynamic-SQL and shows how write complicated DSL SQL | 
|  | 13 | + | 
|  | 14 | + | 
|  | 15 | + | 
|  | 16 | +# Build | 
|  | 17 | + | 
|  | 18 | + | 
|  | 19 | + | 
|  | 20 | +# Run | 
|  | 21 | + | 
|  | 22 | +1. First: modify `api/resources/application.yml` | 
|  | 23 | + | 
|  | 24 | +```yaml | 
|  | 25 | +spring: | 
|  | 26 | + datasource: | 
|  | 27 | + driver-class-name: com.mysql.cj.jdbc.Driver | 
|  | 28 | + url: jdbc:mysql://{your database url}/{your database name} | 
|  | 29 | + username: { your database username } | 
|  | 30 | + password: { your database password }  | 
|  | 31 | +``` | 
|  | 32 | + | 
|  | 33 | +2. Second: modify `dao/resources/generatorConfiguration.xml` | 
|  | 34 | + | 
|  | 35 | +```xml | 
|  | 36 | + | 
|  | 37 | +<generatorConfiguration> | 
|  | 38 | + | 
|  | 39 | + <context id="dsql" targetRuntime="MyBatis3DynamicSql"> | 
|  | 40 | + <!-- ...... --> | 
|  | 41 | + <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" | 
|  | 42 | + connectionURL="jdbc:mysql://{your database url}/{your database name}" | 
|  | 43 | + userId="{your database username}" | 
|  | 44 | + password="{your database password}"/> | 
|  | 45 | + <!-- ...... --> | 
|  | 46 | + </context> | 
|  | 47 | +</generatorConfiguration> | 
|  | 48 | +``` | 
|  | 49 | + | 
|  | 50 | +3. Run Main class `api/java/cc/cc1234/api/Application.java` | 
|  | 51 | + | 
|  | 52 | + | 
|  | 53 | + | 
|  | 54 | +# Module | 
|  | 55 | + | 
|  | 56 | + | 
|  | 57 | + | 
|  | 58 | + | 
|  | 59 | + | 
|  | 60 | +## API | 
|  | 61 | + | 
|  | 62 | +| Method | EndPoint | Request Body | Description | | 
|  | 63 | +| ------ | -------------------------------------- | ------------------------------------- | ----------------------------- | | 
|  | 64 | +| POST | /v1/api/user | {"username":"hello", "gender":"MALE"} | create user | | 
|  | 65 | +| DELETE | /v1/api/users/{userId} | N/A | delete user | | 
|  | 66 | +| PATCH | /v1/api/users/{userId} | {"username":"hello", "gender":"MALE"} | update user basic information | | 
|  | 67 | +| GET | /v1/api/users?page=1&size=20 | N/A | list users | | 
|  | 68 | +| GET | /v1/api/users/{userId}/goods/purchased | N/A | query user purchased goods | | 
0 commit comments