优化用户的查询逻辑,针对逻辑删除
This commit is contained in:
parent
196aac12f3
commit
5ea6c63c32
@ -172,10 +172,9 @@ public class BusinessConstants {
|
||||
public static final byte USER_NOT_MANAGER = 1;
|
||||
/**
|
||||
* 用户状态
|
||||
* 0:正常,1:删除,2封禁
|
||||
* 0:正常,2封禁
|
||||
* */
|
||||
public static final byte USER_STATUS_NORMAL = 0;
|
||||
public static final byte USER_STATUS_DELETE = 1;
|
||||
public static final byte USER_STATUS_BANNED = 2;
|
||||
/**
|
||||
* 日志操作
|
||||
|
||||
@ -26,7 +26,7 @@ public interface UserMapperEx {
|
||||
List<User> getUserListByUserNameOrLoginName(@Param("userName") String userName,
|
||||
@Param("loginName") String loginName);
|
||||
|
||||
int batDeleteOrUpdateUser(@Param("ids") String ids[], @Param("status") byte status);
|
||||
int batDeleteOrUpdateUser(@Param("ids") String[] ids);
|
||||
|
||||
List<TreeNodeEx> getNodeTree();
|
||||
List<TreeNodeEx> getNextNodeTree(Map<String, Object> parameterMap);
|
||||
|
||||
@ -287,9 +287,9 @@ public class UserService {
|
||||
}
|
||||
logService.insertLog("用户", sb.toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
String idsArray[]=ids.split(",");
|
||||
String[] idsArray =ids.split(",");
|
||||
try{
|
||||
result=userMapperEx.batDeleteOrUpdateUser(idsArray,BusinessConstants.USER_STATUS_DELETE);
|
||||
result=userMapperEx.batDeleteOrUpdateUser(idsArray);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
@ -412,7 +412,7 @@ public class UserService {
|
||||
List<User> list = null;
|
||||
try {
|
||||
UserExample example = new UserExample();
|
||||
example.createCriteria().andLoginNameEqualTo(loginName).andStatusNotEqualTo(BusinessConstants.USER_STATUS_DELETE);
|
||||
example.createCriteria().andLoginNameEqualTo(loginName).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
list = userMapper.selectByExample(example);
|
||||
if (null != list && list.size() == 0) {
|
||||
return ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST;
|
||||
@ -438,7 +438,7 @@ public class UserService {
|
||||
try {
|
||||
UserExample example = new UserExample();
|
||||
example.createCriteria().andLoginNameEqualTo(loginName).andPasswordEqualTo(password)
|
||||
.andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
|
||||
.andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
list = userMapper.selectByExample(example);
|
||||
if (null != list && list.size() == 0) {
|
||||
return ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR;
|
||||
@ -452,7 +452,8 @@ public class UserService {
|
||||
|
||||
public User getUserByLoginName(String loginName)throws Exception {
|
||||
UserExample example = new UserExample();
|
||||
example.createCriteria().andLoginNameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
|
||||
example.createCriteria().andLoginNameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL)
|
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<User> list=null;
|
||||
try{
|
||||
list= userMapper.selectByExample(example);
|
||||
@ -468,10 +469,10 @@ public class UserService {
|
||||
|
||||
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||
UserExample example = new UserExample();
|
||||
List <Byte> userStatus=new ArrayList<Byte>();
|
||||
userStatus.add(BusinessConstants.USER_STATUS_DELETE);
|
||||
userStatus.add(BusinessConstants.USER_STATUS_BANNED);
|
||||
example.createCriteria().andIdNotEqualTo(id).andLoginNameEqualTo(name).andStatusNotIn(userStatus);
|
||||
List<Byte> userStatus = new ArrayList<>();
|
||||
userStatus.add(BusinessConstants.USER_STATUS_NORMAL);
|
||||
example.createCriteria().andIdNotEqualTo(id).andLoginNameEqualTo(name).andStatusIn(userStatus)
|
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<User> list=null;
|
||||
try{
|
||||
list= userMapper.selectByExample(example);
|
||||
@ -502,7 +503,8 @@ public class UserService {
|
||||
public Long getIdByLoginName(String loginName) {
|
||||
Long userId = 0L;
|
||||
UserExample example = new UserExample();
|
||||
example.createCriteria().andLoginNameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
|
||||
example.createCriteria().andLoginNameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL)
|
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<User> list = userMapper.selectByExample(example);
|
||||
if(list!=null) {
|
||||
userId = list.get(0).getId();
|
||||
|
||||
@ -72,7 +72,7 @@
|
||||
</select>
|
||||
<update id="batDeleteOrUpdateUser">
|
||||
update jsh_user
|
||||
set status=#{status}
|
||||
set delete_flag = '1'
|
||||
where id in (
|
||||
<foreach collection="ids" item="id" separator=",">
|
||||
#{id}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user