✨ 优化完善
This commit is contained in:
parent
2f1b34b9b3
commit
9a035c729b
4
.env
4
.env
@ -11,4 +11,6 @@ MYSQL_PWD=casbin123
|
||||
MYSQL_DB=casbin_demo
|
||||
# 阿里云通信配置
|
||||
ALI_SMS_KEY=LTAI5tBExwETRZcVcpogQCp7
|
||||
ALI_SMS_SECRET=afZPFabUs5Vmjr3W6R7reI3dNaGa8o
|
||||
ALI_SMS_SECRET=afZPFabUs5Vmjr3W6R7reI3dNaGa8o
|
||||
# JWT 口令
|
||||
JWT_SECRET=bgx6yCtxziJ3it37
|
@ -3,10 +3,10 @@ package controller
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
. "go_api_tmpl/core"
|
||||
. "go_api_tmpl/global"
|
||||
"go_api_tmpl/repository"
|
||||
"go_api_tmpl/utils"
|
||||
. "goweb/core"
|
||||
. "goweb/global"
|
||||
"goweb/repository"
|
||||
"goweb/utils"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"time"
|
||||
@ -47,6 +47,7 @@ func GetSmsCodeController(ctx *gin.Context) {
|
||||
}
|
||||
err = RedisConn.SetWithTimeout(phoneKey, code, "600")
|
||||
if err != nil {
|
||||
Log.Errorf("保存验证码到Redis失败: %v", err.Error())
|
||||
R(ctx).FailWithMessage("验证码发送失败,请稍后重试")
|
||||
return
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package global
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi"
|
||||
"go_api_tmpl/config"
|
||||
"goweb/config"
|
||||
)
|
||||
|
||||
type aliSmsBot struct{}
|
||||
|
@ -2,10 +2,10 @@ package global
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "go_api_tmpl/config"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
. "goweb/config"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
@ -2,8 +2,8 @@ package handle
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go_api_tmpl/global"
|
||||
"go_api_tmpl/repository"
|
||||
"goweb/global"
|
||||
"goweb/repository"
|
||||
)
|
||||
|
||||
// SaveAllRoute 保存入库所有接口路由信息
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"github.com/casbin/casbin/v2"
|
||||
"github.com/casbin/casbin/v2/model"
|
||||
gormAdapter "github.com/casbin/gorm-adapter/v3"
|
||||
"go_api_tmpl/global"
|
||||
"goweb/global"
|
||||
)
|
||||
|
||||
// Casbin 初始化Casbin的RABC模型
|
||||
|
@ -1,8 +1,8 @@
|
||||
package initialization
|
||||
|
||||
import (
|
||||
. "go_api_tmpl/global"
|
||||
"go_api_tmpl/repository"
|
||||
. "goweb/global"
|
||||
"goweb/repository"
|
||||
)
|
||||
|
||||
// DatabaseTable 初始化数据库表结构
|
||||
|
@ -1,8 +1,8 @@
|
||||
package initialization
|
||||
|
||||
import (
|
||||
"go_api_tmpl/config"
|
||||
"go_api_tmpl/global"
|
||||
"goweb/config"
|
||||
"goweb/global"
|
||||
)
|
||||
|
||||
func Init() {
|
||||
|
@ -3,8 +3,8 @@ package initialization
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"go_api_tmpl/config"
|
||||
"go_api_tmpl/global"
|
||||
"goweb/config"
|
||||
"goweb/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
10
main.go
10
main.go
@ -2,11 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go_api_tmpl/core"
|
||||
"go_api_tmpl/handle"
|
||||
"go_api_tmpl/initialization"
|
||||
"go_api_tmpl/middleware"
|
||||
"go_api_tmpl/route"
|
||||
"goweb/core"
|
||||
"goweb/handle"
|
||||
"goweb/initialization"
|
||||
"goweb/middleware"
|
||||
"goweb/route"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -3,8 +3,8 @@ package middleware
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go_api_tmpl/core"
|
||||
. "go_api_tmpl/global"
|
||||
"goweb/core"
|
||||
. "goweb/global"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -3,9 +3,9 @@ package middleware
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang-jwt/jwt"
|
||||
"go_api_tmpl/core"
|
||||
"go_api_tmpl/global"
|
||||
"go_api_tmpl/utils"
|
||||
"goweb/core"
|
||||
"goweb/global"
|
||||
"goweb/utils"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -2,7 +2,7 @@ package middleware
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go_api_tmpl/global"
|
||||
"goweb/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -3,9 +3,9 @@ package middleware
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go_api_tmpl/core"
|
||||
"go_api_tmpl/model"
|
||||
"go_api_tmpl/repository"
|
||||
"goweb/core"
|
||||
"goweb/model"
|
||||
"goweb/repository"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
@ -2,8 +2,8 @@ package repository
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
. "go_api_tmpl/global"
|
||||
"go_api_tmpl/model"
|
||||
. "goweb/global"
|
||||
"goweb/model"
|
||||
)
|
||||
|
||||
type apisRepository struct{}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"go_api_tmpl/global"
|
||||
"go_api_tmpl/model"
|
||||
"goweb/global"
|
||||
"goweb/model"
|
||||
)
|
||||
|
||||
type menuRepository struct{}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"go_api_tmpl/global"
|
||||
"go_api_tmpl/model"
|
||||
"goweb/global"
|
||||
"goweb/model"
|
||||
)
|
||||
|
||||
type requestLogRepository struct{}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"go_api_tmpl/global"
|
||||
"go_api_tmpl/model"
|
||||
"goweb/global"
|
||||
"goweb/model"
|
||||
)
|
||||
|
||||
type roleMenuRepository struct{}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"go_api_tmpl/global"
|
||||
"go_api_tmpl/model"
|
||||
"goweb/global"
|
||||
"goweb/model"
|
||||
)
|
||||
|
||||
type roleRepository struct{}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"go_api_tmpl/global"
|
||||
"go_api_tmpl/model"
|
||||
"goweb/global"
|
||||
"goweb/model"
|
||||
)
|
||||
|
||||
type userRepository struct{}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"go_api_tmpl/global"
|
||||
"go_api_tmpl/model"
|
||||
"goweb/global"
|
||||
"goweb/model"
|
||||
)
|
||||
|
||||
type userRoleRepository struct{}
|
||||
|
@ -2,7 +2,7 @@ package route
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go_api_tmpl/controller"
|
||||
"goweb/controller"
|
||||
)
|
||||
|
||||
// 初始化登录相关接口路由
|
||||
|
@ -2,7 +2,7 @@ package route
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go_api_tmpl/core"
|
||||
"goweb/core"
|
||||
)
|
||||
|
||||
func InitRoute(app *gin.Engine) {
|
||||
|
@ -2,8 +2,8 @@ package route
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go_api_tmpl/core"
|
||||
"go_api_tmpl/middleware"
|
||||
"goweb/core"
|
||||
"goweb/middleware"
|
||||
)
|
||||
|
||||
func initTestRoute(r *gin.RouterGroup) {
|
||||
|
Loading…
Reference in New Issue
Block a user