Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
3cb17a8b
Commit
3cb17a8b
authored
Mar 23, 2017
by
lee_mingzhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change something
parent
6acc86f0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
4 deletions
+61
-4
IpValidator.java
...ava/cn/quantgroup/xyqb/aspect/accessable/IpValidator.java
+1
-1
IpValidatorAdvisor.java
...quantgroup/xyqb/aspect/accessable/IpValidatorAdvisor.java
+48
-0
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+2
-0
UserAttached.java
src/main/java/cn/quantgroup/xyqb/entity/UserAttached.java
+9
-2
xyqb.properties
src/main/resources/config/dev/xyqb.properties
+1
-1
No files found.
src/main/java/cn/quantgroup/xyqb/aspect/
ipfilter
/IpValidator.java
→
src/main/java/cn/quantgroup/xyqb/aspect/
accessable
/IpValidator.java
View file @
3cb17a8b
package
cn
.
quantgroup
.
xyqb
.
aspect
.
ipfilter
;
package
cn
.
quantgroup
.
xyqb
.
aspect
.
accessable
;
import
java.lang.annotation.*
;
...
...
src/main/java/cn/quantgroup/xyqb/aspect/accessable/IpValidatorAdvisor.java
0 → 100644
View file @
3cb17a8b
package
cn
.
quantgroup
.
xyqb
.
aspect
.
accessable
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.util.IPUtil
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
/**
* Created by 11 on 2017/3/23.
*/
@Aspect
@Component
public
class
IpValidatorAdvisor
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
IpValidatorAdvisor
.
class
);
@Value
(
"${config.accessable}"
)
private
boolean
accessable
;
@Pointcut
(
"@annotation(cn.quantgroup.xyqb.aspect.accessable.IpValidator)"
)
private
void
needIpValidate
()
{
}
@Around
(
"needIpValidate()"
)
private
Object
doCapchaValidate
(
ProceedingJoinPoint
pjp
)
throws
Throwable
{
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
String
ip
=
IPUtil
.
getRemoteIP
(
request
);
if
(
accessable
)
{
return
pjp
.
proceed
();
}
else
{
if
(
ip
.
startsWith
(
"172"
)){
return
pjp
.
proceed
();
}
else
{
LOGGER
.
error
(
"非法ip:{}"
,
ip
);
return
JsonResult
.
buildErrorStateResult
(
"非法ip"
,
null
);
}
}
}
}
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
3cb17a8b
package
cn
.
quantgroup
.
xyqb
.
controller
.
external
.
user
;
import
cn.quantgroup.xyqb.aspect.accessable.IpValidator
;
import
cn.quantgroup.xyqb.entity.*
;
import
cn.quantgroup.xyqb.entity.enumerate.*
;
import
cn.quantgroup.xyqb.model.*
;
...
...
@@ -46,6 +47,7 @@ public class InnerController {
private
IWechatService
wechatService
;
@IpValidator
@RequestMapping
(
"/user/search/phoneNo"
)
public
JsonResult
findByPhoneNo
(
String
phoneNo
)
{
User
user
=
userService
.
findByPhoneInDb
(
phoneNo
);
...
...
src/main/java/cn/quantgroup/xyqb/entity/UserAttached.java
View file @
3cb17a8b
...
...
@@ -2,8 +2,7 @@ package cn.quantgroup.xyqb.entity;
import
lombok.Data
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
javax.persistence.*
;
import
java.sql.Timestamp
;
/**
...
...
@@ -13,10 +12,18 @@ import java.sql.Timestamp;
@Entity
@Table
(
name
=
"user_attached"
)
public
class
UserAttached
{
@Id
@Column
(
name
=
"id"
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
@Column
(
name
=
"user_id"
)
private
Long
userId
;
@Column
(
name
=
"avatar"
)
private
String
avatar
;
@Column
(
name
=
"nick"
)
private
String
nick
;
@Column
(
name
=
"created_at"
)
private
Timestamp
createdAt
;
@Column
(
name
=
"updated_at"
)
private
Timestamp
updatedAt
;
}
src/main/resources/config/dev/xyqb.properties
View file @
3cb17a8b
accessable
=
0
config.accessable
=
false
configserver.disable
=
1
configserver.system
=
xyqb-user
...
...
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