优化完善

This commit is contained in:
李寻欢 2021-08-22 00:13:00 +08:00
parent 2f1b34b9b3
commit 9a035c729b
25 changed files with 52 additions and 49 deletions

4
.env
View File

@ -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

View File

@ -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
}

View File

@ -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{}

View File

@ -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
go.mod
View File

@ -1,4 +1,4 @@
module go_api_tmpl
module goweb
go 1.16

View File

@ -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 保存入库所有接口路由信息

View File

@ -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模型

View File

@ -1,8 +1,8 @@
package initialization
import (
. "go_api_tmpl/global"
"go_api_tmpl/repository"
. "goweb/global"
"goweb/repository"
)
// DatabaseTable 初始化数据库表结构

View File

@ -1,8 +1,8 @@
package initialization
import (
"go_api_tmpl/config"
"go_api_tmpl/global"
"goweb/config"
"goweb/global"
)
func Init() {

View File

@ -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
View File

@ -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() {

View File

@ -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"
)

View File

@ -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"
)

View File

@ -2,7 +2,7 @@ package middleware
import (
"github.com/gin-gonic/gin"
"go_api_tmpl/global"
"goweb/global"
"time"
)

View File

@ -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"

View File

@ -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{}

View File

@ -1,8 +1,8 @@
package repository
import (
"go_api_tmpl/global"
"go_api_tmpl/model"
"goweb/global"
"goweb/model"
)
type menuRepository struct{}

View File

@ -1,8 +1,8 @@
package repository
import (
"go_api_tmpl/global"
"go_api_tmpl/model"
"goweb/global"
"goweb/model"
)
type requestLogRepository struct{}

View File

@ -1,8 +1,8 @@
package repository
import (
"go_api_tmpl/global"
"go_api_tmpl/model"
"goweb/global"
"goweb/model"
)
type roleMenuRepository struct{}

View File

@ -1,8 +1,8 @@
package repository
import (
"go_api_tmpl/global"
"go_api_tmpl/model"
"goweb/global"
"goweb/model"
)
type roleRepository struct{}

View File

@ -1,8 +1,8 @@
package repository
import (
"go_api_tmpl/global"
"go_api_tmpl/model"
"goweb/global"
"goweb/model"
)
type userRepository struct{}

View File

@ -1,8 +1,8 @@
package repository
import (
"go_api_tmpl/global"
"go_api_tmpl/model"
"goweb/global"
"goweb/model"
)
type userRoleRepository struct{}

View File

@ -2,7 +2,7 @@ package route
import (
"github.com/gin-gonic/gin"
"go_api_tmpl/controller"
"goweb/controller"
)
// 初始化登录相关接口路由

View File

@ -2,7 +2,7 @@ package route
import (
"github.com/gin-gonic/gin"
"go_api_tmpl/core"
"goweb/core"
)
func InitRoute(app *gin.Engine) {

View File

@ -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) {