Springboot implements custom short URL

Short URL, as the name implies, is a short URL in form. Usually asp or php steering is used. Today in Web 2.0, it has to be said that this is a trend. There are already many similar services. With the help of short URLs, you can replace the original lengthy URLs with short URLs, so that users can share links more easily.

It is used where there is a limit to the number of characters in the text message.Code
implementation:

First create a short URL table in mysql:

CREATE TABLE `short_link` (
  `id` int(22) NOT NULL AUTO_INCREMENT,
  `s_link` varchar(200) DEFAULT NULL COMMENT '短链接',
  `l_link` varchar(500) DEFAULT NULL COMMENT '长链接',
  `type` int(2) DEFAULT '1' COMMENT '1、hlvy博客 2、hlvy github地址',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `is_deleted` int(2) DEFAULT '0' COMMENT '是否删除(0.未删除,1.删除)',
  PRIMARY KEY (`id`),
  KEY `idx_is_deleted` (`is_deleted`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COMMENT='短链接';

The code is implemented here using mybatis

mapper.xml

Guess you like

Origin blog.csdn.net/qq_39313596/article/details/103032129