mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 20:19:16 +08:00
feat(系统设置): 优化用户批量开启的方法
This commit is contained in:
parent
fca0a98267
commit
251f923b43
@ -43,7 +43,6 @@ import jakarta.validation.constraints.NotEmpty;
|
|||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
@ -226,25 +225,20 @@ public class SimpleUserService {
|
|||||||
this.checkProcessUserAndThrowException(request.getSelectIds(), operatorId, operatorName, Translator.get("user.not.disable"));
|
this.checkProcessUserAndThrowException(request.getSelectIds(), operatorId, operatorName, Translator.get("user.not.disable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TableBatchProcessResponse response = new TableBatchProcessResponse();
|
int responseCode = Objects.requireNonNull(CommonBeanFactory.getBean(UserXpackService.class)).guessWhatHowToChangeUser(request.getSelectIds(), request.isEnable(), operatorName);
|
||||||
response.setTotalCount(request.getSelectIds().size());
|
|
||||||
UserExample userExample = new UserExample();
|
|
||||||
userExample.createCriteria().andIdIn(
|
|
||||||
request.getSelectIds()
|
|
||||||
);
|
|
||||||
|
|
||||||
User updateUser = new User();
|
if (responseCode == 0) {
|
||||||
updateUser.setEnable(request.isEnable());
|
TableBatchProcessResponse response = new TableBatchProcessResponse();
|
||||||
updateUser.setUpdateUser(operatorId);
|
response.setTotalCount(request.getSelectIds().size());
|
||||||
updateUser.setUpdateTime(System.currentTimeMillis());
|
response.setSuccessCount(request.getSelectIds().size());
|
||||||
response.setSuccessCount(userMapper.updateByExampleSelective(updateUser, userExample));
|
return response;
|
||||||
|
} else {
|
||||||
if (BooleanUtils.isFalse(request.isEnable())) {
|
if (responseCode == -1) {
|
||||||
//如果是禁用,批量踢出用户
|
throw new MSException(SystemResultCode.USER_TOO_MANY, Translator.getWithArgs("user_open_source_max", 30));
|
||||||
request.getSelectIds().forEach(SessionUtils::kickOutUser);
|
} else {
|
||||||
|
throw new MSException(SystemResultCode.DEPT_USER_TOO_MANY, Translator.getWithArgs("user_dept_max", responseCode));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkUserInDb(List<String> userIdList) {
|
private void checkUserInDb(List<String> userIdList) {
|
||||||
|
@ -4,6 +4,8 @@ import io.metersphere.system.domain.UserInvite;
|
|||||||
import io.metersphere.system.dto.request.UserRegisterRequest;
|
import io.metersphere.system.dto.request.UserRegisterRequest;
|
||||||
import io.metersphere.system.dto.user.request.UserBatchCreateRequest;
|
import io.metersphere.system.dto.user.request.UserBatchCreateRequest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统用户相关接口
|
* 系统用户相关接口
|
||||||
*/
|
*/
|
||||||
@ -12,4 +14,6 @@ public interface UserXpackService {
|
|||||||
int guessWhatHowToAddUser(UserBatchCreateRequest userCreateDTO, String source, String operator);
|
int guessWhatHowToAddUser(UserBatchCreateRequest userCreateDTO, String source, String operator);
|
||||||
|
|
||||||
int guessWhatHowToAddUser(UserRegisterRequest registerRequest, UserInvite userInvite) throws Exception;
|
int guessWhatHowToAddUser(UserRegisterRequest registerRequest, UserInvite userInvite) throws Exception;
|
||||||
|
|
||||||
|
int guessWhatHowToChangeUser(List<String> userIds, boolean enable, String operator);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user