Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sentinel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
sentinel
Commits
fb5a3237
Commit
fb5a3237
authored
Oct 13, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化SwaggerUI,优化接口文档
parent
5db250e7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
182 additions
and
57 deletions
+182
-57
MemberOpenApiController.java
...main/java/com/egolm/film/api/MemberOpenApiController.java
+5
-5
MemberApplyController.java
...java/com/egolm/film/api/member/MemberApplyController.java
+58
-46
MemberInfoController.java
.../java/com/egolm/film/api/member/MemberInfoController.java
+5
-5
ParameterDataTypeReader.java
...spring/web/readers/parameter/ParameterDataTypeReader.java
+112
-0
logback.xml
src/main/resources/logback.xml
+2
-1
No files found.
src/main/java/com/egolm/film/api/MemberOpenApiController.java
View file @
fb5a3237
...
...
@@ -46,9 +46,9 @@ public class MemberOpenApiController {
@PostMapping
(
"register"
)
@ApiOperation
(
"会员注册"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
s
tring"
,
required
=
true
,
name
=
"username"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
s
tring"
,
required
=
true
,
name
=
"password"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
s
tring"
,
required
=
true
,
name
=
"email"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
S
tring"
,
required
=
true
,
name
=
"username"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
S
tring"
,
required
=
true
,
name
=
"password"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
S
tring"
,
required
=
true
,
name
=
"email"
),
})
public
Object
register
(
HttpServletRequest
request
,
String
username
,
String
password
,
String
email
)
{
XException
.
assertNotBlank
(
messages
.
get
(
"err.email_null"
),
email
);
...
...
@@ -76,7 +76,7 @@ public class MemberOpenApiController {
@ResponseBody
@PostMapping
(
"resetPassword"
)
@ApiOperation
(
"找回密码"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
s
tring"
,
required
=
true
,
name
=
"email"
)})
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
S
tring"
,
required
=
true
,
name
=
"email"
)})
public
Object
resetPassword
(
String
email
)
{
XException
.
assertNotBlank
(
messages
.
get
(
"err.email_null"
),
email
);
int
code
=
(
int
)
((
Math
.
random
()
*
9
+
1
)
*
10000000
);
...
...
@@ -113,7 +113,7 @@ public class MemberOpenApiController {
@ResponseBody
@PostMapping
(
"setLocale"
)
@ApiOperation
(
"设置语言环境"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
s
tring"
,
required
=
true
,
name
=
"i18n_language"
,
defaultValue
=
"zh_CN"
)})
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
S
tring"
,
required
=
true
,
name
=
"i18n_language"
,
defaultValue
=
"zh_CN"
)})
public
Object
setLocale
(
HttpSession
session
,
String
i18n_language
)
{
Locale
locale
=
new
Locale
(
i18n_language
);
session
.
setAttribute
(
LocaleSessionInterceptor
.
I18N_LANGUAGE_SESSION
,
locale
);
...
...
src/main/java/com/egolm/film/api/member/MemberApplyController.java
View file @
fb5a3237
This diff is collapsed.
Click to expand it.
src/main/java/com/egolm/film/api/member/MemberInfoController.java
View file @
fb5a3237
...
...
@@ -42,11 +42,11 @@ public class MemberInfoController {
@PostMapping
(
"save"
)
@ApiOperation
(
"保存会员基本信息"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
s
tring"
,
required
=
true
,
name
=
"email"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
s
tring"
,
required
=
false
,
name
=
"realname"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
s
tring"
,
required
=
false
,
name
=
"address"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
s
tring"
,
required
=
false
,
name
=
"company"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
s
tring"
,
required
=
false
,
name
=
"tel"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
S
tring"
,
required
=
true
,
name
=
"email"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
S
tring"
,
required
=
false
,
name
=
"realname"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
S
tring"
,
required
=
false
,
name
=
"address"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
S
tring"
,
required
=
false
,
name
=
"company"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"
S
tring"
,
required
=
false
,
name
=
"tel"
),
})
public
Object
save
(
String
email
,
String
realname
,
String
address
,
String
company
,
String
tel
)
{
LoginToken
loginToken
=
tokenService
.
getToken
();
...
...
src/main/java/springfox/documentation/spring/web/readers/parameter/ParameterDataTypeReader.java
0 → 100644
View file @
fb5a3237
/*
*
* Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package
springfox
.
documentation
.
spring
.
web
.
readers
.
parameter
;
import
static
springfox
.
documentation
.
schema
.
Collections
.
collectionElementType
;
import
static
springfox
.
documentation
.
schema
.
Collections
.
isContainerType
;
import
static
springfox
.
documentation
.
schema
.
Maps
.
isMapType
;
import
static
springfox
.
documentation
.
schema
.
ResolvedTypes
.
modelRefFactory
;
import
static
springfox
.
documentation
.
schema
.
Types
.
isBaseType
;
import
static
springfox
.
documentation
.
schema
.
Types
.
typeNameFor
;
import
static
springfox
.
documentation
.
spi
.
schema
.
contexts
.
ModelContext
.
inputParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
com.fasterxml.classmate.ResolvedType
;
import
com.fasterxml.classmate.TypeResolver
;
import
com.google.common.base.Optional
;
import
springfox.documentation.schema.ModelRef
;
import
springfox.documentation.schema.ModelReference
;
import
springfox.documentation.schema.TypeNameExtractor
;
import
springfox.documentation.service.ResolvedMethodParameter
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spi.schema.contexts.ModelContext
;
import
springfox.documentation.spi.service.ParameterBuilderPlugin
;
import
springfox.documentation.spi.service.contexts.ParameterContext
;
@Component
@Order
(
Ordered
.
HIGHEST_PRECEDENCE
)
public
class
ParameterDataTypeReader
implements
ParameterBuilderPlugin
{
private
final
TypeNameExtractor
nameExtractor
;
private
final
TypeResolver
resolver
;
@Autowired
public
ParameterDataTypeReader
(
TypeNameExtractor
nameExtractor
,
TypeResolver
resolver
)
{
this
.
nameExtractor
=
nameExtractor
;
this
.
resolver
=
resolver
;
}
@Override
public
boolean
supports
(
DocumentationType
delimiter
)
{
return
true
;
}
@Override
public
void
apply
(
ParameterContext
context
)
{
ResolvedMethodParameter
methodParameter
=
context
.
resolvedMethodParameter
();
ResolvedType
parameterType
=
methodParameter
.
getParameterType
();
parameterType
=
context
.
alternateFor
(
parameterType
);
ModelReference
modelRef
=
null
;
if
(
methodParameter
.
hasParameterAnnotation
(
PathVariable
.
class
)
&&
treatAsAString
(
parameterType
))
{
parameterType
=
resolver
.
resolve
(
String
.
class
);
modelRef
=
new
ModelRef
(
"string"
);
}
else
if
(
methodParameter
.
hasParameterAnnotation
(
RequestParam
.
class
)
&&
isMapType
(
parameterType
))
{
modelRef
=
new
ModelRef
(
""
,
new
ModelRef
(
"string"
),
true
);
}
else
if
(
methodParameter
.
hasParameterAnnotation
(
RequestParam
.
class
)
&&
treatRequestParamAsString
(
parameterType
))
{
parameterType
=
resolver
.
resolve
(
String
.
class
);
modelRef
=
new
ModelRef
(
"string"
);
}
if
(!
methodParameter
.
hasParameterAnnotations
())
{
Class
<?>
t
=
parameterType
.
getErasedType
();
String
typeName
=
typeNameFor
(
t
);
if
(
isBaseType
(
typeName
))
{
modelRef
=
new
ModelRef
(
typeName
);
}
else
{
//LOG.warn("Trying to infer dataType {}", parameterType);
}
}
ModelContext
modelContext
=
inputParam
(
parameterType
,
context
.
getDocumentationType
(),
context
.
getAlternateTypeProvider
(),
context
.
getGenericNamingStrategy
(),
context
.
getIgnorableParameterTypes
());
context
.
parameterBuilder
()
.
type
(
parameterType
)
.
modelRef
(
Optional
.
fromNullable
(
modelRef
)
.
or
(
modelRefFactory
(
modelContext
,
nameExtractor
).
apply
(
parameterType
)));
}
private
boolean
treatRequestParamAsString
(
ResolvedType
parameterType
)
{
return
treatAsAString
(
parameterType
)
&&
!
isContainerType
(
parameterType
)
||
(
isContainerType
(
parameterType
)
&&
treatAsAString
(
collectionElementType
(
parameterType
)));
}
private
boolean
treatAsAString
(
ResolvedType
parameterType
)
{
return
!(
isBaseType
(
typeNameFor
(
parameterType
.
getErasedType
()))
||
parameterType
.
getErasedType
().
isEnum
());
}
}
src/main/resources/logback.xml
View file @
fb5a3237
...
...
@@ -7,7 +7,8 @@
<logger
name=
"org"
level=
"INFO"
/>
<logger
name=
"com"
level=
"INFO"
/>
<logger
name=
"com.egolm"
level=
"INFO"
/>
<logger
name=
"swagger"
level=
"DEBUG"
/>
<logger
name=
"com.egolm"
level=
"DEBUG"
/>
<appender
name=
"siftingAppender"
class=
"ch.qos.logback.classic.sift.SiftingAppender"
>
<discriminator>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment