Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sv-springboot
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bsoft
sv-springboot
Commits
730bed88
Commit
730bed88
authored
Oct 24, 2019
by
whl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并,修改bug
parent
18bc050e
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
192 additions
and
19 deletions
+192
-19
bsoft-api/src/main/java/com/bsoft/api/common/handlers/GlobalExceptionHandler.java
+1
-1
bsoft-api/src/main/java/com/bsoft/api/controller/LoginController.java
+6
-7
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/CodeAndPwd.java
+28
-0
bsoft-api/src/main/java/com/bsoft/api/service/Impl/LoginServiceImpl.java
+5
-6
bsoft-api/src/main/resources/application-dev.properties
+0
-4
bsoft-api/src/main/resources/application-test.properties
+29
-0
bsoft-api/src/main/resources/application.properties
+1
-1
bsoft-api/src/main/resources/logback-spring.xml
+122
-0
No files found.
bsoft-api/src/main/java/com/bsoft/api/common/handlers/GlobalExceptionHandler.java
View file @
730bed88
...
@@ -25,7 +25,7 @@ public class GlobalExceptionHandler {
...
@@ -25,7 +25,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
Exception
.
class
)
@ExceptionHandler
(
Exception
.
class
)
@ResponseBody
@ResponseBody
public
Object
defaultErrorHandler
(
HttpServletRequest
request
,
Exception
e
){
public
Object
defaultErrorHandler
(
HttpServletRequest
request
,
Exception
e
){
log
.
error
(
"未知异常:"
,
e
.
getMessag
e
());
log
.
error
(
"未知异常:"
+
e
.
getMessage
(),
e
.
getStackTrac
e
());
return
Result
.
error
();
return
Result
.
error
();
}
}
...
...
bsoft-api/src/main/java/com/bsoft/api/controller/LoginController.java
View file @
730bed88
package
com
.
bsoft
.
api
.
controller
;
package
com
.
bsoft
.
api
.
controller
;
import
com.bsoft.api.common.Result
;
import
com.bsoft.api.common.Result
;
import
com.bsoft.api.model.reqmodel.CodeAndPwd
;
import
com.bsoft.api.service.LoginService
;
import
com.bsoft.api.service.LoginService
;
import
com.bsoft.common.utils.HttpUtil
;
import
com.bsoft.common.utils.HttpUtil
;
import
io.swagger.annotations.*
;
import
io.swagger.annotations.*
;
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.*
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
springfox.documentation.annotations.ApiIgnore
;
import
springfox.documentation.annotations.ApiIgnore
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -26,15 +24,16 @@ public class LoginController {
...
@@ -26,15 +24,16 @@ public class LoginController {
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
value
=
"登录名"
,
name
=
"loginName"
,
required
=
true
,
paramType
=
"query"
),
@ApiImplicitParam
(
value
=
"登录名"
,
name
=
"loginName"
,
required
=
true
,
paramType
=
"query"
),
@ApiImplicitParam
(
value
=
"密码"
,
name
=
"password"
,
required
=
true
,
paramType
=
"query"
)})
@ApiImplicitParam
(
value
=
"密码"
,
name
=
"password"
,
required
=
true
,
paramType
=
"query"
)})
public
Result
<
LoginService
.
LoginInfo
>
login
(
String
loginName
,
String
password
){
public
Result
<
LoginService
.
LoginInfo
>
login
(
@RequestBody
CodeAndPwd
codeAndPwd
,
HttpServletRequest
request
){
String
ip
=
HttpUtil
.
getIP
(
request
);
String
ip
=
HttpUtil
.
getIP
(
request
);
LoginService
.
LoginInfo
loginInfo
=
loginServiceImpl
.
login
(
loginName
,
password
,
ip
);
LoginService
.
LoginInfo
loginInfo
=
loginServiceImpl
.
login
(
codeAndPwd
.
getLoginName
(),
codeAndPwd
.
getPassword
(),
ip
);
return
Result
.
success
(
loginInfo
);
return
Result
.
success
(
loginInfo
);
}
}
@GetMapping
(
"token"
)
@GetMapping
(
"token"
)
@ApiOperation
(
"刷新TOKEN"
)
@ApiOperation
(
"刷新TOKEN"
)
public
Object
refresh
(
@ApiIgnore
HttpServletRequest
request
){
public
Result
<
String
>
refresh
(
@ApiIgnore
HttpServletRequest
request
){
String
oldToken
=
request
.
getHeader
(
"Authorization"
);
String
oldToken
=
request
.
getHeader
(
"Authorization"
);
String
token
=
loginServiceImpl
.
refreshToken
(
oldToken
);
String
token
=
loginServiceImpl
.
refreshToken
(
oldToken
);
return
Result
.
success
(
token
);
return
Result
.
success
(
token
);
...
...
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/CodeAndPwd.java
0 → 100644
View file @
730bed88
package
com
.
bsoft
.
api
.
model
.
reqmodel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
@ApiModel
(
"账号密码"
)
public
class
CodeAndPwd
{
@ApiModelProperty
(
name
=
"账号"
,
required
=
true
)
String
loginName
;
@ApiModelProperty
(
name
=
"密码"
,
required
=
true
)
String
password
;
public
String
getLoginName
()
{
return
loginName
;
}
public
void
setLoginName
(
String
loginName
)
{
this
.
loginName
=
loginName
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
}
bsoft-api/src/main/java/com/bsoft/api/service/Impl/LoginServiceImpl.java
View file @
730bed88
...
@@ -30,15 +30,14 @@ public class LoginServiceImpl implements LoginService {
...
@@ -30,15 +30,14 @@ public class LoginServiceImpl implements LoginService {
SysUser
user
=
userServiceImpl
.
findByLoginName
(
logName
);
SysUser
user
=
userServiceImpl
.
findByLoginName
(
logName
);
if
(
user
!=
null
&&
user
.
getPassword
().
equals
(
password
)){
if
(
user
!=
null
&&
user
.
getPassword
().
equals
(
password
)){
String
token
=
TokenUtil
.
getToken
(
password
,
user
);
String
token
=
TokenUtil
.
getToken
(
password
,
user
);
//修改ip以及最后登录时间
user
.
setLastIp
(
ip
);
user
.
setLastTime
(
new
Date
());
sysUserMapper
.
updateByPrimaryKey
(
user
);
user
.
setPassword
(
null
);
user
.
setPassword
(
null
);
loginInfo
.
setToken
(
token
);
loginInfo
.
setToken
(
token
);
loginInfo
.
setUser
(
user
);
loginInfo
.
setUser
(
user
);
//修改ip以及最后登录时间
SysUser
sysUser
=
loginInfo
.
getUser
();
sysUser
.
setLastIp
(
ip
);
sysUser
.
setLastTime
(
new
Date
());
sysUserMapper
.
updateByPrimaryKey
(
sysUser
);
}
}
return
loginInfo
;
return
loginInfo
;
}
}
...
...
bsoft-api/src/main/resources/application-dev.properties
View file @
730bed88
...
@@ -24,8 +24,5 @@ spring.redis.jedis.pool.min-idle=0
...
@@ -24,8 +24,5 @@ spring.redis.jedis.pool.min-idle=0
# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09
# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09
spring.redis.timeout
=
10000
spring.redis.timeout
=
10000
logging.path
=
/log/
logging.file
=
${logging.path}info.log
swagger.enabled
=
true
swagger.enabled
=
true
swagger.basePackage
=
com.bsoft.api.controller
swagger.basePackage
=
com.bsoft.api.controller
\ No newline at end of file
bsoft-api/src/main/resources/application-test.properties
View file @
730bed88
#### \u5F00\u53D1\u73AF\u5883 ###################################################
jdbc.url
=
jdbc:mysql://192.168.18.55:3306/bsoft?useUnicode=true&characterEncoding=utf8&useSSL=false&autoReconnect=true&rewriteBatchedStatements=TRUE
jdbc.username
=
ll
jdbc.password
=
123456
jdbc.driverClass
=
com.mysql.jdbc.Driver
spring.datasource.driver-class-name
=
oracle.jdbc.driver.OracleDriver
spring.datasource.username
=
ll
spring.datasource.password
=
123456
spring.datasource.url
=
jdbc:oracle:thin:@192.168.18.171:1521:his
# Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA40\uFF09
spring.redis.database
=
1
spring.redis.host
=
192.168.18.55
spring.redis.port
=
6379
spring.redis.password
=
ll123456
spring.redis.jedis.pool.max-active
=
8
# \u8FDE\u63A5\u6C60\u6700\u5927\u963B\u585E\u7B49\u5F85\u65F6\u95F4\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.jedis.pool.max-wait
=
-1
# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5
spring.redis.jedis.pool.max-idle
=
8
# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5
spring.redis.jedis.pool.min-idle
=
0
# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09
spring.redis.timeout
=
10000
swagger.enabled
=
true
swagger.basePackage
=
com.bsoft.api.controller
\ No newline at end of file
bsoft-api/src/main/resources/application.properties
View file @
730bed88
spring.profiles.active
=
dev
spring.profiles.active
=
test
#server.port=8080
#server.port=8080
#server.servlet.context-path=/api
#server.servlet.context-path=/api
mybatis.mapper-locations
=
classpath:mapper/*.xml
mybatis.mapper-locations
=
classpath:mapper/*.xml
...
...
bsoft-api/src/main/resources/logback-spring.xml
0 → 100644
View file @
730bed88
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 尽量别用绝对路径,如果带参数不同容器路径解释可能不同,以下配置参数在pom.xml里 -->
<!-- 日志级别 -->
<property
name=
"log.root.level"
value=
"INFO"
/>
<property
name=
"log.dev.level"
value=
"DEBUG"
/>
<property
name=
"log.test.level"
value=
"DEBUG"
/>
<property
name=
"log.prod.level"
value=
"DEBUG"
/>
<property
name=
"log.max.size"
value=
"100MB"
/>
<!-- 日志文件大小 -->
<property
name=
"log.base"
value=
"logs"
/>
<springProperty
scope=
"context"
name=
"log.moduleName"
source=
"spring.application.name"
defaultValue=
"app"
/>
<!--控制台输出 -->
<appender
name=
"stdoutError"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
ERROR
</level>
</filter>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<Pattern>
%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread]%logger{56}.%method\(\):%L -%msg%n
</Pattern>
<charset>
UTF-8
</charset>
</encoder>
</appender>
<appender
name=
"stdout"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<Pattern>
%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread]%logger{56}.%method\(\):%L -%msg%n
</Pattern>
<charset>
UTF-8
</charset>
</encoder>
</appender>
<!-- 日志文件输出 -->
<appender
name=
"file"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${log.base}/${log.moduleName}.log
</File>
<!-- 设置日志不超过${log.max.size}时的保存路径 -->
<!-- 滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件。-->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<FileNamePattern>
${log.base}/archive/${log.moduleName}_all_%d{yyyy-MM-dd}.%i.log.zip
</FileNamePattern>
<!-- 当天的日志大小 超过${log.max.size}时,压缩日志并保存 -->
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${log.max.size}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- 日志输出的文件的格式 -->
<encoder>
<pattern>
%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread]%logger{56}.%method\(\):%L -%msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
</appender>
<appender
name=
"fileError"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${log.base}/${log.moduleName}.error.log
</File>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
ERROR
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<FileNamePattern>
${log.base}/archive/error/${log.moduleName}_info_%d{yyyy-MM-dd}.%i.log.zip
</FileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${log.max.size}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- 日志输出的文件的格式 -->
<encoder>
<pattern>
%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread]%logger{56}.%method\(\):%L -%msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
</appender>
<appender
name=
"fileInfo"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${log.base}/${log.moduleName}.info.log
</File>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
INFO
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<FileNamePattern>
${log.base}/archive/info/${log.moduleName}_error_%d{yyyy-MM-dd}.%i.log.zip
</FileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${log.max.size}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- 日志输出的文件的格式 -->
<encoder>
<pattern>
%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread]%logger{56}.%method\(\):%L -%msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
</appender>
<springProfile
name=
"dev"
>
<root
level=
"DEBUG"
>
<appender-ref
ref=
"stdout"
/>
</root>
</springProfile>
<springProfile
name=
"test"
>
<logger
name=
"org.ll"
>
<level
value=
"${log.test.level}"
/>
<appender-ref
ref=
"fileInfo"
/>
<appender-ref
ref=
"fileError"
/>
</logger>
<root
level=
"${log.root.level}"
>
<appender-ref
ref=
"file"
/>
<appender-ref
ref=
"stdoutError"
/>
</root>
</springProfile>
<springProfile
name=
"prod"
>
<logger
name=
"org.ll"
>
<level
value=
"${log.prod.level}"
/>
<appender-ref
ref=
"fileInfo"
/>
<appender-ref
ref=
"fileError"
/>
</logger>
<root
level=
"${log.root.level}"
>
<appender-ref
ref=
"file"
/>
<appender-ref
ref=
"stdoutError"
/>
</root>
</springProfile>
</configuration>
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