package middleware import ( "github.com/gin-gonic/gin" "gitlab.finogeeks.club/finclip-backend/apm" "net/http" "strings" ) var ( noNeedCheckExpireUrlList = []string{ "/api/v1/mop/finstore/dev/typeConfig", } ) func CheckEnterpriseIsExpired(c *gin.Context) { traceCtx := apm.ApmClient().TraceContextFromGin(c) for _, v := range noNeedCheckExpireUrlList { if strings.Contains(c.Request.URL.Path, v) { c.Next() return } } userId := c.GetHeader("X-Consumer-Custom-ID") if userId != "" { isExpired, err := hcaller.CheckEnterpriseIsExpired(traceCtx, userId) if err != nil { c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{ "error": "服务调用失败,请重试", "errcode": "FC_SYS_REQ_ERR", "data": make(map[string]interface{}), }) return } if isExpired { c.AbortWithStatusJSON(http.StatusForbidden, gin.H{ "error": "操作失败,当前账号已到期,请联系管理员重新认证", "errcode": "MOP_ENTERPRISE_EXPIRED_ERR", "data": make(map[string]interface{}), }) return } } c.Next() }