转:https://www.jianshu.com/p/6d7e71f25fd3
问题:
解决:
1 |
<span class="token punctuation">.</span><span class="token function">globalRequestParameters</span><span class="token punctuation">(</span><span class="token function">globalRequestParameters</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> |
1 2 3 4 5 6 7 8 9 10 |
<span class="token keyword">private</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation"><</span><span class="token class-name">RequestParameter</span><span class="token punctuation">></span></span> <span class="token function">globalRequestParameters</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token class-name">RequestParameterBuilder</span> parameterBuilder <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">RequestParameterBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">//每次请求加载header</span> <span class="token punctuation">.</span><span class="token function">in</span><span class="token punctuation">(</span><span class="token class-name">ParameterType</span><span class="token punctuation">.</span>HEADER<span class="token punctuation">)</span> <span class="token comment">//头标签</span> <span class="token punctuation">.</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token string">"Token"</span><span class="token punctuation">)</span> <span class="token punctuation">.</span><span class="token function">required</span><span class="token punctuation">(</span><span class="token boolean">false</span><span class="token punctuation">)</span> <span class="token punctuation">.</span><span class="token function">query</span><span class="token punctuation">(</span>param <span class="token operator">-></span> param<span class="token punctuation">.</span><span class="token function">model</span><span class="token punctuation">(</span>model <span class="token operator">-></span> model<span class="token punctuation">.</span><span class="token function">scalarModel</span><span class="token punctuation">(</span><span class="token class-name">ScalarType</span><span class="token punctuation">.</span>STRING<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">return</span> <span class="token class-name">Collections</span><span class="token punctuation">.</span><span class="token function">singletonList</span><span class="token punctuation">(</span>parameterBuilder<span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> |
参考:
https://www.jianshu.com/p/6d7e71f25fd3