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
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
44 additions
and
72 deletions
+44
-72
OAuth2Realm.java
src/main/java/com/govmade/common/oauth2/OAuth2Realm.java
+1
-1
Constant.java
src/main/java/com/govmade/common/utils/Constant.java
+8
-50
MyMetaObjectHandler.java
...in/java/com/govmade/common/utils/MyMetaObjectHandler.java
+1
-1
UserController.java
...com/govmade/modules/system/controller/UserController.java
+16
-11
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 {
throw
new
IncorrectCredentialsException
(
"账号或密码不正确"
);
}
// 账号锁定
if
(
Constant
.
DeleteState
.
DELETE
.
getValue
()
==
ue
.
getState
())
{
if
(
Constant
.
STATE_LOCK
==
ue
.
getState
())
{
throw
new
LockedAccountException
(
"账号已被锁定,请联系管理员"
);
}
...
...
src/main/java/com/govmade/common/utils/Constant.java
View file @
5746e67f
...
...
@@ -12,60 +12,18 @@ public class Constant {
/** 超级管理员ID */
public
static
final
int
SUPER_ADMIN
=
1
;
/**
* 菜单类型
*
* @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_DELETE
=
0
;
MenuType
(
Integer
value
)
{
this
.
value
=
value
;
}
public
static
final
int
STATE_NORMAL
=
1
;
public
Integer
getValue
()
{
return
value
;
}
}
public
static
final
int
STATE_LOCK
=
2
;
/**
* 删除状态
*
*/
public
enum
DeleteState
{
/**
* 删除
*/
DELETE
(
0
),
/**
* 正常
*/
NORMAL
(
1
);
/** 菜单类型 */
public
static
final
int
MENU_CATALOG
=
1
;
private
Integer
value
;
public
static
final
int
MENU_MENU
=
2
;
private
DeleteState
(
Integer
value
)
{
this
.
value
=
value
;
}
public
static
final
int
MENU_BUTTON
=
3
;
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 {
setFieldValByName
(
"createTime"
,
date
,
metaObject
);
setFieldValByName
(
"modifyBy"
,
ue
.
getId
(),
metaObject
);
setFieldValByName
(
"modifyTime"
,
date
,
metaObject
);
setFieldValByName
(
"state"
,
1
,
metaObject
);
setFieldValByName
(
"state"
,
Constant
.
STATE_NORMAL
,
metaObject
);
}
@Override
...
...
src/main/java/com/govmade/modules/system/controller/UserController.java
View file @
5746e67f
package
com
.
govmade
.
modules
.
system
.
controller
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -10,10 +11,11 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
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.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.google.common.collect.Sets
;
import
com.govmade.common.utils.Constant
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.common.utils.R
;
...
...
@@ -22,9 +24,7 @@ import com.govmade.modules.basic.controller.AbstractController;
import
com.govmade.modules.system.entity.UserEntity
;
import
com.govmade.modules.system.service.UserService
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
io.swagger.annotations.ApiOperation
;
/**
* 系统管理 - 用户设置
...
...
@@ -62,13 +62,13 @@ public class UserController extends AbstractController {
* 用户列表
*/
@GetMapping
(
"/list"
)
public
R
list
(
@RequestParam
Map
<
String
,
Object
>
params
)
{
public
R
list
(
Map
<
String
,
Object
>
params
)
{
// 只有超级管理员,才能查看所有用户列表
if
(
getUserId
()
==
Constant
.
SUPER_ADMIN
)
{
params
.
put
(
"createBy"
,
getUserId
());
}
else
{
//params.put("deptId", getUser().getDeptId()); // 部门管理员,查看本部门用户列表
//
params.put("deptId", getUser().getDeptId()); // 部门管理员,查看本部门用户列表
}
PageUtils
page
=
userService
.
queryPage
(
params
);
...
...
@@ -94,14 +94,18 @@ public class UserController extends AbstractController {
* @return
*/
@DeleteMapping
(
"/delete"
)
public
R
deleteUser
(
@RequestParam
Set
<
Long
>
ids
)
{
public
R
deleteUser
(
)
{
userService
.
deleteBatchIds
(
ids
);
Set
<
Long
>
ids
=
Sets
.
newHashSet
();
ids
.
add
(
1L
);
ids
.
add
(
2L
);
userService
.
deleteBatch
(
ids
);
return
R
.
ok
();
}
/**
* 重置密码
*
* @param id
* @return
*/
...
...
@@ -126,10 +130,11 @@ public class UserController extends AbstractController {
password
=
new
Sha256Hash
(
password
).
toHex
();
newPassword
=
new
Sha256Hash
(
newPassword
).
toHex
();
//int count = userService.updatePassword(ShiroUtils.getUserId(), password, newPassword);
// if (count == 0) {
// return R.error("原密码不正确");
// }
// int count = userService.updatePassword(ShiroUtils.getUserId(), password,
// newPassword);
// if (count == 0) {
// return R.error("原密码不正确");
// }
ShiroUtils
.
logout
();
...
...
src/main/java/com/govmade/modules/system/dao/UserDao.java
View file @
5746e67f
package
com
.
govmade
.
modules
.
system
.
dao
;
import
java.util.List
;
import
java.util.Set
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.govmade.modules.system.entity.UserEntity
;
...
...
@@ -33,4 +35,6 @@ public interface UserDao extends BaseMapper<UserEntity> {
*/
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
;
import
java.util.Map
;
import
java.util.Set
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.govmade.common.utils.PageUtils
;
...
...
@@ -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
;
import
java.util.Map
;
import
java.util.Set
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
...
...
@@ -13,6 +13,7 @@ import com.govmade.modules.system.dao.UserDao;
import
com.govmade.modules.system.entity.UserEntity
;
import
com.govmade.modules.system.service.UserService
;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.hutool.core.util.StrUtil
;
/**
...
...
@@ -49,9 +50,8 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
}
@Override
public
void
deleteBatch
(
Long
[]
userIds
)
{
// TODO Auto-generated method stub
public
void
deleteBatch
(
Set
<
Long
>
ids
)
{
this
.
baseMapper
.
deleteBatch
(
ids
);
}
@Override
...
...
src/main/resources/mapper/system/UserDao.xml
View file @
5746e67f
...
...
@@ -3,8 +3,11 @@
<mapper
namespace=
"com.govmade.modules.system.dao.UserDao"
>
<select
id=
"queryByUserName"
resultType=
"UserEntity"
>
select * from sys_user where username = #{username}
</select>
<!-- 批量删除 -->
<update
id=
"deleteBatch"
>
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>
\ 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