26 lines
		
	
	
		
			675 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			675 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Package router ...
 | |
| //
 | |
| // Description : router ...
 | |
| //
 | |
| // Author : go_developer@163.com<白茶清欢>
 | |
| //
 | |
| // Date : 2025-10-30 15:39
 | |
| package router
 | |
| 
 | |
| import "github.com/gin-gonic/gin"
 | |
| 
 | |
| // GetCommonParam 获取公共参数
 | |
| type GetCommonParam func(ctx *gin.Context) (any, error)
 | |
| 
 | |
| // AddCommonParamRule 添加公共参数注入规则
 | |
| func (s *server) AddCommonParamRule(fieldName string, getParamFunc GetCommonParam) {
 | |
| 	s.commonParam[fieldName] = getParamFunc
 | |
| }
 | |
| 
 | |
| // AddCommonParamRules 批量添加公共参数注入规则
 | |
| func (s *server) AddCommonParamRules(rules map[string]GetCommonParam) {
 | |
| 	for fieldName, rule := range rules {
 | |
| 		s.AddCommonParamRule(fieldName, rule)
 | |
| 	}
 | |
| }
 |