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
5746e67f
Commit
5746e67f
authored
Aug 08, 2018
by
Fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量删除
parent
b6449fc2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
77 additions
and
105 deletions
+77
-105
OAuth2Realm.java
src/main/java/com/govmade/common/oauth2/OAuth2Realm.java
+1
-1
Constant.java
src/main/java/com/govmade/common/utils/Constant.java
+9
-51
MyMetaObjectHandler.java
...in/java/com/govmade/common/utils/MyMetaObjectHandler.java
+1
-1
UserController.java
...com/govmade/modules/system/controller/UserController.java
+48
-43
UserDao.java
src/main/java/com/govmade/modules/system/dao/UserDao.java
+4
-0
UserService.java
.../java/com/govmade/modules/system/service/UserService.java
+2
-1
UserServiceImpl.java
.../govmade/modules/system/service/impl/UserServiceImpl.java
+4
-4
UserDao.xml
src/main/resources/mapper/system/UserDao.xml
+8
-4
No files found.
src/main/java/com/govmade/common/oauth2/OAuth2Realm.java
View file @
5746e67f
...
@@ -73,7 +73,7 @@ public class OAuth2Realm extends AuthorizingRealm {
...
@@ -73,7 +73,7 @@ public class OAuth2Realm extends AuthorizingRealm {
throw
new
IncorrectCredentialsException
(
"账号或密码不正确"
);
throw
new
IncorrectCredentialsException
(
"账号或密码不正确"
);
}
}
// 账号锁定
// 账号锁定
if
(
Constant
.
DeleteState
.
DELETE
.
getValue
()
==
ue
.
getState
())
{
if
(
Constant
.
STATE_LOCK
==
ue
.
getState
())
{
throw
new
LockedAccountException
(
"账号已被锁定,请联系管理员"
);
throw
new
LockedAccountException
(
"账号已被锁定,请联系管理员"
);
}
}
...
...
src/main/java/com/govmade/common/utils/Constant.java
View file @
5746e67f
...
@@ -12,60 +12,18 @@ public class Constant {
...
@@ -12,60 +12,18 @@ public class Constant {
/** 超级管理员ID */
/** 超级管理员ID */
public
static
final
int
SUPER_ADMIN
=
1
;
public
static
final
int
SUPER_ADMIN
=
1
;
/**
/** 数据状态 */
* 菜单类型
public
static
final
int
STATE_DELETE
=
0
;
*
* @author Fred
* @email fangtaosh@qq.com
* @date 2018年8月3日
*/
public
enum
MenuType
{
/**
* 目录
*/
CATALOG
(
0
),
/**
* 菜单
*/
MENU
(
1
),
/**
* 按钮
*/
BUTTON
(
2
);
private
Integer
value
;
public
static
final
int
STATE_NORMAL
=
1
;
public
static
final
int
STATE_LOCK
=
2
;
MenuType
(
Integer
value
)
{
/** 菜单类型 */
this
.
value
=
value
;
public
static
final
int
MENU_CATALOG
=
1
;
}
public
Integer
getValue
()
{
public
static
final
int
MENU_MENU
=
2
;
return
value
;
}
}
/**
public
static
final
int
MENU_BUTTON
=
3
;
* 删除状态
*
*/
public
enum
DeleteState
{
/**
* 删除
*/
DELETE
(
0
),
/**
* 正常
*/
NORMAL
(
1
);
private
Integer
value
;
private
DeleteState
(
Integer
value
)
{
this
.
value
=
value
;
}
public
int
getValue
()
{
return
value
;
}
}
}
}
src/main/java/com/govmade/common/utils/MyMetaObjectHandler.java
View file @
5746e67f
...
@@ -24,7 +24,7 @@ public class MyMetaObjectHandler extends MetaObjectHandler {
...
@@ -24,7 +24,7 @@ public class MyMetaObjectHandler extends MetaObjectHandler {
setFieldValByName
(
"createTime"
,
date
,
metaObject
);
setFieldValByName
(
"createTime"
,
date
,
metaObject
);
setFieldValByName
(
"modifyBy"
,
ue
.
getId
(),
metaObject
);
setFieldValByName
(
"modifyBy"
,
ue
.
getId
(),
metaObject
);
setFieldValByName
(
"modifyTime"
,
date
,
metaObject
);
setFieldValByName
(
"modifyTime"
,
date
,
metaObject
);
setFieldValByName
(
"state"
,
1
,
metaObject
);
setFieldValByName
(
"state"
,
Constant
.
STATE_NORMAL
,
metaObject
);
}
}
@Override
@Override
...
...
src/main/java/com/govmade/modules/system/controller/UserController.java
View file @
5746e67f
package
com
.
govmade
.
modules
.
system
.
controller
;
package
com
.
govmade
.
modules
.
system
.
controller
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -10,10 +11,11 @@ import org.springframework.web.bind.annotation.GetMapping;
...
@@ -10,10 +11,11 @@ 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.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
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.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.google.common.collect.Sets
;
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
;
...
@@ -22,9 +24,7 @@ import com.govmade.modules.basic.controller.AbstractController;
...
@@ -22,9 +24,7 @@ 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.core.util.StrUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
io.swagger.annotations.ApiOperation
;
/**
/**
* 系统管理 - 用户设置
* 系统管理 - 用户设置
...
@@ -62,13 +62,13 @@ public class UserController extends AbstractController {
...
@@ -62,13 +62,13 @@ public class UserController extends AbstractController {
* 用户列表
* 用户列表
*/
*/
@GetMapping
(
"/list"
)
@GetMapping
(
"/list"
)
public
R
list
(
@RequestParam
Map
<
String
,
Object
>
params
)
{
public
R
list
(
Map
<
String
,
Object
>
params
)
{
// 只有超级管理员,才能查看所有用户列表
// 只有超级管理员,才能查看所有用户列表
if
(
getUserId
()
==
Constant
.
SUPER_ADMIN
)
{
if
(
getUserId
()
==
Constant
.
SUPER_ADMIN
)
{
params
.
put
(
"createBy"
,
getUserId
());
params
.
put
(
"createBy"
,
getUserId
());
}
else
{
}
else
{
//params.put("deptId", getUser().getDeptId()); // 部门管理员,查看本部门用户列表
//
params.put("deptId", getUser().getDeptId()); // 部门管理员,查看本部门用户列表
}
}
PageUtils
page
=
userService
.
queryPage
(
params
);
PageUtils
page
=
userService
.
queryPage
(
params
);
...
@@ -86,54 +86,59 @@ public class UserController extends AbstractController {
...
@@ -86,54 +86,59 @@ public class UserController extends AbstractController {
public
R
info
(
@PathVariable
(
"id"
)
Long
id
)
{
public
R
info
(
@PathVariable
(
"id"
)
Long
id
)
{
return
R
.
ok
().
put
(
"user"
,
userService
.
queryById
(
id
));
return
R
.
ok
().
put
(
"user"
,
userService
.
queryById
(
id
));
}
}
/**
/**
* 删除、批量删除用户
* 删除、批量删除用户
*
*
* @param ids
* @param ids
* @return
* @return
*/
*/
@DeleteMapping
(
"/delete"
)
@DeleteMapping
(
"/delete"
)
public
R
deleteUser
(
@RequestParam
Set
<
Long
>
ids
)
{
public
R
deleteUser
()
{
Set
<
Long
>
ids
=
Sets
.
newHashSet
();
ids
.
add
(
1L
);
ids
.
add
(
2L
);
userService
.
deleteBatch
(
ids
);
return
R
.
ok
();
}
userService
.
deleteBatchIds
(
ids
);
return
R
.
ok
();
}
/**
/**
* 重置密码
* 重置密码
*
* @param id
* @param id
* @return
* @return
*/
*/
@PostMapping
(
"/reset"
)
@PostMapping
(
"/reset"
)
public
R
reset
(
UserEntity
ue
)
{
public
R
reset
(
UserEntity
ue
)
{
if
(
null
!=
ue
.
getId
())
{
if
(
null
!=
ue
.
getId
())
{
String
password
=
SecureUtil
.
md5
(
"123456"
);
String
password
=
SecureUtil
.
md5
(
"123456"
);
ue
.
setPassword
(
password
);
ue
.
setPassword
(
password
);
userService
.
updateById
(
ue
);
userService
.
updateById
(
ue
);
}
}
return
R
.
ok
();
return
R
.
ok
();
}
}
/**
/**
* 修改登录用户密码
* 修改登录用户密码
*/
*/
@PutMapping
(
"updatePassword"
)
@PutMapping
(
"updatePassword"
)
public
R
password
(
String
password
,
String
newPassword
)
{
public
R
password
(
String
password
,
String
newPassword
)
{
password
=
new
Sha256Hash
(
password
).
toHex
();
password
=
new
Sha256Hash
(
password
).
toHex
();
newPassword
=
new
Sha256Hash
(
newPassword
).
toHex
();
newPassword
=
new
Sha256Hash
(
newPassword
).
toHex
();
//int count = userService.updatePassword(ShiroUtils.getUserId(), password, newPassword);
// int count = userService.updatePassword(ShiroUtils.getUserId(), password,
// if (count == 0) {
// newPassword);
// return R.error("原密码不正确");
// if (count == 0) {
// }
// return R.error("原密码不正确");
// }
ShiroUtils
.
logout
();
ShiroUtils
.
logout
();
return
R
.
ok
();
}
return
R
.
ok
();
}
}
}
src/main/java/com/govmade/modules/system/dao/UserDao.java
View file @
5746e67f
package
com
.
govmade
.
modules
.
system
.
dao
;
package
com
.
govmade
.
modules
.
system
.
dao
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.govmade.modules.system.entity.UserEntity
;
import
com.govmade.modules.system.entity.UserEntity
;
...
@@ -33,4 +35,6 @@ public interface UserDao extends BaseMapper<UserEntity> {
...
@@ -33,4 +35,6 @@ public interface UserDao extends BaseMapper<UserEntity> {
*/
*/
UserEntity
queryByUserName
(
String
username
);
UserEntity
queryByUserName
(
String
username
);
void
deleteBatch
(
@Param
(
"ids"
)
Set
<
Long
>
ids
);
}
}
src/main/java/com/govmade/modules/system/service/UserService.java
View file @
5746e67f
package
com
.
govmade
.
modules
.
system
.
service
;
package
com
.
govmade
.
modules
.
system
.
service
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.common.utils.PageUtils
;
...
@@ -28,7 +29,7 @@ public interface UserService extends IService<UserEntity> {
...
@@ -28,7 +29,7 @@ public interface UserService extends IService<UserEntity> {
/**
/**
* 删除用户
* 删除用户
*/
*/
void
deleteBatch
(
Long
[]
userI
ds
);
void
deleteBatch
(
Set
<
Long
>
i
ds
);
/**
/**
* 修改密码
* 修改密码
...
...
src/main/java/com/govmade/modules/system/service/impl/UserServiceImpl.java
View file @
5746e67f
package
com
.
govmade
.
modules
.
system
.
service
.
impl
;
package
com
.
govmade
.
modules
.
system
.
service
.
impl
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
...
@@ -13,6 +13,7 @@ import com.govmade.modules.system.dao.UserDao;
...
@@ -13,6 +13,7 @@ import com.govmade.modules.system.dao.UserDao;
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.core.util.ArrayUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
/**
/**
...
@@ -49,9 +50,8 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
...
@@ -49,9 +50,8 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
}
}
@Override
@Override
public
void
deleteBatch
(
Long
[]
userIds
)
{
public
void
deleteBatch
(
Set
<
Long
>
ids
)
{
// TODO Auto-generated method stub
this
.
baseMapper
.
deleteBatch
(
ids
);
}
}
@Override
@Override
...
...
src/main/resources/mapper/system/UserDao.xml
View file @
5746e67f
...
@@ -3,8 +3,11 @@
...
@@ -3,8 +3,11 @@
<mapper
namespace=
"com.govmade.modules.system.dao.UserDao"
>
<mapper
namespace=
"com.govmade.modules.system.dao.UserDao"
>
<select
id=
"queryByUserName"
resultType=
"UserEntity"
>
<!-- 批量删除 -->
select * from sys_user where username = #{username}
<update
id=
"deleteBatch"
>
</select>
UPDATE system_users SET state =${@com.govmade.common.utils.Constant@STATE_NORMAL} WHERE id IN
<foreach
collection=
"ids"
item=
"id"
open=
"("
close=
")"
separator=
","
>
#{id}
</foreach>
</update>
</mapper>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment