marge: 合并代码
This commit is contained in:
@@ -22,3 +22,9 @@ const RATE_LIMIT_KEY = "rate_limit:"
|
||||
|
||||
// 登录账户密码错误次数
|
||||
const PWD_ERR_CNT_KEY = "pwd_err_cnt:"
|
||||
|
||||
// 网元信息管理
|
||||
const NE_KEY = "ne_info:"
|
||||
|
||||
// 网元数据管理
|
||||
const NE_DATA_KEY = "ne_data:"
|
||||
|
||||
@@ -121,7 +121,7 @@ func OperateLog(options Options) gin.HandlerFunc {
|
||||
BusinessType: options.BusinessType,
|
||||
OperatorType: options.OperatorType,
|
||||
Method: funcName,
|
||||
OperURL: c.Request.RequestURI,
|
||||
OperURL: c.Request.URL.Path,
|
||||
RequestMethod: c.Request.Method,
|
||||
OperIP: ipaddr,
|
||||
OperLocation: location,
|
||||
|
||||
@@ -14,7 +14,14 @@ import (
|
||||
)
|
||||
|
||||
/**无Token可访问白名单 */
|
||||
var URL_WHITE_LIST = []string{"/performanceManagement", "/faultManagement", "/systemState", "/omcNeConfig"}
|
||||
var URL_WHITE_LIST = []string{
|
||||
"/performanceManagement",
|
||||
"/faultManagement",
|
||||
"/systemState",
|
||||
"/omcNeConfig",
|
||||
"/cdrEvent",
|
||||
"/upload-ue",
|
||||
}
|
||||
|
||||
// PreAuthorize 用户身份授权认证校验
|
||||
//
|
||||
|
||||
@@ -65,6 +65,11 @@ func IPAddrLocation(c *gin.Context) (string, string) {
|
||||
|
||||
// Authorization 解析请求头
|
||||
func Authorization(c *gin.Context) string {
|
||||
// Query请求查询
|
||||
if authQuery, ok := c.GetQuery(token.RESPONSE_FIELD); ok && authQuery != "" {
|
||||
return authQuery
|
||||
}
|
||||
// Header请求头
|
||||
authHeader := c.GetHeader(token.HEADER_KEY)
|
||||
if authHeader == "" {
|
||||
return ""
|
||||
@@ -99,11 +104,22 @@ func UaOsBrowser(c *gin.Context) (string, string) {
|
||||
// AcceptLanguage 解析客户端接收语言 zh:中文 en: 英文
|
||||
func AcceptLanguage(c *gin.Context) string {
|
||||
preferredLanguage := language.English
|
||||
acceptLanguage := c.GetHeader("Accept-Language")
|
||||
tags, _, _ := language.ParseAcceptLanguage(acceptLanguage)
|
||||
if len(tags) > 0 {
|
||||
preferredLanguage = tags[0]
|
||||
|
||||
// Query请求查询
|
||||
if v, ok := c.GetQuery("language"); ok && v != "" {
|
||||
tags, _, _ := language.ParseAcceptLanguage(v)
|
||||
if len(tags) > 0 {
|
||||
preferredLanguage = tags[0]
|
||||
}
|
||||
}
|
||||
// Header请求头
|
||||
if v := c.GetHeader("Accept-Language"); v != "" {
|
||||
tags, _, _ := language.ParseAcceptLanguage(v)
|
||||
if len(tags) > 0 {
|
||||
preferredLanguage = tags[0]
|
||||
}
|
||||
}
|
||||
|
||||
// 只取前缀
|
||||
lang := preferredLanguage.String()
|
||||
arr := strings.Split(lang, "-")
|
||||
|
||||
Reference in New Issue
Block a user