Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
1dc677f3a0 | ||
|
2f9a4b5f6c | ||
|
d4f9204b24 |
1
go.mod
1
go.mod
@ -78,6 +78,7 @@ require (
|
||||
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/joho/godotenv v1.5.1 // indirect
|
||||
github.com/jonboulle/clockwork v0.4.0 // indirect
|
||||
github.com/josharian/native v1.1.0 // indirect
|
||||
github.com/jpillora/backoff v1.0.0 // indirect
|
||||
|
2
go.sum
2
go.sum
@ -776,6 +776,8 @@ github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHW
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||
github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4=
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
// @description: 登陆相关API
|
||||
// @param r
|
||||
func ClientApi(r *gin.RouterGroup) {
|
||||
client := r.Group("client", middleware.Authorization(), middleware.RequestLog())
|
||||
client := r.Group("client", middleware.RequestLog(), middleware.Authorization())
|
||||
{
|
||||
client.POST("", api.Client().Save) // 新增/编辑客户端
|
||||
client.DELETE("/:id", api.Client().Delete) // 删除客户端
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
// @description: 控制台相关接口
|
||||
// @param r
|
||||
func DashboardApi(r *gin.RouterGroup) {
|
||||
dashboard := r.Group("dashboard", middleware.Authorization(), middleware.RequestLog())
|
||||
dashboard := r.Group("dashboard", middleware.RequestLog(), middleware.Authorization())
|
||||
{
|
||||
dashboard.GET("/request/list", api.Dashboard().List) // 请求日志
|
||||
dashboard.GET("/daily-poetry", api.Dashboard().DailyPoetry) // 每日诗词
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
// @description: 设置相关API
|
||||
// @param r
|
||||
func SettingApi(r *gin.RouterGroup) {
|
||||
setting := r.Group("setting", middleware.Authorization(), middleware.RequestLog())
|
||||
setting := r.Group("setting", middleware.RequestLog(), middleware.Authorization())
|
||||
{
|
||||
setting.POST("", api.Setting().Set) // 新增/编辑设置
|
||||
setting.DELETE("/:code", api.Setting().Delete) // 删除配置
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
// @description: 用户相关API
|
||||
// @param r
|
||||
func UserApi(r *gin.RouterGroup) {
|
||||
userApi := r.Group("user", middleware.Authorization(), middleware.RequestLog())
|
||||
userApi := r.Group("user", middleware.RequestLog(), middleware.Authorization())
|
||||
{
|
||||
userApi.GET("/info", api.User().GetLoginUser) // 获取当前登陆用户信息
|
||||
userApi.POST("", api.User().SaveUser) // 新增/编辑用户
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/glebarez/sqlite"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"github.com/spf13/viper"
|
||||
"golang.zx2c4.com/wireguard/wgctrl"
|
||||
@ -27,6 +28,7 @@ import (
|
||||
func Init() {
|
||||
initLogger() // 初始化日志
|
||||
initConfig() // 读取配置文件
|
||||
initEnv() // 加载环境变量文件
|
||||
initWireguard() // 初始化wireguard客户端
|
||||
initDatabase() // 初始化数据库
|
||||
initRedis() // 初始化redis
|
||||
@ -153,3 +155,11 @@ func initLogger() {
|
||||
FileEnable: true,
|
||||
})
|
||||
}
|
||||
|
||||
// initEnv
|
||||
// @description: 初始化环境变量
|
||||
func initEnv() {
|
||||
if err := godotenv.Load(".env"); err != nil {
|
||||
log.Errorf("加载.env文件失败: %v", err.Error())
|
||||
}
|
||||
}
|
||||
|
@ -22,16 +22,3 @@ type Client struct {
|
||||
func (Client) TableName() string {
|
||||
return "t_client"
|
||||
}
|
||||
|
||||
// Watcher
|
||||
// @description: 监听日志
|
||||
type Watcher struct {
|
||||
Base
|
||||
ClientId string `json:"clientId" gorm:"type:char(36);not null;comment:'客户端id'"`
|
||||
NotifyResult string `json:"notifyResult" gorm:"type:text;default null;comment:'通知结果'"`
|
||||
IsSend int `json:"isSend" gorm:"type:tinyint(1);default 0;comment:'是否已通知'"`
|
||||
}
|
||||
|
||||
func (Watcher) TableName() string {
|
||||
return "t_watcher"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user