【7.1.6】新增运维平台检测用户接口

pull/26/head
majianguo 2022-01-27 15:16:37 +08:00
parent 8463b0ef26
commit 71a920ada8
4 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1,64 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.system.api.enums;
import lombok.Getter;
/**
*
*
* @author fengshuonan
* @date 2020/11/23 21:30
*/
@Getter
public enum DevopsCheckStatusEnum {
/**
*
*/
USER_NOT_EXIST(0),
/**
*
*/
ACCOUNT_PASSWORD_ERROR(1),
/**
*
*/
REQUESTER_NOT_OPEN_SWITCH(2),
/**
*
*/
SUCCESSFUL(999);
private final Integer code;
DevopsCheckStatusEnum(Integer code) {
this.code = code;
}
}

View File

@ -268,6 +268,19 @@ public class SysUserController {
return new SuccessResponseData<>(sysUserService.getAllUserIdList());
}
/**
*
*
* @return {@link PageResult< Integer>}
* @author majianguo
* @date 2022/1/27 14:29
**/
@GetResource(name = "运维平台接口检测", path = "/sysUser/devopsApiCheck")
public ResponseData<Integer> devopsApiCheck(SysUserRequest sysUserRequest) {
return new SuccessResponseData<>(sysUserService.devopsApiCheck(sysUserRequest));
}
/**
* token
*

View File

@ -263,4 +263,13 @@ public interface SysUserService extends IService<SysUser>, UserServiceApi {
* @date 2022/1/17 15:05
**/
String getTokenByUserId(Long userId);
/**
*
*
* @return {@link Integer}
* @author majianguo
* @date 2022/1/27 14:29
**/
Integer devopsApiCheck(SysUserRequest sysUserRequest);
}

View File

@ -57,6 +57,7 @@ import cn.stylefeng.roses.kernel.system.api.DataScopeApi;
import cn.stylefeng.roses.kernel.system.api.OrganizationServiceApi;
import cn.stylefeng.roses.kernel.system.api.ResourceServiceApi;
import cn.stylefeng.roses.kernel.system.api.RoleServiceApi;
import cn.stylefeng.roses.kernel.system.api.enums.DevopsCheckStatusEnum;
import cn.stylefeng.roses.kernel.system.api.enums.UserStatusEnum;
import cn.stylefeng.roses.kernel.system.api.exception.SystemModularException;
import cn.stylefeng.roses.kernel.system.api.exception.enums.user.SysUserExceptionEnum;
@ -642,6 +643,21 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return jwtToken;
}
@Override
public Integer devopsApiCheck(SysUserRequest sysUserRequest) {
String account = sysUserRequest.getAccount();
String password = sysUserRequest.getPassword();
SysUser sysUser = this.getUserByAccount(account);
if (ObjectUtil.isEmpty(sysUser)) {
return DevopsCheckStatusEnum.USER_NOT_EXIST.getCode();
} else if (!passwordStoredEncryptApi.checkPassword(password, sysUser.getPassword())) {
return DevopsCheckStatusEnum.ACCOUNT_PASSWORD_ERROR.getCode();
} else if (!SystemConfigExpander.getDevSwitchStatus()) {
return DevopsCheckStatusEnum.REQUESTER_NOT_OPEN_SWITCH.getCode();
}
return DevopsCheckStatusEnum.SUCCESSFUL.getCode();
}
@Override
public UserLoginInfoDTO getUserLoginInfo(String account) {