新增TKmapper自动生成部分代码功能组件
This commit is contained in:
+53
-2
@@ -33,7 +33,58 @@
|
||||
<artifactId>tls-sig-api-v2</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<!--通用mapper-->
|
||||
<dependency>
|
||||
<groupId>tk.mybatis</groupId>
|
||||
<artifactId>mapper-spring-boot-starter</artifactId>
|
||||
<version>2.1.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 通用mapper代码生成器-->
|
||||
<plugin>
|
||||
<groupId>org.mybatis.generator</groupId>
|
||||
<artifactId>mybatis-generator-maven-plugin</artifactId>
|
||||
<version>1.3.6</version>
|
||||
<configuration>
|
||||
<configurationFile>
|
||||
${basedir}/src/main/resources/generator/generatorConfig.xml
|
||||
</configurationFile>
|
||||
<overwrite>true</overwrite>
|
||||
<verbose>true</verbose>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.26</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>tk.mybatis</groupId>
|
||||
<artifactId>mapper</artifactId>
|
||||
<version>4.1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.20</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.ruoyi.system.domain.entity.baseinfo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Data
|
||||
@Table(name = "country")
|
||||
public class Country {
|
||||
/**
|
||||
* 国家ID
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "CountryId")
|
||||
@GeneratedValue(generator = "JDBC")
|
||||
private Integer countryid;
|
||||
|
||||
/**
|
||||
* 国家名称
|
||||
*/
|
||||
@Column(name = "CountryName")
|
||||
private String countryname;
|
||||
|
||||
/**
|
||||
* 国家英文名
|
||||
*/
|
||||
@Column(name = "EnglishName")
|
||||
private String englishname;
|
||||
|
||||
/**
|
||||
* 国家缩写
|
||||
*/
|
||||
@Column(name = "AbbreviationName")
|
||||
private String abbreviationname;
|
||||
|
||||
/**
|
||||
* 国家名本地
|
||||
*/
|
||||
@Column(name = "CountryNameLocal")
|
||||
private String countrynamelocal;
|
||||
|
||||
/**
|
||||
* 国家标志路径
|
||||
*/
|
||||
@Column(name = "FlagPath")
|
||||
private String flagpath;
|
||||
|
||||
/**
|
||||
* 是否启用 1代表启用0代表不启用
|
||||
*/
|
||||
@Column(name = "IsActive")
|
||||
private Byte isactive;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@Column(name = "Longitude")
|
||||
private BigDecimal longitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
@Column(name = "Latitude")
|
||||
private BigDecimal latitude;
|
||||
|
||||
/**
|
||||
* 主页路径
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 时区
|
||||
*/
|
||||
@Column(name = "Timezone")
|
||||
private Integer timezone;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Column(name = "CreatedBy")
|
||||
private Integer createdby;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "DateCreated")
|
||||
private Date datecreated;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@Column(name = "UpdatedBy")
|
||||
private Integer updatedby;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column(name = "DateUpdated")
|
||||
private Date dateupdated;
|
||||
|
||||
/**
|
||||
* 国家地图Json
|
||||
*/
|
||||
@Column(name = "CountryJson")
|
||||
private String countryjson;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ruoyi.system.mapper.baseinfo;
|
||||
|
||||
|
||||
import com.ruoyi.system.domain.entity.baseinfo.Country;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CountryDAO {
|
||||
/**
|
||||
* 查询国家
|
||||
*/
|
||||
@Select("select * from country where CountryId=${CountryId}")
|
||||
List<Country> selectCountryInfoById(@Param("CountryId") Integer CountryId);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ruoyi.system.mapper.baseinfo;
|
||||
|
||||
|
||||
import com.ruoyi.system.domain.entity.baseinfo.Country;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
public interface CountryMapper extends Mapper<Country> {
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.system.domain.entity.baseinfo.Country;
|
||||
import com.ruoyi.system.mapper.baseinfo.CountryDAO;
|
||||
import com.ruoyi.system.mapper.baseinfo.CountryMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class TestMapperService {
|
||||
@Autowired
|
||||
CountryMapper countryMapper;
|
||||
@Autowired
|
||||
CountryDAO countryDAO;
|
||||
public Object queryCountry() {
|
||||
List<Country> countries = countryMapper.selectAll();
|
||||
return countries;
|
||||
}
|
||||
public Object queryCountryById(Integer countryId) {
|
||||
List<Country> countries = countryDAO.selectCountryInfoById(countryId);
|
||||
return countries;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
jdbc.driverClass=com.mysql.cj.jdbc.Driver
|
||||
jdbc.url=jdbc:mysql://121.40.189.20:3306/test_smart_arbitration?serverTimezone=Asia/Shanghai&useSSL=false&zeroDateTimeBehavior=CONVERT_TO_NULL&nullCatalogMeansCurrent=true
|
||||
jdbc.user=root
|
||||
jdbc.password=YMzc157#
|
||||
#目标模块项目路径
|
||||
targetprojectpath=E:/WorkCode/SH/Mediation-Backend/ruoyi-system
|
||||
#模块名称
|
||||
moduleName=diagnosis
|
||||
#表名
|
||||
tableName=country
|
||||
#主键
|
||||
premaryId=CountryId
|
||||
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE generatorConfiguration
|
||||
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
|
||||
|
||||
<generatorConfiguration>
|
||||
<properties resource="generator/config.properties"/>
|
||||
|
||||
<context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
|
||||
<property name="beginningDelimiter" value="`"/>
|
||||
<property name="endingDelimiter" value="`"/>
|
||||
|
||||
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
|
||||
<property name="mappers" value="tk.mybatis.mapper.common.Mapper"/>
|
||||
<property name="caseSensitive" value="true"/>
|
||||
<property name="lombok" value="Getter,Setter,ToString"/>
|
||||
</plugin>
|
||||
|
||||
<jdbcConnection driverClass="${jdbc.driverClass}"
|
||||
connectionURL="${jdbc.url}"
|
||||
userId="${jdbc.user}"
|
||||
password="${jdbc.password}">
|
||||
</jdbcConnection>
|
||||
<!--实体-->
|
||||
<javaModelGenerator targetPackage="com.ruoyi.system.domain.entity.${moduleName}"
|
||||
targetProject="src/main/java"/>
|
||||
<!--mapper.xml-->
|
||||
<sqlMapGenerator targetPackage="com.ruoyi.system.mapper.${moduleName}"
|
||||
targetProject="src/main/resources"/>
|
||||
<!--mapper接口-->
|
||||
<javaClientGenerator targetPackage="com.ruoyi.system.mapper.${moduleName}"
|
||||
targetProject="src/main/java"
|
||||
type="XMLMAPPER"/>
|
||||
<!--需要生成的数据库表-->
|
||||
<table tableName="${tableName}">
|
||||
<generatedKey column="${premaryId}" sqlStatement="JDBC"/>
|
||||
</table>
|
||||
</context>
|
||||
</generatorConfiguration>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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.ruoyi.system.mapper.baseinfo.CountryMapper">
|
||||
<resultMap id="BaseResultMap" type="com.ruoyi.system.domain.entity.baseinfo.Country">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
-->
|
||||
<id column="CountryId" jdbcType="INTEGER" property="countryid" />
|
||||
<result column="CountryName" jdbcType="VARCHAR" property="countryname" />
|
||||
<result column="EnglishName" jdbcType="VARCHAR" property="englishname" />
|
||||
<result column="AbbreviationName" jdbcType="VARCHAR" property="abbreviationname" />
|
||||
<result column="CountryNameLocal" jdbcType="VARCHAR" property="countrynamelocal" />
|
||||
<result column="FlagPath" jdbcType="VARCHAR" property="flagpath" />
|
||||
<result column="IsActive" jdbcType="TINYINT" property="isactive" />
|
||||
<result column="Longitude" jdbcType="DECIMAL" property="longitude" />
|
||||
<result column="Latitude" jdbcType="DECIMAL" property="latitude" />
|
||||
<result column="url" jdbcType="VARCHAR" property="url" />
|
||||
<result column="Timezone" jdbcType="INTEGER" property="timezone" />
|
||||
<result column="CreatedBy" jdbcType="INTEGER" property="createdby" />
|
||||
<result column="DateCreated" jdbcType="TIMESTAMP" property="datecreated" />
|
||||
<result column="UpdatedBy" jdbcType="INTEGER" property="updatedby" />
|
||||
<result column="DateUpdated" jdbcType="TIMESTAMP" property="dateupdated" />
|
||||
<result column="CountryJson" jdbcType="VARCHAR" property="countryjson" />
|
||||
</resultMap>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user