Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
govdna
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
开发共享交流平台
govdna
Commits
881e04d3
Commit
881e04d3
authored
Aug 08, 2018
by
Fred
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://115.233.227.46:8066/root/govdna.git
parents
040f641b
c7a478aa
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
360 additions
and
0 deletions
+360
-0
org.springframework.ide.eclipse.prefs
.settings/org.springframework.ide.eclipse.prefs
+2
-0
Assert.java
src/main/java/com/govmade/common/utils/Assert.java
+24
-0
ShiroUtils.java
src/main/java/com/govmade/common/utils/ShiroUtils.java
+57
-0
RoleController.java
...com/govmade/modules/system/controller/RoleController.java
+71
-0
UserController.java
...com/govmade/modules/system/controller/UserController.java
+59
-0
RoleDao.java
src/main/java/com/govmade/modules/system/dao/RoleDao.java
+18
-0
RoleEntity.java
...in/java/com/govmade/modules/system/entity/RoleEntity.java
+41
-0
RoleService.java
.../java/com/govmade/modules/system/service/RoleService.java
+37
-0
RoleServiceImpl.java
.../govmade/modules/system/service/impl/RoleServiceImpl.java
+51
-0
No files found.
.settings/org.springframework.ide.eclipse.prefs
0 → 100644
View file @
881e04d3
boot.validation.initialized=true
eclipse.preferences.version=1
src/main/java/com/govmade/common/utils/Assert.java
0 → 100644
View file @
881e04d3
package
com
.
govmade
.
common
.
utils
;
import
org.apache.commons.lang.StringUtils
;
import
com.govmade.common.exception.RRException
;
/**
* 数据校验
*
*/
public
abstract
class
Assert
{
public
static
void
isBlank
(
String
str
,
String
message
)
{
if
(
StringUtils
.
isBlank
(
str
))
{
throw
new
RRException
(
message
);
}
}
public
static
void
isNull
(
Object
object
,
String
message
)
{
if
(
object
==
null
)
{
throw
new
RRException
(
message
);
}
}
}
src/main/java/com/govmade/common/utils/ShiroUtils.java
0 → 100644
View file @
881e04d3
package
com
.
govmade
.
common
.
utils
;
import
org.apache.shiro.SecurityUtils
;
import
org.apache.shiro.session.Session
;
import
org.apache.shiro.subject.Subject
;
import
com.govmade.common.exception.RRException
;
import
com.govmade.modules.system.entity.UserEntity
;
/**
* Shiro工具类
*
*/
public
class
ShiroUtils
{
public
static
Session
getSession
()
{
return
SecurityUtils
.
getSubject
().
getSession
();
}
public
static
Subject
getSubject
()
{
return
SecurityUtils
.
getSubject
();
}
public
static
UserEntity
getUserEntity
()
{
return
(
UserEntity
)
SecurityUtils
.
getSubject
().
getPrincipal
();
}
public
static
Long
getUserId
()
{
return
getUserEntity
().
getId
();
}
public
static
void
setSessionAttribute
(
Object
key
,
Object
value
)
{
getSession
().
setAttribute
(
key
,
value
);
}
public
static
Object
getSessionAttribute
(
Object
key
)
{
return
getSession
().
getAttribute
(
key
);
}
public
static
boolean
isLogin
()
{
return
SecurityUtils
.
getSubject
().
getPrincipal
()
!=
null
;
}
public
static
void
logout
()
{
SecurityUtils
.
getSubject
().
logout
();
}
public
static
String
getKaptcha
(
String
key
)
{
Object
kaptcha
=
getSessionAttribute
(
key
);
if
(
kaptcha
==
null
)
{
throw
new
RRException
(
"验证码已失效"
);
}
getSession
().
removeAttribute
(
key
);
return
kaptcha
.
toString
();
}
}
src/main/java/com/govmade/modules/system/controller/RoleController.java
0 → 100644
View file @
881e04d3
package
com
.
govmade
.
modules
.
system
.
controller
;
import
java.util.Map
;
import
java.util.Set
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.common.utils.R
;
import
com.govmade.modules.basic.controller.AbstractController
;
import
com.govmade.modules.system.entity.RoleEntity
;
import
com.govmade.modules.system.service.RoleService
;
/**
* 系统管理 - 角色设置
*
* @author 刘弈臻
* @date 2018年8月7日
*/
@RestController
@RequestMapping
(
"/system/role"
)
public
class
RoleController
extends
AbstractController
{
@Autowired
private
RoleService
roleService
;
/**
* 角色列表
*/
@GetMapping
(
"/list"
)
public
R
list
(
@RequestParam
Map
<
String
,
Object
>
params
)
{
PageUtils
page
=
roleService
.
queryPage
(
params
);
return
R
.
ok
().
put
(
"page"
,
page
);
}
/**
* 保存或更新权限
*/
@PostMapping
(
"/save"
)
public
R
save
(
RoleEntity
role
)
{
if
(
null
==
role
.
getId
())
{
if
(
this
.
roleService
.
checkRole
(
role
.
getName
())
>
0
)
{
return
R
.
error
(
role
.
getName
()
+
" 已存在!"
);
}
}
roleService
.
save
(
role
);
return
R
.
ok
();
}
/**
* 删除或批量删除角色
*/
@DeleteMapping
(
"/delete"
)
public
R
deleteUser
(
@RequestParam
Set
<
Long
>
ids
)
{
roleService
.
deleteBatchIds
(
ids
);
return
R
.
ok
();
}
}
src/main/java/com/govmade/modules/system/controller/UserController.java
View file @
881e04d3
package
com
.
govmade
.
modules
.
system
.
controller
;
package
com
.
govmade
.
modules
.
system
.
controller
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
org.apache.shiro.crypto.hash.Sha256Hash
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.govmade.common.utils.Assert
;
import
com.govmade.common.utils.Constant
;
import
com.govmade.common.utils.Constant
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.common.utils.R
;
import
com.govmade.common.utils.R
;
import
com.govmade.common.utils.ShiroUtils
;
import
com.govmade.modules.basic.controller.AbstractController
;
import
com.govmade.modules.basic.controller.AbstractController
;
import
com.govmade.modules.system.entity.UserEntity
;
import
com.govmade.modules.system.entity.UserEntity
;
import
com.govmade.modules.system.service.UserService
;
import
com.govmade.modules.system.service.UserService
;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
io.swagger.annotations.ApiOperation
;
/**
/**
* 系统管理 - 用户设置
* 系统管理 - 用户设置
...
@@ -78,4 +87,54 @@ public class UserController extends AbstractController {
...
@@ -78,4 +87,54 @@ public class UserController extends AbstractController {
return
R
.
ok
().
put
(
"user"
,
userService
.
queryById
(
id
));
return
R
.
ok
().
put
(
"user"
,
userService
.
queryById
(
id
));
}
}
/**
* 删除、批量删除用户
*
* @param ids
* @return
*/
@DeleteMapping
(
"/delete"
)
public
R
deleteUser
(
@RequestParam
Set
<
Long
>
ids
)
{
userService
.
deleteBatchIds
(
ids
);
return
R
.
ok
();
}
/**
* 重置密码
* @param id
* @return
*/
@PostMapping
(
"/reset"
)
public
R
reset
(
UserEntity
ue
)
{
if
(
null
!=
ue
.
getId
())
{
String
password
=
SecureUtil
.
md5
(
"123456"
);
ue
.
setPassword
(
password
);
userService
.
updateById
(
ue
);
}
return
R
.
ok
();
}
/**
* 修改登录用户密码
*/
@PutMapping
(
"updatePassword"
)
public
R
password
(
String
password
,
String
newPassword
)
{
Assert
.
isBlank
(
newPassword
,
"新密码不为能空"
);
password
=
new
Sha256Hash
(
password
).
toHex
();
newPassword
=
new
Sha256Hash
(
newPassword
).
toHex
();
//int count = userService.updatePassword(ShiroUtils.getUserId(), password, newPassword);
// if (count == 0) {
// return R.error("原密码不正确");
// }
ShiroUtils
.
logout
();
return
R
.
ok
();
}
}
}
src/main/java/com/govmade/modules/system/dao/RoleDao.java
0 → 100644
View file @
881e04d3
package
com
.
govmade
.
modules
.
system
.
dao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.govmade.modules.system.entity.RoleEntity
;
/**
* 系统管理 - 角色设置
*
* @author 刘弈臻
* @date 2018年8月7日
*/
@Mapper
public
interface
RoleDao
extends
BaseMapper
<
RoleEntity
>{
}
src/main/java/com/govmade/modules/system/entity/RoleEntity.java
0 → 100644
View file @
881e04d3
package
com
.
govmade
.
modules
.
system
.
entity
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.govmade.modules.basic.entity.BaseEntity
;
/**
* 系统管理 - 角色设置
*
* @author 刘弈臻
* @date 2018年8月7日
*/
@TableName
(
"system_roles"
)
public
class
RoleEntity
extends
BaseEntity
<
Long
>{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
//角色名称
private
String
descn
;
//描述
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescn
()
{
return
descn
;
}
public
void
setDescn
(
String
descn
)
{
this
.
descn
=
descn
;
}
}
src/main/java/com/govmade/modules/system/service/RoleService.java
0 → 100644
View file @
881e04d3
package
com
.
govmade
.
modules
.
system
.
service
;
import
java.util.Map
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.modules.system.entity.RoleEntity
;
/**
* 系统管理 - 角色设置
*
* @author 刘弈臻
* @date 2018年8月7日
*/
public
interface
RoleService
extends
IService
<
RoleEntity
>{
/**
* 查看角色列表
*/
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
/**
* 保存或修改角色
*/
void
save
(
RoleEntity
role
);
/**
* 删除角色
*/
void
deleteBatch
(
Long
[]
roleIds
);
/**
* 角色查重
*/
Integer
checkRole
(
String
name
);
}
src/main/java/com/govmade/modules/system/service/impl/RoleServiceImpl.java
0 → 100644
View file @
881e04d3
package
com
.
govmade
.
modules
.
system
.
service
.
impl
;
import
java.util.Map
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.common.utils.Query
;
import
com.govmade.modules.system.dao.RoleDao
;
import
com.govmade.modules.system.entity.RoleEntity
;
import
com.govmade.modules.system.service.RoleService
;
import
cn.hutool.core.util.StrUtil
;
/**
* 系统管理 - 角色设置
*
* @author 刘弈臻
* @date 2018年8月7日
*/
@Service
(
"RoleService"
)
public
class
RoleServiceImpl
extends
ServiceImpl
<
RoleDao
,
RoleEntity
>
implements
RoleService
{
@Override
public
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
String
name
=
(
String
)
params
.
get
(
"name"
);
Page
<
RoleEntity
>
page
=
this
.
selectPage
(
new
Query
<
RoleEntity
>(
params
).
getPage
(),
new
EntityWrapper
<
RoleEntity
>()
.
eq
(
StrUtil
.
isNotBlank
(
name
),
"name"
,
name
));
return
new
PageUtils
(
page
);
}
@Override
public
void
save
(
RoleEntity
role
)
{
super
.
insertOrUpdate
(
role
);
}
@Override
public
void
deleteBatch
(
Long
[]
roleIds
)
{
// TODO Auto-generated method stub
}
@Override
public
Integer
checkRole
(
String
name
)
{
return
super
.
selectCount
(
new
EntityWrapper
<
RoleEntity
>().
eq
(
"name"
,
name
));
}
}
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