Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bpm
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王厚康
bpm
Commits
9610ce64
Commit
9610ce64
authored
Mar 22, 2019
by
王厚康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登陆验证
parent
68a77ac3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
533 additions
and
1030 deletions
+533
-1030
pom.xml
pom.xml
+15
-1
DruidConfig.java
src/main/java/com/bbd/bpm/config/DruidConfig.java
+78
-0
SecurityUser.java
src/main/java/com/bbd/bpm/config/SecurityUser.java
+62
-0
SwaggerConfig.java
src/main/java/com/bbd/bpm/config/SwaggerConfig.java
+17
-11
ThreadPoolConfig.java
src/main/java/com/bbd/bpm/config/ThreadPoolConfig.java
+28
-0
WebSecurityConfig.java
src/main/java/com/bbd/bpm/config/WebSecurityConfig.java
+101
-0
MiaoController.java
src/main/java/com/bbd/bpm/controller/MiaoController.java
+0
-281
LoginController.java
src/main/java/com/bbd/bpm/controller/user/LoginController.java
+47
-0
UserController.java
src/main/java/com/bbd/bpm/controller/user/UserController.java
+1
-1
User.java
src/main/java/com/bbd/bpm/domain/User.java
+117
-28
UserRepository.java
src/main/java/com/bbd/bpm/repository/UserRepository.java
+12
-0
UserService.java
src/main/java/com/bbd/bpm/service/UserService.java
+0
-12
MiaoServiceImpl.java
src/main/java/com/bbd/bpm/serviceImpl/MiaoServiceImpl.java
+0
-236
TestUtil.java
src/main/java/com/bbd/bpm/util/TestUtil.java
+20
-0
application.properties
src/main/resources/application.properties
+12
-35
index.html
src/main/resources/templates/bpm/index.html
+10
-212
index.html
src/main/resources/templates/index.html
+8
-181
login.html
src/main/resources/templates/login.html
+5
-32
No files found.
pom.xml
View file @
9610ce64
...
...
@@ -29,6 +29,11 @@
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-security
</artifactId>
</dependency>
<dependency>
<groupId>
org.activiti
</groupId>
<artifactId>
activiti-spring-boot-starter-basic
</artifactId>
<version>
6.0.0
</version>
...
...
@@ -91,7 +96,16 @@
<version>
1.2.3
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
<version>
1.0.24
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.31
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
...
...
src/main/java/com/bbd/bpm/config/DruidConfig.java
0 → 100644
View file @
9610ce64
package
com
.
bbd
.
bpm
.
config
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.alibaba.druid.pool.DruidDataSourceFactory
;
import
com.alibaba.druid.support.http.StatViewServlet
;
import
com.alibaba.druid.support.http.WebStatFilter
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
org.springframework.core.env.*
;
import
javax.sql.DataSource
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Properties
;
/**
* Created by houkang on 2019/3/19.
*/
@Configuration
public
class
DruidConfig
{
private
static
final
String
DB_PREFIX
=
"spring.datasource-"
;
@Autowired
private
Environment
environment
;
@Bean
@ConfigurationProperties
(
prefix
=
DB_PREFIX
)
public
DataSource
druidDataSource
()
{
Properties
dbProperties
=
new
Properties
();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
for
(
PropertySource
<?>
propertySource
:
((
AbstractEnvironment
)
environment
).
getPropertySources
())
{
getPropertiesFromSource
(
propertySource
,
map
);
}
dbProperties
.
putAll
(
map
);
DruidDataSource
dds
;
try
{
dds
=
(
DruidDataSource
)
DruidDataSourceFactory
.
createDataSource
(
dbProperties
);
dds
.
init
();
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"load datasource error, dbProperties is :"
+
dbProperties
,
e
);
}
return
dds
;
}
private
void
getPropertiesFromSource
(
PropertySource
<?>
propertySource
,
Map
<
String
,
Object
>
map
)
{
if
(
propertySource
instanceof
MapPropertySource
)
{
for
(
String
key
:
((
MapPropertySource
)
propertySource
).
getPropertyNames
())
{
if
(
key
.
startsWith
(
DB_PREFIX
))
map
.
put
(
key
.
replaceFirst
(
DB_PREFIX
,
""
),
propertySource
.
getProperty
(
key
));
else
if
(
key
.
startsWith
(
DB_PREFIX
))
map
.
put
(
key
.
replaceFirst
(
DB_PREFIX
,
""
),
propertySource
.
getProperty
(
key
));
}
}
if
(
propertySource
instanceof
CompositePropertySource
)
{
for
(
PropertySource
<?>
s
:
((
CompositePropertySource
)
propertySource
).
getPropertySources
())
{
getPropertiesFromSource
(
s
,
map
);
}
}
}
@Bean
public
ServletRegistrationBean
druidServlet
()
{
return
new
ServletRegistrationBean
(
new
StatViewServlet
(),
"/druid/*"
);
}
@Bean
public
FilterRegistrationBean
filterRegistrationBean
()
{
FilterRegistrationBean
filterRegistrationBean
=
new
FilterRegistrationBean
();
filterRegistrationBean
.
setFilter
(
new
WebStatFilter
());
filterRegistrationBean
.
addUrlPatterns
(
"/*"
);
filterRegistrationBean
.
addInitParameter
(
"exclusions"
,
"*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
);
return
filterRegistrationBean
;
}
}
src/main/java/com/bbd/bpm/config/SecurityUser.java
0 → 100644
View file @
9610ce64
package
com
.
bbd
.
bpm
.
config
;
import
com.bbd.bpm.domain.User
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.authority.SimpleGrantedAuthority
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
java.util.ArrayList
;
import
java.util.Collection
;
/**
* Created by houkang on 2019/3/19.
*/
public
class
SecurityUser
extends
User
implements
UserDetails
{
private
static
final
long
serialVersionUID
=
1L
;
public
SecurityUser
(
User
user
)
{
if
(
user
!=
null
)
{
this
.
setUserUuid
(
user
.
getUserUuid
());
this
.
setUsername
(
user
.
getUsername
());
this
.
setPassword
(
user
.
getPassword
());
this
.
setEmail
(
user
.
getEmail
());
this
.
setTelephone
(
user
.
getTelephone
());
this
.
setRole
(
user
.
getRole
());
this
.
setImage
(
user
.
getImage
());
this
.
setLastIp
(
user
.
getLastIp
());
this
.
setLastTime
(
user
.
getLastTime
());
}
}
@Override
public
Collection
<?
extends
GrantedAuthority
>
getAuthorities
()
{
Collection
<
GrantedAuthority
>
authorities
=
new
ArrayList
<>();
String
username
=
this
.
getUsername
();
if
(
username
!=
null
)
{
SimpleGrantedAuthority
authority
=
new
SimpleGrantedAuthority
(
username
);
authorities
.
add
(
authority
);
}
return
authorities
;
}
@Override
public
boolean
isAccountNonExpired
()
{
return
true
;
}
@Override
public
boolean
isAccountNonLocked
()
{
return
true
;
}
@Override
public
boolean
isCredentialsNonExpired
()
{
return
true
;
}
@Override
public
boolean
isEnabled
()
{
return
true
;
}
}
\ No newline at end of file
src/main/java/com/bbd/bpm/config/SwaggerConfig.java
View file @
9610ce64
...
...
@@ -8,7 +8,6 @@ import springfox.documentation.builders.PathSelectors;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.*
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spi.service.contexts.SecurityContext
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
...
...
@@ -20,29 +19,35 @@ import java.time.LocalDate;
public
class
SwaggerConfig
{
@Bean
public
Docket
pe
tApi
()
{
public
Docket
createRes
tApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
.
select
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.bbd.bpm.controller"
))
.
paths
(
PathSelectors
.
any
())
.
build
()
.
apiInfo
(
apiInfo
())
.
pathMapping
(
"/"
)
.
directModelSubstitute
(
LocalDate
.
class
,
String
.
class
)
.
genericModelSubstitutes
(
ResponseEntity
.
class
)
.
useDefaultResponseMessages
(
false
);
.
build
();
}
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
"
IOS Api Documentation
"
)
.
description
(
"
IOS Api Documentation
"
)
.
contact
(
new
Contact
(
"Jason"
,
"http://www.iata.org"
,
"sunjc@iata.org"
)
)
.
title
(
"
springboot利用swagger构建api文档
"
)
.
description
(
"
简单优雅的restfun风格,http://blog.csdn.net/saytime
"
)
.
termsOfServiceUrl
(
"http://blog.csdn.net/saytime"
)
.
version
(
"1.0"
)
.
build
();
}
/**
* @ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页数1开始", dataType = "int",paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "每页的大小", dataType = "int",paramType = "query"),
@ApiImplicitParam(name = "userId", value = "当前登录的用户id", dataType = "int",paramType = "query")
})
* */
}
\ No newline at end of file
src/main/java/com/bbd/bpm/config/ThreadPoolConfig.java
0 → 100644
View file @
9610ce64
package
com
.
bbd
.
bpm
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.ThreadPoolExecutor
;
/**
* Created by houkang on 2019/3/19.
*/
@Configuration
@EnableAsync
public
class
ThreadPoolConfig
{
@Bean
public
Executor
getExecutor
()
{
ThreadPoolTaskExecutor
executor
=
new
ThreadPoolTaskExecutor
();
executor
.
setCorePoolSize
(
5
);
//线程池维护线程的最少数量
executor
.
setMaxPoolSize
(
30
);
//线程池维护线程的最大数量
executor
.
setQueueCapacity
(
8
);
//缓存队列
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
//对拒绝task的处理策略
executor
.
setKeepAliveSeconds
(
60
);
//允许的空闲时间
executor
.
initialize
();
return
executor
;
}
}
\ No newline at end of file
src/main/java/com/bbd/bpm/config/WebSecurityConfig.java
0 → 100644
View file @
9610ce64
package
com
.
bbd
.
bpm
.
config
;
import
com.bbd.bpm.domain.User
;
import
com.bbd.bpm.repository.UserRepository
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler
;
import
org.springframework.security.web.authentication.logout.LogoutSuccessHandler
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
/**
* Created by houkang on 2019/3/19.
*/
@Configuration
@EnableWebSecurity
public
class
WebSecurityConfig
extends
WebSecurityConfigurerAdapter
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
WebSecurityConfig
.
class
);
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
//配置策略
http
.
csrf
().
disable
();
http
.
authorizeRequests
().
antMatchers
(
"/static/**"
).
permitAll
().
anyRequest
().
authenticated
().
and
().
formLogin
().
loginPage
(
"/login"
).
permitAll
().
successHandler
(
loginSuccessHandler
()).
and
().
logout
().
permitAll
().
invalidateHttpSession
(
true
).
deleteCookies
(
"JSESSIONID"
).
logoutSuccessHandler
(
logoutSuccessHandler
()).
and
().
sessionManagement
().
maximumSessions
(
10
).
expiredUrl
(
"/login"
);
}
@Autowired
public
void
configureGlobal
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
.
userDetailsService
(
userDetailsService
()).
passwordEncoder
(
passwordEncoder
());
auth
.
eraseCredentials
(
false
);
}
@Bean
public
BCryptPasswordEncoder
passwordEncoder
()
{
//密码加密
return
new
BCryptPasswordEncoder
(
4
);
}
@Bean
public
LogoutSuccessHandler
logoutSuccessHandler
()
{
//登出处理
return
new
LogoutSuccessHandler
()
{
@Override
public
void
onLogoutSuccess
(
HttpServletRequest
httpServletRequest
,
HttpServletResponse
httpServletResponse
,
Authentication
authentication
)
throws
IOException
,
ServletException
{
try
{
SecurityUser
user
=
(
SecurityUser
)
authentication
.
getPrincipal
();
logger
.
info
(
"USER : "
+
user
.
getUsername
()
+
" LOGOUT SUCCESS ! "
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"LOGOUT EXCEPTION , e : "
+
e
.
getMessage
());
}
httpServletResponse
.
sendRedirect
(
"/login"
);
}
};
}
@Bean
public
SavedRequestAwareAuthenticationSuccessHandler
loginSuccessHandler
()
{
//登入处理
return
new
SavedRequestAwareAuthenticationSuccessHandler
()
{
@Override
public
void
onAuthenticationSuccess
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Authentication
authentication
)
throws
IOException
,
ServletException
{
User
userDetails
=
(
User
)
authentication
.
getPrincipal
();
logger
.
info
(
"USER : "
+
userDetails
.
getUsername
()
+
" LOGIN SUCCESS ! "
);
super
.
onAuthenticationSuccess
(
request
,
response
,
authentication
);
}
};
}
@Bean
@Override
public
UserDetailsService
userDetailsService
()
{
//用户登录实现
return
new
UserDetailsService
()
{
@Autowired
private
UserRepository
userRepository
;
@Override
public
UserDetails
loadUserByUsername
(
String
s
)
throws
UsernameNotFoundException
{
User
user
=
userRepository
.
findByUsername
(
s
);
if
(
user
==
null
){
throw
new
UsernameNotFoundException
(
"Username "
+
s
+
" not found"
);}
return
new
SecurityUser
(
user
);
}
};
}
}
\ No newline at end of file
src/main/java/com/bbd/bpm/controller/MiaoController.java
deleted
100644 → 0
View file @
68a77ac3
package
com
.
bbd
.
bpm
.
controller
;
import
com.bbd.bpm.domain.User
;
import
com.bbd.bpm.domain.VacationForm
;
import
com.bbd.bpm.service.MiaoService
;
import
com.bbd.bpm.util.ResultInfo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
@Controller
public
class
MiaoController
{
@Autowired
private
MiaoService
miaoService
;
@GetMapping
(
"/"
)
public
String
login
(){
return
"login"
;
}
//申请者的首页
@GetMapping
(
"/home"
)
public
String
index
(
ModelMap
model
,
HttpServletRequest
request
){
List
<
VacationForm
>
forms
=
miaoService
.
formList
();
Cookie
[]
cookies
=
request
.
getCookies
();
String
user
=
""
;
//从cookie中获取当前用户
if
(
cookies
!=
null
)
{
for
(
Cookie
cookie
:
cookies
)
{
if
(
cookie
.
getName
().
equals
(
"userInfo"
))
{
user
=
cookie
.
getValue
();
break
;
}
}
}
List
<
HashMap
<
String
,
Object
>>
formsMap
=
new
ArrayList
<
HashMap
<
String
,
Object
>>();
for
(
VacationForm
form
:
forms
)
{
//申请者只能看到自己申请的请假单信息
if
(
user
.
equals
(
form
.
getApplicant
()))
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"id"
,
form
.
getId
());
map
.
put
(
"title"
,
form
.
getTitle
());
map
.
put
(
"content"
,
form
.
getContent
());
map
.
put
(
"applicant"
,
form
.
getApplicant
());
map
.
put
(
"days"
,
form
.
getDays
());
map
.
put
(
"state"
,
form
.
getState
());
formsMap
.
add
(
map
);
}
}
//将forms参数返回
model
.
addAttribute
(
"forms"
,
formsMap
);
return
"index"
;
}
//审核者的首页
@GetMapping
(
"/homeApprover"
)
public
String
indexApprover
(
ModelMap
model
){
List
<
VacationForm
>
forms
=
miaoService
.
formList
();
List
<
HashMap
<
String
,
Object
>>
formsMap
=
new
ArrayList
<
HashMap
<
String
,
Object
>>();
for
(
VacationForm
form
:
forms
)
{
//审核者只能看到待审核状态的请假单
if
(
"领导审核"
.
equals
(
form
.
getState
()))
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"id"
,
form
.
getId
());
map
.
put
(
"title"
,
form
.
getTitle
());
map
.
put
(
"content"
,
form
.
getContent
());
map
.
put
(
"applicant"
,
form
.
getApplicant
());
map
.
put
(
"state"
,
form
.
getState
());
formsMap
.
add
(
map
);
}
}
model
.
addAttribute
(
"forms"
,
formsMap
);
return
"indexApprover"
;
}
//管理层的首页
@GetMapping
(
"/homeApproverzjl"
)
public
String
homeApproverzjl
(
ModelMap
model
){
List
<
VacationForm
>
forms
=
miaoService
.
formList
();
List
<
HashMap
<
String
,
Object
>>
formsMap
=
new
ArrayList
<
HashMap
<
String
,
Object
>>();
for
(
VacationForm
form
:
forms
)
{
//审核者只能看到待审核状态的请假单
if
(
"管理层审核"
.
equals
(
form
.
getState
()))
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"id"
,
form
.
getId
());
map
.
put
(
"title"
,
form
.
getTitle
());
map
.
put
(
"content"
,
form
.
getContent
());
map
.
put
(
"applicant"
,
form
.
getApplicant
());
map
.
put
(
"state"
,
form
.
getState
());
formsMap
.
add
(
map
);
}
}
model
.
addAttribute
(
"forms"
,
formsMap
);
return
"indexApproverzjl"
;
}
//人事的首页
@GetMapping
(
"/homeApproverHr"
)
public
String
homeApproverHr
(
ModelMap
model
){
List
<
VacationForm
>
forms
=
miaoService
.
formList
();
List
<
HashMap
<
String
,
Object
>>
formsMap
=
new
ArrayList
<
HashMap
<
String
,
Object
>>();
for
(
VacationForm
form
:
forms
)
{
//审核者只能看到待审核状态的请假单
if
(
"通知人事"
.
equals
(
form
.
getState
())||
"已结束"
.
equals
(
form
.
getState
()))
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"id"
,
form
.
getId
());
map
.
put
(
"title"
,
form
.
getTitle
());
map
.
put
(
"content"
,
form
.
getContent
());
map
.
put
(
"applicant"
,
form
.
getApplicant
());
map
.
put
(
"state"
,
form
.
getState
());
map
.
put
(
"approver"
,
form
.
getApprover
());
formsMap
.
add
(
map
);
}
}
model
.
addAttribute
(
"forms"
,
formsMap
);
return
"indexApproverHr"
;
}
//请假单页面
@GetMapping
(
"/form"
)
public
String
form
(){
return
"form"
;
}
@PostMapping
(
"/login"
)
@ResponseBody
public
ResultInfo
login
(
HttpServletRequest
request
,
HttpServletResponse
response
){
ResultInfo
result
=
new
ResultInfo
();
String
username
=
request
.
getParameter
(
"username"
);
User
user
=
miaoService
.
loginSuccess
(
username
);
if
(
user
!=
null
)
{
result
.
setCode
(
200
);
result
.
setMsg
(
"登录成功"
);
result
.
setInfo
(
user
);
//用户信息存放在Cookie中,实际情况下保存在Redis更佳
Cookie
cookie
=
new
Cookie
(
"userInfo"
,
username
);
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
}
else
{
result
.
setCode
(
300
);
result
.
setMsg
(
"登录名不存在,登录失败"
);
}
return
result
;
}
@GetMapping
(
"/logout"
)
@ResponseBody
public
ResultInfo
logout
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
ResultInfo
result
=
new
ResultInfo
();
Cookie
[]
cookies
=
request
.
getCookies
();
if
(
cookies
!=
null
)
{
for
(
Cookie
cookie
:
cookies
)
{
if
(
cookie
.
getName
().
equals
(
"userInfo"
))
{
cookie
.
setValue
(
null
);
// 立即销毁cookie
cookie
.
setMaxAge
(
0
);
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
break
;
}
}
}
result
.
setCode
(
200
);
return
result
;
}
//添加请假单
@GetMapping
(
"/writeForm"
)
@ResponseBody
public
ResultInfo
writeForm
(
HttpServletRequest
request
){
ResultInfo
result
=
new
ResultInfo
();
String
title
=
request
.
getParameter
(
"title"
);
String
days
=
request
.
getParameter
(
"days"
);
String
content
=
request
.
getParameter
(
"content"
);
String
operator
=
request
.
getParameter
(
"operator"
);
VacationForm
form
=
miaoService
.
writeForm
(
title
,
content
,
operator
,
days
);
result
.
setCode
(
200
);
result
.
setMsg
(
"填写请假条成功"
);
result
.
setInfo
(
form
);
return
result
;
}
//申请者放弃请假
@GetMapping
(
"/giveup"
)
@ResponseBody
public
ResultInfo
giveup
(
HttpServletRequest
request
){
ResultInfo
result
=
new
ResultInfo
();
String
formId
=
request
.
getParameter
(
"formId"
);
String
days
=
request
.
getParameter
(
"days"
);
String
operator
=
request
.
getParameter
(
"operator"
);
miaoService
.
completeProcess
(
days
,
formId
,
operator
,
"giveup"
);
result
.
setCode
(
200
);
result
.
setMsg
(
"放弃请假成功"
);
return
result
;
}
//申请未通过
@GetMapping
(
"/giveups"
)
@ResponseBody
public
ResultInfo
giveups
(
HttpServletRequest
request
){
ResultInfo
result
=
new
ResultInfo
();
String
formId
=
request
.
getParameter
(
"formId"
);
String
days
=
request
.
getParameter
(
"days"
);
String
operator
=
request
.
getParameter
(
"operator"
);
miaoService
.
completeProcesss
(
days
,
formId
,
operator
,
"giveup"
);
result
.
setCode
(
200
);
result
.
setMsg
(
"放弃请假成功"
);
return
result
;
}
//申请者申请请假
@GetMapping
(
"/apply"
)
@ResponseBody
public
ResultInfo
apply
(
HttpServletRequest
request
){
ResultInfo
result
=
new
ResultInfo
();
String
formId
=
request
.
getParameter
(
"formId"
);
String
operator
=
request
.
getParameter
(
"operator"
);
String
days
=
request
.
getParameter
(
"days"
);
miaoService
.
completeProcess
(
days
,
formId
,
operator
,
"apply"
);
result
.
setCode
(
200
);
result
.
setMsg
(
"申请请假成功"
);
return
result
;
}
//审批者审核请假信息
@GetMapping
(
"/approve"
)
@ResponseBody
public
ResultInfo
approve
(
HttpServletRequest
request
){
ResultInfo
result
=
new
ResultInfo
();
String
formId
=
request
.
getParameter
(
"formId"
);
String
operator
=
request
.
getParameter
(
"operator"
);
miaoService
.
approverVacation
(
formId
,
operator
);
result
.
setCode
(
200
);
result
.
setMsg
(
"请假审核成功"
);
return
result
;
}
//获取某条请假信息当前状态
@GetMapping
(
"/currentState"
)
public
HashMap
<
String
,
String
>
currentState
(
HttpServletRequest
request
){
String
formId
=
request
.
getParameter
(
"formId"
);
HashMap
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
=
miaoService
.
getCurrentState
(
formId
);
return
map
;
}
@GetMapping
(
"/historyState"
)
@ResponseBody
public
ResultInfo
queryHistoricTask
(
HttpServletRequest
request
){
ResultInfo
result
=
new
ResultInfo
();
String
formId
=
request
.
getParameter
(
"formId"
);
List
process
=
miaoService
.
historyState
(
formId
);
result
.
setCode
(
200
);
result
.
setInfo
(
process
);
return
result
;
}
}
src/main/java/com/bbd/bpm/controller/user/LoginController.java
0 → 100644
View file @
9610ce64
package
com
.
bbd
.
bpm
.
controller
.
user
;
import
com.bbd.bpm.domain.User
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.context.SecurityContext
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
import
java.security.Principal
;
/**
* Created by houkang on 2019/3/19.
*/
@Controller
public
class
LoginController
{
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
GET
)
public
String
login
()
{
return
"login"
;
}
@RequestMapping
(
value
=
"/"
,
method
=
RequestMethod
.
GET
)
public
String
root
(
Principal
principal
,
ModelMap
m
)
{
m
.
addAttribute
(
"userName"
,
principal
.
getName
());
return
"bpm/index"
;
}
public
User
getUser
()
{
//为了session从获取用户信息,可以配置如下
User
user
=
new
User
();
SecurityContext
ctx
=
SecurityContextHolder
.
getContext
();
Authentication
auth
=
ctx
.
getAuthentication
();
if
(
auth
.
getPrincipal
()
instanceof
UserDetails
){
user
=
(
User
)
auth
.
getPrincipal
();}
return
user
;
}
public
HttpServletRequest
getRequest
()
{
return
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
}
}
\ No newline at end of file
src/main/java/com/bbd/bpm/controller/user/
u
serController.java
→
src/main/java/com/bbd/bpm/controller/user/
U
serController.java
View file @
9610ce64
...
...
@@ -18,7 +18,7 @@ import javax.servlet.http.HttpSession;
@Controller
@RequestMapping
(
value
=
"bpm/user"
)
public
class
u
serController
{
public
class
U
serController
{
...
...
src/main/java/com/bbd/bpm/domain/User.java
View file @
9610ce64
package
com
.
bbd
.
bpm
.
domain
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
javax.persistence.*
;
/**
* Created by houkang on 2019/1/3.
*/
//用户信息表
@Entity
@Table
(
name
=
"user"
)
public
class
User
{
@Id
@GeneratedValue
private
Integer
id
;
private
String
name
;
//用户身份标识(1-申请者,2-审核者)
private
Integer
type
;
private
Integer
delete_flag
;
public
Integer
getId
()
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
@Column
(
name
=
"id"
)
private
Integer
id
;
@Column
(
name
=
"user_uuid"
)
private
String
userUuid
;
//用户UUID
@Column
(
name
=
"username"
)
private
String
username
;
//用户名
@Column
(
name
=
"password"
)
private
String
password
;
//用户密码
@Column
(
name
=
"email"
)
private
String
email
;
//用户邮箱
@Column
(
name
=
"telephone"
)
private
String
telephone
;
//电话号码
@Column
(
name
=
"role"
)
private
String
role
;
//用户角色
@Column
(
name
=
"image"
)
private
String
image
;
//用户头像
@Column
(
name
=
"last_ip"
)
private
String
lastIp
;
//上次登录IP
@Column
(
name
=
"last_time"
)
private
String
lastTime
;
//上次登录时间
public
Integer
getId
()
{
return
id
;
}
...
...
@@ -28,28 +51,93 @@ public class User {
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
public
String
getUserUuid
()
{
return
userUuid
;
}
public
void
setUserUuid
(
String
userUuid
)
{
this
.
userUuid
=
userUuid
;
}
public
String
getLastIp
()
{
return
lastIp
;
}
public
void
setLastIp
(
String
lastIp
)
{
this
.
lastIp
=
lastIp
;
}
public
String
getLastTime
()
{
return
lastTime
;
}
public
void
set
Name
(
String
na
me
)
{
this
.
name
=
na
me
;
public
void
set
LastTime
(
String
lastTi
me
)
{
this
.
lastTime
=
lastTi
me
;
}
public
Integer
getTyp
e
()
{
return
typ
e
;
public
String
getUsernam
e
()
{
return
usernam
e
;
}
public
void
set
Type
(
Integer
typ
e
)
{
this
.
type
=
typ
e
;
public
void
set
Username
(
String
usernam
e
)
{
this
.
username
=
usernam
e
;
}
public
Integer
getDelete_flag
()
{
return
delete_flag
;
public
String
getPassword
()
{
return
password
;
}
public
void
set
Delete_flag
(
Integer
delete_flag
)
{
this
.
delete_flag
=
delete_flag
;
public
void
set
Password
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
String
getTelephone
()
{
return
telephone
;
}
public
void
setTelephone
(
String
telephone
)
{
this
.
telephone
=
telephone
;
}
public
String
getRole
()
{
return
role
;
}
public
void
setRole
(
String
role
)
{
this
.
role
=
role
;
}
public
String
getImage
()
{
return
image
;
}
public
void
setImage
(
String
image
)
{
this
.
image
=
image
;
}
@Override
public
String
toString
()
{
return
"User{"
+
"id="
+
id
+
", user_uuid='"
+
userUuid
+
'\''
+
", username='"
+
username
+
'\''
+
", password='"
+
password
+
'\''
+
", email='"
+
email
+
'\''
+
", telephone='"
+
telephone
+
'\''
+
", role='"
+
role
+
'\''
+
", image='"
+
image
+
'\''
+
", last_ip='"
+
lastIp
+
'\''
+
", last_time='"
+
lastTime
+
'\''
+
'}'
;
}
}
\ No newline at end of file
src/main/java/com/bbd/bpm/repository/UserRepository.java
0 → 100644
View file @
9610ce64
package
com
.
bbd
.
bpm
.
repository
;
import
com.bbd.bpm.domain.User
;
import
org.springframework.data.jpa.repository.JpaRepository
;
/**
* Created by houkang on 2019/3/19.
*/
public
interface
UserRepository
extends
JpaRepository
<
User
,
Long
>
{
User
findByUsername
(
String
username
);
}
src/main/java/com/bbd/bpm/service/UserService.java
deleted
100644 → 0
View file @
68a77ac3
package
com
.
bbd
.
bpm
.
service
;
import
com.bbd.bpm.domain.User
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
UserService
extends
JpaRepository
<
User
,
Long
>
{
public
List
<
User
>
findByName
(
String
name
);
}
\ No newline at end of file
src/main/java/com/bbd/bpm/serviceImpl/MiaoServiceImpl.java
deleted
100644 → 0
View file @
68a77ac3
package
com
.
bbd
.
bpm
.
serviceImpl
;
import
com.bbd.bpm.domain.User
;
import
com.bbd.bpm.domain.VacationForm
;
import
com.bbd.bpm.service.MiaoService
;
import
com.bbd.bpm.service.UserService
;
import
com.bbd.bpm.service.VacationFormService
;
import
io.swagger.models.auth.In
;
import
org.activiti.engine.HistoryService
;
import
org.activiti.engine.RuntimeService
;
import
org.activiti.engine.TaskService
;
import
org.activiti.engine.history.HistoricTaskInstance
;
import
org.activiti.engine.task.Task
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.*
;
@Service
(
"miaoService"
)
public
class
MiaoServiceImpl
implements
MiaoService
{
@Autowired
private
RuntimeService
runtimeService
;
@Autowired
private
TaskService
taskService
;
@Autowired
HistoryService
historyService
;
@Autowired
private
VacationFormService
vacationFormService
;
@Autowired
private
UserService
userService
;
//填写请假信息
@Override
public
VacationForm
writeForm
(
String
title
,
String
content
,
String
applicant
,
String
days
)
{
VacationForm
form
=
new
VacationForm
();
String
approver
=
"未知审批者"
;
form
.
setTitle
(
title
);
form
.
setDays
(
Integer
.
valueOf
(
days
));
form
.
setContent
(
content
);
form
.
setApplicant
(
applicant
);
form
.
setApprover
(
approver
);
vacationFormService
.
save
(
form
);
Map
<
String
,
Object
>
variables
=
new
HashMap
<
String
,
Object
>();
variables
.
put
(
"employee"
,
form
.
getApplicant
());
//开始请假流程,使用formId作为流程的businessKey
runtimeService
.
startProcessInstanceByKey
(
"myProcee"
,
form
.
getId
().
toString
(),
variables
);
return
form
;
}
//根据选择,申请或放弃请假
@Override
public
void
completeProcess
(
String
days
,
String
formId
,
String
operator
,
String
input
)
{
//根据businessKey找到当前任务节点
Task
task
=
taskService
.
createTaskQuery
().
processInstanceBusinessKey
(
formId
).
singleResult
();
//设置输入参数,使流程自动流转到对应节点
taskService
.
setVariable
(
task
.
getId
(),
"input"
,
input
);
taskService
.
complete
(
task
.
getId
());
if
(
"apply"
.
equals
(
input
))
{
applyVacation
(
formId
,
operator
,
days
);
}
else
{
giveupVacation
(
formId
,
operator
);
}
}
//放弃请假
@Override
public
boolean
giveupVacation
(
String
formId
,
String
operator
)
{
Task
task
=
taskService
.
createTaskQuery
().
processInstanceBusinessKey
(
formId
).
singleResult
();
Map
<
String
,
Object
>
variables
=
new
HashMap
<
String
,
Object
>();
variables
.
put
(
"employee"
,
operator
);
//认领任务
taskService
.
claim
(
task
.
getId
(),
operator
);
//完成任务
taskService
.
complete
(
task
.
getId
(),
variables
);
return
true
;
}
public
boolean
applyVacation
(
String
formId
,
String
operator
,
String
days
)
{
Task
task
=
taskService
.
createTaskQuery
().
processInstanceBusinessKey
(
formId
).
singleResult
();
Map
<
String
,
Object
>
variables
=
new
HashMap
<
String
,
Object
>();
List
<
User
>
users
=
userService
.
findAll
();
String
managers
=
""
;
//获取所有具有审核权限的用户
for
(
User
user
:
users
)
{
if
(
user
.
getType
().
equals
(
2
))
{
managers
+=
user
.
getName
()
+
","
;
}
}
managers
=
managers
.
substring
(
0
,
managers
.
length
()
-
1
);
variables
.
put
(
"employee"
,
operator
);
variables
.
put
(
"managers"
,
managers
);
Integer
day
=
Integer
.
valueOf
(
days
);
variables
.
put
(
"days"
,
day
);
taskService
.
claim
(
task
.
getId
(),
operator
);
taskService
.
complete
(
task
.
getId
(),
variables
);
return
true
;
}
@Override
public
boolean
approverVacation
(
String
formId
,
String
operator
)
{
Task
task
=
taskService
.
createTaskQuery
().
processInstanceBusinessKey
(
formId
).
singleResult
();
Map
<
String
,
Object
>
variables
=
new
HashMap
<
String
,
Object
>();
List
<
User
>
users
=
userService
.
findAll
();
String
managers
=
""
;
//获取所有具有审核权限的用户
for
(
User
user
:
users
)
{
if
(
user
.
getType
().
equals
(
3
))
{
managers
+=
user
.
getName
()
+
","
;
}
}
managers
=
managers
.
substring
(
0
,
managers
.
length
()
-
1
);
variables
.
put
(
"employee"
,
operator
);
variables
.
put
(
"managers"
,
managers
);
taskService
.
claim
(
task
.
getId
(),
operator
);
taskService
.
complete
(
task
.
getId
(),
variables
);
//更新请假信息的审核人
try
{
VacationForm
form
=
vacationFormService
.
findById
(
Integer
.
parseInt
(
formId
)).
get
();
if
(
form
!=
null
)
{
form
.
setApprover
(
operator
);
vacationFormService
.
save
(
form
);
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
true
;
}
//获取请假信息的当前流程状态
@Override
public
HashMap
<
String
,
String
>
getCurrentState
(
String
formId
)
{
HashMap
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
Task
task
=
taskService
.
createTaskQuery
().
processInstanceBusinessKey
(
formId
).
singleResult
();
if
(
task
!=
null
)
{
map
.
put
(
"status"
,
"processing"
);
map
.
put
(
"taskId"
,
task
.
getId
());
map
.
put
(
"taskName"
,
task
.
getName
());
map
.
put
(
"user"
,
task
.
getAssignee
());
}
else
{
map
.
put
(
"status"
,
"finish"
);
}
return
map
;
}
//请假列表
@Override
public
List
<
VacationForm
>
formList
()
{
List
<
VacationForm
>
formList
=
vacationFormService
.
findAll
();
for
(
VacationForm
form
:
formList
)
{
Task
task
=
taskService
.
createTaskQuery
().
processInstanceBusinessKey
(
form
.
getId
().
toString
())
.
singleResult
();
if
(
task
!=
null
)
{
String
state
=
task
.
getName
();
form
.
setState
(
state
);
}
else
{
form
.
setState
(
"已结束"
);
}
}
return
formList
;
}
//登录验证用户名是否存在
@Override
public
User
loginSuccess
(
String
username
)
{
List
<
User
>
users
=
userService
.
findByName
(
username
);
if
(
users
!=
null
&&
users
.
size
()
>
0
)
{
User
user
=
users
.
get
(
0
);
return
user
;
}
return
null
;
}
//获取当前登录用户
public
String
getCurrentUser
(
HttpServletRequest
request
)
{
String
user
=
""
;
Cookie
[]
cookies
=
request
.
getCookies
();
if
(
cookies
!=
null
)
{
for
(
Cookie
cookie
:
cookies
)
{
if
(
cookie
.
getName
().
equals
(
"userInfo"
))
{
user
=
cookie
.
getValue
();
}
}
}
return
user
;
}
//获取已执行的流程信息
@Override
public
List
historyState
(
String
formId
)
{
List
<
HashMap
<
String
,
String
>>
processList
=
new
ArrayList
<
HashMap
<
String
,
String
>>();
List
<
HistoricTaskInstance
>
list
=
historyService
.
createHistoricTaskInstanceQuery
()
.
processInstanceBusinessKey
(
formId
).
list
();
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
for
(
HistoricTaskInstance
hti
:
list
)
{
HashMap
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
"name"
,
hti
.
getName
());
map
.
put
(
"operator"
,
hti
.
getAssignee
());
processList
.
add
(
map
);
}
}
return
processList
;
}
@Override
public
void
completeProcesss
(
String
days
,
String
formId
,
String
operator
,
String
input
)
{
//根据businessKey找到当前任务节点
Task
task
=
taskService
.
createTaskQuery
().
processInstanceBusinessKey
(
formId
).
singleResult
();
//设置输入参数,使流程自动流转到对应节点
taskService
.
setVariable
(
task
.
getId
(),
"input"
,
input
);
taskService
.
complete
(
task
.
getId
());
giveupVacations
(
formId
,
operator
);
}
//放弃请假
public
boolean
giveupVacations
(
String
formId
,
String
operator
)
{
Task
task
=
taskService
.
createTaskQuery
().
processInstanceBusinessKey
(
formId
).
singleResult
();
Map
<
String
,
Object
>
variables
=
new
HashMap
<
String
,
Object
>();
VacationForm
vacationForm
=
vacationFormService
.
getOne
(
Integer
.
valueOf
(
formId
));
variables
.
put
(
"employee"
,
vacationForm
.
getApplicant
());
variables
.
put
(
"managers"
,
operator
);
//认领任务
taskService
.
claim
(
task
.
getId
(),
vacationForm
.
getApplicant
());
return
true
;
}
}
src/main/java/com/bbd/bpm/util/TestUtil.java
0 → 100644
View file @
9610ce64
package
com
.
bbd
.
bpm
.
util
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
/**
* Created by houkang on 2019/3/19.
*/
public
class
TestUtil
{
public
static
void
encoder
()
{
String
password
=
"admin"
;
BCryptPasswordEncoder
encoder
=
new
BCryptPasswordEncoder
(
4
);
String
enPassword
=
encoder
.
encode
(
password
);
System
.
out
.
println
(
enPassword
);
}
public
static
void
main
(
String
[]
args
){
encoder
();
}
}
src/main/resources/application.properties
View file @
9610ce64
#端口
server.port
=
8081
spring.datasource.url
=
jdbc:mysql://106.75.97.50:3306/test?characterEncoding=UTF-8
spring.datasource.username
=
airuser
spring.datasource.password
=
!@JD@2016
spring.datasource.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
spring.datasource.driverClassName
=
com.mysql.cj.jdbc.Driver
##Druid##
#spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
#连接池启动时创建的连接数量的初始值
spring.datasource.initialSize
=
5
#最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请
spring.datasource.minIdle
=
5
#连接池的最大值,同一时间可以从池分配的最多连接数量,0时无限制
spring.datasource.maxActive
=
100
#最大建立连接等待时间。单位为 ms,如果超过此时间将接到异常。设为-1表示无限制
spring.datasource.maxWait
=
60000
#1) Destroy线程会检测连接的间隔时间2) testWhileIdle的判断依据,详细看testWhileIdle属性的说明
spring.datasource.timeBetweenEvictionRunsMillis
=
60000
#配置一个连接在池中最小生存的时间,单位是毫秒
spring.datasource.minEvictableIdleTimeMillis
=
300000
#用来检测连接是否有效的sql,要求是一个查询语句
spring.datasource.validationQuery
=
SELECT 1
#建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效
spring.datasource.testWhileIdle
=
true
#申请连接时执行validationQuery检测连接是否有效,配置true会降低性能
spring.datasource.testOnBorrow
=
false
#归还连接时执行validationQuery检测连接是否有效,配置true会降低性能
spring.datasource.testOnReturn
=
false
#是否缓存preparedStatement,也就是PSCache。PSCache对支持游标的数据库性能提升巨大,比如说oracle。在mysql5.5以下的版本中没有PSCache功能,建议关闭掉。
spring.datasource.poolPreparedStatements
=
true
#指定每个连接上PSCache的大小
spring.datasource.maxPoolPreparedStatementPerConnectionSize
=
20
#属性类型是字符串,通过别名的方式配置扩展插件,
spring.datasource-url
=
jdbc:mysql://106.75.97.50:3306/test?characterEncoding=UTF-8
spring.datasource-username
=
airuser
spring.datasource-password
=
!@JD@2016
spring.datasource-type=com.alibaba.druid.pool.DruidDataSource
spring.datasource-driver-class-name
=
com.mysql.cj.jdbc.Driver
#常用的插件有:监控统计用的filter:stat日志用的filter:log4j防御sql注入的filter:wall
spring.datasource.filters
=
stat,wall,log4j
spring.datasource.useGlobalDataSourceStat
=
true
###############################
# Specify the DBMS
spring.jpa.database
=
MYSQL
...
...
@@ -48,7 +21,11 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.resources.add-mappings
=
true
springfox.documentation.swagger.v2.path
:
/api-docs
spring.freemarker.template-loader-path
=
classpath:/templates/
spring.freemarker.suffix
=
.html
spring.freemarker.content-type
:
= text/html
spring.freemarker.charset
=
UTF-8
spring.mvc.static-path-pattern
=
/**
src/main/resources/templates/bpm/index.html
View file @
9610ce64
This diff is collapsed.
Click to expand it.
src/main/resources/templates/index.html
View file @
9610ce64
<!DOCTYPE html>
<html
xmlns:th=
"http://www.w3.org/1999/xhtml
"
>
<html
lang=
"en
"
>
<head>
<meta
charset=
"UTF-8"
/
>
<title>
工作流
</title>
<link
rel=
"stylesheet"
href=
"http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css"
/>
<meta
charset=
"UTF-8"
>
<title>
首页
</title>
<
#
assign
user=
Session.SPRING_SECURITY_CONTEXT.authentication.principal
/
>
</head>
<body>
<div>
<button
onclick=
"writeForm()"
>
填写请假单
</button>
<button
class=
"log"
onclick=
"logout()"
>
退出
</button>
</div>
<table
th:if=
"${forms.size()}>0"
>
<thead>
<tr>
<td>
请假标题
</td>
<td>
请假内容
</td>
<td>
请假人
</td>
<td>
请假天数
</td>
<td>
状态
</td>
<td>
操作
</td>
</tr>
</thead>
<tr
th:each=
"form:${forms}"
>
<td
th:text=
"${form.title}"
></td>
<td
th:text=
"${form.content}"
></td>
<td
th:text=
"${form.days}"
></td>
<td
th:text=
"${form.applicant}"
></td>
<td
th:text=
"${form.state}"
></td>
<td>
<button
th:if=
"${form.state} == '填写请假单'"
th:onclick=
"'javascript:apply(\''+${form.id}+'\',\''+${form.days}+'\')'"
>
申请请假
</button>
<button
th:if=
"${form.state} == '填写请假单'"
th:onclick=
"'javascript:giveup(\''+${form.id}+'\')'"
>
放弃请假
</button>
<button
th:onclick=
"'javascript:checkState(\''+${form.id}+'\')'"
data-toggle=
"modal"
data-target=
"#myModal"
>
查看流程
</button>
</td>
</tr>
</table>
<div
th:if=
"${forms.size()}==0"
>
<br
/>
暂无请假数据
</div>
<!-- 模态框(Modal) -->
<div
class=
"modal fade"
id=
"myModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h4
class=
"modal-title"
id=
"myModalLabel"
>
流程
</h4>
</div>
<div
class=
"modal-body"
>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
关闭
</button>
</div>
</div>
</div>
</div>
欢迎你,${user.username}
<br/>
<a
href=
"/logout"
>
注销
</a>
</body>
</html>
<style>
body
{
margin
:
10px
10px
100px
10px
;
}
*
{
font-family
:
"微软雅黑"
;
font-size
:
15px
;
}
td
{
padding
:
5px
10px
;
border
:
1px
solid
#ccc
;
}
button
{
padding
:
5px
;
margin
:
5px
0
;
border
:
1px
solid
#aaa
;
border-radius
:
4px
;
}
.log
{
float
:
right
;
padding
:
5px
8px
;
background
:
#ec5757
;
color
:
#fff
;
}
</style>
<script
src=
"http://libs.baidu.com/jquery/1.9.1/jquery.min.js"
></script>
<script
src=
"http://apps.bdimg.com/libs/bootstrap/3.3.4/js/bootstrap.min.js"
></script>
<script>
function
writeForm
()
{
location
.
href
=
"/form"
;
}
function
logout
()
{
$
.
ajax
({
url
:
"/logout"
,
success
:
function
(
data
)
{
if
(
data
.
code
==
200
)
{
location
.
href
=
"/"
;
}
}
});
}
function
apply
(
formId
,
days
)
{
var
operator
=
getUser
();
if
(
operator
==
""
)
{
location
.
href
=
"/"
;
}
$
.
ajax
({
url
:
"/apply"
,
data
:
{
"formId"
:
formId
,
"operator"
:
operator
,
"days"
:
days
},
success
:
function
(
data
)
{
if
(
data
.
code
==
200
)
{
location
.
href
=
"/home"
;
}
}
});
}
function
giveup
(
formId
)
{
var
operator
=
getUser
();
if
(
operator
==
""
)
{
location
.
href
=
"/"
;
}
$
.
ajax
({
url
:
"/giveup"
,
data
:
{
"formId"
:
formId
,
"operator"
:
operator
},
success
:
function
(
data
)
{
if
(
data
.
code
==
200
)
{
location
.
href
=
"/home"
;
}
}
});
}
function
checkState
(
formId
)
{
$
.
ajax
({
url
:
"/historyState"
,
data
:
{
"formId"
:
formId
},
success
:
function
(
data
)
{
if
(
data
.
code
==
200
)
{
var
processList
=
data
.
info
;
var
html
=
""
;
$
.
each
(
processList
,
function
(
i
,
item
){
html
+=
"<span>"
+
item
.
name
+
"(操作人:"
+
item
.
operator
+
")"
+
"</span><br/><br/>"
;
});
$
(
".modal-body"
).
html
(
html
);
}
}
});
}
function
getUser
()
{
var
name
=
"userInfo="
;
var
user
=
""
;
var
ca
=
document
.
cookie
.
split
(
';'
);
$
.
each
(
ca
,
function
(
i
,
item
)
{
if
(
item
.
indexOf
(
name
)
!=
-
1
)
{
user
=
item
.
substring
(
name
.
length
,
item
.
length
);
}
});
return
user
;
}
</script>
\ No newline at end of file
</html>
\ No newline at end of file
src/main/resources/templates/login.html
View file @
9610ce64
...
...
@@ -6,9 +6,11 @@
</head>
<body>
<div>
<span>
登录
</span>
<input
id=
"username"
placeholder=
"用户名"
/><br
/>
<button
onclick=
"login()"
>
提交
</button>
<form
action=
"/login"
method=
"post"
>
用户名 :
<input
type=
"text"
name=
"username"
/>
密码 :
<input
type=
"password"
name=
"password"
/>
<input
type=
"submit"
value=
"登录"
>
</form>
</div>
</body>
</html>
...
...
@@ -42,31 +44,3 @@ button {
</style>
<script
src=
"http://libs.baidu.com/jquery/1.9.1/jquery.min.js"
></script>
<script>
function
login
(){
$
.
ajax
({
url
:
"/login"
,
type
:
"POST"
,
data
:
{
"username"
:
$
(
"#username"
).
val
()
},
success
:
function
(
data
)
{
console
.
log
(
data
)
if
(
data
.
code
==
200
){
if
(
data
.
info
.
type
==
1
){
location
.
href
=
"/home"
;
}
else
if
(
data
.
info
.
type
==
2
){
location
.
href
=
"/homeApprover"
;
}
else
if
(
data
.
info
.
type
==
3
){
location
.
href
=
"/homeApproverHr"
;
}
else
{
location
.
href
=
"/homeApproverzjl"
;
}
}
else
{
alert
(
data
.
msg
);
}
}
});
return
false
;
}
</script>
\ No newline at end of file
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