diff --git a/controller/api/v1/basic/business.go b/controller/api/v1/basic/business.go index b0f2807..822406d 100644 --- a/controller/api/v1/basic/business.go +++ b/controller/api/v1/basic/business.go @@ -39,6 +39,7 @@ func GetBusinesses(c *gin.Context) { // @Description // @Accept mpfd // @Produce json +// @Param Authorization header string true "auth by /auth" // @Param name formData string true "业务系统 名称" // @Param desc formData string false "业务系统 描述" // @Param c_id formData int false "业务系统 云端id" @@ -75,6 +76,7 @@ func AddBusiness(c *gin.Context) { // @Description // @Accept mpfd // @Produce json +// @Param Authorization header string true "auth by /auth" // @Param id path int true "业务系统 ID" // @Param name formData string false "业务系统 名称" // @Param desc formData string false "业务系统 描述" @@ -123,6 +125,7 @@ func EditBusiness(c *gin.Context) { // @Description // @Accept json // @Produce json +// @Param Authorization header string true "auth by /auth" // @Param id path int true "业务系统 ID" // @Success 200 {string} json "{"code" : 200, "msg" : "ok"}" // @Router /v1/businesses/{id} [delete] diff --git a/controller/api/v1/basic/meta_database.go b/controller/api/v1/basic/meta_database.go index e23e4de..0fc1399 100644 --- a/controller/api/v1/basic/meta_database.go +++ b/controller/api/v1/basic/meta_database.go @@ -17,6 +17,7 @@ import ( // @Description // @Accept json // @Produce json +// @Param Authorization header string true "auth by /auth" // @Success 200 {string} json "{"code" : 200, "basic" : {}, "msg": "ok" }" // @Router /v1/meta_databases [get] func GetMetaDatabases(c *gin.Context) { @@ -45,6 +46,7 @@ func GetMetaDatabases(c *gin.Context) { // @Description // @Accept mpfd // @Produce json +// @Param Authorization header string true "auth by /auth" // @Param name formData string true "数据源 名称" // @Param host formData string true "数据源 地址" // @Param port formData int true "数据源 端口号" @@ -122,6 +124,7 @@ func AddMetaDatabase(c *gin.Context) { // @Description // @Accept mpfd // @Produce json +// @Param Authorization header string true "auth by /auth" // @Param id path int true "数据源 ID" // @Param name formData string false "数据源 名称" // @Param host formData string false "数据源 地址" @@ -210,6 +213,7 @@ func EditMetaDatabase(c *gin.Context) { // @Description // @Accept json // @Produce json +// @Param Authorization header string true "auth by /auth" // @Param id path int true "数据源 ID" // @Success 200 {string} json "{"code" : 200, "msg" : "ok"}" // @Router /v1/meta_databases/{id} [delete] diff --git a/controller/api/v1/basic/meta_table.go b/controller/api/v1/basic/meta_table.go index ae08a54..4b2bca0 100644 --- a/controller/api/v1/basic/meta_table.go +++ b/controller/api/v1/basic/meta_table.go @@ -11,6 +11,7 @@ import ( // @Description // @Accept json // @Produce json +// @Param Authorization header string true "auth by /auth" // @Param id path int true "数据源 ID" // @Success 200 {string} json "{"code" : 200, "basic" : {}, "msg": "ok" }" // @Router /v1/meta_databases/{id}/meta_tables [get] diff --git a/controller/api/v1/basic/vendor.go b/controller/api/v1/basic/vendor.go index 223861b..38fedf2 100644 --- a/controller/api/v1/basic/vendor.go +++ b/controller/api/v1/basic/vendor.go @@ -16,6 +16,7 @@ import ( // @Description // @Accept json // @Produce json +// @Param Authorization header string true "auth by /auth" // @Success 200 {string} json "{"code" : 200, "data" : {}, "msg" : "ok"}" // @Router /v1/vendors [get] func GetVendors(c *gin.Context) { @@ -38,6 +39,7 @@ func GetVendors(c *gin.Context) { // @Description // @Accept mpfd // @Produce json +// @Param Authorization header string true "auth by /auth" // @Param name formData string true "系统厂商 名称" // @Param c_id formData int false "系统厂商 云端id" // @Success 200 {string} json "{"code" : 200, "msg" : "ok"}" @@ -72,6 +74,7 @@ func AddVendor(c *gin.Context) { // @Description // @Accept mpfd // @Produce json +// @Param Authorization header string true "auth by /auth" // @Param id path int true "系统厂商 ID" // @Param name formData string false "系统厂商 名称" // @Param c_id formData int false "系统厂商 云端id" @@ -117,6 +120,7 @@ func EditVendor(c *gin.Context) { // @Description // @Accept json // @Produce json +// @Param Authorization header string true "auth by /auth" // @Param id path int true "系统厂商 ID" // @Success 200 {string} json "{"code" : 200, "msg" : "ok"}" // @Router /v1/vendors/{id} [delete] diff --git a/middleware/jwt/jwt.go b/middleware/jwt/jwt.go index 39417fc..37a49a6 100644 --- a/middleware/jwt/jwt.go +++ b/middleware/jwt/jwt.go @@ -24,10 +24,14 @@ func JWT() gin.HandlerFunc { } else if time.Now().Unix() > claims.ExpiresAt { code = e.ERROR_AUTH_CHECK_TOKEN_TIMEOUT } - username := claims.Username - loginUUID := claims.StandardClaims.Id - val, err := util.Redis.Get("login:" + loginUUID).Result() - if val != username { + if claims != nil { + username := claims.Username + loginUUID := claims.StandardClaims.Id + val, _ := util.Redis.Get("login:" + loginUUID).Result() + if val != username { + code = e.ERROR_AUTH_CHECK_TOKEN_FAIL + } + } else { code = e.ERROR_AUTH_CHECK_TOKEN_FAIL } } diff --git a/models/basic/business.go b/models/basic/business.go index e2406a0..dd02ba7 100644 --- a/models/basic/business.go +++ b/models/basic/business.go @@ -1,6 +1,8 @@ package basic -import "github.com/viletyy/potato/pkg/util" +import ( + "github.com/viletyy/potato/pkg/util" +) type Business struct { util.Model