feat:数据库连接、序列化日期
This commit is contained in:
@@ -30,6 +30,11 @@
|
||||
<artifactId>enlish-spring-boot-starter-biz-operationlog</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.yinlihupo.framework.jackson</groupId>
|
||||
<artifactId>enlish-spring-boot-starter-jackson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
@@ -40,10 +45,30 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Mybatis -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MySQL 驱动 -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<!-- 代码生成器 -->
|
||||
<plugin>
|
||||
<groupId>org.mybatis.generator</groupId>
|
||||
<artifactId>mybatis-generator-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.yinlihupo.enlish.service;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.yinlihupo.enlish.service.domain.mapper")
|
||||
public class EnlishServiceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.yinlihupo.enlish.service.deoms.web;
|
||||
|
||||
import com.yinlihupo.framework.biz.operationlog.aspect.ApiOperationLog;
|
||||
import com.yinlihupo.framework.common.response.Response;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class TestController {
|
||||
|
||||
@GetMapping("/test")
|
||||
@ApiOperationLog(description = "测试接口")
|
||||
public Response<String> test() {
|
||||
return Response.success("Hello, 犬小哈专栏");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yinlihupo.enlish.service.domain.dataobject;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Builder
|
||||
public class ClassDO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String title;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yinlihupo.enlish.service.domain.mapper;
|
||||
|
||||
import com.yinlihupo.enlish.service.domain.dataobject.ClassDO;
|
||||
|
||||
public interface ClassDOMapper {
|
||||
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(ClassDO record);
|
||||
|
||||
int insertSelective(ClassDO record);
|
||||
|
||||
ClassDO selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(ClassDO record);
|
||||
|
||||
int updateByPrimaryKey(ClassDO record);
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver # 指定数据库驱动类
|
||||
# 数据库连接信息
|
||||
url: jdbc:mysql://124.220.58.5:3306/enlish
|
||||
username: root # 数据库用户名
|
||||
password: YLHP@admin123 # 数据库密码
|
||||
10
enlish-service/src/main/resources/config/application.yml
Normal file
10
enlish-service/src/main/resources/config/application.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
server:
|
||||
port: 8080 # 项目启动的端口
|
||||
|
||||
spring:
|
||||
profiles:
|
||||
active: dev # 默认激活 dev 本地开发环境
|
||||
|
||||
mybatis:
|
||||
# MyBatis xml 配置文件路径
|
||||
mapper-locations: classpath:/mapper/**/*.xml
|
||||
55
enlish-service/src/main/resources/generatorConfig.xml
Normal file
55
enlish-service/src/main/resources/generatorConfig.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE generatorConfiguration
|
||||
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
|
||||
<generatorConfiguration>
|
||||
<context id="mysqlTables" targetRuntime="MyBatis3" defaultModelType="flat">
|
||||
|
||||
<!-- 自动检查关键字,为关键字增加反引号,如:`type` -->
|
||||
<property name="autoDelimitKeywords" value="true"/>
|
||||
<property name="beginningDelimiter" value="`"/>
|
||||
<property name="endingDelimiter" value="`"/>
|
||||
<!-- 指定生成的 Java 文件编码 -->
|
||||
<property name="javaFileEncoding" value="UTF-8"/>
|
||||
|
||||
<!-- 对生成的注释进行控制 -->
|
||||
<commentGenerator>
|
||||
<!-- 由于此插件生成的注释不太美观,这里设置不生成任何注释 -->
|
||||
<property name="suppressAllComments" value="true"/>
|
||||
</commentGenerator>
|
||||
|
||||
<!-- 数据库链接 -->
|
||||
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
|
||||
connectionURL="jdbc:mysql://124.220.58.5:3306/enlish"
|
||||
userId="root"
|
||||
password="YLHP@admin123">
|
||||
<!-- 解决多个重名的表生成表结构不一致问题 -->
|
||||
<property name="nullCatalogMeansCurrent" value="true"/>
|
||||
</jdbcConnection>
|
||||
|
||||
<!-- 不强制将所有的数值类型映射为 Java 的 BigDecimal 类型 -->
|
||||
<javaTypeResolver>
|
||||
<property name="forceBigDecimals" value="false"/>
|
||||
</javaTypeResolver>
|
||||
|
||||
<!-- DO 实体类存放路径 -->
|
||||
<javaModelGenerator targetPackage="com.yinlihupo.enlish.service.domain.dataobject"
|
||||
targetProject="src/main/java"/>
|
||||
|
||||
<!-- Mapper xml 文件存放路径-->
|
||||
<sqlMapGenerator targetPackage="mapper"
|
||||
targetProject="src/main/resources"/>
|
||||
|
||||
<!-- Mapper 接口存放路径 -->
|
||||
<javaClientGenerator type="XMLMAPPER" targetPackage="com.yinlihupo.enlish.service.domain.mapper"
|
||||
targetProject="src/main/java"/>
|
||||
|
||||
<!-- 需要生成的表-实体类 -->
|
||||
<table tableName="class" domainObjectName="ClassDO"
|
||||
enableCountByExample="false"
|
||||
enableUpdateByExample="false"
|
||||
enableDeleteByExample="false"
|
||||
enableSelectByExample="false"
|
||||
selectByExampleQueryId="false"/>
|
||||
</context>
|
||||
</generatorConfiguration>
|
||||
65
enlish-service/src/main/resources/mapper/ClassDOMapper.xml
Normal file
65
enlish-service/src/main/resources/mapper/ClassDOMapper.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yinlihupo.enlish.service.domain.mapper.ClassDOMapper">
|
||||
<resultMap id="BaseResultMap" type="com.yinlihupo.enlish.service.domain.dataobject.ClassDO">
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="title" jdbcType="VARCHAR" property="title" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, title
|
||||
</sql>
|
||||
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from class
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from class
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
|
||||
<insert id="insert" parameterType="com.yinlihupo.enlish.service.domain.dataobject.ClassDO">
|
||||
insert into class (id, title)
|
||||
values (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
|
||||
<insert id="insertSelective" parameterType="com.yinlihupo.enlish.service.domain.dataobject.ClassDO">
|
||||
insert into class
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="title != null">
|
||||
title,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="title != null">
|
||||
#{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.yinlihupo.enlish.service.domain.dataobject.ClassDO">
|
||||
update class
|
||||
<set>
|
||||
<if test="title != null">
|
||||
title = #{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
|
||||
<update id="updateByPrimaryKey" parameterType="com.yinlihupo.enlish.service.domain.dataobject.ClassDO">
|
||||
update class
|
||||
set title = #{title,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user