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 org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
@ -226,25 +225,20 @@ public class SimpleUserService {
|
||||
this.checkProcessUserAndThrowException(request.getSelectIds(), operatorId, operatorName, Translator.get("user.not.disable"));
|
||||
}
|
||||
|
||||
TableBatchProcessResponse response = new TableBatchProcessResponse();
|
||||
response.setTotalCount(request.getSelectIds().size());
|
||||
UserExample userExample = new UserExample();
|
||||
userExample.createCriteria().andIdIn(
|
||||
request.getSelectIds()
|
||||
);
|
||||
int responseCode = Objects.requireNonNull(CommonBeanFactory.getBean(UserXpackService.class)).guessWhatHowToChangeUser(request.getSelectIds(), request.isEnable(), operatorName);
|
||||
|
||||
User updateUser = new User();
|
||||
updateUser.setEnable(request.isEnable());
|
||||
updateUser.setUpdateUser(operatorId);
|
||||
updateUser.setUpdateTime(System.currentTimeMillis());
|
||||
response.setSuccessCount(userMapper.updateByExampleSelective(updateUser, userExample));
|
||||
|
||||
if (BooleanUtils.isFalse(request.isEnable())) {
|
||||
//如果是禁用,批量踢出用户
|
||||
request.getSelectIds().forEach(SessionUtils::kickOutUser);
|
||||
if (responseCode == 0) {
|
||||
TableBatchProcessResponse response = new TableBatchProcessResponse();
|
||||
response.setTotalCount(request.getSelectIds().size());
|
||||
response.setSuccessCount(request.getSelectIds().size());
|
||||
return response;
|
||||
} else {
|
||||
if (responseCode == -1) {
|
||||
throw new MSException(SystemResultCode.USER_TOO_MANY, Translator.getWithArgs("user_open_source_max", 30));
|
||||
} else {
|
||||
throw new MSException(SystemResultCode.DEPT_USER_TOO_MANY, Translator.getWithArgs("user_dept_max", responseCode));
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
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.user.request.UserBatchCreateRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统用户相关接口
|
||||
*/
|
||||
@ -12,4 +14,6 @@ public interface UserXpackService {
|
||||
int guessWhatHowToAddUser(UserBatchCreateRequest userCreateDTO, String source, String operator);
|
||||
|
||||
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