Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
registration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
13
Issues
13
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
丁伟
registration
Commits
9407336e
Commit
9407336e
authored
Dec 24, 2023
by
丁伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、取消qq邮箱无法注册的问题。
2、增加“是否购买CDCS/CSDG考前培训”
parent
a37736f7
Show whitespace changes
Inline
Side-by-side
Showing
43 changed files
with
538 additions
and
435 deletions
+538
-435
src/main/java/org/ccpit/base/dao/BaseDao.java
+21
-21
src/main/java/org/ccpit/base/dao/IDao.java
+15
-0
src/main/java/org/ccpit/base/modol/BaseEntity.java
+1
-5
src/main/java/org/ccpit/base/role/IRole.java
+2
-0
src/main/java/org/ccpit/base/role/Role.java
+7
-9
src/main/java/org/ccpit/base/role/RoleController.java
+48
-48
src/main/java/org/ccpit/base/role/RoleDao.java
+2
-2
src/main/java/org/ccpit/base/role/RoleService.java
+30
-28
src/main/java/org/ccpit/base/role/RoleUrl.java
+1
-2
src/main/java/org/ccpit/base/security/CmsTagSupport.java
+11
-11
src/main/java/org/ccpit/base/security/LoginFilter.java
+6
-10
src/main/java/org/ccpit/base/security/SecurityAllRoleTag.java
+5
-8
src/main/java/org/ccpit/base/security/SecurityAnyRoleTag.java
+4
-4
src/main/java/org/ccpit/base/security/SecurityUriTag.java
+10
-9
src/main/java/org/ccpit/base/user/IUser.java
+2
-0
src/main/java/org/ccpit/base/user/User.java
+39
-15
src/main/java/org/ccpit/base/user/UserController.java
+39
-48
src/main/java/org/ccpit/base/user/UserDao.java
+11
-9
src/main/java/org/ccpit/base/user/UserService.java
+40
-40
src/main/java/org/ccpit/base/utils/CryptUtil.java
+3
-4
src/main/java/org/ccpit/base/utils/HtmlEscapeUtil.java
+3
-3
src/main/java/org/ccpit/base/utils/ImgFontByte.java
+0
-0
src/main/java/org/ccpit/base/utils/MailSender.java
+9
-9
src/main/java/org/ccpit/base/utils/PasswordHash.java
+2
-4
src/main/java/org/ccpit/base/utils/PopupAuthenticator.java
+1
-0
src/main/java/org/ccpit/base/utils/ReadConfigUtil.java
+5
-5
src/main/java/org/ccpit/base/utils/SqlEscapeUtil.java
+4
-3
src/main/java/org/ccpit/base/utils/UserRolesUtil.java
+1
-2
src/main/java/org/ccpit/base/utils/ValidateCode.java
+25
-26
src/main/java/org/ccpit/base/utils/mailUtil/Mail.java
+23
-4
src/main/java/org/ccpit/base/utils/mailUtil/MailUtil.java
+22
-33
src/main/java/org/ccpit/business/registerManage/ExcelHelper.java
+5
-0
src/main/java/org/ccpit/business/registerManage/RegisterController.java
+0
-2
src/main/java/org/ccpit/business/registerManage/RegisterInfo.java
+13
-1
src/main/resources/framework.properties
+6
-6
src/main/sql/update.sql
+6
-3
src/main/sql/update_20210616.sql
+45
-15
src/main/sql/update_20210702.sql
+11
-4
src/main/sql/update_20211222.sql
+4
-2
src/main/webapp/WEB-INF/jsp/front/info.jsp
+42
-33
src/main/webapp/WEB-INF/jsp/front/reg.jsp
+9
-2
src/main/webapp/WEB-INF/jsp/front/reg2.jsp
+1
-1
src/main/webapp/resource/front/js/reg.js
+4
-4
No files found.
src/main/java/org/ccpit/base/dao/BaseDao.java
View file @
9407336e
...
@@ -44,10 +44,10 @@ public class BaseDao<T> implements IDao<T> {
...
@@ -44,10 +44,10 @@ public class BaseDao<T> implements IDao<T> {
boolean
success
;
boolean
success
;
try
{
try
{
hibernateTemplate
.
saveOrUpdate
(
t
);
hibernateTemplate
.
saveOrUpdate
(
t
);
success
=
true
;
success
=
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
success
=
false
;
success
=
false
;
throw
new
RuntimeException
(
"save failed"
,
e
);
throw
new
RuntimeException
(
"save failed"
,
e
);
}
}
return
success
;
return
success
;
}
}
...
@@ -103,10 +103,10 @@ public class BaseDao<T> implements IDao<T> {
...
@@ -103,10 +103,10 @@ public class BaseDao<T> implements IDao<T> {
boolean
success
;
boolean
success
;
try
{
try
{
hibernateTemplate
.
delete
(
t
);
hibernateTemplate
.
delete
(
t
);
success
=
true
;
success
=
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
success
=
false
;
success
=
false
;
throw
new
RuntimeException
(
"save failed"
,
e
);
throw
new
RuntimeException
(
"save failed"
,
e
);
}
}
return
success
;
return
success
;
}
}
...
@@ -121,13 +121,13 @@ public class BaseDao<T> implements IDao<T> {
...
@@ -121,13 +121,13 @@ public class BaseDao<T> implements IDao<T> {
boolean
success
=
false
;
boolean
success
=
false
;
try
{
try
{
T
t
=
queryById
(
id
);
T
t
=
queryById
(
id
);
if
(
t
!=
null
)
{
if
(
t
!=
null
)
{
hibernateTemplate
.
delete
(
t
);
hibernateTemplate
.
delete
(
t
);
success
=
true
;
success
=
true
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
success
=
false
;
success
=
false
;
throw
new
RuntimeException
(
"save failed"
,
e
);
throw
new
RuntimeException
(
"save failed"
,
e
);
}
}
return
success
;
return
success
;
}
}
...
@@ -146,10 +146,10 @@ public class BaseDao<T> implements IDao<T> {
...
@@ -146,10 +146,10 @@ public class BaseDao<T> implements IDao<T> {
for
(
int
i
=
0
;
i
<
ts
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
ts
.
size
();
i
++)
{
hibernateTemplate
.
saveOrUpdate
(
ts
.
get
(
i
));
hibernateTemplate
.
saveOrUpdate
(
ts
.
get
(
i
));
}
}
success
=
true
;
success
=
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
success
=
false
;
success
=
false
;
throw
new
RuntimeException
(
"save failed"
,
e
);
throw
new
RuntimeException
(
"save failed"
,
e
);
}
}
return
success
;
return
success
;
}
}
...
@@ -168,10 +168,10 @@ public class BaseDao<T> implements IDao<T> {
...
@@ -168,10 +168,10 @@ public class BaseDao<T> implements IDao<T> {
for
(
int
i
=
0
;
i
<
ts
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
ts
.
size
();
i
++)
{
hibernateTemplate
.
delete
(
ts
.
get
(
i
));
hibernateTemplate
.
delete
(
ts
.
get
(
i
));
}
}
success
=
true
;
success
=
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
success
=
false
;
success
=
false
;
throw
new
RuntimeException
(
"save failed"
,
e
);
throw
new
RuntimeException
(
"save failed"
,
e
);
}
}
return
success
;
return
success
;
...
...
src/main/java/org/ccpit/base/dao/IDao.java
View file @
9407336e
...
@@ -11,51 +11,66 @@ import java.util.List;
...
@@ -11,51 +11,66 @@ import java.util.List;
public
interface
IDao
<
T
>
{
public
interface
IDao
<
T
>
{
/**
/**
* 实例化一个实体
* 实例化一个实体
*
* @param t
* @param t
*/
*/
public
boolean
save
(
T
t
);
public
boolean
save
(
T
t
);
/**
/**
* 实例化所有实体
* 实例化所有实体
*
* @param t
* @param t
*/
*/
public
boolean
saveAll
(
List
<
T
>
list
);
public
boolean
saveAll
(
List
<
T
>
list
);
/**
/**
* 删除一个实体
* 删除一个实体
*
* @param t
* @param t
*/
*/
public
boolean
delete
(
T
t
);
public
boolean
delete
(
T
t
);
/**
/**
* 删除一个实体
* 删除一个实体
*
* @param id
* @param id
*/
*/
public
boolean
deleteById
(
long
id
);
public
boolean
deleteById
(
long
id
);
/**
/**
* 删除所有实体
* 删除所有实体
*
* @param t
* @param t
*/
*/
public
boolean
deleteAll
(
List
<
T
>
list
);
public
boolean
deleteAll
(
List
<
T
>
list
);
/**
/**
* 查询实体
* 查询实体
*
* @param t
* @param t
*/
*/
public
List
<
T
>
query
(
final
String
hql
,
final
Object
...
params
);
public
List
<
T
>
query
(
final
String
hql
,
final
Object
...
params
);
/**
/**
* 查询所有
* 查询所有
*
* @param t
* @param t
*/
*/
public
List
<
T
>
queryAll
();
public
List
<
T
>
queryAll
();
/**
/**
* 分页查询
* 分页查询
*
* @param pageRequest
* @param pageRequest
* @param hql
* @param hql
* @param values
* @param values
* @return
* @return
*/
*/
public
Page
findPage
(
PageRequest
pageRequest
,
String
hql
,
Object
[]
values
);
public
Page
findPage
(
PageRequest
pageRequest
,
String
hql
,
Object
[]
values
);
/**
/**
* 获取实体的Class
* 获取实体的Class
*
* @param t
* @param t
*/
*/
public
Class
getEntityClass
();
public
Class
getEntityClass
();
...
...
src/main/java/org/ccpit/base/modol/BaseEntity.java
View file @
9407336e
package
org
.
ccpit
.
base
.
modol
;
package
org
.
ccpit
.
base
.
modol
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.lang.annotation.Inherited
;
/**
/**
* Created by Administrator on 2015/8/13.
* Created by Administrator on 2015/8/13.
*/
*/
public
class
BaseEntity
implements
IEntity
,
Serializable
{
public
class
BaseEntity
implements
IEntity
,
Serializable
{
/**
/**
* Serializable ID
* Serializable ID
*/
*/
...
...
src/main/java/org/ccpit/base/role/IRole.java
View file @
9407336e
...
@@ -7,7 +7,9 @@ import java.util.List;
...
@@ -7,7 +7,9 @@ import java.util.List;
*/
*/
public
interface
IRole
{
public
interface
IRole
{
public
String
getRoleName
();
public
String
getRoleName
();
public
List
<
RoleUrl
>
getUrlPerfixs
();
public
List
<
RoleUrl
>
getUrlPerfixs
();
public
long
getId
();
public
long
getId
();
}
}
src/main/java/org/ccpit/base/role/Role.java
View file @
9407336e
package
org
.
ccpit
.
base
.
role
;
package
org
.
ccpit
.
base
.
role
;
import
org.ccpit.base.modol.BaseEntity
;
import
org.ccpit.base.modol.BaseEntity
;
import
org.hibernate.annotations.
*
;
import
org.hibernate.annotations.
CacheConcurrencyStrategy
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Entity
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -36,7 +34,7 @@ public class Role extends BaseEntity implements IRole {
...
@@ -36,7 +34,7 @@ public class Role extends BaseEntity implements IRole {
}
}
@Override
@Override
@OneToMany
(
cascade
=
CascadeType
.
ALL
,
fetch
=
FetchType
.
EAGER
)
@OneToMany
(
cascade
=
CascadeType
.
ALL
,
fetch
=
FetchType
.
EAGER
)
public
List
<
RoleUrl
>
getUrlPerfixs
()
{
public
List
<
RoleUrl
>
getUrlPerfixs
()
{
return
urlPerfixs
;
return
urlPerfixs
;
}
}
...
@@ -55,19 +53,19 @@ public class Role extends BaseEntity implements IRole {
...
@@ -55,19 +53,19 @@ public class Role extends BaseEntity implements IRole {
@Override
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
return
(
"role"
+
getId
()).
hashCode
();
return
(
"role"
+
getId
()).
hashCode
();
}
}
@Override
@Override
public
boolean
equals
(
Object
o
)
{
public
boolean
equals
(
Object
o
)
{
if
(
o
==
null
)
{
if
(
o
==
null
)
{
return
false
;
return
false
;
}
}
if
(
o
==
this
)
{
if
(
o
==
this
)
{
return
true
;
return
true
;
}
}
if
(
o
.
getClass
()
==
Role
.
class
)
{
if
(
o
.
getClass
()
==
Role
.
class
)
{
return
o
.
hashCode
()
==
this
.
hashCode
();
return
o
.
hashCode
()
==
this
.
hashCode
();
}
}
return
false
;
return
false
;
}
}
...
...
src/main/java/org/ccpit/base/role/RoleController.java
View file @
9407336e
package
org
.
ccpit
.
base
.
role
;
package
org
.
ccpit
.
base
.
role
;
import
java.io.IOException
;
import
java.util.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONArray
;
import
org.ccpit.base.controller.BaseController
;
import
org.ccpit.base.controller.BaseController
;
import
org.ccpit.base.controller.Page
;
import
org.ccpit.base.controller.PageRequest
;
import
org.ccpit.base.controller.PageRequest
;
import
org.ccpit.base.user.User
;
import
org.ccpit.base.user.User
;
import
org.ccpit.base.user.UserService
;
import
org.ccpit.base.user.UserService
;
...
@@ -20,30 +12,38 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -20,30 +12,38 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.ModelAndView
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* Created by Administrator on 2015/9/6.
* Created by Administrator on 2015/9/6.
*/
*/
@Controller
@Controller
@RequestMapping
(
"/admin/role"
)
@RequestMapping
(
"/admin/role"
)
public
class
RoleController
extends
BaseController
{
public
class
RoleController
extends
BaseController
{
@Autowired
@Autowired
private
RoleService
roleService
;
private
RoleService
roleService
;
@Autowired
@Autowired
private
UserService
userService
;
private
UserService
userService
;
@RequestMapping
(
"/goinRoleListPage"
)
@RequestMapping
(
"/goinRoleListPage"
)
public
Object
manage
(){
public
Object
manage
()
{
return
new
ModelAndView
(
"admin/role/roleListPage"
);
return
new
ModelAndView
(
"admin/role/roleListPage"
);
}
}
@RequestMapping
(
"/addRole"
)
@RequestMapping
(
"/addRole"
)
public
void
addRole
(
String
roleName
,
String
urlPerfixs
,
String
description
,
HttpServletResponse
response
)
{
public
void
addRole
(
String
roleName
,
String
urlPerfixs
,
String
description
,
HttpServletResponse
response
)
{
String
result
=
""
;
String
result
=
""
;
boolean
flag
=
roleService
.
addRole
(
roleName
,
urlPerfixs
,
description
);
boolean
flag
=
roleService
.
addRole
(
roleName
,
urlPerfixs
,
description
);
if
(
flag
)
{
if
(
flag
)
{
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存成功!\" }"
;
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存成功!\" }"
;
}
else
{
}
else
{
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存失败!\" }"
;
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存失败!\" }"
;
}
}
try
{
try
{
response
.
setContentType
(
"text/html"
);
response
.
setContentType
(
"text/html"
);
...
@@ -52,28 +52,28 @@ public class RoleController extends BaseController{
...
@@ -52,28 +52,28 @@ public class RoleController extends BaseController{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
/**
/**
*
* addRolePri:(添加角色操作权限). <br/>
* addRolePri:(添加角色操作权限). <br/>
* TODO(这里描述这个方法适用条件 – 可选).<br/>
* TODO(这里描述这个方法适用条件 – 可选).<br/>
* TODO(这里描述这个方法的执行流程 – 可选).<br/>
* TODO(这里描述这个方法的执行流程 – 可选).<br/>
* TODO(这里描述这个方法的使用方法 – 可选).<br/>
* TODO(这里描述这个方法的使用方法 – 可选).<br/>
* TODO(这里描述这个方法的注意事项 – 可选).<br/>
* TODO(这里描述这个方法的注意事项 – 可选).<br/>
*
*
* @author dingwei
* @return
* @return
* @author dingwei
* @since JDK 1.6
* @since JDK 1.6
*/
*/
@RequestMapping
(
"/addRolePri"
)
@RequestMapping
(
"/addRolePri"
)
public
void
addRolePri
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
void
addRolePri
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
String
result
=
""
;
String
result
=
""
;
String
roleId
=
request
.
getParameter
(
"roleId"
);
String
roleId
=
request
.
getParameter
(
"roleId"
);
String
urlPrefixs
=
request
.
getParameter
(
"priIds"
);
String
urlPrefixs
=
request
.
getParameter
(
"priIds"
);
boolean
flag
=
roleService
.
editRole
(
Long
.
valueOf
(
roleId
),
""
,
urlPrefixs
,
""
);
boolean
flag
=
roleService
.
editRole
(
Long
.
valueOf
(
roleId
),
""
,
urlPrefixs
,
""
);
if
(
flag
)
{
if
(
flag
)
{
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存成功!\" }"
;
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存成功!\" }"
;
}
else
{
}
else
{
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存失败!\" }"
;
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存失败!\" }"
;
}
}
try
{
try
{
response
.
setContentType
(
"text/html"
);
response
.
setContentType
(
"text/html"
);
...
@@ -84,13 +84,13 @@ public class RoleController extends BaseController{
...
@@ -84,13 +84,13 @@ public class RoleController extends BaseController{
}
}
@RequestMapping
(
"/editRole/{id}"
)
@RequestMapping
(
"/editRole/{id}"
)
public
void
editRole
(
@PathVariable
long
id
,
String
roleName
,
String
urlPerfixs
,
String
description
,
HttpServletResponse
response
)
{
public
void
editRole
(
@PathVariable
long
id
,
String
roleName
,
String
urlPerfixs
,
String
description
,
HttpServletResponse
response
)
{
String
result
=
""
;
String
result
=
""
;
boolean
flag
=
roleService
.
editRole
(
id
,
roleName
,
urlPerfixs
,
description
);
boolean
flag
=
roleService
.
editRole
(
id
,
roleName
,
urlPerfixs
,
description
);
if
(
flag
)
{
if
(
flag
)
{
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存成功!\" }"
;
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存成功!\" }"
;
}
else
{
}
else
{
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存失败!\" }"
;
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存失败!\" }"
;
}
}
try
{
try
{
response
.
setContentType
(
"text/html"
);
response
.
setContentType
(
"text/html"
);
...
@@ -102,9 +102,9 @@ public class RoleController extends BaseController{
...
@@ -102,9 +102,9 @@ public class RoleController extends BaseController{
@RequestMapping
(
"/userRoles/{id}"
)
@RequestMapping
(
"/userRoles/{id}"
)
@ResponseBody
@ResponseBody
public
Object
userRoles
(
@PathVariable
long
id
){
public
Object
userRoles
(
@PathVariable
long
id
)
{
User
user
=
userService
.
getUser
(
id
);
User
user
=
userService
.
getUser
(
id
);
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
return
userService
.
getUserRoles
(
user
);
return
userService
.
getUserRoles
(
user
);
}
}
return
"false"
;
return
"false"
;
...
@@ -112,12 +112,12 @@ public class RoleController extends BaseController{
...
@@ -112,12 +112,12 @@ public class RoleController extends BaseController{
@RequestMapping
(
"/delRoles"
)
@RequestMapping
(
"/delRoles"
)
@ResponseBody
@ResponseBody
public
Object
delRoles
(
HttpServletRequest
request
){
public
Object
delRoles
(
HttpServletRequest
request
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
String
jsonIds
=
request
.
getParameter
(
"ids"
);
String
jsonIds
=
request
.
getParameter
(
"ids"
);
JSONArray
jsonArray
=
JSONArray
.
fromObject
(
jsonIds
);
JSONArray
jsonArray
=
JSONArray
.
fromObject
(
jsonIds
);
Object
[]
ids
=
jsonArray
.
toArray
();
Object
[]
ids
=
jsonArray
.
toArray
();
for
(
Object
str
:
ids
)
{
for
(
Object
str
:
ids
)
{
boolean
flag
=
roleService
.
deleteRole
((
Integer
)
str
);
boolean
flag
=
roleService
.
deleteRole
((
Integer
)
str
);
}
}
map
.
put
(
"flag"
,
true
);
map
.
put
(
"flag"
,
true
);
...
@@ -127,7 +127,7 @@ public class RoleController extends BaseController{
...
@@ -127,7 +127,7 @@ public class RoleController extends BaseController{
@RequestMapping
(
"/saveUserRoles/{id}"
)
@RequestMapping
(
"/saveUserRoles/{id}"
)
@ResponseBody
@ResponseBody
public
Object
saveUserRoles
(
@PathVariable
long
id
,
HttpServletRequest
request
,
String
[]
ids
)
{
public
Object
saveUserRoles
(
@PathVariable
long
id
,
HttpServletRequest
request
,
String
[]
ids
)
{
System
.
out
.
println
(
ids
);
System
.
out
.
println
(
ids
);
User
user
=
userService
.
getUser
(
id
);
User
user
=
userService
.
getUser
(
id
);
//todo save
//todo save
...
@@ -135,14 +135,14 @@ public class RoleController extends BaseController{
...
@@ -135,14 +135,14 @@ public class RoleController extends BaseController{
JSONArray
jsonArray
=
JSONArray
.
fromObject
(
ids
);
JSONArray
jsonArray
=
JSONArray
.
fromObject
(
ids
);
Object
[]
arr
=
jsonArray
.
toArray
();
Object
[]
arr
=
jsonArray
.
toArray
();
Long
[]
longs
=
new
Long
[
arr
.
length
];
Long
[]
longs
=
new
Long
[
arr
.
length
];
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
longs
[
i
]
=
Long
.
parseLong
(
arr
[
i
].
toString
());
longs
[
i
]
=
Long
.
parseLong
(
arr
[
i
].
toString
());
}
}
boolean
flag
=
userService
.
saveUserRoles
(
user
,
longs
);
boolean
flag
=
userService
.
saveUserRoles
(
user
,
longs
);
if
(
flag
){
if
(
flag
)
{
map
.
put
(
"flag"
,
true
);
map
.
put
(
"flag"
,
true
);
map
.
put
(
"info"
,
"数据删除成功!"
);
map
.
put
(
"info"
,
"数据删除成功!"
);
}
else
{
}
else
{
map
.
put
(
"flag"
,
false
);
map
.
put
(
"flag"
,
false
);
map
.
put
(
"info"
,
"保存失败!"
);
map
.
put
(
"info"
,
"保存失败!"
);
}
}
...
@@ -152,15 +152,15 @@ public class RoleController extends BaseController{
...
@@ -152,15 +152,15 @@ public class RoleController extends BaseController{
@RequestMapping
(
"/getAllRoles"
)
@RequestMapping
(
"/getAllRoles"
)
@ResponseBody
@ResponseBody
public
Object
getAllRoles
(
HttpServletRequest
request
){
public
Object
getAllRoles
(
HttpServletRequest
request
)
{
PageRequest
pageRequest
=
getPage
(
request
);
PageRequest
pageRequest
=
getPage
(
request
);
String
roleName
=
request
.
getParameter
(
"roleName"
);
String
roleName
=
request
.
getParameter
(
"roleName"
);
StringBuffer
hql
=
new
StringBuffer
(
"from Role where 1=1"
);
StringBuffer
hql
=
new
StringBuffer
(
"from Role where 1=1"
);
if
(
null
==
roleName
)
{
if
(
null
==
roleName
)
{
}
else
{
}
else
{
if
(
null
!=
roleName
)
{
if
(
null
!=
roleName
)
{
hql
.
append
(
" and roleName like '%"
+
roleName
+
"%'"
);
hql
.
append
(
" and roleName like '%"
+
roleName
+
"%'"
);
}
}
}
}
List
<
Role
>
pageRole
=
roleService
.
getAll
(
hql
.
toString
());
List
<
Role
>
pageRole
=
roleService
.
getAll
(
hql
.
toString
());
...
@@ -169,10 +169,10 @@ public class RoleController extends BaseController{
...
@@ -169,10 +169,10 @@ public class RoleController extends BaseController{
@RequestMapping
(
"/getRoleByID"
)
@RequestMapping
(
"/getRoleByID"
)
@ResponseBody
@ResponseBody
public
Role
getRoleByID
(
HttpServletRequest
request
)
{
public
Role
getRoleByID
(
HttpServletRequest
request
)
{
String
roleId
=
request
.
getParameter
(
"roleId"
);
String
roleId
=
request
.
getParameter
(
"roleId"
);
Role
role
=
null
;
Role
role
=
null
;
if
(
null
!=
roleId
)
{
if
(
null
!=
roleId
)
{
role
=
roleService
.
get
(
Long
.
valueOf
(
roleId
));
role
=
roleService
.
get
(
Long
.
valueOf
(
roleId
));
}
}
return
role
;
return
role
;
...
@@ -180,11 +180,11 @@ public class RoleController extends BaseController{
...
@@ -180,11 +180,11 @@ public class RoleController extends BaseController{
@RequestMapping
(
"/getRolesList"
)
@RequestMapping
(
"/getRolesList"
)
@ResponseBody
@ResponseBody
public
Object
getRolesList
(
HttpServletRequest
request
)
{
public
Object
getRolesList
(
HttpServletRequest
request
)
{
List
<
Role
>
listBo
=
roleService
.
getAllRoles
();
List
<
Role
>
listBo
=
roleService
.
getAllRoles
();
List
list
=
new
ArrayList
();
List
list
=
new
ArrayList
();
if
(
null
!=
listBo
)
{
if
(
null
!=
listBo
)
{
for
(
int
i
=
0
;
i
<
listBo
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
listBo
.
size
();
i
++)
{
Map
result
=
new
HashMap
();
Map
result
=
new
HashMap
();
result
.
put
(
"id"
,
listBo
.
get
(
i
).
getId
());
result
.
put
(
"id"
,
listBo
.
get
(
i
).
getId
());
result
.
put
(
"text"
,
listBo
.
get
(
i
).
getRoleName
());
result
.
put
(
"text"
,
listBo
.
get
(
i
).
getRoleName
());
...
...
src/main/java/org/ccpit/base/role/RoleDao.java
View file @
9407336e
...
@@ -9,8 +9,8 @@ import org.springframework.stereotype.Repository;
...
@@ -9,8 +9,8 @@ import org.springframework.stereotype.Repository;
*/
*/
@Repository
@Repository
public
class
RoleDao
extends
BaseDao
<
Role
>
{
public
class
RoleDao
extends
BaseDao
<
Role
>
{
public
Role
getRoleByUrl
(
String
url
){
public
Role
getRoleByUrl
(
String
url
)
{
Role
role
=
findUnique
(
"select r from "
+
Role
.
class
.
getName
()+
" as r left join r.urlPerfixs as p where p.url = ?"
,
new
String
[]{
url
});
Role
role
=
findUnique
(
"select r from "
+
Role
.
class
.
getName
()
+
" as r left join r.urlPerfixs as p where p.url = ?"
,
new
String
[]{
url
});
return
role
;
return
role
;
}
}
}
}
src/main/java/org/ccpit/base/role/RoleService.java
View file @
9407336e
...
@@ -5,14 +5,15 @@ import org.ccpit.base.controller.Convert;
...
@@ -5,14 +5,15 @@ import org.ccpit.base.controller.Convert;
import
org.ccpit.base.controller.Page
;
import
org.ccpit.base.controller.Page
;
import
org.ccpit.base.controller.PageBo
;
import
org.ccpit.base.controller.PageBo
;
import
org.ccpit.base.controller.PageRequest
;
import
org.ccpit.base.controller.PageRequest
;
import
org.ccpit.base.user.UserDao
;
import
org.ccpit.base.utils.UrlRolesMapper
;
import
org.ccpit.base.utils.UrlRolesMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
javax.transaction.Transactional
;
import
javax.transaction.Transactional
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* Created by Administrator on 2015/9/6.
* Created by Administrator on 2015/9/6.
...
@@ -25,7 +26,7 @@ public class RoleService {
...
@@ -25,7 +26,7 @@ public class RoleService {
@Autowired
@Autowired
private
UrlRolesMapper
mapper
;
private
UrlRolesMapper
mapper
;
public
boolean
addRole
(
String
roleName
,
String
url
,
String
description
)
{
public
boolean
addRole
(
String
roleName
,
String
url
,
String
description
)
{
Role
role
=
new
Role
();
Role
role
=
new
Role
();
role
.
setRoleName
(
roleName
);
role
.
setRoleName
(
roleName
);
role
.
setDescription
(
description
);
role
.
setDescription
(
description
);
...
@@ -46,14 +47,14 @@ public class RoleService {
...
@@ -46,14 +47,14 @@ public class RoleService {
return
result
;
return
result
;
}
}
public
boolean
editRole
(
long
id
,
String
roleName
,
String
urlPrefixs
,
String
description
)
{
public
boolean
editRole
(
long
id
,
String
roleName
,
String
urlPrefixs
,
String
description
)
{
Role
role
=
roleDao
.
queryById
(
id
);
Role
role
=
roleDao
.
queryById
(
id
);
urlPrefixs
=
getPriId
(
urlPrefixs
);
urlPrefixs
=
getPriId
(
urlPrefixs
);
if
(
role
!=
null
)
{
if
(
role
!=
null
)
{
if
(
null
!=
roleName
&&
!
""
.
equals
(
roleName
))
{
if
(
null
!=
roleName
&&
!
""
.
equals
(
roleName
))
{
role
.
setRoleName
(
roleName
);
role
.
setRoleName
(
roleName
);
}
}
if
(
null
!=
roleName
&&
!
""
.
equals
(
description
))
{
if
(
null
!=
roleName
&&
!
""
.
equals
(
description
))
{
role
.
setDescription
(
description
);
role
.
setDescription
(
description
);
}
}
List
<
RoleUrl
>
urlList
=
new
ArrayList
<
RoleUrl
>();
List
<
RoleUrl
>
urlList
=
new
ArrayList
<
RoleUrl
>();
...
@@ -86,7 +87,7 @@ public class RoleService {
...
@@ -86,7 +87,7 @@ public class RoleService {
return
roleDao
.
findPage
(
pr
,
"from "
+
Role
.
class
.
getName
(),
null
);
return
roleDao
.
findPage
(
pr
,
"from "
+
Role
.
class
.
getName
(),
null
);
}
}
public
Page
<
Role
>
getAll
(
PageRequest
pr
,
String
hql
)
{
public
Page
<
Role
>
getAll
(
PageRequest
pr
,
String
hql
)
{
return
roleDao
.
findPage
(
pr
,
hql
,
null
);
return
roleDao
.
findPage
(
pr
,
hql
,
null
);
}
}
...
@@ -95,27 +96,27 @@ public class RoleService {
...
@@ -95,27 +96,27 @@ public class RoleService {
}
}
public
List
<
Role
>
getAllRoles
(){
public
List
<
Role
>
getAllRoles
()
{
return
roleDao
.
queryAll
();
return
roleDao
.
queryAll
();
}
}
public
Map
<
String
,
Object
>
convertToMap
(
Role
role
)
{
public
Map
<
String
,
Object
>
convertToMap
(
Role
role
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
if
(
role
==
null
)
if
(
role
==
null
)
return
map
;
return
map
;
List
<
String
>
urls
=
new
ArrayList
<
String
>();
List
<
String
>
urls
=
new
ArrayList
<
String
>();
for
(
RoleUrl
roleUrl
:
role
.
getUrlPerfixs
())
{
for
(
RoleUrl
roleUrl
:
role
.
getUrlPerfixs
())
{
urls
.
add
(
roleUrl
.
getUrl
());
urls
.
add
(
roleUrl
.
getUrl
());
}
}
map
.
put
(
"urlPrefixs"
,
StringUtils
.
join
(
urls
,
","
));
map
.
put
(
"urlPrefixs"
,
StringUtils
.
join
(
urls
,
","
));
map
.
put
(
"roleName"
,
role
.
getRoleName
());
map
.
put
(
"roleName"
,
role
.
getRoleName
());
map
.
put
(
"id"
,
role
.
getId
());
map
.
put
(
"id"
,
role
.
getId
());
map
.
put
(
"urlPerfixs"
,
urls
);
map
.
put
(
"urlPerfixs"
,
urls
);
map
.
put
(
"description"
,
role
.
getDescription
());
map
.
put
(
"description"
,
role
.
getDescription
());
return
map
;
return
map
;
}
}
public
PageBo
<
Role
>
convert
(
Page
<
Role
>
page
){
public
PageBo
<
Role
>
convert
(
Page
<
Role
>
page
)
{
return
new
PageBo
<
Role
>(
page
,
new
Convert
<
Role
>()
{
return
new
PageBo
<
Role
>(
page
,
new
Convert
<
Role
>()
{
@Override
@Override
public
Map
<
String
,
Object
>
convert
(
Role
obj
)
{
public
Map
<
String
,
Object
>
convert
(
Role
obj
)
{
...
@@ -126,31 +127,32 @@ public class RoleService {
...
@@ -126,31 +127,32 @@ public class RoleService {
/**
/**
* 根据url查找role
* 根据url查找role
*
* @param url
* @param url
* @return
* @return
*/
*/
public
Role
findRoleByUrl
(
String
url
){
public
Role
findRoleByUrl
(
String
url
)
{
return
roleDao
.
getRoleByUrl
(
url
);
return
roleDao
.
getRoleByUrl
(
url
);
}
}
//去掉重复priId
//去掉重复priId
private
String
getPriId
(
String
priIds
)
{
private
String
getPriId
(
String
priIds
)
{
List
list
=
new
ArrayList
();
List
list
=
new
ArrayList
();
String
[]
str
=
priIds
.
split
(
","
);
String
[]
str
=
priIds
.
split
(
","
);
if
(
null
!=
str
&&
!
""
.
equals
(
str
))
{
if
(
null
!=
str
&&
!
""
.
equals
(
str
))
{
for
(
int
i
=
0
;
i
<
str
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
str
.
length
;
i
++)
{
if
(!
list
.
contains
(
str
[
i
]))
{
if
(!
list
.
contains
(
str
[
i
]))
{
list
.
add
(
str
[
i
]);
list
.
add
(
str
[
i
]);
}
}
}
}
}
}
String
priId
=
""
;
String
priId
=
""
;
if
(
null
!=
list
&&
list
.
size
()>
0
)
{
if
(
null
!=
list
&&
list
.
size
()
>
0
)
{
for
(
int
j
=
0
;
j
<
list
.
size
();
j
++)
{
for
(
int
j
=
0
;
j
<
list
.
size
();
j
++)
{
String
id
=
(
String
)
list
.
get
(
j
);
String
id
=
(
String
)
list
.
get
(
j
);
priId
+=
id
+
","
;
priId
+=
id
+
","
;
}
}
}
}
return
priId
.
substring
(
0
,
priId
.
length
()-
1
);
return
priId
.
substring
(
0
,
priId
.
length
()
-
1
);
}
}
}
}
src/main/java/org/ccpit/base/role/RoleUrl.java
View file @
9407336e
package
org
.
ccpit
.
base
.
role
;
package
org
.
ccpit
.
base
.
role
;
import
org.ccpit.base.modol.BaseEntity
;
import
org.ccpit.base.modol.BaseEntity
;
import
org.hibernate.annotations.
*
;
import
org.hibernate.annotations.
CacheConcurrencyStrategy
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
javax.persistence.Entity
;
/**
/**
* 角色 地址 映射表
* 角色 地址 映射表
...
...
src/main/java/org/ccpit/base/security/CmsTagSupport.java
View file @
9407336e
...
@@ -2,12 +2,9 @@ package org.ccpit.base.security;
...
@@ -2,12 +2,9 @@ package org.ccpit.base.security;
import
org.ccpit.base.controller.BaseController
;
import
org.ccpit.base.controller.BaseController
;
import
org.ccpit.base.user.User
;
import
org.ccpit.base.user.User
;
import
org.ccpit.base.user.UserService
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.BeansException
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.web.context.WebApplicationContext
;
import
org.springframework.web.context.support.WebApplicationContextUtils
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.jsp.JspException
;
import
javax.servlet.jsp.JspException
;
...
@@ -16,14 +13,14 @@ import javax.servlet.jsp.tagext.TagSupport;
...
@@ -16,14 +13,14 @@ import javax.servlet.jsp.tagext.TagSupport;
/**
/**
* Created by Administrator on 2015/9/8.
* Created by Administrator on 2015/9/8.
*/
*/
public
class
CmsTagSupport
extends
TagSupport
implements
ApplicationContextAware
{
public
class
CmsTagSupport
extends
TagSupport
implements
ApplicationContextAware
{
static
String
SPLIT
=
","
;
static
String
SPLIT
=
","
;
static
ApplicationContext
ac
;
static
ApplicationContext
ac
;
public
User
getUser
(){
public
User
getUser
()
{
HttpServletRequest
req
=
(
HttpServletRequest
)
pageContext
.
getRequest
();
HttpServletRequest
req
=
(
HttpServletRequest
)
pageContext
.
getRequest
();
Object
obj
=
req
.
getSession
().
getAttribute
(
BaseController
.
USER_IN_SESSION
);
Object
obj
=
req
.
getSession
().
getAttribute
(
BaseController
.
USER_IN_SESSION
);
if
(
obj
==
null
)
if
(
obj
==
null
)
return
null
;
return
null
;
return
(
User
)
obj
;
return
(
User
)
obj
;
// UserService userService = ac.getBean(UserService.class);
// UserService userService = ac.getBean(UserService.class);
...
@@ -33,21 +30,24 @@ public class CmsTagSupport extends TagSupport implements ApplicationContextAware
...
@@ -33,21 +30,24 @@ public class CmsTagSupport extends TagSupport implements ApplicationContextAware
@Override
@Override
public
int
doStartTag
()
throws
JspException
{
public
int
doStartTag
()
throws
JspException
{
if
(
getUser
()
==
null
)
if
(
getUser
()
==
null
)
return
SKIP_BODY
;
return
SKIP_BODY
;
return
validate
()
?
EVAL_PAGE:
SKIP_BODY
;
return
validate
()
?
EVAL_PAGE
:
SKIP_BODY
;
}
}
/**
/**
* validate the security return the result
* validate the security return the result
*
* @return
* @return
*/
*/
public
boolean
validate
(){
public
boolean
validate
()
{
return
false
;
return
false
;
};
}
;
@Override
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
ac
=
applicationContext
;
ac
=
applicationContext
;
}
}
}
}
src/main/java/org/ccpit/base/security/LoginFilter.java
View file @
9407336e
...
@@ -3,15 +3,10 @@ package org.ccpit.base.security;
...
@@ -3,15 +3,10 @@ package org.ccpit.base.security;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.ccpit.base.controller.BaseController
;
import
org.ccpit.base.controller.BaseController
;
import
org.springframework.beans.BeansException
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
javax.servlet.*
;
import
javax.servlet.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.jsp.jstl.sql.Result
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -19,7 +14,7 @@ import java.util.List;
...
@@ -19,7 +14,7 @@ import java.util.List;
/**
/**
* 用户登录Filter 拦截后台所有请求
* 用户登录Filter 拦截后台所有请求
*
*
<p>
* Created by sqp on 2015/9/30.
* Created by sqp on 2015/9/30.
*/
*/
public
class
LoginFilter
implements
Filter
{
public
class
LoginFilter
implements
Filter
{
...
@@ -27,6 +22,7 @@ public class LoginFilter implements Filter {
...
@@ -27,6 +22,7 @@ public class LoginFilter implements Filter {
private
List
<
String
>
exceptPaths
=
new
ArrayList
<
String
>();
private
List
<
String
>
exceptPaths
=
new
ArrayList
<
String
>();
//拦截之后重定向的url
//拦截之后重定向的url
private
String
redirectPath
=
""
;
private
String
redirectPath
=
""
;
@Override
@Override
public
void
init
(
FilterConfig
filterConfig
)
throws
ServletException
{
public
void
init
(
FilterConfig
filterConfig
)
throws
ServletException
{
...
@@ -43,16 +39,16 @@ public class LoginFilter implements Filter {
...
@@ -43,16 +39,16 @@ public class LoginFilter implements Filter {
HttpServletRequest
request
=
(
HttpServletRequest
)
servletRequest
;
HttpServletRequest
request
=
(
HttpServletRequest
)
servletRequest
;
HttpServletResponse
response
=
(
HttpServletResponse
)
servletResponse
;
HttpServletResponse
response
=
(
HttpServletResponse
)
servletResponse
;
if
(
exceptPaths
.
contains
(
request
.
getRequestURI
())){
if
(
exceptPaths
.
contains
(
request
.
getRequestURI
()))
{
filterChain
.
doFilter
(
request
,
servletResponse
);
filterChain
.
doFilter
(
request
,
servletResponse
);
return
;
return
;
}
}
if
(
request
.
getSession
().
getAttribute
(
BaseController
.
USER_IN_SESSION
)
==
null
&&
request
.
getSession
().
getAttribute
(
"registerInfo"
)==
null
)
{
if
(
request
.
getSession
().
getAttribute
(
BaseController
.
USER_IN_SESSION
)
==
null
&&
request
.
getSession
().
getAttribute
(
"registerInfo"
)
==
null
)
{
response
.
sendRedirect
(
redirectPath
);
response
.
sendRedirect
(
redirectPath
);
return
;
return
;
}
}
filterChain
.
doFilter
(
request
,
servletResponse
);
filterChain
.
doFilter
(
request
,
servletResponse
);
}
}
@Override
@Override
...
...
src/main/java/org/ccpit/base/security/SecurityAllRoleTag.java
View file @
9407336e
package
org
.
ccpit
.
base
.
security
;
package
org
.
ccpit
.
base
.
security
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.ccpit.base.role.Role
;
import
org.ccpit.base.role.Role
;
import
org.ccpit.base.user.UserService
;
import
org.ccpit.base.user.UserService
;
import
javax.servlet.jsp.JspException
;
import
javax.servlet.jsp.tagext.TagSupport
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -19,21 +16,21 @@ public class SecurityAllRoleTag extends CmsTagSupport {
...
@@ -19,21 +16,21 @@ public class SecurityAllRoleTag extends CmsTagSupport {
@Override
@Override
public
boolean
validate
()
{
public
boolean
validate
()
{
if
(
roles
==
null
||
roles
.
isEmpty
())
if
(
roles
==
null
||
roles
.
isEmpty
())
return
true
;
return
true
;
String
[]
roles
=
getRoles
().
split
(
SPLIT
);
String
[]
roles
=
getRoles
().
split
(
SPLIT
);
List
<
Role
>
tagRoles
=
new
ArrayList
<
Role
>();
List
<
Role
>
tagRoles
=
new
ArrayList
<
Role
>();
for
(
String
roleId
:
roles
)
{
for
(
String
roleId
:
roles
)
{
Role
r
=
new
Role
();
Role
r
=
new
Role
();
if
(
StringUtils
.
isNumeric
(
roleId
))
if
(
StringUtils
.
isNumeric
(
roleId
))
r
.
setId
(
Long
.
parseLong
(
roleId
));
r
.
setId
(
Long
.
parseLong
(
roleId
));
tagRoles
.
add
(
r
);
tagRoles
.
add
(
r
);
}
}
Set
<
Role
>
userRoles
=
ac
.
getBean
(
UserService
.
class
).
getUserRolesIncludeGroup
(
getUser
());
Set
<
Role
>
userRoles
=
ac
.
getBean
(
UserService
.
class
).
getUserRolesIncludeGroup
(
getUser
());
boolean
can
=
true
;
boolean
can
=
true
;
for
(
Role
r
:
tagRoles
)
{
for
(
Role
r
:
tagRoles
)
{
if
(!
userRoles
.
contains
(
r
)){
if
(!
userRoles
.
contains
(
r
))
{
can
=
false
;
can
=
false
;
break
;
break
;
}
}
...
...
src/main/java/org/ccpit/base/security/SecurityAnyRoleTag.java
View file @
9407336e
...
@@ -20,19 +20,19 @@ public class SecurityAnyRoleTag extends CmsTagSupport {
...
@@ -20,19 +20,19 @@ public class SecurityAnyRoleTag extends CmsTagSupport {
@Override
@Override
public
boolean
validate
()
{
public
boolean
validate
()
{
if
(
roles
==
null
||
roles
.
isEmpty
())
if
(
roles
==
null
||
roles
.
isEmpty
())
return
true
;
return
true
;
String
[]
roles
=
getRoles
().
split
(
SPLIT
);
String
[]
roles
=
getRoles
().
split
(
SPLIT
);
List
<
Role
>
tagRoles
=
new
ArrayList
<
Role
>();
List
<
Role
>
tagRoles
=
new
ArrayList
<
Role
>();
for
(
String
roleId
:
roles
)
{
for
(
String
roleId
:
roles
)
{
Role
r
=
new
Role
();
Role
r
=
new
Role
();
if
(
StringUtils
.
isNumeric
(
roleId
))
if
(
StringUtils
.
isNumeric
(
roleId
))
r
.
setId
(
Long
.
parseLong
(
roleId
));
r
.
setId
(
Long
.
parseLong
(
roleId
));
tagRoles
.
add
(
r
);
tagRoles
.
add
(
r
);
}
}
Set
<
Role
>
userRoles
=
ac
.
getBean
(
UserService
.
class
).
getUserRolesIncludeGroup
(
getUser
());
Set
<
Role
>
userRoles
=
ac
.
getBean
(
UserService
.
class
).
getUserRolesIncludeGroup
(
getUser
());
return
CollectionUtils
.
containsAny
(
tagRoles
,
userRoles
);
return
CollectionUtils
.
containsAny
(
tagRoles
,
userRoles
);
}
}
public
String
getRoles
()
{
public
String
getRoles
()
{
...
...
src/main/java/org/ccpit/base/security/SecurityUriTag.java
View file @
9407336e
package
org
.
ccpit
.
base
.
security
;
package
org
.
ccpit
.
base
.
security
;
import
java.util.Set
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.ccpit.base.role.Role
;
import
org.ccpit.base.role.Role
;
import
org.ccpit.base.utils.UrlRolesMapper
;
import
org.ccpit.base.utils.UrlRolesMapper
;
import
org.ccpit.base.utils.UserRolesUtil
;
import
org.ccpit.base.utils.UserRolesUtil
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Set
;
/**
/**
* 自定义标签 判断用户权限
* 自定义标签 判断用户权限
* Created by Administrator on 2015/9/7.
* Created by Administrator on 2015/9/7.
*/
*/
@Component
@Component
public
class
SecurityUriTag
extends
CmsTagSupport
{
public
class
SecurityUriTag
extends
CmsTagSupport
{
/** Uri to check */
/**
* Uri to check
*/
private
String
uri
;
private
String
uri
;
@Override
@Override
public
boolean
validate
()
{
public
boolean
validate
()
{
Set
<
Role
>
roles
=
ac
.
getBean
(
UrlRolesMapper
.
class
).
getRoles
(
getUri
());
Set
<
Role
>
roles
=
ac
.
getBean
(
UrlRolesMapper
.
class
).
getRoles
(
getUri
());
if
(
roles
==
null
||
roles
.
isEmpty
())
{
if
(
roles
==
null
||
roles
.
isEmpty
())
{
return
false
;
return
false
;
}
}
UserRolesUtil
userRolesUtil
=
ac
.
getBean
(
UserRolesUtil
.
class
);
UserRolesUtil
userRolesUtil
=
ac
.
getBean
(
UserRolesUtil
.
class
);
Set
<
Role
>
roleSet
=
userRolesUtil
.
getAllRoles
((
HttpServletRequest
)
pageContext
.
getRequest
());
Set
<
Role
>
roleSet
=
userRolesUtil
.
getAllRoles
((
HttpServletRequest
)
pageContext
.
getRequest
());
if
(
roleSet
.
isEmpty
()){
if
(
roleSet
.
isEmpty
())
{
return
false
;
return
false
;
}
}
return
CollectionUtils
.
containsAny
(
roles
,
roleSet
);
return
CollectionUtils
.
containsAny
(
roles
,
roleSet
);
}
}
public
String
getUri
()
{
public
String
getUri
()
{
...
...
src/main/java/org/ccpit/base/user/IUser.java
View file @
9407336e
...
@@ -5,6 +5,8 @@ package org.ccpit.base.user;
...
@@ -5,6 +5,8 @@ package org.ccpit.base.user;
*/
*/
public
interface
IUser
{
public
interface
IUser
{
public
String
getUsername
();
public
String
getUsername
();
public
String
getLoginName
();
public
String
getLoginName
();
public
long
getId
();
public
long
getId
();
}
}
src/main/java/org/ccpit/base/user/User.java
View file @
9407336e
package
org
.
ccpit
.
base
.
user
;
package
org
.
ccpit
.
base
.
user
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.Set
;
import
javax.persistence.*
;
import
org.ccpit.base.modol.BaseEntity
;
import
org.ccpit.base.modol.BaseEntity
;
import
org.ccpit.base.role.Role
;
import
org.ccpit.base.role.Role
;
import
org.hibernate.annotations.Cache
;
import
org.hibernate.annotations.Cache
;
import
org.hibernate.annotations.CacheConcurrencyStrategy
;
import
org.hibernate.annotations.CacheConcurrencyStrategy
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.Set
;
/**
/**
* Created by Administrator on 2015/9/2.
* Created by Administrator on 2015/9/2.
*/
*/
@Entity
@Entity
@Cache
(
usage
=
CacheConcurrencyStrategy
.
READ_WRITE
)
@Cache
(
usage
=
CacheConcurrencyStrategy
.
READ_WRITE
)
public
class
User
extends
BaseEntity
implements
IUser
,
Serializable
{
public
class
User
extends
BaseEntity
implements
IUser
,
Serializable
{
/**
/**
* serialVersionUID:TODO(用一句话描述这个变量表示什么).
* serialVersionUID:TODO(用一句话描述这个变量表示什么).
*
* @since JDK 1.6
* @since JDK 1.6
*/
*/
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
@@ -89,6 +89,7 @@ public class User extends BaseEntity implements IUser,Serializable{
...
@@ -89,6 +89,7 @@ public class User extends BaseEntity implements IUser,Serializable{
public
long
getId
()
{
public
long
getId
()
{
return
super
.
getId
();
return
super
.
getId
();
}
}
@Override
@Override
public
String
getUsername
()
{
public
String
getUsername
()
{
return
username
;
return
username
;
...
@@ -117,26 +118,27 @@ public class User extends BaseEntity implements IUser,Serializable{
...
@@ -117,26 +118,27 @@ public class User extends BaseEntity implements IUser,Serializable{
@Override
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
return
(
"user"
+
getId
()).
hashCode
();
return
(
"user"
+
getId
()).
hashCode
();
}
}
@Override
@Override
public
boolean
equals
(
Object
o
)
{
public
boolean
equals
(
Object
o
)
{
if
(
o
==
null
)
{
if
(
o
==
null
)
{
return
false
;
return
false
;
}
}
if
(
o
==
this
)
{
if
(
o
==
this
)
{
return
true
;
return
true
;
}
}
if
(
o
.
getClass
()
==
User
.
class
)
{
if
(
o
.
getClass
()
==
User
.
class
)
{
return
o
.
hashCode
()
==
this
.
hashCode
();
return
o
.
hashCode
()
==
this
.
hashCode
();
}
}
return
false
;
return
false
;
}
}
@ManyToMany
(
fetch
=
FetchType
.
EAGER
,
cascade
=
CascadeType
.
ALL
)
@ManyToMany
(
fetch
=
FetchType
.
EAGER
,
cascade
=
CascadeType
.
ALL
)
@JoinTable
(
name
=
"user_Roles"
,
@JoinTable
(
name
=
"user_Roles"
,
joinColumns
=
{
@JoinColumn
(
name
=
"user_id"
,
referencedColumnName
=
"id"
)},
joinColumns
=
{
@JoinColumn
(
name
=
"user_id"
,
referencedColumnName
=
"id"
)},
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"role_id"
,
referencedColumnName
=
"id"
)})
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"role_id"
,
referencedColumnName
=
"id"
)})
public
Set
<
Role
>
getRoles
()
{
public
Set
<
Role
>
getRoles
()
{
return
roles
;
return
roles
;
}
}
...
@@ -144,69 +146,91 @@ public class User extends BaseEntity implements IUser,Serializable{
...
@@ -144,69 +146,91 @@ public class User extends BaseEntity implements IUser,Serializable{
public
void
setRoles
(
Set
<
Role
>
roles
)
{
public
void
setRoles
(
Set
<
Role
>
roles
)
{
this
.
roles
=
roles
;
this
.
roles
=
roles
;
}
}
public
String
getUserType
()
{
public
String
getUserType
()
{
return
userType
;
return
userType
;
}
}
public
void
setUserType
(
String
userType
)
{
public
void
setUserType
(
String
userType
)
{
this
.
userType
=
userType
;
this
.
userType
=
userType
;
}
}
public
Integer
getAge
()
{
public
Integer
getAge
()
{
return
age
;
return
age
;
}
}
public
void
setAge
(
Integer
age
)
{
public
void
setAge
(
Integer
age
)
{
this
.
age
=
age
;
this
.
age
=
age
;
}
}
public
String
getSex
()
{
public
String
getSex
()
{
return
sex
;
return
sex
;
}
}
public
void
setSex
(
String
sex
)
{
public
void
setSex
(
String
sex
)
{
this
.
sex
=
sex
;
this
.
sex
=
sex
;
}
}
public
String
getCompany
()
{
public
String
getCompany
()
{
return
company
;
return
company
;
}
}
public
void
setCompany
(
String
company
)
{
public
void
setCompany
(
String
company
)
{
this
.
company
=
company
;
this
.
company
=
company
;
}
}
public
String
getEmail
()
{
public
String
getEmail
()
{
return
email
;
return
email
;
}
}
public
void
setEmail
(
String
email
)
{
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
this
.
email
=
email
;
}
}
public
Integer
getCountStatus
()
{
public
Integer
getCountStatus
()
{
return
countStatus
;
return
countStatus
;
}
}
public
void
setCountStatus
(
Integer
countStatus
)
{
public
void
setCountStatus
(
Integer
countStatus
)
{
this
.
countStatus
=
countStatus
;
this
.
countStatus
=
countStatus
;
}
}
public
String
getTelphone
()
{
public
String
getTelphone
()
{
return
telphone
;
return
telphone
;
}
}
public
void
setTelphone
(
String
telphone
)
{
public
void
setTelphone
(
String
telphone
)
{
this
.
telphone
=
telphone
;
this
.
telphone
=
telphone
;
}
}
public
String
getCreator
()
{
public
String
getCreator
()
{
return
creator
;
return
creator
;
}
}
public
void
setCreator
(
String
creator
)
{
public
void
setCreator
(
String
creator
)
{
this
.
creator
=
creator
;
this
.
creator
=
creator
;
}
}
public
long
getCreatorId
()
{
public
long
getCreatorId
()
{
return
creatorId
;
return
creatorId
;
}
}
public
void
setCreatorId
(
long
creatorId
)
{
public
void
setCreatorId
(
long
creatorId
)
{
this
.
creatorId
=
creatorId
;
this
.
creatorId
=
creatorId
;
}
}
public
Date
getCreateTime
()
{
public
Date
getCreateTime
()
{
return
createTime
;
return
createTime
;
}
}
public
void
setCreateTime
(
Date
createTime
)
{
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
this
.
createTime
=
createTime
;
}
}
public
Integer
getLoginCount
()
{
public
Integer
getLoginCount
()
{
return
loginCount
;
return
loginCount
;
}
}
public
void
setLoginCount
(
Integer
loginCount
)
{
public
void
setLoginCount
(
Integer
loginCount
)
{
this
.
loginCount
=
loginCount
;
this
.
loginCount
=
loginCount
;
}
}
...
...
src/main/java/org/ccpit/base/user/UserController.java
View file @
9407336e
package
org
.
ccpit
.
base
.
user
;
package
org
.
ccpit
.
base
.
user
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONArray
;
import
org.ccpit.base.controller.BaseController
;
import
org.ccpit.base.controller.BaseController
;
import
org.ccpit.base.controller.Page
;
import
org.ccpit.base.controller.Page
;
import
org.ccpit.base.controller.PageRequest
;
import
org.ccpit.base.controller.PageRequest
;
...
@@ -22,7 +9,6 @@ import org.ccpit.base.role.RoleDao;
...
@@ -22,7 +9,6 @@ import org.ccpit.base.role.RoleDao;
import
org.ccpit.base.usergroup.UserGroup
;
import
org.ccpit.base.usergroup.UserGroup
;
import
org.ccpit.base.usergroup.UserGroupDao
;
import
org.ccpit.base.usergroup.UserGroupDao
;
import
org.ccpit.base.usergroup.UserGroupService
;
import
org.ccpit.base.usergroup.UserGroupService
;
import
org.ccpit.base.utils.CryptUtil
;
import
org.ccpit.base.utils.PasswordHash
;
import
org.ccpit.base.utils.PasswordHash
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -33,6 +19,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -33,6 +19,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.ModelAndView
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.*
;
/**
/**
* Created by sqp on 2015/9/5.
* Created by sqp on 2015/9/5.
*/
*/
...
@@ -67,7 +58,7 @@ public class UserController extends BaseController {
...
@@ -67,7 +58,7 @@ public class UserController extends BaseController {
}
}
@RequestMapping
(
"/addUser"
)
@RequestMapping
(
"/addUser"
)
public
void
addUser
(
HttpServletRequest
request
,
HttpServletResponse
response
,
User
user
)
{
public
void
addUser
(
HttpServletRequest
request
,
HttpServletResponse
response
,
User
user
)
{
String
result
=
""
;
String
result
=
""
;
User
user_in_session
=
(
User
)
request
.
getSession
().
getAttribute
(
"user_in_session"
);
User
user_in_session
=
(
User
)
request
.
getSession
().
getAttribute
(
"user_in_session"
);
try
{
try
{
...
@@ -79,17 +70,17 @@ public class UserController extends BaseController {
...
@@ -79,17 +70,17 @@ public class UserController extends BaseController {
user
.
setCreatorId
(
user_in_session
.
getId
());
user
.
setCreatorId
(
user_in_session
.
getId
());
user
.
setCreator
(
user_in_session
.
getUsername
());
user
.
setCreator
(
user_in_session
.
getUsername
());
user
.
setCreateTime
(
new
Date
());
user
.
setCreateTime
(
new
Date
());
if
(
null
==
user
.
getUserType
())
{
if
(
null
==
user
.
getUserType
())
{
user
.
setUserType
(
"back"
);
user
.
setUserType
(
"back"
);
}
}
if
(
null
==
user
.
getCountStatus
())
{
if
(
null
==
user
.
getCountStatus
())
{
user
.
setCountStatus
(
1
);
user
.
setCountStatus
(
1
);
}
}
boolean
flag
=
userService
.
addUser
(
user
);
boolean
flag
=
userService
.
addUser
(
user
);
if
(
flag
)
{
if
(
flag
)
{
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存成功!\" }"
;
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存成功!\" }"
;
}
else
{
}
else
{
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存失败!\" }"
;
result
=
"{ \"flag\": "
+
flag
+
", \"info\": \"数据保存失败!\" }"
;
}
}
try
{
try
{
response
.
setContentType
(
"text/html"
);
response
.
setContentType
(
"text/html"
);
...
@@ -105,31 +96,31 @@ public class UserController extends BaseController {
...
@@ -105,31 +96,31 @@ public class UserController extends BaseController {
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
User
user1
=
userService
.
getUser
(
id
);
User
user1
=
userService
.
getUser
(
id
);
boolean
flag
=
false
;
boolean
flag
=
false
;
if
(
null
!=
user
.
getAge
())
{
if
(
null
!=
user
.
getAge
())
{
user1
.
setAge
(
user
.
getAge
());
user1
.
setAge
(
user
.
getAge
());
}
}
if
(
null
!=
user
.
getCountStatus
())
{
if
(
null
!=
user
.
getCountStatus
())
{
user1
.
setCountStatus
(
user
.
getCountStatus
());
user1
.
setCountStatus
(
user
.
getCountStatus
());
}
}
if
(
null
!=
user
.
getCompany
())
{
if
(
null
!=
user
.
getCompany
())
{
user1
.
setCompany
(
user
.
getCompany
());
user1
.
setCompany
(
user
.
getCompany
());
}
}
if
(
null
!=
user
.
getEmail
())
{
if
(
null
!=
user
.
getEmail
())
{
user1
.
setEmail
(
user
.
getEmail
());
user1
.
setEmail
(
user
.
getEmail
());
}
}
if
(
null
!=
user
.
getLoginName
())
{
if
(
null
!=
user
.
getLoginName
())
{
user1
.
setLoginName
(
user
.
getLoginName
());
user1
.
setLoginName
(
user
.
getLoginName
());
}
}
if
(
null
!=
user
.
getSex
())
{
if
(
null
!=
user
.
getSex
())
{
user1
.
setSex
(
user
.
getSex
());
user1
.
setSex
(
user
.
getSex
());
}
}
if
(
null
!=
user
.
getTelphone
())
{
if
(
null
!=
user
.
getTelphone
())
{
user1
.
setTelphone
(
user
.
getTelphone
());
user1
.
setTelphone
(
user
.
getTelphone
());
}
}
if
(
null
!=
user
.
getUsername
())
{
if
(
null
!=
user
.
getUsername
())
{
user1
.
setUsername
(
user
.
getUsername
());
user1
.
setUsername
(
user
.
getUsername
());
}
}
if
(
null
!=
user
.
getUserType
())
{
if
(
null
!=
user
.
getUserType
())
{
user1
.
setUserType
(
user
.
getUserType
());
user1
.
setUserType
(
user
.
getUserType
());
}
}
flag
=
userService
.
updateUser
(
user1
);
flag
=
userService
.
updateUser
(
user1
);
...
@@ -157,13 +148,13 @@ public class UserController extends BaseController {
...
@@ -157,13 +148,13 @@ public class UserController extends BaseController {
JSONArray
jsonArray
=
JSONArray
.
fromObject
(
jsonIds
);
JSONArray
jsonArray
=
JSONArray
.
fromObject
(
jsonIds
);
Object
[]
ids
=
jsonArray
.
toArray
();
Object
[]
ids
=
jsonArray
.
toArray
();
boolean
flag
=
false
;
boolean
flag
=
false
;
for
(
Object
str
:
ids
)
{
for
(
Object
str
:
ids
)
{
flag
=
userService
.
deleteUser
((
Integer
)
str
);
flag
=
userService
.
deleteUser
((
Integer
)
str
);
}
}
if
(
flag
)
{
if
(
flag
)
{
map
.
put
(
"flag"
,
flag
);
map
.
put
(
"flag"
,
flag
);
map
.
put
(
"info"
,
"数据删除成功!"
);
map
.
put
(
"info"
,
"数据删除成功!"
);
}
else
{
}
else
{
map
.
put
(
"info"
,
"数据删除失败!"
);
map
.
put
(
"info"
,
"数据删除失败!"
);
}
}
return
map
;
return
map
;
...
@@ -183,18 +174,18 @@ public class UserController extends BaseController {
...
@@ -183,18 +174,18 @@ public class UserController extends BaseController {
String
userName
=
request
.
getParameter
(
"userName"
);
String
userName
=
request
.
getParameter
(
"userName"
);
String
userType
=
request
.
getParameter
(
"userType"
);
String
userType
=
request
.
getParameter
(
"userType"
);
StringBuffer
hql
=
new
StringBuffer
(
"from User where 1=1"
);
StringBuffer
hql
=
new
StringBuffer
(
"from User where 1=1"
);
if
(
null
==
userName
&&
null
==
userType
)
{
if
(
null
==
userName
&&
null
==
userType
)
{
hql
.
append
(
" order by createTime desc"
);
hql
.
append
(
" order by createTime desc"
);
}
else
{
}
else
{
if
(
null
!=
userName
&&
!
""
.
equals
(
userName
))
{
if
(
null
!=
userName
&&
!
""
.
equals
(
userName
))
{
hql
.
append
(
" and userName like '%"
+
userName
+
"%'"
);
hql
.
append
(
" and userName like '%"
+
userName
+
"%'"
);
}
}
if
(
null
!=
userType
&&
!
""
.
equals
(
userType
))
{
if
(
null
!=
userType
&&
!
""
.
equals
(
userType
))
{
hql
.
append
(
" and userType ='"
+
userType
+
"'"
);
hql
.
append
(
" and userType ='"
+
userType
+
"'"
);
}
}
hql
.
append
(
" order by createTime desc"
);
hql
.
append
(
" order by createTime desc"
);
}
}
Page
<
User
>
users
=
userService
.
queryPage
(
pageRequest
,
hql
.
toString
());
Page
<
User
>
users
=
userService
.
queryPage
(
pageRequest
,
hql
.
toString
());
return
userService
.
convert
(
users
);
return
userService
.
convert
(
users
);
}
}
...
@@ -226,7 +217,7 @@ public class UserController extends BaseController {
...
@@ -226,7 +217,7 @@ public class UserController extends BaseController {
*/
*/
@RequestMapping
(
"/resetPass"
)
@RequestMapping
(
"/resetPass"
)
@ResponseBody
@ResponseBody
public
Object
resetPass
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
Object
resetPass
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
Map
result
=
new
HashMap
();
Map
result
=
new
HashMap
();
String
id
=
request
.
getParameter
(
"userId"
);
String
id
=
request
.
getParameter
(
"userId"
);
User
user
=
userService
.
getUser
(
Long
.
valueOf
(
id
));
User
user
=
userService
.
getUser
(
Long
.
valueOf
(
id
));
...
@@ -236,9 +227,9 @@ public class UserController extends BaseController {
...
@@ -236,9 +227,9 @@ public class UserController extends BaseController {
throw
new
RuntimeException
(
"重置用户密码加密失败...."
,
e
);
throw
new
RuntimeException
(
"重置用户密码加密失败...."
,
e
);
}
}
boolean
b
=
userService
.
updateUser
(
user
);
boolean
b
=
userService
.
updateUser
(
user
);
if
(
b
)
{
if
(
b
)
{
result
.
put
(
"flag"
,
true
);
result
.
put
(
"flag"
,
true
);
}
else
{
}
else
{
result
.
put
(
"flag"
,
false
);
result
.
put
(
"flag"
,
false
);
}
}
return
result
;
return
result
;
...
@@ -249,7 +240,7 @@ public class UserController extends BaseController {
...
@@ -249,7 +240,7 @@ public class UserController extends BaseController {
*/
*/
@RequestMapping
(
"/changePass/{rePass}"
)
@RequestMapping
(
"/changePass/{rePass}"
)
@ResponseBody
@ResponseBody
public
Object
changePass
(
HttpServletRequest
request
,
@PathVariable
String
rePass
)
{
public
Object
changePass
(
HttpServletRequest
request
,
@PathVariable
String
rePass
)
{
Map
result
=
new
HashMap
();
Map
result
=
new
HashMap
();
User
user
=
(
User
)
request
.
getSession
().
getAttribute
(
"user_in_session"
);
User
user
=
(
User
)
request
.
getSession
().
getAttribute
(
"user_in_session"
);
try
{
try
{
...
@@ -258,10 +249,10 @@ public class UserController extends BaseController {
...
@@ -258,10 +249,10 @@ public class UserController extends BaseController {
throw
new
RuntimeException
(
"修改用户密码加密失败...."
,
e
);
throw
new
RuntimeException
(
"修改用户密码加密失败...."
,
e
);
}
}
boolean
b
=
userService
.
updateUser
(
user
);
boolean
b
=
userService
.
updateUser
(
user
);
if
(
b
)
{
if
(
b
)
{
result
.
put
(
"flag"
,
true
);
result
.
put
(
"flag"
,
true
);
result
.
put
(
"info"
,
"密码修改成功!"
);
result
.
put
(
"info"
,
"密码修改成功!"
);
}
else
{
}
else
{
result
.
put
(
"flag"
,
false
);
result
.
put
(
"flag"
,
false
);
}
}
return
result
;
return
result
;
...
@@ -269,11 +260,11 @@ public class UserController extends BaseController {
...
@@ -269,11 +260,11 @@ public class UserController extends BaseController {
@RequestMapping
(
"/getUsersList"
)
@RequestMapping
(
"/getUsersList"
)
@ResponseBody
@ResponseBody
public
Object
getUsersList
(
HttpServletRequest
request
)
{
public
Object
getUsersList
(
HttpServletRequest
request
)
{
List
<
User
>
listBo
=
userService
.
getAllUsers
();
List
<
User
>
listBo
=
userService
.
getAllUsers
();
List
list
=
new
ArrayList
();
List
list
=
new
ArrayList
();
if
(
null
!=
listBo
)
{
if
(
null
!=
listBo
)
{
for
(
int
i
=
0
;
i
<
listBo
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
listBo
.
size
();
i
++)
{
Map
result
=
new
HashMap
();
Map
result
=
new
HashMap
();
result
.
put
(
"id"
,
listBo
.
get
(
i
).
getId
());
result
.
put
(
"id"
,
listBo
.
get
(
i
).
getId
());
result
.
put
(
"text"
,
listBo
.
get
(
i
).
getUsername
());
result
.
put
(
"text"
,
listBo
.
get
(
i
).
getUsername
());
...
...
src/main/java/org/ccpit/base/user/UserDao.java
View file @
9407336e
package
org
.
ccpit
.
base
.
user
;
package
org
.
ccpit
.
base
.
user
;
import
java.util.Set
;
import
org.ccpit.base.dao.BaseDao
;
import
org.ccpit.base.dao.BaseDao
;
import
org.ccpit.base.role.Role
;
import
org.ccpit.base.role.Role
;
import
org.ccpit.base.usergroup.UserGroupDao
;
import
org.ccpit.base.usergroup.UserGroupDao
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
java.util.Set
;
/**
/**
* 用户实体操作类
* 用户实体操作类
* Created by sqp on 2015/9/5.
* Created by sqp on 2015/9/5.
*/
*/
@Repository
@Repository
public
class
UserDao
extends
BaseDao
<
User
>{
public
class
UserDao
extends
BaseDao
<
User
>
{
@Autowired
@Autowired
private
UserGroupDao
userGroupDao
;
private
UserGroupDao
userGroupDao
;
public
User
getUserByLoginName
(
String
loginName
){
public
User
getUserByLoginName
(
String
loginName
)
{
String
hql
=
"from User where loginName = ?"
;
String
hql
=
"from User where loginName = ?"
;
User
user
=
super
.
findUnique
(
hql
,
new
String
[]{
loginName
});
User
user
=
super
.
findUnique
(
hql
,
new
String
[]{
loginName
});
return
user
;
return
user
;
...
@@ -30,20 +30,21 @@ public class UserDao extends BaseDao<User>{
...
@@ -30,20 +30,21 @@ public class UserDao extends BaseDao<User>{
* @param role
* @param role
* @return
* @return
*/
*/
public
boolean
canUserOrInGroup
(
User
user
,
Role
role
)
{
public
boolean
canUserOrInGroup
(
User
user
,
Role
role
)
{
boolean
can
=
canUser
(
user
,
role
);
boolean
can
=
canUser
(
user
,
role
);
if
(!
can
){
if
(!
can
)
{
can
=
userGroupDao
.
canUserInGroup
(
user
,
role
);
can
=
userGroupDao
.
canUserInGroup
(
user
,
role
);
}
}
return
can
;
return
can
;
}
}
/**
/**
* 获取一个用户所拥有的所有角色,包括用户所在的组拥有的角色
* 获取一个用户所拥有的所有角色,包括用户所在的组拥有的角色
*
* @param user
* @param user
* @return
* @return
*/
*/
public
Set
<
Role
>
getUserRolesIncludeGroup
(
User
user
){
public
Set
<
Role
>
getUserRolesIncludeGroup
(
User
user
)
{
Set
<
Role
>
roles
=
user
.
getRoles
();
Set
<
Role
>
roles
=
user
.
getRoles
();
Set
<
Role
>
rolesInGroup
=
userGroupDao
.
getRolesForUser
(
user
);
Set
<
Role
>
rolesInGroup
=
userGroupDao
.
getRolesForUser
(
user
);
roles
.
addAll
(
rolesInGroup
);
roles
.
addAll
(
rolesInGroup
);
...
@@ -52,11 +53,12 @@ public class UserDao extends BaseDao<User>{
...
@@ -52,11 +53,12 @@ public class UserDao extends BaseDao<User>{
/**
/**
* 判断用户是否具有某个角色
* 判断用户是否具有某个角色
*
* @param user
* @param user
* @param role
* @param role
* @return
* @return
*/
*/
public
boolean
canUser
(
User
user
,
Role
role
)
{
public
boolean
canUser
(
User
user
,
Role
role
)
{
return
user
.
getRoles
().
contains
(
role
);
return
user
.
getRoles
().
contains
(
role
);
}
}
...
...
src/main/java/org/ccpit/base/user/UserService.java
View file @
9407336e
package
org
.
ccpit
.
base
.
user
;
package
org
.
ccpit
.
base
.
user
;
import
java.text.SimpleDateFormat
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.transaction.Transactional
;
import
org.ccpit.base.controller.Convert
;
import
org.ccpit.base.controller.Convert
;
import
org.ccpit.base.controller.Page
;
import
org.ccpit.base.controller.Page
;
import
org.ccpit.base.controller.PageBo
;
import
org.ccpit.base.controller.PageBo
;
...
@@ -18,6 +9,10 @@ import org.ccpit.base.role.RoleDao;
...
@@ -18,6 +9,10 @@ import org.ccpit.base.role.RoleDao;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
javax.transaction.Transactional
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
/**
* Created by sqp on 2015/9/5.
* Created by sqp on 2015/9/5.
*/
*/
...
@@ -31,36 +26,37 @@ public class UserService {
...
@@ -31,36 +26,37 @@ public class UserService {
@Autowired
@Autowired
private
RoleDao
roleDao
;
private
RoleDao
roleDao
;
public
List
<
User
>
getAllUsers
(){
public
List
<
User
>
getAllUsers
()
{
return
userDao
.
queryAll
();
return
userDao
.
queryAll
();
}
}
public
User
getUserByLoginName
(
String
loginName
){
public
User
getUserByLoginName
(
String
loginName
)
{
return
userDao
.
getUserByLoginName
(
loginName
);
return
userDao
.
getUserByLoginName
(
loginName
);
}
}
public
boolean
addUser
(
User
user
){
public
boolean
addUser
(
User
user
)
{
return
userDao
.
save
(
user
);
return
userDao
.
save
(
user
);
}
}
public
boolean
updateUser
(
User
user
){
public
boolean
updateUser
(
User
user
)
{
return
userDao
.
update
(
user
);
return
userDao
.
update
(
user
);
}
}
public
boolean
deleteUser
(
long
id
){
public
boolean
deleteUser
(
long
id
)
{
return
userDao
.
deleteById
(
id
);
return
userDao
.
deleteById
(
id
);
}
}
public
Page
<
User
>
queryPage
(
PageRequest
pr
){
public
Page
<
User
>
queryPage
(
PageRequest
pr
)
{
Page
<
User
>
page
=
userDao
.
findPage
(
pr
,
"from "
+
User
.
class
.
getName
(),
new
String
[]{});
Page
<
User
>
page
=
userDao
.
findPage
(
pr
,
"from "
+
User
.
class
.
getName
(),
new
String
[]{});
return
page
;
return
page
;
}
}
public
Page
<
User
>
queryPage
(
PageRequest
pr
,
String
hql
)
{
public
Page
<
User
>
queryPage
(
PageRequest
pr
,
String
hql
)
{
Page
<
User
>
page
=
userDao
.
findPage
(
pr
,
hql
,
new
String
[]{});
Page
<
User
>
page
=
userDao
.
findPage
(
pr
,
hql
,
new
String
[]{});
return
page
;
return
page
;
}
}
public
User
getUser
(
long
id
){
public
User
getUser
(
long
id
)
{
return
userDao
.
queryById
(
id
);
return
userDao
.
queryById
(
id
);
}
}
...
@@ -71,80 +67,84 @@ public class UserService {
...
@@ -71,80 +67,84 @@ public class UserService {
* @param role
* @param role
* @return
* @return
*/
*/
public
boolean
canUserOrInGroup
(
User
user
,
Role
role
)
{
public
boolean
canUserOrInGroup
(
User
user
,
Role
role
)
{
return
userDao
.
canUserOrInGroup
(
user
,
role
);
return
userDao
.
canUserOrInGroup
(
user
,
role
);
}
}
/**
/**
* 获取一个用户的所有角色
* 获取一个用户的所有角色
*
* @param user
* @param user
* @return
* @return
*/
*/
public
Set
<
Role
>
getUserRoles
(
User
user
){
public
Set
<
Role
>
getUserRoles
(
User
user
)
{
User
user1
=
userDao
.
queryById
(
user
.
getId
());
User
user1
=
userDao
.
queryById
(
user
.
getId
());
return
user1
.
getRoles
();
return
user1
.
getRoles
();
}
}
/**
/**
* 获取一个用户所拥有的所有角色,包括用户所在的组拥有的角色
* 获取一个用户所拥有的所有角色,包括用户所在的组拥有的角色
*
* @param user
* @param user
* @return
* @return
*/
*/
public
Set
<
Role
>
getUserRolesIncludeGroup
(
User
user
){
public
Set
<
Role
>
getUserRolesIncludeGroup
(
User
user
)
{
return
userDao
.
getUserRolesIncludeGroup
(
user
);
return
userDao
.
getUserRolesIncludeGroup
(
user
);
}
}
public
boolean
saveUserRoles
(
User
user
,
Long
[]
ids
)
{
public
boolean
saveUserRoles
(
User
user
,
Long
[]
ids
)
{
Set
<
Role
>
roles
=
new
HashSet
<
Role
>();
Set
<
Role
>
roles
=
new
HashSet
<
Role
>();
for
(
long
id
:
ids
)
{
for
(
long
id
:
ids
)
{
roles
.
add
(
roleDao
.
queryById
(
id
));
roles
.
add
(
roleDao
.
queryById
(
id
));
}
}
return
saveUserRoles
(
user
,
roles
);
return
saveUserRoles
(
user
,
roles
);
}
}
public
boolean
saveUserRoles
(
User
user
,
Set
<
Role
>
roleSet
){
public
boolean
saveUserRoles
(
User
user
,
Set
<
Role
>
roleSet
)
{
boolean
success
=
false
;
boolean
success
=
false
;
try
{
try
{
user
.
getRoles
().
clear
();
user
.
getRoles
().
clear
();
boolean
b
=
userDao
.
update
(
user
);
boolean
b
=
userDao
.
update
(
user
);
if
(
b
)
{
if
(
b
)
{
User
user1
=
userDao
.
queryById
(
user
.
getId
());
User
user1
=
userDao
.
queryById
(
user
.
getId
());
user1
.
setRoles
(
roleSet
);
user1
.
setRoles
(
roleSet
);
success
=
userDao
.
save
(
user1
);
success
=
userDao
.
save
(
user1
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
success
=
false
;
success
=
false
;
}
}
return
success
;
return
success
;
}
}
public
Map
<
String
,
Object
>
convertToMap
(
User
User
)
{
public
Map
<
String
,
Object
>
convertToMap
(
User
User
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
if
(
User
==
null
)
{
if
(
User
==
null
)
{
return
map
;
return
map
;
}
}
Set
<
Role
>
roleSet
=
User
.
getRoles
();
Set
<
Role
>
roleSet
=
User
.
getRoles
();
String
roles
=
""
;
String
roles
=
""
;
if
(
null
!=
roleSet
)
{
if
(
null
!=
roleSet
)
{
if
(
roleSet
.
size
()>
0
)
{
if
(
roleSet
.
size
()
>
0
)
{
for
(
Role
role
:
roleSet
)
{
for
(
Role
role
:
roleSet
)
{
roles
+=
role
.
getRoleName
()+
","
;
roles
+=
role
.
getRoleName
()
+
","
;
}
}
roles
=
roles
.
substring
(
0
,
roles
.
length
()-
1
);
roles
=
roles
.
substring
(
0
,
roles
.
length
()
-
1
);
}
}
}
}
map
.
put
(
"id"
,
User
.
getId
());
map
.
put
(
"id"
,
User
.
getId
());
map
.
put
(
"createTime"
,
null
==
User
.
getCreateTime
()?
""
:
sdf
.
format
(
User
.
getCreateTime
()));
map
.
put
(
"createTime"
,
null
==
User
.
getCreateTime
()
?
""
:
sdf
.
format
(
User
.
getCreateTime
()));
map
.
put
(
"creator"
,
User
.
getCreator
());
map
.
put
(
"creator"
,
User
.
getCreator
());
map
.
put
(
"username"
,
User
.
getUsername
());
map
.
put
(
"username"
,
User
.
getUsername
());
map
.
put
(
"loginName"
,
User
.
getLoginName
());
map
.
put
(
"loginName"
,
User
.
getLoginName
());
map
.
put
(
"countStatus"
,
1
==
User
.
getCountStatus
()
?
"有效"
:
"无效"
);
map
.
put
(
"countStatus"
,
1
==
User
.
getCountStatus
()
?
"有效"
:
"无效"
);
map
.
put
(
"loginCount"
,
User
.
getLoginCount
());
map
.
put
(
"loginCount"
,
User
.
getLoginCount
());
map
.
put
(
"company"
,
User
.
getCompany
());
map
.
put
(
"company"
,
User
.
getCompany
());
map
.
put
(
"userType"
,
"back"
.
equals
(
User
.
getUserType
())?
"后台用户"
:
"非后台用户"
);
map
.
put
(
"userType"
,
"back"
.
equals
(
User
.
getUserType
())
?
"后台用户"
:
"非后台用户"
);
map
.
put
(
"roles"
,
roles
);
map
.
put
(
"roles"
,
roles
);
return
map
;
return
map
;
}
}
public
PageBo
<
User
>
convert
(
Page
<
User
>
page
){
public
PageBo
<
User
>
convert
(
Page
<
User
>
page
)
{
return
new
PageBo
<
User
>(
page
,
new
Convert
<
User
>()
{
return
new
PageBo
<
User
>(
page
,
new
Convert
<
User
>()
{
@Override
@Override
public
Map
<
String
,
Object
>
convert
(
User
obj
)
{
public
Map
<
String
,
Object
>
convert
(
User
obj
)
{
...
...
src/main/java/org/ccpit/base/utils/CryptUtil.java
View file @
9407336e
package
org
.
ccpit
.
base
.
utils
;
package
org
.
ccpit
.
base
.
utils
;
import
java.security.MessageDigest
;
import
javax.crypto.Cipher
;
import
javax.crypto.Cipher
;
import
javax.crypto.KeyGenerator
;
import
javax.crypto.KeyGenerator
;
import
javax.crypto.SecretKey
;
import
javax.crypto.SecretKey
;
import
javax.crypto.spec.SecretKeySpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.security.MessageDigest
;
/**
/**
* @Description �����㷨
* @Description �����㷨
* @Version V0.1
* @Version V0.1
...
@@ -13,8 +13,7 @@ import javax.crypto.spec.SecretKeySpec;
...
@@ -13,8 +13,7 @@ import javax.crypto.spec.SecretKeySpec;
* @Date 2015��4��3�� ����3:07:18 JDK�汾��sun jdk 1.6
* @Date 2015��4��3�� ����3:07:18 JDK�汾��sun jdk 1.6
* ���¼�¼****************************** �汾�� <�汾��> �����ڣ� <����> ���ˣ� <��������>
* ���¼�¼****************************** �汾�� <�汾��> �����ڣ� <����> ���ˣ� <��������>
* �����ݣ� <����������>
* �����ݣ� <����������>
**********************************************************************
* *********************************************************************
*
*/
*/
public
class
CryptUtil
{
public
class
CryptUtil
{
...
...
src/main/java/org/ccpit/base/utils/HtmlEscapeUtil.java
View file @
9407336e
...
@@ -6,7 +6,6 @@ package org.ccpit.base.utils;
...
@@ -6,7 +6,6 @@ package org.ccpit.base.utils;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.ccpit.base.modol.EscapeHTML
;
import
org.ccpit.base.modol.EscapeHTML
;
import
org.ccpit.base.modol.EscapeSql
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
...
@@ -65,12 +64,13 @@ public class HtmlEscapeUtil<T> {
...
@@ -65,12 +64,13 @@ public class HtmlEscapeUtil<T> {
/**
/**
* Escape the Sql with the annotation
* Escape the Sql with the annotation
*
* @param t
* @param t
* @return
* @return
*/
*/
public
T
escape
(
T
t
){
public
T
escape
(
T
t
)
{
EscapeHTML
annotation
=
t
.
getClass
().
getAnnotation
(
EscapeHTML
.
class
);
EscapeHTML
annotation
=
t
.
getClass
().
getAnnotation
(
EscapeHTML
.
class
);
if
(
annotation
!=
null
)
{
if
(
annotation
!=
null
)
{
encode
(
t
);
encode
(
t
);
except
(
annotation
.
except
());
except
(
annotation
.
except
());
execute
();
execute
();
...
...
src/main/java/org/ccpit/base/utils/ImgFontByte.java
View file @
9407336e
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/main/java/org/ccpit/base/utils/MailSender.java
View file @
9407336e
package
org
.
ccpit
.
base
.
utils
;
package
org
.
ccpit
.
base
.
utils
;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.apache.log4j.Logger
;
import
org.apache.log4j.Logger
;
import
org.ccpit.base.user.User
;
import
javax.mail.*
;
import
javax.mail.*
;
import
javax.mail.internet.InternetAddress
;
import
javax.mail.internet.InternetAddress
;
...
@@ -26,8 +24,8 @@ public class MailSender {
...
@@ -26,8 +24,8 @@ public class MailSender {
public
static
String
HOST
;
public
static
String
HOST
;
private
static
final
Logger
logger
=
Logger
.
getLogger
(
MailSender
.
class
);
private
static
final
Logger
logger
=
Logger
.
getLogger
(
MailSender
.
class
);
static
{
static
{
Map
<
String
,
String
>
configMap
=
ReadConfigUtil
.
getPlatformConfig
();
Map
<
String
,
String
>
configMap
=
ReadConfigUtil
.
getPlatformConfig
();
USERNAME
=
configMap
.
get
(
"email.name"
);
USERNAME
=
configMap
.
get
(
"email.name"
);
PASSWORD
=
configMap
.
get
(
"email.password"
);
PASSWORD
=
configMap
.
get
(
"email.password"
);
HOST
=
configMap
.
get
(
"email.host"
);
HOST
=
configMap
.
get
(
"email.host"
);
...
@@ -35,18 +33,20 @@ public class MailSender {
...
@@ -35,18 +33,20 @@ public class MailSender {
/**
/**
* 发送邮件
* 发送邮件
*
* @param targetAddress 收件人
* @param targetAddress 收件人
* @param subject 主题
* @param subject 主题
* @param body 内容
* @param body 内容
* @return 发送成功
* @return 发送成功
*/
*/
public
static
boolean
send
(
String
targetAddress
,
String
subject
,
String
body
)
{
public
static
boolean
send
(
String
targetAddress
,
String
subject
,
String
body
)
{
EmailBody
emailBody
=
new
EmailBody
();
EmailBody
emailBody
=
new
EmailBody
();
emailBody
.
setContent
(
body
);
emailBody
.
setContent
(
body
);
emailBody
.
setSubject
(
subject
);
emailBody
.
setSubject
(
subject
);
emailBody
.
setSentDate
(
new
Date
());
emailBody
.
setSentDate
(
new
Date
());
return
send
(
targetAddress
,
emailBody
);
return
send
(
targetAddress
,
emailBody
);
}
}
/**
/**
* 发送邮件
* 发送邮件
*
*
...
@@ -56,7 +56,7 @@ public class MailSender {
...
@@ -56,7 +56,7 @@ public class MailSender {
* @param: @param mimeDTO 邮件部分参数
* @param: @param mimeDTO 邮件部分参数
* @return: boolean
* @return: boolean
*/
*/
public
static
boolean
send
(
String
targetAddress
,
EmailBody
body
){
public
static
boolean
send
(
String
targetAddress
,
EmailBody
body
)
{
Properties
props
=
new
Properties
();
Properties
props
=
new
Properties
();
props
.
put
(
"mail.pop.host"
,
HOST
);
props
.
put
(
"mail.pop.host"
,
HOST
);
props
.
setProperty
(
"mail.pop.auth"
,
"true"
);
props
.
setProperty
(
"mail.pop.auth"
,
"true"
);
...
@@ -64,7 +64,7 @@ public class MailSender {
...
@@ -64,7 +64,7 @@ public class MailSender {
props
.
put
(
"mail.pop.password"
,
PASSWORD
);
props
.
put
(
"mail.pop.password"
,
PASSWORD
);
props
.
put
(
"mail.pop.starttls.enable"
,
"true"
);
props
.
put
(
"mail.pop.starttls.enable"
,
"true"
);
props
.
put
(
"mail.transport.protocol"
,
"POP3"
);
props
.
put
(
"mail.transport.protocol"
,
"POP3"
);
props
.
put
(
"mail.pop.port"
,
465
);
props
.
put
(
"mail.pop.port"
,
465
);
Session
session
=
Session
.
getInstance
(
props
,
new
PopupAuthenticator
(
USERNAME
,
PASSWORD
));
Session
session
=
Session
.
getInstance
(
props
,
new
PopupAuthenticator
(
USERNAME
,
PASSWORD
));
boolean
success
=
false
;
boolean
success
=
false
;
...
@@ -87,7 +87,7 @@ public class MailSender {
...
@@ -87,7 +87,7 @@ public class MailSender {
logger
.
info
(
"成功发送了邮件到"
+
targetAddress
+
" 主题:["
+
body
.
getSubject
()
+
"] 内容["
+
body
.
getContent
()
+
"]"
);
logger
.
info
(
"成功发送了邮件到"
+
targetAddress
+
" 主题:["
+
body
.
getSubject
()
+
"] 内容["
+
body
.
getContent
()
+
"]"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
success
=
false
;
success
=
false
;
logger
.
warn
(
"到"
+
targetAddress
+
"的邮件发送失败,"
+
e
);
logger
.
warn
(
"到"
+
targetAddress
+
"的邮件发送失败,"
+
e
);
// throw new RuntimeException("email send error",e);
// throw new RuntimeException("email send error",e);
}
}
return
success
;
return
success
;
...
...
src/main/java/org/ccpit/base/utils/PasswordHash.java
View file @
9407336e
...
@@ -5,19 +5,17 @@
...
@@ -5,19 +5,17 @@
* Package Name:org.ccpit.base.utils
* Package Name:org.ccpit.base.utils
* Date:2015年10月23日下午2:10:48
* Date:2015年10月23日下午2:10:48
* Copyright (c) 2015, dingwei@ccpit.org All Rights Reserved.
* Copyright (c) 2015, dingwei@ccpit.org All Rights Reserved.
*
*/
*/
package
org
.
ccpit
.
base
.
utils
;
package
org
.
ccpit
.
base
.
utils
;
import
javax.crypto.SecretKeyFactory
;
import
javax.crypto.spec.PBEKeySpec
;
import
java.math.BigInteger
;
import
java.math.BigInteger
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.SecureRandom
;
import
java.security.SecureRandom
;
import
java.security.spec.InvalidKeySpecException
;
import
java.security.spec.InvalidKeySpecException
;
import
javax.crypto.SecretKeyFactory
;
import
javax.crypto.spec.PBEKeySpec
;
/**
/**
* ClassName:PasswordHash <br/>
* ClassName:PasswordHash <br/>
* Function: TODO ADD FUNCTION. <br/>
* Function: TODO ADD FUNCTION. <br/>
...
...
src/main/java/org/ccpit/base/utils/PopupAuthenticator.java
View file @
9407336e
...
@@ -17,6 +17,7 @@ public class PopupAuthenticator extends Authenticator {
...
@@ -17,6 +17,7 @@ public class PopupAuthenticator extends Authenticator {
this
.
username
=
user
;
this
.
username
=
user
;
this
.
password
=
pass
;
this
.
password
=
pass
;
}
}
protected
PasswordAuthentication
getPasswordAuthentication
()
{
protected
PasswordAuthentication
getPasswordAuthentication
()
{
return
new
PasswordAuthentication
(
username
,
password
);
return
new
PasswordAuthentication
(
username
,
password
);
}
}
...
...
src/main/java/org/ccpit/base/utils/ReadConfigUtil.java
View file @
9407336e
package
org
.
ccpit
.
base
.
utils
;
package
org
.
ccpit
.
base
.
utils
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.Properties
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
/**
* @Description TODO【用一句话描述该文件做什么】
* @Description TODO【用一句话描述该文件做什么】
* @Author dingwei
* @Author dingwei
...
@@ -42,7 +42,7 @@ public class ReadConfigUtil {
...
@@ -42,7 +42,7 @@ public class ReadConfigUtil {
}
}
if
(
properties
!=
null
)
if
(
properties
!=
null
)
for
(
Enumeration
en
=
properties
.
propertyNames
();
en
for
(
Enumeration
en
=
properties
.
propertyNames
();
en
.
hasMoreElements
();)
{
.
hasMoreElements
();
)
{
String
key
=
(
String
)
en
.
nextElement
();
String
key
=
(
String
)
en
.
nextElement
();
String
value
=
properties
.
getProperty
(
key
);
String
value
=
properties
.
getProperty
(
key
);
...
...
src/main/java/org/ccpit/base/utils/SqlEscapeUtil.java
View file @
9407336e
...
@@ -8,7 +8,6 @@ import org.apache.commons.lang.StringEscapeUtils;
...
@@ -8,7 +8,6 @@ import org.apache.commons.lang.StringEscapeUtils;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.ccpit.base.modol.EscapeSql
;
import
org.ccpit.base.modol.EscapeSql
;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -103,18 +102,20 @@ public class SqlEscapeUtil<T> {
...
@@ -103,18 +102,20 @@ public class SqlEscapeUtil<T> {
/**
/**
* Escape the Sql with the annotation
* Escape the Sql with the annotation
*
* @param t
* @param t
* @return
* @return
*/
*/
public
T
escape
(
T
t
){
public
T
escape
(
T
t
)
{
EscapeSql
annotation
=
t
.
getClass
().
getAnnotation
(
EscapeSql
.
class
);
EscapeSql
annotation
=
t
.
getClass
().
getAnnotation
(
EscapeSql
.
class
);
if
(
annotation
!=
null
)
{
if
(
annotation
!=
null
)
{
encode
(
t
);
encode
(
t
);
except
(
annotation
.
except
());
except
(
annotation
.
except
());
execute
();
execute
();
}
}
return
t
;
return
t
;
}
}
/**
/**
* 过滤方法
* 过滤方法
*
*
...
...
src/main/java/org/ccpit/base/utils/UserRolesUtil.java
View file @
9407336e
...
@@ -11,7 +11,6 @@ import org.springframework.context.ApplicationContextAware;
...
@@ -11,7 +11,6 @@ import org.springframework.context.ApplicationContextAware;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -68,7 +67,7 @@ public class UserRolesUtil implements ApplicationContextAware {
...
@@ -68,7 +67,7 @@ public class UserRolesUtil implements ApplicationContextAware {
public
Set
<
Role
>
getRoles
(
HttpServletRequest
request
,
String
scope
)
{
public
Set
<
Role
>
getRoles
(
HttpServletRequest
request
,
String
scope
)
{
Set
<
Role
>
roles
=
new
HashSet
<
Role
>();
Set
<
Role
>
roles
=
new
HashSet
<
Role
>();
Object
object
=
request
.
getSession
().
getAttribute
(
scope
);
Object
object
=
request
.
getSession
().
getAttribute
(
scope
);
if
(
object
==
null
)
{
if
(
object
==
null
)
{
initOrReload
(
request
);
initOrReload
(
request
);
object
=
request
.
getSession
().
getAttribute
(
scope
);
object
=
request
.
getSession
().
getAttribute
(
scope
);
}
}
...
...
src/main/java/org/ccpit/base/utils/ValidateCode.java
View file @
9407336e
package
org
.
ccpit
.
base
.
utils
;
package
org
.
ccpit
.
base
.
utils
;
import
java.awt.Color
;
import
java
.awt.Font
;
import
java
x.imageio.ImageIO
;
import
java.awt.
Graphics2D
;
import
java.awt.
*
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.util.Random
;
import
java.util.Random
;
import
javax.imageio.ImageIO
;
/**
/**
* 验证码生成器
* 验证码生成器
* @author dsna
*
*
* @author dsna
*/
*/
public
class
ValidateCode
{
public
class
ValidateCode
{
// 图片的宽度。
// 图片的宽度。
...
@@ -26,51 +25,50 @@ public class ValidateCode {
...
@@ -26,51 +25,50 @@ public class ValidateCode {
// 验证码
// 验证码
private
String
code
=
null
;
private
String
code
=
null
;
// 验证码图片Buffer
// 验证码图片Buffer
private
BufferedImage
buffImg
=
null
;
private
BufferedImage
buffImg
=
null
;
private
char
[]
codeSequence
=
{
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
private
char
[]
codeSequence
=
{
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
'K'
,
'M'
,
'N'
,
'P'
,
'R'
,
'S'
,
'T'
,
'U'
,
'V'
,
'W'
,
'K'
,
'M'
,
'N'
,
'P'
,
'R'
,
'S'
,
'T'
,
'U'
,
'V'
,
'W'
,
'X'
,
'Y'
,
'Z'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
};
'X'
,
'Y'
,
'Z'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
};
public
ValidateCode
()
{
public
ValidateCode
()
{
this
.
createCode
();
this
.
createCode
();
}
}
/**
/**
*
* @param width 图片宽
* @param width 图片宽
* @param height 图片高
* @param height 图片高
*/
*/
public
ValidateCode
(
int
width
,
int
height
)
{
public
ValidateCode
(
int
width
,
int
height
)
{
this
.
width
=
width
;
this
.
width
=
width
;
this
.
height
=
height
;
this
.
height
=
height
;
this
.
createCode
();
this
.
createCode
();
}
}
/**
/**
*
* @param width 图片宽
* @param width 图片宽
* @param height 图片高
* @param height 图片高
* @param codeCount 字符个数
* @param codeCount 字符个数
* @param lineCount 干扰线条数
* @param lineCount 干扰线条数
*/
*/
public
ValidateCode
(
int
width
,
int
height
,
int
codeCount
,
int
lineCount
)
{
public
ValidateCode
(
int
width
,
int
height
,
int
codeCount
,
int
lineCount
)
{
this
.
width
=
width
;
this
.
width
=
width
;
this
.
height
=
height
;
this
.
height
=
height
;
this
.
codeCount
=
codeCount
;
this
.
codeCount
=
codeCount
;
this
.
lineCount
=
lineCount
;
this
.
lineCount
=
lineCount
;
this
.
createCode
();
this
.
createCode
();
}
}
public
void
createCode
()
{
public
void
createCode
()
{
int
x
=
0
,
fontHeight
=
0
,
codeY
=
0
;
int
x
=
0
,
fontHeight
=
0
,
codeY
=
0
;
int
red
=
0
,
green
=
0
,
blue
=
0
;
int
red
=
0
,
green
=
0
,
blue
=
0
;
x
=
width
/
(
codeCount
+
2
);
//每个字符的宽度
x
=
width
/
(
codeCount
+
2
);
//每个字符的宽度
fontHeight
=
height
-
2
;
//字体的高度
fontHeight
=
height
-
2
;
//字体的高度
codeY
=
height
-
4
;
codeY
=
height
-
4
;
// 图像buffer
// 图像buffer
buffImg
=
new
BufferedImage
(
width
,
height
,
BufferedImage
.
TYPE_INT_RGB
);
buffImg
=
new
BufferedImage
(
width
,
height
,
BufferedImage
.
TYPE_INT_RGB
);
Graphics2D
g
=
buffImg
.
createGraphics
();
Graphics2D
g
=
buffImg
.
createGraphics
();
// 生成随机数
// 生成随机数
Random
random
=
new
Random
();
Random
random
=
new
Random
();
...
@@ -78,15 +76,15 @@ public class ValidateCode {
...
@@ -78,15 +76,15 @@ public class ValidateCode {
g
.
setColor
(
Color
.
WHITE
);
g
.
setColor
(
Color
.
WHITE
);
g
.
fillRect
(
0
,
0
,
width
,
height
);
g
.
fillRect
(
0
,
0
,
width
,
height
);
// 创建字体
// 创建字体
ImgFontByte
imgFont
=
new
ImgFontByte
();
ImgFontByte
imgFont
=
new
ImgFontByte
();
Font
font
=
imgFont
.
getFont
(
fontHeight
);
Font
font
=
imgFont
.
getFont
(
fontHeight
);
g
.
setFont
(
font
);
g
.
setFont
(
font
);
for
(
int
i
=
0
;
i
<
lineCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
lineCount
;
i
++)
{
int
xs
=
random
.
nextInt
(
width
);
int
xs
=
random
.
nextInt
(
width
);
int
ys
=
random
.
nextInt
(
height
);
int
ys
=
random
.
nextInt
(
height
);
int
xe
=
xs
+
random
.
nextInt
(
width
/
8
);
int
xe
=
xs
+
random
.
nextInt
(
width
/
8
);
int
ye
=
ys
+
random
.
nextInt
(
height
/
8
);
int
ye
=
ys
+
random
.
nextInt
(
height
/
8
);
red
=
random
.
nextInt
(
255
);
red
=
random
.
nextInt
(
255
);
green
=
random
.
nextInt
(
255
);
green
=
random
.
nextInt
(
255
);
blue
=
random
.
nextInt
(
255
);
blue
=
random
.
nextInt
(
255
);
...
@@ -109,7 +107,7 @@ public class ValidateCode {
...
@@ -109,7 +107,7 @@ public class ValidateCode {
randomCode
.
append
(
strRand
);
randomCode
.
append
(
strRand
);
}
}
// 将四位数字的验证码保存到Session中。
// 将四位数字的验证码保存到Session中。
code
=
randomCode
.
toString
();
code
=
randomCode
.
toString
();
}
}
public
void
write
(
String
path
)
throws
IOException
{
public
void
write
(
String
path
)
throws
IOException
{
...
@@ -121,6 +119,7 @@ public class ValidateCode {
...
@@ -121,6 +119,7 @@ public class ValidateCode {
ImageIO
.
write
(
buffImg
,
"png"
,
sos
);
ImageIO
.
write
(
buffImg
,
"png"
,
sos
);
sos
.
close
();
sos
.
close
();
}
}
public
BufferedImage
getBuffImg
()
{
public
BufferedImage
getBuffImg
()
{
return
buffImg
;
return
buffImg
;
}
}
...
...
src/main/java/org/ccpit/base/utils/mailUtil/Mail.java
View file @
9407336e
...
@@ -5,8 +5,7 @@
...
@@ -5,8 +5,7 @@
* Package Name:org.ccpit.base.utils.mailUtil
* Package Name:org.ccpit.base.utils.mailUtil
* Date:2015年11月19日上午10:50:34
* Date:2015年11月19日上午10:50:34
* Copyright (c) 2015, dingwei@ccpit.org All Rights Reserved.
* Copyright (c) 2015, dingwei@ccpit.org All Rights Reserved.
*
*/
*/
package
org
.
ccpit
.
base
.
utils
.
mailUtil
;
package
org
.
ccpit
.
base
.
utils
.
mailUtil
;
...
@@ -22,7 +21,7 @@ import java.io.Serializable;
...
@@ -22,7 +21,7 @@ import java.io.Serializable;
* @since JDK 1.6
* @since JDK 1.6
* @see
* @see
*/
*/
public
class
Mail
implements
Serializable
{
public
class
Mail
implements
Serializable
{
/**
/**
* serialVersionUID:TODO(用一句话描述这个变量表示什么).
* serialVersionUID:TODO(用一句话描述这个变量表示什么).
...
@@ -77,71 +76,91 @@ public class Mail implements Serializable{
...
@@ -77,71 +76,91 @@ public class Mail implements Serializable{
public
String
getHost
()
{
public
String
getHost
()
{
return
host
;
return
host
;
}
}
public
void
setHost
(
String
host
)
{
public
void
setHost
(
String
host
)
{
this
.
host
=
host
;
this
.
host
=
host
;
}
}
public
String
getSender
()
{
public
String
getSender
()
{
return
sender
;
return
sender
;
}
}
public
void
setSender
(
String
sender
)
{
public
void
setSender
(
String
sender
)
{
this
.
sender
=
sender
;
this
.
sender
=
sender
;
}
}
public
String
getReceiver
()
{
public
String
getReceiver
()
{
return
receiver
;
return
receiver
;
}
}
public
void
setReceiver
(
String
receiver
)
{
public
void
setReceiver
(
String
receiver
)
{
this
.
receiver
=
receiver
;
this
.
receiver
=
receiver
;
}
}
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
this
.
name
=
name
;
}
}
public
String
getEmailCount
()
{
public
String
getEmailCount
()
{
return
emailCount
;
return
emailCount
;
}
}
public
void
setEmailCount
(
String
emailCount
)
{
public
void
setEmailCount
(
String
emailCount
)
{
this
.
emailCount
=
emailCount
;
this
.
emailCount
=
emailCount
;
}
}
public
String
getEmailPassword
()
{
public
String
getEmailPassword
()
{
return
emailPassword
;
return
emailPassword
;
}
}
public
void
setEmailPassword
(
String
emailPassword
)
{
public
void
setEmailPassword
(
String
emailPassword
)
{
this
.
emailPassword
=
emailPassword
;
this
.
emailPassword
=
emailPassword
;
}
}
public
String
getMailTitle
()
{
public
String
getMailTitle
()
{
return
mailTitle
;
return
mailTitle
;
}
}
public
void
setMailTitle
(
String
mailTitle
)
{
public
void
setMailTitle
(
String
mailTitle
)
{
this
.
mailTitle
=
mailTitle
;
this
.
mailTitle
=
mailTitle
;
}
}
public
String
getMailMessage
()
{
public
String
getMailMessage
()
{
return
mailMessage
;
return
mailMessage
;
}
}
public
void
setMailMessage
(
String
mailMessage
)
{
public
void
setMailMessage
(
String
mailMessage
)
{
this
.
mailMessage
=
mailMessage
;
this
.
mailMessage
=
mailMessage
;
}
}
public
String
getProtocol
()
{
public
String
getProtocol
()
{
return
protocol
;
return
protocol
;
}
}
public
void
setProtocol
(
String
protocol
)
{
public
void
setProtocol
(
String
protocol
)
{
this
.
protocol
=
protocol
;
this
.
protocol
=
protocol
;
}
}
public
String
getCopyTo
()
{
public
String
getCopyTo
()
{
return
copyTo
;
return
copyTo
;
}
}
public
void
setCopyTo
(
String
copyTo
)
{
public
void
setCopyTo
(
String
copyTo
)
{
this
.
copyTo
=
copyTo
;
this
.
copyTo
=
copyTo
;
}
}
public
String
getAffix
()
{
public
String
getAffix
()
{
return
affix
;
return
affix
;
}
}
public
void
setAffix
(
String
affix
)
{
public
void
setAffix
(
String
affix
)
{
this
.
affix
=
affix
;
this
.
affix
=
affix
;
}
}
}
}
src/main/java/org/ccpit/base/utils/mailUtil/MailUtil.java
View file @
9407336e
...
@@ -5,31 +5,20 @@
...
@@ -5,31 +5,20 @@
* Package Name:org.ccpit.base.utils.mailUtil
* Package Name:org.ccpit.base.utils.mailUtil
* Date:2015年11月19日上午11:15:36
* Date:2015年11月19日上午11:15:36
* Copyright (c) 2015, dingwei@ccpit.org All Rights Reserved.
* Copyright (c) 2015, dingwei@ccpit.org All Rights Reserved.
*
*/
*/
package
org
.
ccpit
.
base
.
utils
.
mailUtil
;
package
org
.
ccpit
.
base
.
utils
.
mailUtil
;
import
javax.activation.DataHandler
;
import
javax.activation.FileDataSource
;
import
javax.mail.*
;
import
javax.mail.internet.*
;
import
java.io.File
;
import
java.io.File
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.Set
;
import
javax.activation.DataHandler
;
import
javax.activation.FileDataSource
;
import
javax.mail.Message
;
import
javax.mail.MessagingException
;
import
javax.mail.NoSuchProviderException
;
import
javax.mail.Session
;
import
javax.mail.Transport
;
import
javax.mail.internet.InternetAddress
;
import
javax.mail.internet.MimeBodyPart
;
import
javax.mail.internet.MimeMessage
;
import
javax.mail.internet.MimeMultipart
;
import
javax.mail.internet.MimeUtility
;
/**
/**
* ClassName:MailUtil <br/>
* ClassName:MailUtil <br/>
...
@@ -44,13 +33,13 @@ import javax.mail.internet.MimeUtility;
...
@@ -44,13 +33,13 @@ import javax.mail.internet.MimeUtility;
public
class
MailUtil
{
public
class
MailUtil
{
public
static
boolean
sendMail
(
Mail
mail
)
{
public
static
boolean
sendMail
(
Mail
mail
)
{
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"mail.host"
,
mail
.
getHost
());
properties
.
setProperty
(
"mail.host"
,
mail
.
getHost
());
properties
.
setProperty
(
"mail.transport.protocol"
,
mail
.
getProtocol
());
properties
.
setProperty
(
"mail.transport.protocol"
,
mail
.
getProtocol
());
properties
.
setProperty
(
"mail.smtp.auth"
,
"true"
);
properties
.
setProperty
(
"mail.smtp.auth"
,
"true"
);
properties
.
put
(
"mail.smtp.ssl.enable"
,
true
);
properties
.
put
(
"mail.smtp.ssl.enable"
,
true
);
//使用JavaMail发送邮件的5个步骤
//使用JavaMail发送邮件的5个步骤
//1、创建session
//1、创建session
Session
session
=
Session
.
getInstance
(
properties
);
Session
session
=
Session
.
getInstance
(
properties
);
...
@@ -63,12 +52,12 @@ public class MailUtil {
...
@@ -63,12 +52,12 @@ public class MailUtil {
//3、连上邮件服务器
//3、连上邮件服务器
transport
.
connect
(
mail
.
getHost
(),
mail
.
getEmailCount
(),
mail
.
getEmailPassword
());
transport
.
connect
(
mail
.
getHost
(),
mail
.
getEmailCount
(),
mail
.
getEmailPassword
());
//4、创建邮件
//4、创建邮件
final
Message
message
=
createMail
(
session
,
mail
);
final
Message
message
=
createMail
(
session
,
mail
);
//5、发送邮件
//5、发送邮件
new
Thread
()
{
new
Thread
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
try
{
try
{
transport
.
sendMessage
(
message
,
message
.
getAllRecipients
());
transport
.
sendMessage
(
message
,
message
.
getAllRecipients
());
transport
.
close
();
transport
.
close
();
...
@@ -90,43 +79,43 @@ public class MailUtil {
...
@@ -90,43 +79,43 @@ public class MailUtil {
return
flag
;
return
flag
;
}
}
public
static
MimeMessage
createMail
(
Session
session
,
Mail
mail
)
{
public
static
MimeMessage
createMail
(
Session
session
,
Mail
mail
)
{
MimeMessage
mimeMessage
=
new
MimeMessage
(
session
);
//构建邮件体
MimeMessage
mimeMessage
=
new
MimeMessage
(
session
);
//构建邮件体
try
{
try
{
if
(
null
!=
mail
.
getSender
())
{
if
(
null
!=
mail
.
getSender
())
{
//设置发件人
//设置发件人
mimeMessage
.
setFrom
(
new
InternetAddress
(
mail
.
getSender
()));
mimeMessage
.
setFrom
(
new
InternetAddress
(
mail
.
getSender
()));
}
}
if
(
null
!=
mail
.
getReceiver
())
{
if
(
null
!=
mail
.
getReceiver
())
{
String
[]
address
=
mail
.
getReceiver
().
split
(
";"
);
String
[]
address
=
mail
.
getReceiver
().
split
(
";"
);
InternetAddress
[]
addresses
=
new
InternetAddress
[
address
.
length
];
InternetAddress
[]
addresses
=
new
InternetAddress
[
address
.
length
];
for
(
int
i
=
0
;
i
<
address
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
address
.
length
;
i
++)
{
addresses
[
i
]
=
new
InternetAddress
(
address
[
i
]);
addresses
[
i
]
=
new
InternetAddress
(
address
[
i
]);
}
}
//设置收件人 群发
//设置收件人 群发
mimeMessage
.
setRecipients
(
Message
.
RecipientType
.
TO
,
addresses
);
mimeMessage
.
setRecipients
(
Message
.
RecipientType
.
TO
,
addresses
);
}
}
if
(
null
!=
mail
.
getCopyTo
())
{
if
(
null
!=
mail
.
getCopyTo
())
{
String
[]
address
=
mail
.
getReceiver
().
split
(
";"
);
String
[]
address
=
mail
.
getReceiver
().
split
(
";"
);
InternetAddress
[]
addresses
=
new
InternetAddress
[
address
.
length
];
InternetAddress
[]
addresses
=
new
InternetAddress
[
address
.
length
];
for
(
int
i
=
0
;
i
<
address
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
address
.
length
;
i
++)
{
addresses
[
i
]
=
new
InternetAddress
(
address
[
i
]);
addresses
[
i
]
=
new
InternetAddress
(
address
[
i
]);
}
}
//抄送人 群发
//抄送人 群发
mimeMessage
.
setRecipients
(
Message
.
RecipientType
.
CC
,
addresses
);
mimeMessage
.
setRecipients
(
Message
.
RecipientType
.
CC
,
addresses
);
}
}
//邮件主题
//邮件主题
mimeMessage
.
setSubject
(
mail
.
getMailTitle
()==
null
?
""
:
mail
.
getMailTitle
());
mimeMessage
.
setSubject
(
mail
.
getMailTitle
()
==
null
?
""
:
mail
.
getMailTitle
());
//创建邮件正文 为了避免邮件正文中文乱码问题,需要使用charset=UTF-8指明字符编码
//创建邮件正文 为了避免邮件正文中文乱码问题,需要使用charset=UTF-8指明字符编码
MimeBodyPart
mimeBodyPart
=
new
MimeBodyPart
();
MimeBodyPart
mimeBodyPart
=
new
MimeBodyPart
();
mimeBodyPart
.
setContent
(
mail
.
getMailMessage
(),
"text/html;charset=UTF-8"
);
mimeBodyPart
.
setContent
(
mail
.
getMailMessage
(),
"text/html;charset=UTF-8"
);
Set
<
MimeBodyPart
>
mimeBodyPartSet
=
new
HashSet
<
MimeBodyPart
>();
Set
<
MimeBodyPart
>
mimeBodyPartSet
=
new
HashSet
<
MimeBodyPart
>();
//创建邮件附件
//创建邮件附件
if
(
null
!=
mail
.
getAffix
()&&!
""
.
equals
(
mail
.
getAffix
()))
{
if
(
null
!=
mail
.
getAffix
()
&&
!
""
.
equals
(
mail
.
getAffix
()))
{
//多附件,附件地址之间以";"分隔
//多附件,附件地址之间以";"分隔
String
[]
affixs
=
mail
.
getAffix
().
split
(
";"
);
String
[]
affixs
=
mail
.
getAffix
().
split
(
";"
);
for
(
int
i
=
0
;
i
<
affixs
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
affixs
.
length
;
i
++)
{
File
file
=
new
File
(
affixs
[
i
]);
File
file
=
new
File
(
affixs
[
i
]);
MimeBodyPart
mbp
=
new
MimeBodyPart
();
MimeBodyPart
mbp
=
new
MimeBodyPart
();
DataHandler
dh
=
new
DataHandler
(
new
FileDataSource
(
file
));
DataHandler
dh
=
new
DataHandler
(
new
FileDataSource
(
file
));
...
@@ -138,8 +127,8 @@ public class MailUtil {
...
@@ -138,8 +127,8 @@ public class MailUtil {
//创建容器描述数据关系
//创建容器描述数据关系
MimeMultipart
mimeMultipart
=
new
MimeMultipart
();
MimeMultipart
mimeMultipart
=
new
MimeMultipart
();
mimeMultipart
.
addBodyPart
(
mimeBodyPart
);
mimeMultipart
.
addBodyPart
(
mimeBodyPart
);
if
(
null
!=
mimeBodyPartSet
&&
mimeBodyPartSet
.
size
()>
0
)
{
if
(
null
!=
mimeBodyPartSet
&&
mimeBodyPartSet
.
size
()
>
0
)
{
for
(
MimeBodyPart
mbp
:
mimeBodyPartSet
)
{
for
(
MimeBodyPart
mbp
:
mimeBodyPartSet
)
{
mimeMultipart
.
addBodyPart
(
mbp
);
mimeMultipart
.
addBodyPart
(
mbp
);
}
}
}
}
...
...
src/main/java/org/ccpit/business/registerManage/ExcelHelper.java
View file @
9407336e
...
@@ -102,6 +102,7 @@ public class ExcelHelper {
...
@@ -102,6 +102,7 @@ public class ExcelHelper {
cell22
.
setCellType
(
XSSFCell
.
CELL_TYPE_STRING
);
cell22
.
setCellType
(
XSSFCell
.
CELL_TYPE_STRING
);
cell23
.
setCellType
(
XSSFCell
.
CELL_TYPE_STRING
);
cell23
.
setCellType
(
XSSFCell
.
CELL_TYPE_STRING
);
cell24
.
setCellType
(
XSSFCell
.
CELL_TYPE_STRING
);
cell24
.
setCellType
(
XSSFCell
.
CELL_TYPE_STRING
);
cell25
.
setCellType
(
XSSFCell
.
CELL_TYPE_STRING
);
//在单元格中输入数据
//在单元格中输入数据
cell0
.
setCellValue
(
"提交时间"
);
cell0
.
setCellValue
(
"提交时间"
);
...
@@ -129,6 +130,7 @@ public class ExcelHelper {
...
@@ -129,6 +130,7 @@ public class ExcelHelper {
cell22
.
setCellValue
(
"考试科目"
);
cell22
.
setCellValue
(
"考试科目"
);
cell23
.
setCellValue
(
"报名类型"
);
cell23
.
setCellValue
(
"报名类型"
);
cell24
.
setCellValue
(
"报名状态"
);
cell24
.
setCellValue
(
"报名状态"
);
cell25
.
setCellValue
(
"是否购买CDCS/CSDG考前培训"
);
cell0
.
setCellStyle
(
style
);
cell0
.
setCellStyle
(
style
);
//循环导出数据到excel中
//循环导出数据到excel中
for
(
int
i
=
0
;
i
<
newsInfoList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
newsInfoList
.
size
();
i
++)
{
...
@@ -159,6 +161,9 @@ public class ExcelHelper {
...
@@ -159,6 +161,9 @@ public class ExcelHelper {
rowi
.
createCell
(
21
).
setCellValue
(
registerInfo
.
getCity_en
());
//CITY SELECT
rowi
.
createCell
(
21
).
setCellValue
(
registerInfo
.
getCity_en
());
//CITY SELECT
rowi
.
createCell
(
22
).
setCellValue
(
registerInfo
.
getSubject
());
//考试科目
rowi
.
createCell
(
22
).
setCellValue
(
registerInfo
.
getSubject
());
//考试科目
rowi
.
createCell
(
24
).
setCellValue
(
registerInfo
.
getRegisterStatus
());
//报名状态
rowi
.
createCell
(
24
).
setCellValue
(
registerInfo
.
getRegisterStatus
());
//报名状态
if
(
null
!=
registerInfo
.
getIfBuyFee
()){
rowi
.
createCell
(
25
).
setCellValue
(
1
==
registerInfo
.
getIfBuyFee
()
?
"是"
:
"否"
);
//是否购买CDCS/CSDG靠前培训
}
}
}
try
{
try
{
book
.
write
(
os
);
book
.
write
(
os
);
...
...
src/main/java/org/ccpit/business/registerManage/RegisterController.java
View file @
9407336e
...
@@ -25,9 +25,7 @@ import org.ccpit.base.user.User;
...
@@ -25,9 +25,7 @@ import org.ccpit.base.user.User;
import
org.ccpit.business.phase.Phase
;
import
org.ccpit.business.phase.Phase
;
import
org.ccpit.business.phase.PhaseService
;
import
org.ccpit.business.phase.PhaseService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.ModelAndView
;
...
...
src/main/java/org/ccpit/business/registerManage/RegisterInfo.java
View file @
9407336e
...
@@ -26,7 +26,7 @@ import org.springframework.format.annotation.DateTimeFormat;
...
@@ -26,7 +26,7 @@ import org.springframework.format.annotation.DateTimeFormat;
* Reason: TODO ADD REASON. <br/>
* Reason: TODO ADD REASON. <br/>
* Date: 2015年11月9日 下午5:33:37 <br/>
* Date: 2015年11月9日 下午5:33:37 <br/>
*
*
* @author
sunqipeng
* @author
dingwei
* @see
* @see
* @since JDK 1.6
* @since JDK 1.6
*/
*/
...
@@ -95,6 +95,10 @@ public class RegisterInfo implements Serializable {
...
@@ -95,6 +95,10 @@ public class RegisterInfo implements Serializable {
*/
*/
private
Integer
invoiceType
;
private
Integer
invoiceType
;
/**
/**
* 是否购买CDCS/CSDG考前培训 1 表示 是 | 2 表示否
*/
private
Integer
ifBuyFee
;
/**
* 省
* 省
*/
*/
private
String
province
;
private
String
province
;
...
@@ -721,5 +725,13 @@ public class RegisterInfo implements Serializable {
...
@@ -721,5 +725,13 @@ public class RegisterInfo implements Serializable {
public
void
setDistrict
(
String
district
)
{
public
void
setDistrict
(
String
district
)
{
this
.
district
=
district
;
this
.
district
=
district
;
}
}
public
Integer
getIfBuyFee
()
{
return
ifBuyFee
;
}
public
void
setIfBuyFee
(
Integer
ifBuyFee
)
{
this
.
ifBuyFee
=
ifBuyFee
;
}
}
}
src/main/resources/framework.properties
View file @
9407336e
# jdbc.X
# jdbc.X
jdbc.driverClassName
=
com.mysql.jdbc.Driver
jdbc.driverClassName
=
com.mysql.jdbc.Driver
# 生产环境 docker 环境下一定要注意 将localhost 换成mysql
# 生产环境 docker 环境下一定要注意 将localhost 换成mysql
jdbc.url
=
jdbc:mysql://mysql:3306/registration?createDatabaseIfNotExist=true&characterEncoding=utf-8
#
jdbc.url=jdbc:mysql://mysql:3306/registration?createDatabaseIfNotExist=true&characterEncoding=utf-8
jdbc.user
=
root
#
jdbc.user=root
jdbc.pass
=
root
#
jdbc.pass=root
# 开发环境
# 开发环境
#
jdbc.url=jdbc:mysql://localhost:3306/registration_0611?createDatabaseIfNotExist=true&characterEncoding=utf-8
jdbc.url
=
jdbc:mysql://localhost:3306/registration_0611?createDatabaseIfNotExist=true&characterEncoding=utf-8
#
jdbc.user=ccpit
jdbc.user
=
ccpit
#
jdbc.pass=ccpit1516
jdbc.pass
=
ccpit1516
# hibernate.X
# hibernate.X
hibernate.dialect
=
org.hibernate.dialect.MySQL5Dialect
hibernate.dialect
=
org.hibernate.dialect.MySQL5Dialect
...
...
src/main/sql/update.sql
View file @
9407336e
/* create by dingwei 20211212 start */
/* create by dingwei 20211212 start */
alter
table
reg_subjectinfo
add
province
varchar
(
100
)
Null
;
alter
table
reg_subjectinfo
alter
table
reg_subjectinfo
add
chengshi
varchar
(
100
)
Null
;
add
province
varchar
(
100
)
Null
;
alter
table
reg_subjectinfo
add
district
varchar
(
100
)
Null
;
alter
table
reg_subjectinfo
add
chengshi
varchar
(
100
)
Null
;
alter
table
reg_subjectinfo
add
district
varchar
(
100
)
Null
;
/* create by dingwei 20211212 end */
/* create by dingwei 20211212 end */
src/main/sql/update_20210616.sql
View file @
9407336e
/* create by dingwei 20210611 start */
/* create by dingwei 20210611 start */
delete
from
reg_subjectinfo
where
registerInfo_id
=
12978
;
delete
delete
from
reg_subjectinfo
where
registerInfo_id
=
12977
;
from
reg_subjectinfo
delete
from
reg_subjectinfo
where
registerInfo_id
=
12976
;
where
registerInfo_id
=
12978
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12975
;
delete
delete
from
reg_subjectinfo
where
registerInfo_id
=
12969
;
from
reg_subjectinfo
delete
from
reg_subjectinfo
where
registerInfo_id
=
12974
;
where
registerInfo_id
=
12977
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12971
;
delete
delete
from
reg_subjectinfo
where
registerInfo_id
=
12970
;
from
reg_subjectinfo
delete
from
reg_subjectinfo
where
registerInfo_id
=
12968
;
where
registerInfo_id
=
12976
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12967
;
delete
delete
from
reg_subjectinfo
where
registerInfo_id
=
12964
;
from
reg_subjectinfo
delete
from
reg_subjectinfo
where
registerInfo_id
=
12956
;
where
registerInfo_id
=
12975
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12955
;
delete
delete
from
reg_subjectinfo
where
registerInfo_id
=
12954
;
from
reg_subjectinfo
delete
from
reg_subjectinfo
where
registerInfo_id
=
12953
;
where
registerInfo_id
=
12969
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12974
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12971
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12970
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12968
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12967
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12964
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12956
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12955
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12954
;
delete
from
reg_subjectinfo
where
registerInfo_id
=
12953
;
/* create by dingwei 20210611 end */
/* create by dingwei 20210611 end */
src/main/sql/update_20210702.sql
View file @
9407336e
/* create by dingwei 20210617 start */
/* create by dingwei 20210617 start */
set
character
set
utf8
;
set
update
reg_subjectinfo
set
registerName
=
'邓默'
where
registerInfo_id
=
12983
;
character
set
utf8
;
update
reg_subjectinfo
set
registerName
=
'丁伟'
where
registerInfo_id
=
12979
;
update
reg_subjectinfo
update
reg_subjectinfo
set
registerName
=
'丁伟'
where
registerInfo_id
=
12979
;
set
registerName
=
'邓默'
where
registerInfo_id
=
12983
;
update
reg_subjectinfo
set
registerName
=
'丁伟'
where
registerInfo_id
=
12979
;
update
reg_subjectinfo
set
registerName
=
'丁伟'
where
registerInfo_id
=
12979
;
/* create by dingwei 20210617 end */
/* create by dingwei 20210617 end */
src/main/sql/update_20211222.sql
View file @
9407336e
...
@@ -3,4 +3,6 @@ alter table reg_registerinfo modify taxIssue Integer;
...
@@ -3,4 +3,6 @@ alter table reg_registerinfo modify taxIssue Integer;
alter
table
reg_subjectinfo
modify
taxIssue
Integer
;
alter
table
reg_subjectinfo
modify
taxIssue
Integer
;
/* create by dingwei 20210702 end */
/* create by dingwei 20210702 end */
select
id
,
name
,
whetherDelete
from
reg_registerinfo
where
taxpayerNum
=
'9142'
;
select
id
,
name
,
whetherDelete
\ No newline at end of file
from
reg_registerinfo
where
taxpayerNum
=
'9142'
;
\ No newline at end of file
src/main/webapp/WEB-INF/jsp/front/info.jsp
View file @
9407336e
...
@@ -270,6 +270,15 @@
...
@@ -270,6 +270,15 @@
</c:if>
</c:if>
</c:if>
</c:if>
<tr>
<tr>
<td
class=
"name"
>
是否购买CDCS/CSDG
</br>
考前培训:
</td>
<c:if
test=
"${registerInfo.ifBuyFee == 1}"
>
<td>
是
</td>
</c:if>
<c:if
test=
"${registerInfo.ifBuyFee == 2}"
>
<td>
否
</td>
</c:if>
</tr>
<tr>
<td
class=
"name"
>
Family Name:
</td>
<td
class=
"name"
>
Family Name:
</td>
<td>
${registerInfo.name_en}
</td>
<td>
${registerInfo.name_en}
</td>
...
@@ -312,11 +321,11 @@
...
@@ -312,11 +321,11 @@
<td
class=
"name"
>
COUNTRY:
</td>
<td
class=
"name"
>
COUNTRY:
</td>
<td>
中国
</td>
<td>
中国
</td>
</tr>
</tr>
<tr
>
<
%
--
<
tr
>
--%
>
<td
class=
"title"
background=
"/resource/front/img/dh.gif"
height=
"24"
colspan=
"3"
>
<
%
--
<
td
class=
"title"
background=
"/resource/front/img/dh.gif"
height=
"24"
colspan=
"3"
>
--%
>
上传考生名片
<
%
--
上传考生名片
--
%
>
</td
>
<
%
--
</
td
>
--%
>
</tr
>
<
%
--
</
tr
>
--%
>
<
%
--
<
tr
>
--%>
<
%
--
<
tr
>
--%>
<
%
--
<
td
class=
"name"
>
选择科目
</td>
--%>
<
%
--
<
td
class=
"name"
>
选择科目
</td>
--%>
<
%
--
<
td
align=
"left"
width=
"30%"
>
--%>
<
%
--
<
td
align=
"left"
width=
"30%"
>
--%>
...
@@ -331,34 +340,34 @@
...
@@ -331,34 +340,34 @@
<
%
--
</
select
>
--%>
<
%
--
</
select
>
--%>
<
%
--
</
td
>
--%>
<
%
--
</
td
>
--%>
<
%
--
</
tr
>
--%>
<
%
--
</
tr
>
--%>
<tr
>
<
%
--
<
tr
>
--%
>
<td
class=
"name"
>
考生名片:
</td
>
<
%
--
<
td
class=
"name"
>
考生名片:
</td>
--%
>
<td
align=
"left"
width=
"30%"
>
<
%
--
<
td
align=
"left"
width=
"30%"
>
--%
>
<input
id=
"imageUrlId1"
class=
"PhotoUpload"
type=
"file"
name=
'file'
/
>
<
%
--
<
input
id=
"imageUrlId1"
class=
"PhotoUpload"
type=
"file"
name=
'file'
/>
--%
>
</td
>
<
%
--
</
td
>
--%
>
<td
align=
"left"
>
<
%
--
<
td
align=
"left"
>
--%
>
<input
data-target=
"imageUrlId1"
class=
"PhotoUploadButton"
type=
"button"
value=
"上传"
<
%
--
<
input
data-target=
"imageUrlId1"
class=
"PhotoUploadButton"
type=
"button"
value=
"上传"
--
%
>
name=
"upload"
style=
"width:80px;height:20px"
>
<
%
--
name=
"upload"
style=
"width:80px;height:20px"
>
--%
>
</td
>
<
%
--
</
td
>
--%
>
</tr
>
<
%
--
</
tr
>
--%
>
<tr
>
<
%
--
<
tr
>
--%
>
<td></td
>
<
%
--
<
td
></td>
--%
>
<td
>
<
%
--
<
td
>
--%
>
<div><img
data-target=
"imageUrlId1"
id=
"img1"
src=
"${registerInfo.img1}"
<
%
--
<
div
><img
data-target=
"imageUrlId1"
id=
"img1"
src=
"${registerInfo.img1}"
--
%
>
style=
"width:150px;height:100px"
></div
>
<
%
--
style=
"width:150px;height:100px"
></div>
--%
>
</td
>
<
%
--
</
td
>
--%
>
<td
align=
"left"
valign=
"top"
>
<
%
--
<
td
align=
"left"
valign=
"top"
>
--%
>
<p
style=
"color: #000000"
>
图片支持式为:bmp、gif、jpeg、jpg、png,图片大小不要超过1M
</p
>
<
%
--
<
p
style=
"color: #000000"
>
图片支持式为:bmp、gif、jpeg、jpg、png,图片大小不要超过1M
</p>
--%
>
<p
style=
"color: red;font-size:16px"
>
如开具增值税专用发票,请考生上传个人名片,
</p
>
<
%
--
<
p
style=
"color: red;font-size:16px"
>
如开具增值税专用发票,请考生上传个人名片,
</p>
--%
>
<p
style=
"color: red;font-size:16px"
>
或其他可证明考生供职于发票抬头所在单位的证明文件,如工牌、入职证明书(拍照即可)等
</p
>
<
%
--
<
p
style=
"color: red;font-size:16px"
>
或其他可证明考生供职于发票抬头所在单位的证明文件,如工牌、入职证明书(拍照即可)等
</p>
--%
>
</td
>
<
%
--
</
td
>
--%
>
</tr
>
<
%
--
</
tr
>
--%
>
<tr
>
<
%
--
<
tr
>
--%
>
<td></td
>
<
%
--
<
td
></td>
--%
>
<td
>
<
%
--
<
td
>
--%
>
<Button
id=
"saveCertificateId"
style=
"width:80px;height:20px"
>
保存照片
</Button
>
<
%
--
<
Button
id=
"saveCertificateId"
style=
"width:80px;height:20px"
>
保存照片
</Button>
--%
>
</td
>
<
%
--
</
td
>
--%
>
</tr
>
<
%
--
</
tr
>
--%
>
<tr>
<tr>
<td
class=
"title"
background=
"/resource/front/img/dh.gif"
height=
"24"
colspan=
"3"
>
My LIBF 登录
<td
class=
"title"
background=
"/resource/front/img/dh.gif"
height=
"24"
colspan=
"3"
>
My LIBF 登录
...
...
src/main/webapp/WEB-INF/jsp/front/reg.jsp
View file @
9407336e
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
<tr
id=
"trEmial"
name=
"email33"
>
<tr
id=
"trEmial"
name=
"email33"
>
<td
class=
"name"
width=
"15%"
><span
style=
"color: red;"
>
*
</span><yh:yh
id=
"1_Info_Email"
english=
"E-mail:"
isnotnull=
"1"
>
邮箱:
</yh:yh></td>
<td
class=
"name"
width=
"15%"
><span
style=
"color: red;"
>
*
</span><yh:yh
id=
"1_Info_Email"
english=
"E-mail:"
isnotnull=
"1"
>
邮箱:
</yh:yh></td>
<td
width=
"25%"
><input
name=
"email"
value=
""
style=
"width:220px"
onblur=
"this.value=this.value.toLowerCase().replace(/(^\s*)|(\s*$)/g,""); "
type=
"text"
><input
name=
"A_MAINID"
type=
"hidden"
><input
name=
"A_LINK_ID"
type=
"hidden"
><input
name=
"A_ROLEID"
type=
"hidden"
><input
name=
"A_LANGID"
type=
"hidden"
><input
name=
"A_CON_CNF_ID"
type=
"hidden"
><input
name=
"A_STAT_ID"
type=
"hidden"
><input
name=
"A_AUDITSTATE"
type=
"hidden"
><input
name=
"D_LINK_ID"
type=
"hidden"
><input
name=
"D_MAINID"
type=
"hidden"
></td>
<td
width=
"25%"
><input
name=
"email"
value=
""
style=
"width:220px"
onblur=
"this.value=this.value.toLowerCase().replace(/(^\s*)|(\s*$)/g,""); "
type=
"text"
><input
name=
"A_MAINID"
type=
"hidden"
><input
name=
"A_LINK_ID"
type=
"hidden"
><input
name=
"A_ROLEID"
type=
"hidden"
><input
name=
"A_LANGID"
type=
"hidden"
><input
name=
"A_CON_CNF_ID"
type=
"hidden"
><input
name=
"A_STAT_ID"
type=
"hidden"
><input
name=
"A_AUDITSTATE"
type=
"hidden"
><input
name=
"D_LINK_ID"
type=
"hidden"
><input
name=
"D_MAINID"
type=
"hidden"
></td>
<td
width=
"50%"
><span
class=
"reg_body"
>
必填:
请勿使用QQ邮箱,
邮箱会作为登录名,请如实填写
</span></td>
<td
width=
"50%"
><span
class=
"reg_body"
>
必填:邮箱会作为登录名,请如实填写
</span></td>
</tr>
</tr>
<tr
id=
"trPassWord"
name=
"password33"
>
<tr
id=
"trPassWord"
name=
"password33"
>
<td
class=
"name"
><span
style=
"color: red;"
>
*
</span><yh:yh
id=
"1_Info_Password"
english=
"Password:"
isnotnull=
"1"
>
密码:
</yh:yh></td>
<td
class=
"name"
><span
style=
"color: red;"
>
*
</span><yh:yh
id=
"1_Info_Password"
english=
"Password:"
isnotnull=
"1"
>
密码:
</yh:yh></td>
...
@@ -122,7 +122,14 @@
...
@@ -122,7 +122,14 @@
type=
"text"
></textarea></td>
type=
"text"
></textarea></td>
<td><span
class=
"reg_body"
>
必填:可以安全收到邮寄材料的地址
</span></td>
<td><span
class=
"reg_body"
>
必填:可以安全收到邮寄材料的地址
</span></td>
</tr>
</tr>
<tr
id=
"trIfBuyFee"
name=
"trIfBuyFee"
>
<td
class=
"name"
><span
style=
"color: red;"
>
*
</span>
是否购买CDCS/CSDG
</br>
考前培训:
</td>
<td
>
<input
class=
"required"
checked=
"checked"
type=
"radio"
name=
"ifBuyFee"
value=
"1"
width=
"40%"
>
是
</input>
  
<input
class=
"required"
type=
"radio"
name=
"ifBuyFee"
value=
"2"
width=
"40%"
>
否
</input>
</td>
<td><span
class=
"reg_body"
>
必选
</span></td>
</tr>
<tr>
<tr>
<td
class=
"name"
><span
style=
"color: red;"
>
*
</span><yh:yh
id=
"1_customitem6"
english=
"Custom Item6:"
isnotnull=
"0"
>
增值税发票:
</yh:yh></td>
<td
class=
"name"
><span
style=
"color: red;"
>
*
</span><yh:yh
id=
"1_customitem6"
english=
"Custom Item6:"
isnotnull=
"0"
>
增值税发票:
</yh:yh></td>
<td><select
class=
"required"
id=
"appreciationTaxTypeId"
name=
"appreciationTaxType"
style=
"width:225px"
>
<td><select
class=
"required"
id=
"appreciationTaxTypeId"
name=
"appreciationTaxType"
style=
"width:225px"
>
...
...
src/main/webapp/WEB-INF/jsp/front/reg2.jsp
View file @
9407336e
...
@@ -67,7 +67,7 @@
...
@@ -67,7 +67,7 @@
<tr
id=
"trEmial"
name=
"email33"
>
<tr
id=
"trEmial"
name=
"email33"
>
<td
class=
"name"
width=
"15%"
><span
style=
"color: red;"
>
*
</span><yh:yh
id=
"1_Info_Email"
english=
"E-mail:"
isnotnull=
"1"
>
邮箱:
</yh:yh></td>
<td
class=
"name"
width=
"15%"
><span
style=
"color: red;"
>
*
</span><yh:yh
id=
"1_Info_Email"
english=
"E-mail:"
isnotnull=
"1"
>
邮箱:
</yh:yh></td>
<td
width=
"25%"
><input
name=
"email"
value=
""
style=
"width:220px"
onblur=
"this.value=this.value.toLowerCase().replace(/(^\s*)|(\s*$)/g,""); "
type=
"text"
><input
name=
"A_MAINID"
type=
"hidden"
><input
name=
"A_LINK_ID"
type=
"hidden"
><input
name=
"A_ROLEID"
type=
"hidden"
><input
name=
"A_LANGID"
type=
"hidden"
><input
name=
"A_CON_CNF_ID"
type=
"hidden"
><input
name=
"A_STAT_ID"
type=
"hidden"
><input
name=
"A_AUDITSTATE"
type=
"hidden"
><input
name=
"D_LINK_ID"
type=
"hidden"
><input
name=
"D_MAINID"
type=
"hidden"
></td>
<td
width=
"25%"
><input
name=
"email"
value=
""
style=
"width:220px"
onblur=
"this.value=this.value.toLowerCase().replace(/(^\s*)|(\s*$)/g,""); "
type=
"text"
><input
name=
"A_MAINID"
type=
"hidden"
><input
name=
"A_LINK_ID"
type=
"hidden"
><input
name=
"A_ROLEID"
type=
"hidden"
><input
name=
"A_LANGID"
type=
"hidden"
><input
name=
"A_CON_CNF_ID"
type=
"hidden"
><input
name=
"A_STAT_ID"
type=
"hidden"
><input
name=
"A_AUDITSTATE"
type=
"hidden"
><input
name=
"D_LINK_ID"
type=
"hidden"
><input
name=
"D_MAINID"
type=
"hidden"
></td>
<td
width=
"50%"
><span
class=
"reg_body"
>
请勿使用QQ邮箱,
邮箱会作为登录名,请如实填写
</span></td>
<td
width=
"50%"
><span
class=
"reg_body"
>
邮箱会作为登录名,请如实填写
</span></td>
</tr>
</tr>
<tr
id=
"trPassWord"
name=
"password33"
>
<tr
id=
"trPassWord"
name=
"password33"
>
<td
class=
"name"
><span
style=
"color: red;"
>
*
</span><yh:yh
id=
"1_Info_Password"
english=
"Password:"
isnotnull=
"1"
>
密码:
</yh:yh></td>
<td
class=
"name"
><span
style=
"color: red;"
>
*
</span><yh:yh
id=
"1_Info_Password"
english=
"Password:"
isnotnull=
"1"
>
密码:
</yh:yh></td>
...
...
src/main/webapp/resource/front/js/reg.js
View file @
9407336e
...
@@ -85,10 +85,10 @@ var REG = function () {
...
@@ -85,10 +85,10 @@ var REG = function () {
});
});
$
(
"[name=email]"
).
on
(
"blur"
,
function
()
{
$
(
"[name=email]"
).
on
(
"blur"
,
function
()
{
var
e
=
$
(
"[name=email]"
).
val
();
var
e
=
$
(
"[name=email]"
).
val
();
if
(
new
RegExp
(
"^
\\
w+@qq
\
.com$"
).
test
(
e
))
{
//
if (new RegExp("^\\w+@qq\.com$").test(e)) {
showWarning
(
$
(
"[name=email]"
),
"请勿使用QQ邮箱注册!"
);
//
showWarning($("[name=email]"), "请勿使用QQ邮箱注册!");
return
;
//
return;
}
//
}
var
filter
=
/^
([
a-zA-Z0-9_
\.\-])
+
\@(([
a-zA-Z0-9
\-])
+
\.)
+
([
a-zA-Z0-9
]{2,4})
+$/
;
var
filter
=
/^
([
a-zA-Z0-9_
\.\-])
+
\@(([
a-zA-Z0-9
\-])
+
\.)
+
([
a-zA-Z0-9
]{2,4})
+$/
;
if
(
!
filter
.
test
(
e
))
{
if
(
!
filter
.
test
(
e
))
{
showWarning
(
$
(
"[name=email]"
),
"邮箱格式不正确!"
);
showWarning
(
$
(
"[name=email]"
),
"邮箱格式不正确!"
);
...
...
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