Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 86fe383

Browse files
committed
增加外链重定向链接
1 parent 9b0dd91 commit 86fe383

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

config/db.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ CREATE TABLE IF NOT EXISTS `user_login` (
121121
UNIQUE KEY (`email`),
122122
KEY `logintime` (`login_time`)
123123
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '用户登录表';
124-
124+
125125
CREATE TABLE IF NOT EXISTS `bind_user` (
126126
`id` int unsigned NOT NULL AUTO_INCREMENT,
127127
`uid` int unsigned NOT NULL DEFAULT 0 COMMENT '本站用户UID',
@@ -692,7 +692,7 @@ CREATE TABLE IF NOT EXISTS `gctt_user` (
692692
`num` int unsigned NOT NULl DEFAULT 0 COMMENT '翻译的文章数',
693693
`words` int unsigned NOT NULl DEFAULT 0 COMMENT '翻译的字数',
694694
`avg_time` int unsigned NOT NULl DEFAULT 0 COMMENT '平均每篇用时(秒)',
695-
`role` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '角色,如 组长、选题、校对等',
695+
`role` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '角色,如 组长、选题、校对等。0-译者;1-组长;2-选题;3-校对;4-核心成员',
696696
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
697697
PRIMARY KEY (`id`),
698698
UNIQUE KEY (`username`),
@@ -727,7 +727,7 @@ CREATE TABLE IF NOT EXISTS `gctt_timeline` (
727727
CREATE TABLE IF NOT EXISTS `gctt_issue` (
728728
`id` int unsigned NOT NULL DEFAULT 0 COMMENT '选题的 issue 编号',
729729
`translator` varchar(31) NOT NULL DEFAULT '' COMMENT '译者 Github 用户名',
730-
`email` varchar(63) NOT NULL DEFAULT '' COMMENT '译者邮箱',
730+
`email` varchar(63) NOT NULL DEFAULT '' COMMENT '译者邮箱',
731731
`title` varchar(127) NOT NULL DEFAULT '' COMMENT 'issue 标题',
732732
`translating_at` int unsigned NOT NULL DEFAULT 0 COMMENT '开始翻译时间(认领时间)',
733733
`translated_at` int unsigned NOT NULL DEFAULT 0 COMMENT '完成翻译时间(close 时间)',
@@ -789,14 +789,14 @@ CREATE TABLE IF NOT EXISTS `subject_follower` (
789789
CREATE TABLE IF NOT EXISTS `download` (
790790
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '自增',
791791
`version` varchar(31) NOT NULL DEFAULT '' COMMENT '版本号',
792-
`filename` varchar(63) NOT NULL DEFAULT '' COMMENT '文件名',
792+
`filename` varchar(63) NOT NULL DEFAULT '' COMMENT '文件名',
793793
`kind` varchar(31) NOT NULL DEFAULT '' COMMENT '类型',
794794
`os` varchar(31) NOT NULL DEFAULT '' COMMENT '操作系统',
795795
`arch` varchar(31) NOT NULL DEFAULT '' COMMENT '架构',
796796
`size` int unsigned NOT NULL DEFAULT 0 COMMENT '大小,单位 MB',
797797
`checksum` varchar(64) NOT NULL DEFAULT '' COMMENT 'SHA1/256 校验和',
798798
`is_recommend` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '是否推荐(推荐的高亮显示)',
799-
`category` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0-Archived versions; 1-Stable versions; 2-Unstable versions;',
799+
`category` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0-Archived versions; 1-Stable versions; 2-Unstable versions;',
800800
`seq` int unsigned NOT NULL DEFAULT 0 COMMENT '排序,越大越靠前',
801801
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
802802
PRIMARY KEY (`id`)
@@ -816,4 +816,4 @@ CREATE TABLE `wechat_user` (
816816
UNIQUE KEY `openid` (`openid`),
817817
KEY `uid` (`uid`),
818818
KEY `updated_at` (`updated_at`)
819-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='微信用户绑定表';
819+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='微信用户绑定表';

src/http/controller/index.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func (self IndexController) RegisterRoute(g *echo.Group) {
3232
g.GET("/wr", self.WrapUrl)
3333
g.GET("/pkgdoc", self.Pkgdoc)
3434
g.GET("/markdown", self.Markdown)
35+
g.GET("/link", self.Link)
3536
}
3637

3738
func (IndexController) Index(ctx echo.Context) error {
@@ -199,3 +200,9 @@ func (IndexController) Pkgdoc(ctx echo.Context) error {
199200
func (IndexController) Markdown(ctx echo.Context) error {
200201
return render(ctx, "markdown.html", nil)
201202
}
203+
204+
// Link 用于重定向外部链接,比如广告链接
205+
func (IndexController) Link(ctx echo.Context) error {
206+
tUrl := ctx.QueryParam("url")
207+
return ctx.Redirect(http.StatusSeeOther, tUrl)
208+
}

0 commit comments

Comments
 (0)