Skip to content

Commit 00b725c

Browse files
committed
mybatis generator help project
0 parents  commit 00b725c

File tree

6 files changed

+495
-0
lines changed

6 files changed

+495
-0
lines changed

pom.xml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>self.springcloud</groupId>
8+
<artifactId>mybatisgen</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
12+
<build>
13+
<plugins>
14+
<plugin>
15+
<groupId>org.mybatis.generator</groupId>
16+
<artifactId>mybatis-generator-maven-plugin</artifactId>
17+
<version>1.3.2</version>
18+
</plugin>
19+
</plugins>
20+
</build>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>mysql</groupId>
25+
<artifactId>mysql-connector-java</artifactId>
26+
<version>5.1.34</version>
27+
</dependency>
28+
</dependencies>
29+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package self.springcloud.dao;
2+
3+
import self.springcloud.domain.ProductInfo;
4+
5+
public interface ProductInfoMapper {
6+
int deleteByPrimaryKey(String productId);
7+
8+
int insert(ProductInfo record);
9+
10+
int insertSelective(ProductInfo record);
11+
12+
ProductInfo selectByPrimaryKey(String productId);
13+
14+
int updateByPrimaryKeySelective(ProductInfo record);
15+
16+
int updateByPrimaryKey(ProductInfo record);
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package self.springcloud.domain;
2+
3+
import java.math.BigDecimal;
4+
import java.util.Date;
5+
6+
public class ProductInfo {
7+
private String productId;
8+
9+
private String productName;
10+
11+
private BigDecimal productPrice;
12+
13+
private Integer productStock;
14+
15+
private String productDescription;
16+
17+
private String productIcon;
18+
19+
private Byte productStatus;
20+
21+
private Integer categoryType;
22+
23+
private Date createTime;
24+
25+
private Date updateTime;
26+
27+
public String getProductId() {
28+
return productId;
29+
}
30+
31+
public void setProductId(String productId) {
32+
this.productId = productId == null ? null : productId.trim();
33+
}
34+
35+
public String getProductName() {
36+
return productName;
37+
}
38+
39+
public void setProductName(String productName) {
40+
this.productName = productName == null ? null : productName.trim();
41+
}
42+
43+
public BigDecimal getProductPrice() {
44+
return productPrice;
45+
}
46+
47+
public void setProductPrice(BigDecimal productPrice) {
48+
this.productPrice = productPrice;
49+
}
50+
51+
public Integer getProductStock() {
52+
return productStock;
53+
}
54+
55+
public void setProductStock(Integer productStock) {
56+
this.productStock = productStock;
57+
}
58+
59+
public String getProductDescription() {
60+
return productDescription;
61+
}
62+
63+
public void setProductDescription(String productDescription) {
64+
this.productDescription = productDescription == null ? null : productDescription.trim();
65+
}
66+
67+
public String getProductIcon() {
68+
return productIcon;
69+
}
70+
71+
public void setProductIcon(String productIcon) {
72+
this.productIcon = productIcon == null ? null : productIcon.trim();
73+
}
74+
75+
public Byte getProductStatus() {
76+
return productStatus;
77+
}
78+
79+
public void setProductStatus(Byte productStatus) {
80+
this.productStatus = productStatus;
81+
}
82+
83+
public Integer getCategoryType() {
84+
return categoryType;
85+
}
86+
87+
public void setCategoryType(Integer categoryType) {
88+
this.categoryType = categoryType;
89+
}
90+
91+
public Date getCreateTime() {
92+
return createTime;
93+
}
94+
95+
public void setCreateTime(Date createTime) {
96+
this.createTime = createTime;
97+
}
98+
99+
public Date getUpdateTime() {
100+
return updateTime;
101+
}
102+
103+
public void setUpdateTime(Date updateTime) {
104+
this.updateTime = updateTime;
105+
}
106+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE generatorConfiguration
3+
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
4+
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
5+
<generatorConfiguration>
6+
<!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包-->
7+
<classPathEntry location="d:\mysql-connector-java-5.1.47.jar"/>
8+
<context id="DB2Tables" targetRuntime="MyBatis3">
9+
<commentGenerator>
10+
<property name="suppressDate" value="true"/>
11+
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
12+
<property name="suppressAllComments" value="true"/>
13+
</commentGenerator>
14+
<!--数据库链接URL,用户名、密码 -->
15+
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://101.200.81.38:9916/eshop" userId="devAccount" password="pw7VS$K">
16+
</jdbcConnection>
17+
<javaTypeResolver>
18+
<property name="forceBigDecimals" value="false"/>
19+
</javaTypeResolver>
20+
<!-- 生成模型的包名和位置-->
21+
<javaModelGenerator targetPackage="self.springcloud.domain" targetProject="src/main/java">
22+
<property name="enableSubPackages" value="true"/>
23+
<property name="trimStrings" value="true"/>
24+
</javaModelGenerator>
25+
<!-- 生成映射文件的包名和位置-->
26+
<sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
27+
<property name="enableSubPackages" value="true"/>
28+
</sqlMapGenerator>
29+
<!-- 生成DAO的包名和位置-->
30+
<javaClientGenerator type="XMLMAPPER" targetPackage="self.springcloud.dao" targetProject="src/main/java">
31+
<property name="enableSubPackages" value="true"/>
32+
</javaClientGenerator>
33+
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
34+
<table tableName="product_info" domainObjectName="ProductInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
35+
36+
</context>
37+
</generatorConfiguration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3+
<mapper namespace="self.springcloud.dao.ProductInfoMapper" >
4+
<resultMap id="BaseResultMap" type="self.springcloud.domain.ProductInfo" >
5+
<id column="product_id" property="productId" jdbcType="VARCHAR" />
6+
<result column="product_name" property="productName" jdbcType="VARCHAR" />
7+
<result column="product_price" property="productPrice" jdbcType="DECIMAL" />
8+
<result column="product_stock" property="productStock" jdbcType="INTEGER" />
9+
<result column="product_description" property="productDescription" jdbcType="VARCHAR" />
10+
<result column="product_icon" property="productIcon" jdbcType="VARCHAR" />
11+
<result column="product_status" property="productStatus" jdbcType="TINYINT" />
12+
<result column="category_type" property="categoryType" jdbcType="INTEGER" />
13+
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
14+
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
15+
</resultMap>
16+
<sql id="Base_Column_List" >
17+
product_id, product_name, product_price, product_stock, product_description, product_icon,
18+
product_status, category_type, create_time, update_time
19+
</sql>
20+
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
21+
select
22+
<include refid="Base_Column_List" />
23+
from product_info
24+
where product_id = #{productId,jdbcType=VARCHAR}
25+
</select>
26+
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
27+
delete from product_info
28+
where product_id = #{productId,jdbcType=VARCHAR}
29+
</delete>
30+
<insert id="insert" parameterType="self.springcloud.domain.ProductInfo" >
31+
insert into product_info (product_id, product_name, product_price,
32+
product_stock, product_description, product_icon,
33+
product_status, category_type, create_time,
34+
update_time)
35+
values (#{productId,jdbcType=VARCHAR}, #{productName,jdbcType=VARCHAR}, #{productPrice,jdbcType=DECIMAL},
36+
#{productStock,jdbcType=INTEGER}, #{productDescription,jdbcType=VARCHAR}, #{productIcon,jdbcType=VARCHAR},
37+
#{productStatus,jdbcType=TINYINT}, #{categoryType,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
38+
#{updateTime,jdbcType=TIMESTAMP})
39+
</insert>
40+
<insert id="insertSelective" parameterType="self.springcloud.domain.ProductInfo" >
41+
insert into product_info
42+
<trim prefix="(" suffix=")" suffixOverrides="," >
43+
<if test="productId != null" >
44+
product_id,
45+
</if>
46+
<if test="productName != null" >
47+
product_name,
48+
</if>
49+
<if test="productPrice != null" >
50+
product_price,
51+
</if>
52+
<if test="productStock != null" >
53+
product_stock,
54+
</if>
55+
<if test="productDescription != null" >
56+
product_description,
57+
</if>
58+
<if test="productIcon != null" >
59+
product_icon,
60+
</if>
61+
<if test="productStatus != null" >
62+
product_status,
63+
</if>
64+
<if test="categoryType != null" >
65+
category_type,
66+
</if>
67+
<if test="createTime != null" >
68+
create_time,
69+
</if>
70+
<if test="updateTime != null" >
71+
update_time,
72+
</if>
73+
</trim>
74+
<trim prefix="values (" suffix=")" suffixOverrides="," >
75+
<if test="productId != null" >
76+
#{productId,jdbcType=VARCHAR},
77+
</if>
78+
<if test="productName != null" >
79+
#{productName,jdbcType=VARCHAR},
80+
</if>
81+
<if test="productPrice != null" >
82+
#{productPrice,jdbcType=DECIMAL},
83+
</if>
84+
<if test="productStock != null" >
85+
#{productStock,jdbcType=INTEGER},
86+
</if>
87+
<if test="productDescription != null" >
88+
#{productDescription,jdbcType=VARCHAR},
89+
</if>
90+
<if test="productIcon != null" >
91+
#{productIcon,jdbcType=VARCHAR},
92+
</if>
93+
<if test="productStatus != null" >
94+
#{productStatus,jdbcType=TINYINT},
95+
</if>
96+
<if test="categoryType != null" >
97+
#{categoryType,jdbcType=INTEGER},
98+
</if>
99+
<if test="createTime != null" >
100+
#{createTime,jdbcType=TIMESTAMP},
101+
</if>
102+
<if test="updateTime != null" >
103+
#{updateTime,jdbcType=TIMESTAMP},
104+
</if>
105+
</trim>
106+
</insert>
107+
<update id="updateByPrimaryKeySelective" parameterType="self.springcloud.domain.ProductInfo" >
108+
update product_info
109+
<set >
110+
<if test="productName != null" >
111+
product_name = #{productName,jdbcType=VARCHAR},
112+
</if>
113+
<if test="productPrice != null" >
114+
product_price = #{productPrice,jdbcType=DECIMAL},
115+
</if>
116+
<if test="productStock != null" >
117+
product_stock = #{productStock,jdbcType=INTEGER},
118+
</if>
119+
<if test="productDescription != null" >
120+
product_description = #{productDescription,jdbcType=VARCHAR},
121+
</if>
122+
<if test="productIcon != null" >
123+
product_icon = #{productIcon,jdbcType=VARCHAR},
124+
</if>
125+
<if test="productStatus != null" >
126+
product_status = #{productStatus,jdbcType=TINYINT},
127+
</if>
128+
<if test="categoryType != null" >
129+
category_type = #{categoryType,jdbcType=INTEGER},
130+
</if>
131+
<if test="createTime != null" >
132+
create_time = #{createTime,jdbcType=TIMESTAMP},
133+
</if>
134+
<if test="updateTime != null" >
135+
update_time = #{updateTime,jdbcType=TIMESTAMP},
136+
</if>
137+
</set>
138+
where product_id = #{productId,jdbcType=VARCHAR}
139+
</update>
140+
<update id="updateByPrimaryKey" parameterType="self.springcloud.domain.ProductInfo" >
141+
update product_info
142+
set product_name = #{productName,jdbcType=VARCHAR},
143+
product_price = #{productPrice,jdbcType=DECIMAL},
144+
product_stock = #{productStock,jdbcType=INTEGER},
145+
product_description = #{productDescription,jdbcType=VARCHAR},
146+
product_icon = #{productIcon,jdbcType=VARCHAR},
147+
product_status = #{productStatus,jdbcType=TINYINT},
148+
category_type = #{categoryType,jdbcType=INTEGER},
149+
create_time = #{createTime,jdbcType=TIMESTAMP},
150+
update_time = #{updateTime,jdbcType=TIMESTAMP}
151+
where product_id = #{productId,jdbcType=VARCHAR}
152+
</update>
153+
</mapper>

0 commit comments

Comments
 (0)