Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Initial commit
- Loading branch information
汪文杰
committed
Jan 3, 2019
0 parents
commit ab31d78
Showing
106 changed files
with
4,411 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>demo_mall</artifactId> | ||
<groupId>com.sanbangzi</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>code_generator</artifactId> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.mybatis.generator</groupId> | ||
<artifactId>mybatis-generator-maven-plugin</artifactId> | ||
<version>1.3.6</version> | ||
<configuration> | ||
<configurationFile>${basedir}/src/main/resources/generatorConfig.xml</configurationFile> | ||
<overwrite>true</overwrite> | ||
<verbose>true</verbose> | ||
</configuration> | ||
<dependencies> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>5.1.45</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>tk.mybatis</groupId> | ||
<artifactId>mapper</artifactId> | ||
<version>4.0.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.freemarker</groupId> | ||
<artifactId>freemarker</artifactId> | ||
<version>2.3.23</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ${package}; | ||
|
||
import ${tableClass.fullClassName}; | ||
|
||
/** | ||
* 通用 Mapper 代码生成器 | ||
* | ||
* @author mapper-generator | ||
*/ | ||
public interface ${tableClass.shortClassName}${mapperSuffix} extends ${baseMapper!"com.sanbangzi.common.utils.MyMapper"}<${tableClass.shortClassName}> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?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="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"/> | ||
</plugin> | ||
|
||
<plugin type="tk.mybatis.mapper.generator.TemplateFilePlugin"> | ||
<property name="targetProject" value="src/main/java"/> | ||
<property name="targetPackage" value="com.isea533.mybatis.mapper"/> | ||
<property name="templatePath" value="generator/mapper.ftl"/> | ||
<property name="mapperSuffix" value="Dao"/> | ||
<property name="fileName" value="${tableClass.shortClassName}${mapperSuffix}.java"/> | ||
</plugin> | ||
|
||
<jdbcConnection driverClass="com.mysql.jdbc.Driver" | ||
connectionURL="jdbc:mysql://127.0.0.1:3306/test" | ||
userId="root" | ||
password="flame"> | ||
</jdbcConnection> | ||
|
||
<javaModelGenerator targetPackage="com.isea533.mybatis.model" targetProject="src/main/java"/> | ||
|
||
<sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources"/> | ||
|
||
<javaClientGenerator targetPackage="com.isea533.mybatis.mapper" targetProject="src/main/java" | ||
type="XMLMAPPER"/> | ||
|
||
<table tableName="t_user"> | ||
<generatedKey column="id" sqlStatement="JDBC"/> | ||
</table> | ||
</context> | ||
</generatorConfiguration> | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.sanbangzi</groupId> | ||
<artifactId>demo_mall</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
<artifactId>common</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>commons-codec</groupId> | ||
<artifactId>commons-codec</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.github.pagehelper</groupId> | ||
<artifactId>pagehelper-spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>tk.mybatis</groupId> | ||
<artifactId>mapper</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.squareup.okhttp3</groupId> | ||
<artifactId>okhttp</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.squareup.okio</groupId> | ||
<artifactId>okio</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
60 changes: 60 additions & 0 deletions
60
common/src/main/java/com/sanbangzi/common/utils/BeanUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.sanbangzi.common.utils; | ||
|
||
import com.google.common.collect.Lists; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.BeanUtils; | ||
|
||
import java.util.List; | ||
|
||
public class BeanUtil extends BeanUtils { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(BeanUtil.class); | ||
|
||
/** | ||
* 对象拷贝 (数据源为空返回空) | ||
* @param from 数据源 | ||
* @param to 目标对象 | ||
* @param <T> 范型 | ||
* @return 数据源为空返回空 | ||
* @throws Exception | ||
*/ | ||
public static <T> T copyObject(Object from, Class to) { | ||
Object dest = null; | ||
try { | ||
if (null == from) { | ||
return null; | ||
} | ||
dest = to.newInstance(); | ||
copyProperties(from, dest); | ||
} catch (Exception e) { | ||
LOGGER.error("拷贝对象错误:" + e); | ||
} | ||
return (T) dest; | ||
} | ||
|
||
/** | ||
* 拷贝集合 | ||
* @param from 数据源 | ||
* @param to 目标 | ||
* @param <T> 范型 | ||
* @return 数据源为空不返回空 | ||
*/ | ||
public static <T> List<T> copyList(List from, Class to) { | ||
if (null == from || from.isEmpty()) { | ||
return Lists.newArrayList(); | ||
} | ||
List<T> dest = Lists.newArrayList(); | ||
from.forEach((Object e) -> { | ||
try { | ||
T toObject = (T) to.newInstance(); | ||
copyProperties(e, toObject); | ||
dest.add(toObject); | ||
} catch (Exception e1) { | ||
LOGGER.error("拷贝集合错误:" + e1); | ||
} | ||
}); | ||
return dest; | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
common/src/main/java/com/sanbangzi/common/utils/CollectionUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.sanbangzi.common.utils; | ||
|
||
import java.util.Collection; | ||
|
||
public class CollectionUtil { | ||
|
||
public static boolean isBlank(Collection c) { | ||
return null == c || c.isEmpty(); | ||
} | ||
|
||
public static boolean isNotBlank(Collection c) { | ||
return !isBlank(c); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
common/src/main/java/com/sanbangzi/common/utils/DigestUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.sanbangzi.common.utils; | ||
|
||
import org.apache.commons.codec.digest.DigestUtils; | ||
|
||
public class DigestUtil extends DigestUtils { | ||
} |
7 changes: 7 additions & 0 deletions
7
common/src/main/java/com/sanbangzi/common/utils/MyMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.sanbangzi.common.utils; | ||
|
||
import tk.mybatis.mapper.common.Mapper; | ||
import tk.mybatis.mapper.common.MySqlMapper; | ||
|
||
public interface MyMapper<T> extends Mapper<T>, MySqlMapper<T> { | ||
} |
34 changes: 34 additions & 0 deletions
34
common/src/main/java/com/sanbangzi/common/utils/MyPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.sanbangzi.common.utils; | ||
|
||
|
||
import com.github.pagehelper.PageInfo; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class MyPage<T> { | ||
|
||
// 页数 | ||
private Integer pageNum; | ||
|
||
// 每页大小 | ||
private Integer pageSize; | ||
|
||
// 总页数 | ||
private Integer pages; | ||
|
||
// 总记录数 | ||
private Long total; | ||
|
||
// 数据 | ||
private List<T> data; | ||
|
||
public static MyPage newInstance(PageInfo pageInfo) { | ||
return new MyPage(pageInfo.getPageNum(), pageInfo.getPageSize(), pageInfo.getPages(), pageInfo.getTotal(), pageInfo.getList()); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
common/src/main/java/com/sanbangzi/common/utils/RandomUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.sanbangzi.common.utils; | ||
|
||
import java.util.UUID; | ||
|
||
public class RandomUtil { | ||
|
||
/** | ||
* 32位uuid | ||
* @return | ||
*/ | ||
public static String uuid() { | ||
return UUID.randomUUID().toString().replaceAll("-", "").toString(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
common/src/main/java/com/sanbangzi/common/utils/StringUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.sanbangzi.common.utils; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public class StringUtil extends StringUtils { | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
common/src/main/java/com/sanbangzi/common/utils/WebResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.sanbangzi.common.utils; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class WebResponse { | ||
|
||
private Integer code; | ||
|
||
private String msg; | ||
|
||
private Object data; | ||
} |
Oops, something went wrong.