-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 26e9d89
Showing
31 changed files
with
1,437 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,34 @@ | ||
logs/ | ||
target/ | ||
mvnw | ||
mvnw.cmd | ||
.mvn/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/** | ||
!**/src/test/** | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
|
||
### VS Code ### | ||
.vscode/ |
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,19 @@ | ||
# Getting Started | ||
|
||
### Reference Documentation | ||
For further reference, please consider the following sections: | ||
|
||
* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) | ||
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.3.0.RELEASE/maven-plugin/) | ||
* [Spring Web](https://docs.spring.io/spring-boot/docs/2.3.0.RELEASE/reference/htmlsingle/#boot-features-developing-web-applications) | ||
* [Spring Boot DevTools](https://docs.spring.io/spring-boot/docs/2.3.0.RELEASE/reference/htmlsingle/#using-boot-devtools) | ||
* [Validation](https://docs.spring.io/spring-boot/docs/2.3.0.RELEASE/reference/htmlsingle/#boot-features-validation) | ||
|
||
### Guides | ||
The following guides illustrate how to use some features concretely: | ||
|
||
* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) | ||
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) | ||
* [Building REST services with Spring](https://spring.io/guides/tutorials/bookmarks/) | ||
* [Accessing data with MySQL](https://spring.io/guides/gs/accessing-data-mysql/) | ||
|
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 @@ | ||
DROP TABLE IF EXISTS `t_id_segment_cfg`; | ||
CREATE TABLE `t_id_segment_cfg` ( | ||
`id` bigint(20) NOT NULL AUTO_INCREMENT | ||
COMMENT '主键', | ||
`biz_tag` varchar(64) NOT NULL | ||
COMMENT '业务标识', | ||
`start_id` bigint(20) NOT NULL DEFAULT '1' | ||
COMMENT '起始id', | ||
`step` int(11) NOT NULL | ||
COMMENT '步长', | ||
`version` bigint(20) NOT NULL DEFAULT '0' | ||
COMMENT '版本号', | ||
`description` varchar(128) NOT NULL | ||
COMMENT '描述', | ||
`created_time` datetime DEFAULT CURRENT_TIMESTAMP | ||
COMMENT '创建时间', | ||
`updated_time` datetime DEFAULT CURRENT_TIMESTAMP | ||
ON UPDATE CURRENT_TIMESTAMP | ||
COMMENT '更新时间', | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `uk_biz_tag` (`biz_tag`) USING BTREE | ||
) | ||
ENGINE = InnoDB | ||
DEFAULT CHARSET = utf8 | ||
COLLATE = utf8_bin | ||
COMMENT ='ID号段配置表'; | ||
|
||
INSERT INTO `t_id_segment_cfg` (`biz_tag`, `start_id`, `step`, `description`) VALUES ('short_url', 1, 100000, '短链'); | ||
|
||
|
||
DROP TABLE IF EXISTS `t_url_mapping`; | ||
CREATE TABLE `t_url_mapping` ( | ||
`id` bigint(20) NOT NULL AUTO_INCREMENT | ||
COMMENT '主键', | ||
`keyword` varchar(64) NOT NULL | ||
COMMENT '唯一标识', | ||
`biz_type` varchar(32) NOT NULL | ||
COMMENT '业务标识', | ||
`origin_url` varchar(256) NOT NULL | ||
COMMENT '原始url', | ||
`origin_url_md5` varchar(64) NOT NULL | ||
COMMENT '原始urlMd5', | ||
`description` varchar(128) NOT NULL | ||
COMMENT '描述', | ||
`creator` varchar(64) NOT NULL | ||
COMMENT '创建者', | ||
`created_time` datetime DEFAULT CURRENT_TIMESTAMP | ||
COMMENT '创建时间', | ||
`updated_time` datetime DEFAULT CURRENT_TIMESTAMP | ||
ON UPDATE CURRENT_TIMESTAMP | ||
COMMENT '更新时间', | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `uk_keyword` (`keyword`) USING BTREE, | ||
KEY `idx_origin_url_md5`(`origin_url_md5`) USING BTREE, | ||
KEY `idx_biz_type_keyword_md5`(`biz_type`, `keyword`,`origin_url_md5`) USING BTREE | ||
|
||
) | ||
ENGINE = InnoDB | ||
DEFAULT CHARSET = utf8 | ||
COLLATE = utf8_bin | ||
COMMENT ='url映射表'; | ||
|
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,114 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.blues</groupId> | ||
<artifactId>shorturl</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>short-url</name> | ||
<packaging>jar</packaging> | ||
<description>Demo project for Spring Boot</description> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<spring-boot.version>2.3.0.RELEASE</spring-boot.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-validation</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-devtools</artifactId> | ||
<scope>runtime</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mybatis.spring.boot</groupId> | ||
<artifactId>mybatis-spring-boot-starter</artifactId> | ||
<version>1.3.3</version> | ||
</dependency> | ||
<!-- 分页插件 --> | ||
<dependency> | ||
<groupId>com.github.pagehelper</groupId> | ||
<artifactId>pagehelper-spring-boot-starter</artifactId> | ||
<version>1.3.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>fastjson</artifactId> | ||
<version>1.2.46</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-dependencies</artifactId> | ||
<version>${spring-boot.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
<encoding>UTF-8</encoding> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<version>2.3.0.RELEASE</version> | ||
<configuration> | ||
<mainClass>com.blues.shorturl.ShorturlApplication</mainClass> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>repackage</id> | ||
<goals> | ||
<goal>repackage</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</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,13 @@ | ||
package com.blues.shorturl; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class ShorturlApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ShorturlApplication.class, args); | ||
} | ||
|
||
} |
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,16 @@ | ||
package com.blues.shorturl.common; | ||
|
||
public class Constants { | ||
/** | ||
* 重试次数 | ||
*/ | ||
public static final int RETRY = 3; | ||
/** | ||
* 预加载下个号段的百分比 | ||
*/ | ||
public static final int LOADING_THRESHOLD = 50; | ||
|
||
private Constants() { | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/blues/shorturl/dao/IdSegmentCfgMapper.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,13 @@ | ||
package com.blues.shorturl.dao; | ||
|
||
import com.blues.shorturl.entity.IdSegmentCfg; | ||
import org.apache.ibatis.annotations.Mapper; | ||
|
||
@Mapper | ||
public interface IdSegmentCfgMapper { | ||
int insert(IdSegmentCfg record); | ||
|
||
IdSegmentCfg selectByBizTag(String bizTag); | ||
|
||
int updateByBizTag(IdSegmentCfg record); | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/blues/shorturl/dao/UrlMappingMapper.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,29 @@ | ||
package com.blues.shorturl.dao; | ||
|
||
import com.blues.shorturl.entity.UrlMapping; | ||
import org.apache.ibatis.annotations.Mapper; | ||
|
||
import java.util.List; | ||
|
||
@Mapper | ||
public interface UrlMappingMapper { | ||
int deleteByPrimaryKey(Long id); | ||
|
||
int insert(UrlMapping record); | ||
|
||
int insertSelective(UrlMapping record); | ||
|
||
UrlMapping selectByPrimaryKey(Long id); | ||
|
||
UrlMapping selectByMd5(String md5); | ||
|
||
UrlMapping selectByKeyword(String keyword); | ||
|
||
List<UrlMapping> selectByCondition(UrlMapping record); | ||
|
||
List<UrlMapping> selectByBizType(List<String> types); | ||
|
||
int updateByPrimaryKeySelective(UrlMapping record); | ||
|
||
int updateByPrimaryKey(UrlMapping record); | ||
} |
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.blues.shorturl.entity; | ||
|
||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
@Data | ||
public class IdSegment implements Serializable { | ||
private Long startId; | ||
private Long midId; | ||
private Long endId; | ||
private AtomicLong currentId; | ||
} |
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,18 @@ | ||
package com.blues.shorturl.entity; | ||
|
||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
|
||
@Data | ||
public class IdSegmentCfg implements Serializable { | ||
private Long id; | ||
private String bizTag; | ||
private Long startId; | ||
private Integer step; | ||
private String description; | ||
private Long version; | ||
private Date createdTime; | ||
private Date updatedTime; | ||
} |
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,52 @@ | ||
package com.blues.shorturl.entity; | ||
|
||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
|
||
/** | ||
* t_url_mapping | ||
* | ||
* @author | ||
*/ | ||
@Data | ||
public class UrlMapping implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
/** | ||
* 主键 | ||
*/ | ||
private Long id; | ||
/** | ||
* 唯一标识 | ||
*/ | ||
private String keyword; | ||
/** | ||
* 业务标识 | ||
*/ | ||
private String bizType; | ||
/** | ||
* 原始url | ||
*/ | ||
private String originUrl; | ||
/** | ||
* 原始urlMd5 | ||
*/ | ||
private String originUrlMd5; | ||
/** | ||
* 描述 | ||
*/ | ||
private String description; | ||
/** | ||
* 创建者 | ||
*/ | ||
private String creator; | ||
/** | ||
* 创建时间 | ||
*/ | ||
private Date createdTime; | ||
/** | ||
* 更新时间 | ||
*/ | ||
private Date updatedTime; | ||
} |
Oops, something went wrong.