Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
xiaolang
/
expert
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
62a13034
authored
Apr 13, 2020
by
xiaolang850403
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目的结构调整
parent
8a0629e2
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
117 additions
and
81 deletions
+117
-81
pom.xml
+6
-0
src/main/java/com/asset/ExpertApplication.java
+1
-0
src/main/java/com/asset/common/Common.java
+1
-1
src/main/java/com/asset/common/ResultUtil.java
+1
-1
src/main/java/com/asset/config/DruidConfig.java
+0
-58
src/main/java/com/asset/config/MybatisPlusConfig.java
+0
-5
src/main/java/com/asset/controller/admin/AdminController.java
+1
-3
src/main/java/com/asset/controller/admin/FailLogController.java
+1
-1
src/main/java/com/asset/controller/admin/FailReasonController.java
+1
-1
src/main/java/com/asset/controller/system/AreaController.java
+1
-1
src/main/java/com/asset/controller/system/CaptchaController.java
+1
-1
src/main/java/com/asset/controller/system/JobController.java
+1
-1
src/main/java/com/asset/controller/system/SmsController.java
+1
-1
src/main/java/com/asset/controller/system/UploadController.java
+1
-2
src/main/java/com/asset/core/enums/CodeEnum.java
+1
-1
src/main/java/com/asset/core/enums/ExpertTypeEnum.java
+1
-1
src/main/java/com/asset/core/enums/StatusEnum.java
+1
-1
src/main/java/com/asset/core/filter/TokenInterceptor.java
+88
-0
src/main/java/com/asset/domain/User.java
+5
-1
src/main/resources/application-dev.yml
+1
-1
src/main/resources/application.properties
+3
-0
No files found.
pom.xml
View file @
62a13034
...
@@ -126,6 +126,12 @@
...
@@ -126,6 +126,12 @@
<artifactId>
freemarker
</artifactId>
<artifactId>
freemarker
</artifactId>
<version>
2.3.29
</version>
<version>
2.3.29
</version>
</dependency>
</dependency>
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
<dependency>
<groupId>
com.auth0
</groupId>
<artifactId>
java-jwt
</artifactId>
<version>
3.8.3
</version>
</dependency>
</dependencies>
</dependencies>
...
...
src/main/java/com/asset/ExpertApplication.java
View file @
62a13034
...
@@ -3,6 +3,7 @@ package com.asset;
...
@@ -3,6 +3,7 @@ package com.asset;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.context.annotation.ComponentScan
;
@MapperScan
(
value
=
"com.asset.mapper"
)
@MapperScan
(
value
=
"com.asset.mapper"
)
@SpringBootApplication
@SpringBootApplication
...
...
src/main/java/com/asset/common/Common.java
View file @
62a13034
...
@@ -47,7 +47,7 @@ public class Common {
...
@@ -47,7 +47,7 @@ public class Common {
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
return
sf
.
format
(
d
);
return
sf
.
format
(
d
);
}
}
//字符串转换成时间戳
//字符串
时间日期
转换成时间戳
public
static
long
getStringToDate
(
String
time
)
{
public
static
long
getStringToDate
(
String
time
)
{
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Date
date
=
new
Date
();
Date
date
=
new
Date
();
...
...
src/main/java/com/asset/common/ResultUtil.java
View file @
62a13034
package
com
.
asset
.
common
;
package
com
.
asset
.
common
;
import
com.asset.domain.Result
;
import
com.asset.domain.Result
;
import
com.asset.enums.CodeEnum
;
import
com.asset.
core.
enums.CodeEnum
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.FieldError
;
import
org.springframework.validation.FieldError
;
...
...
src/main/java/com/asset/config/DruidConfig.java
deleted
100644 → 0
View file @
8a0629e2
package
com
.
asset
.
config
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.alibaba.druid.support.http.StatViewServlet
;
import
com.alibaba.druid.support.http.WebStatFilter
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.boot.web.servlet.ServletRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
javax.sql.DataSource
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
/*
* @author xiaol
* @date 2019/12/26
*/
@Configuration
public
class
DruidConfig
{
@ConfigurationProperties
(
prefix
=
"spring.datasource"
)
@Bean
public
DataSource
druid
(){
return
new
DruidDataSource
();
}
//配置Druid的监控
//配置一个管理后台的servlet
@Bean
public
ServletRegistrationBean
statViewServlet
(){
ServletRegistrationBean
bean
=
new
ServletRegistrationBean
(
new
StatViewServlet
(),
"/druid/*"
);
Map
<
String
,
Object
>
initParams
=
new
HashMap
<>();
initParams
.
put
(
"loginUsername"
,
"admin"
);
initParams
.
put
(
"loginPassword"
,
"123456"
);
initParams
.
put
(
"allow"
,
""
);
initParams
.
put
(
"deny"
,
"192.168.0.51"
);
bean
.
setInitParameters
(
initParams
);
return
bean
;
}
//配置一份web监控
public
FilterRegistrationBean
WebStatFilter
(){
//通过FilterRegistrationBean实例设置优先级可以生效
//通过@WebFilter无效
FilterRegistrationBean
bean
=
new
FilterRegistrationBean
<>();
bean
.
setFilter
(
new
WebStatFilter
());
//注册自定义过滤器
Map
<
String
,
Object
>
initParams
=
new
HashMap
<>();
initParams
.
put
(
"exclusions"
,
"*.js,*.css,/druid/*"
);
bean
.
setInitParameters
(
initParams
);
bean
.
setUrlPatterns
(
Arrays
.
asList
(
"/*"
));
return
bean
;
}
}
src/main/java/com/asset/config/MybatisPlusConfig.java
View file @
62a13034
...
@@ -3,13 +3,8 @@ package com.asset.config;
...
@@ -3,13 +3,8 @@ package com.asset.config;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
;
/**
* @Author: 落亦-
* @Date: 2019/11/23 19:16
*/
@Configuration
@Configuration
@ConditionalOnClass
(
value
=
{
PaginationInterceptor
.
class
})
@ConditionalOnClass
(
value
=
{
PaginationInterceptor
.
class
})
public
class
MybatisPlusConfig
{
public
class
MybatisPlusConfig
{
...
...
src/main/java/com/asset/controller/admin/AdminController.java
View file @
62a13034
...
@@ -4,16 +4,14 @@ import com.asset.common.*;
...
@@ -4,16 +4,14 @@ import com.asset.common.*;
import
com.asset.domain.Result
;
import
com.asset.domain.Result
;
import
com.asset.domain.User
;
import
com.asset.domain.User
;
import
com.asset.domain.system.*
;
import
com.asset.domain.system.*
;
import
com.asset.mapper.UserMapper
;
import
com.asset.service.UserService
;
import
com.asset.service.UserService
;
import
com.asset.service.system.*
;
import
com.asset.service.system.*
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
com.asset.enums.CodeEnum
;
import
com.asset.
core.
enums.CodeEnum
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
...
src/main/java/com/asset/controller/admin/FailLogController.java
View file @
62a13034
...
@@ -3,7 +3,7 @@ package com.asset.controller.admin;
...
@@ -3,7 +3,7 @@ package com.asset.controller.admin;
import
com.asset.common.ResultUtil
;
import
com.asset.common.ResultUtil
;
import
com.asset.domain.Result
;
import
com.asset.domain.Result
;
import
com.asset.domain.system.FailLog
;
import
com.asset.domain.system.FailLog
;
import
com.asset.enums.CodeEnum
;
import
com.asset.
core.
enums.CodeEnum
;
import
com.asset.service.system.FailLogService
;
import
com.asset.service.system.FailLogService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
src/main/java/com/asset/controller/admin/FailReasonController.java
View file @
62a13034
...
@@ -3,7 +3,7 @@ package com.asset.controller.admin;
...
@@ -3,7 +3,7 @@ package com.asset.controller.admin;
import
com.asset.common.ResultUtil
;
import
com.asset.common.ResultUtil
;
import
com.asset.domain.Result
;
import
com.asset.domain.Result
;
import
com.asset.domain.system.FailReason
;
import
com.asset.domain.system.FailReason
;
import
com.asset.enums.CodeEnum
;
import
com.asset.
core.
enums.CodeEnum
;
import
com.asset.service.system.FailReasonService
;
import
com.asset.service.system.FailReasonService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
src/main/java/com/asset/controller/system/AreaController.java
View file @
62a13034
...
@@ -3,7 +3,7 @@ package com.asset.controller.system;
...
@@ -3,7 +3,7 @@ package com.asset.controller.system;
import
com.asset.common.ResultUtil
;
import
com.asset.common.ResultUtil
;
import
com.asset.domain.Result
;
import
com.asset.domain.Result
;
import
com.asset.domain.system.Area
;
import
com.asset.domain.system.Area
;
import
com.asset.enums.CodeEnum
;
import
com.asset.
core.
enums.CodeEnum
;
import
com.asset.service.system.AreaService
;
import
com.asset.service.system.AreaService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
src/main/java/com/asset/controller/system/CaptchaController.java
View file @
62a13034
...
@@ -4,7 +4,7 @@ import com.asset.common.Common;
...
@@ -4,7 +4,7 @@ import com.asset.common.Common;
import
com.asset.common.ResultUtil
;
import
com.asset.common.ResultUtil
;
import
com.asset.domain.Result
;
import
com.asset.domain.Result
;
import
com.asset.domain.system.Captcha
;
import
com.asset.domain.system.Captcha
;
import
com.asset.enums.CodeEnum
;
import
com.asset.
core.
enums.CodeEnum
;
import
com.asset.service.system.CaptchaService
;
import
com.asset.service.system.CaptchaService
;
import
com.wf.captcha.SpecCaptcha
;
import
com.wf.captcha.SpecCaptcha
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
src/main/java/com/asset/controller/system/JobController.java
View file @
62a13034
...
@@ -3,7 +3,7 @@ package com.asset.controller.system;
...
@@ -3,7 +3,7 @@ package com.asset.controller.system;
import
com.asset.common.ResultUtil
;
import
com.asset.common.ResultUtil
;
import
com.asset.domain.Result
;
import
com.asset.domain.Result
;
import
com.asset.domain.system.Job
;
import
com.asset.domain.system.Job
;
import
com.asset.enums.CodeEnum
;
import
com.asset.
core.
enums.CodeEnum
;
import
com.asset.service.system.JobService
;
import
com.asset.service.system.JobService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
src/main/java/com/asset/controller/system/SmsController.java
View file @
62a13034
...
@@ -5,7 +5,7 @@ import com.asset.common.ResultUtil;
...
@@ -5,7 +5,7 @@ import com.asset.common.ResultUtil;
import
com.asset.common.Sms
;
import
com.asset.common.Sms
;
import
com.asset.domain.Result
;
import
com.asset.domain.Result
;
import
com.asset.domain.system.Code
;
import
com.asset.domain.system.Code
;
import
com.asset.enums.CodeEnum
;
import
com.asset.
core.
enums.CodeEnum
;
import
com.asset.service.system.CodeService
;
import
com.asset.service.system.CodeService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
src/main/java/com/asset/controller/system/UploadController.java
View file @
62a13034
...
@@ -4,7 +4,7 @@ import com.aliyun.oss.OSS;
...
@@ -4,7 +4,7 @@ import com.aliyun.oss.OSS;
import
com.aliyun.oss.OSSClientBuilder
;
import
com.aliyun.oss.OSSClientBuilder
;
import
com.asset.common.ResultUtil
;
import
com.asset.common.ResultUtil
;
import
com.asset.domain.Result
;
import
com.asset.domain.Result
;
import
com.asset.enums.CodeEnum
;
import
com.asset.
core.
enums.CodeEnum
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
@@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RestController;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
...
src/main/java/com/asset/enums/CodeEnum.java
→
src/main/java/com/asset/
core/
enums/CodeEnum.java
View file @
62a13034
package
com
.
asset
.
enums
;
package
com
.
asset
.
core
.
enums
;
public
enum
CodeEnum
{
public
enum
CodeEnum
{
...
...
src/main/java/com/asset/enums/ExpertTypeEnum.java
→
src/main/java/com/asset/
core/
enums/ExpertTypeEnum.java
View file @
62a13034
package
com
.
asset
.
enums
;
package
com
.
asset
.
core
.
enums
;
import
com.baomidou.mybatisplus.annotation.EnumValue
;
import
com.baomidou.mybatisplus.annotation.EnumValue
;
import
lombok.Getter
;
import
lombok.Getter
;
...
...
src/main/java/com/asset/enums/StatusEnum.java
→
src/main/java/com/asset/
core/
enums/StatusEnum.java
View file @
62a13034
package
com
.
asset
.
enums
;
package
com
.
asset
.
core
.
enums
;
public
enum
StatusEnum
{
public
enum
StatusEnum
{
ON
(
0
,
"正常"
),
ON
(
0
,
"正常"
),
...
...
src/main/java/com/asset/core/filter/TokenInterceptor.java
0 → 100644
View file @
62a13034
package
com
.
asset
.
core
.
filter
;
import
com.asset.common.Common
;
import
com.asset.core.jwt.TokenUtil
;
import
com.asset.domain.User
;
import
com.asset.service.UserService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.web.servlet.ModelAndView
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Date
;
@Component
public
class
TokenInterceptor
implements
HandlerInterceptor
{
@Autowired
UserService
userService
;
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
if
(
request
.
getMethod
().
equals
(
"OPTIONS"
))
{
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
return
true
;
}
response
.
setCharacterEncoding
(
"utf-8"
);
String
token
=
request
.
getHeader
(
"token"
);
if
(
token
!=
null
)
{
// 拦截验证校验token是否正确,并验证token的有效期
boolean
result
=
TokenUtil
.
verify
(
token
);
if
(
result
)
{
System
.
out
.
println
(
"通过拦截器"
);
return
true
;
}
}
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setContentType
(
"application/json; charset=utf-8"
);
try
{
//JSONObject json = new JSONObject();
//json.put("msg", "token失效");
//json.put("code", "10007");
//response.getWriter().append(json.toJSONString());
System
.
out
.
println
(
"认证失败,未通过拦截器,需重新生成token"
);
//判断用户表记录的token的有效期是否过期
Object
mobile
=
request
.
getSession
().
getAttribute
(
"mobile"
);
QueryWrapper
<
User
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"mobile"
,
mobile
);
User
user
=
userService
.
getOne
(
queryWrapper
);
//比较数据库里token的refexpire的最长期限
if
(
Common
.
getStringToDate
(
user
.
getLoginTime
())+
Long
.
valueOf
(
user
.
getRefexpire
())
>
System
.
currentTimeMillis
()){
System
.
out
.
println
(
"刷新token,生成新的token"
);
token
=
TokenUtil
.
sign
(
mobile
.
toString
());
response
.
setHeader
(
"token"
,
token
);
//手动调用刷新token接口时就需要下面的更新token代码,自动更新就不需要
User
user1
=
new
User
();
user1
.
setToken
(
token
);
QueryWrapper
<
User
>
userQueryWrapper
=
new
QueryWrapper
<>();
userQueryWrapper
.
eq
(
"id"
,
user
.
getId
());
userService
.
update
(
user1
,
userQueryWrapper
);
return
true
;
}
else
{
//数据表里的长效期的时间过期了,则要重新登录
System
.
out
.
println
(
"token超过了最长时效,请重新登录"
);
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"msg"
,
"token超过了最长时效,请重新登录"
);
json
.
put
(
"code"
,
"10007"
);
response
.
getWriter
().
append
(
json
.
toJSONString
());
return
false
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
response
.
sendError
(
500
);
return
false
;
}
}
@Override
public
void
postHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
object
,
ModelAndView
mv
)
throws
Exception
{
}
}
src/main/java/com/asset/domain/User.java
View file @
62a13034
...
@@ -117,7 +117,7 @@ public class User implements Serializable {
...
@@ -117,7 +117,7 @@ public class User implements Serializable {
private
String
expertRange
;
private
String
expertRange
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
private
Date
loginTime
;
private
String
loginTime
;
//@JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8")
//@JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8")
//private Date yy;
//private Date yy;
...
@@ -133,4 +133,8 @@ public class User implements Serializable {
...
@@ -133,4 +133,8 @@ public class User implements Serializable {
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
String
reason
;
private
String
reason
;
private
String
token
;
private
String
refexpire
;
}
}
src/main/resources/application-dev.yml
View file @
62a13034
...
@@ -29,7 +29,7 @@ pagehelper:
...
@@ -29,7 +29,7 @@ pagehelper:
#日志
#日志
logging
:
logging
:
file
:
file
:
path
:
/Users/langxiao/Code/java/
assets
/logs
path
:
/Users/langxiao/Code/java/
expert
/logs
name
:
my.log.%d{yyyy-MM-dd}.log
name
:
my.log.%d{yyyy-MM-dd}.log
max-history
:
30
max-history
:
30
max-size
:
10MB
max-size
:
10MB
...
...
src/main/resources/application.properties
View file @
62a13034
spring.profiles.active
=
dev
spring.profiles.active
=
dev
//设置登录过期时间
refexpire
=
604800000
#图片存储目录
#图片存储目录
filePath
=
D:/phpStudy/WWW/images/
filePath
=
D:/phpStudy/WWW/images/
...
...
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