You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by do...@apache.org on 2022/07/26 06:59:54 UTC
[inlong] branch master updated: [INLONG-5203][Manager] Refactor the user interface (#5204)
This is an automated email from the ASF dual-hosted git repository.
dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git
The following commit(s) were added to refs/heads/master by this push:
new a64806636 [INLONG-5203][Manager] Refactor the user interface (#5204)
a64806636 is described below
commit a64806636a28b3946c42f98639e002b9d980e76c
Author: healchow <he...@gmail.com>
AuthorDate: Tue Jul 26 14:59:49 2022 +0800
[INLONG-5203][Manager] Refactor the user interface (#5204)
---
.../src/components/StaffSelect/index.tsx | 2 +-
.../src/pages/UserManagement/index.tsx | 2 +-
.../manager/common/pojo/user/UserDetail.java | 55 --
.../manager/common/pojo/user/UserDetailListVO.java | 46 --
.../common/pojo/user/UserDetailPageRequest.java | 35 -
.../inlong/manager/common/pojo/user/UserInfo.java | 68 +-
.../user/{LoginUser.java => UserLoginRequest.java} | 2 +-
.../pojo/user/{UserInfo.java => UserRequest.java} | 45 +-
.../manager/common/pojo/user/UserRoleCode.java | 1 +
.../inlong/manager/common/util/LoginUserUtils.java | 12 +-
.../inlong/manager/dao/entity/UserEntity.java | 9 +-
.../manager/dao/entity/UserEntityExample.java | 801 ---------------------
.../manager/dao/mapper/UserEntityMapper.java | 20 +-
.../main/resources/mappers/UserEntityMapper.xml | 230 ++----
.../service/cluster/InlongClusterServiceImpl.java | 30 +-
.../inlong/manager/service/core/UserService.java | 48 +-
.../service/core/impl/ConsumptionServiceImpl.java | 2 +-
.../manager/service/core/impl/UserServiceImpl.java | 183 +++--
.../core/operationlog/OperationLogRecorder.java | 11 +-
.../main/resources/h2/apache_inlong_manager.sql | 10 +-
.../manager-test/src/main/resources/h2/data.sql | 12 +-
.../manager-web/sql/apache_inlong_manager.sql | 17 +-
.../auth/openapi/OpenAPIAuthenticatingRealm.java | 10 +-
.../manager/web/auth/web/AuthenticationFilter.java | 12 +-
.../manager/web/auth/web/WebAuthorizingRealm.java | 26 +-
.../web/config/ControllerExceptionHandler.java | 40 +-
.../manager/web/controller/AnnoController.java | 25 +-
.../web/controller/ConsumptionController.java | 12 +-
.../manager/web/controller/DataNodeController.java | 6 +-
.../web/controller/InlongClusterController.java | 30 +-
.../web/controller/InlongGroupController.java | 26 +-
.../web/controller/InlongStreamController.java | 22 +-
.../web/controller/StreamSinkController.java | 6 +-
.../web/controller/StreamSourceController.java | 6 +-
.../web/controller/StreamTransformController.java | 6 +-
.../manager/web/controller/UserController.java | 34 +-
.../web/controller/WorkflowApproverController.java | 6 +-
.../manager/web/controller/WorkflowController.java | 24 +-
.../org/apache/inlong/manager/web/WebBaseTest.java | 6 +-
.../manager/web/controller/AnnoControllerTest.java | 40 +-
40 files changed, 456 insertions(+), 1522 deletions(-)
diff --git a/inlong-dashboard/src/components/StaffSelect/index.tsx b/inlong-dashboard/src/components/StaffSelect/index.tsx
index c61a2d96b..30b7559f9 100644
--- a/inlong-dashboard/src/components/StaffSelect/index.tsx
+++ b/inlong-dashboard/src/components/StaffSelect/index.tsx
@@ -106,7 +106,7 @@ const StaffSelect: React.FC<StaffSelectProps> = ({
const { data: staffList, loading, run: getStaffList } = useRequest(
(userName = '') => ({
- url: '/user/listAllUsers',
+ url: '/user/listAll',
params: {
userName,
},
diff --git a/inlong-dashboard/src/pages/UserManagement/index.tsx b/inlong-dashboard/src/pages/UserManagement/index.tsx
index c10ab17e6..cfccfe74b 100644
--- a/inlong-dashboard/src/pages/UserManagement/index.tsx
+++ b/inlong-dashboard/src/pages/UserManagement/index.tsx
@@ -43,7 +43,7 @@ const Comp: React.FC = () => {
const { data, loading, run: getList } = useRequest(
{
- url: '/user/listAllUsers',
+ url: '/user/listAll',
params: options,
},
{
diff --git a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserDetail.java b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserDetail.java
deleted file mode 100644
index ab6c0eaaa..000000000
--- a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserDetail.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.inlong.manager.common.pojo.user;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import java.util.Set;
-
-/**
- * User info
- */
-@ApiModel("User info")
-public class UserDetail {
-
- @ApiModelProperty(value = "username")
- private String username;
-
- @ApiModelProperty(value = "user roles")
- private Set<String> roles;
-
- @ApiModelProperty(value = "Version number")
- private Integer version;
-
- public String getUsername() {
- return username;
- }
-
- public UserDetail setUsername(String username) {
- this.username = username;
- return this;
- }
-
- public Set<String> getRoles() {
- return roles;
- }
-
- public void setRoles(Set<String> roles) {
- this.roles = roles;
- }
-}
diff --git a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserDetailListVO.java b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserDetailListVO.java
deleted file mode 100644
index 50f842371..000000000
--- a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserDetailListVO.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.inlong.manager.common.pojo.user;
-
-import java.util.Date;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-/**
- * User detail list VO.
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-public class UserDetailListVO {
-
- private Integer id;
-
- private String name;
-
- private Integer accountType;
-
- private Date createTime;
-
- private String createBy;
-
- private String status;
-
- private Date dueDate;
-
- private Integer version;
-}
diff --git a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserDetailPageRequest.java b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserDetailPageRequest.java
deleted file mode 100644
index 7de70018f..000000000
--- a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserDetailPageRequest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.inlong.manager.common.pojo.user;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import org.apache.inlong.manager.common.beans.PageRequest;
-
-/**
- * User detail page request.
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-public class UserDetailPageRequest extends PageRequest {
-
- public String username;
-
- public Integer type;
-
-}
diff --git a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserInfo.java b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserInfo.java
index c514915ec..fa8fda326 100644
--- a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserInfo.java
+++ b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserInfo.java
@@ -17,63 +17,73 @@
package org.apache.inlong.manager.common.pojo.user;
+import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
import lombok.Data;
-import lombok.NoArgsConstructor;
-import org.apache.inlong.manager.common.enums.UserTypeEnum;
-import org.apache.inlong.manager.common.validation.InEnumInt;
import javax.validation.constraints.Min;
-import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
+import java.util.Date;
+import java.util.Set;
/**
- * User info, including username, password, etc.
+ * User info
*/
@Data
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
@ApiModel("User info")
public class UserInfo {
+ @ApiModelProperty(value = "Primary key")
private Integer id;
- /**
- * User type {@link UserTypeEnum}
- */
- @NotNull(message = "type cannot be null")
- @InEnumInt(UserTypeEnum.class)
- @ApiModelProperty(value = "type: 0 - manager, 1 - operator", required = true)
- private Integer type;
+ @ApiModelProperty(value = "Username")
+ private String name;
- @NotBlank(message = "username cannot be blank")
- @ApiModelProperty(value = "username", required = true)
- private String username;
-
- @ApiModelProperty(value = "password")
+ @ApiModelProperty(value = "User password")
private String password;
- @ApiModelProperty(value = "newPassword")
- private String newPassword;
-
- @ApiModelProperty("secret key")
+ @ApiModelProperty("Secret key")
private String secretKey;
- @ApiModelProperty("public key")
+ @ApiModelProperty("Public key")
private String publicKey;
- @ApiModelProperty("private key")
+ @ApiModelProperty("Private key")
private String privateKey;
+ @ApiModelProperty("Encryption key version")
+ private Integer encryptVersion;
+
+ @ApiModelProperty(value = "Account type: 0 - manager, 1 - operator", required = true)
+ private Integer accountType;
+
@Min(1)
@NotNull(message = "validDays cannot be null")
- @ApiModelProperty(value = "valid days", required = true)
+ @ApiModelProperty(value = "Valid days", required = true)
private Integer validDays;
+ @ApiModelProperty(value = "Name of creator")
+ private String creator;
+
+ @ApiModelProperty(value = "Name of modifier")
+ private String modifier;
+
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date createTime;
+
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date modifyTime;
+
+ @ApiModelProperty(value = "User status, valid or not")
+ private String status;
+
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date dueDate;
+
+ @ApiModelProperty(value = "User roles")
+ private Set<String> roles;
+
@ApiModelProperty(value = "Version number")
private Integer version;
diff --git a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/LoginUser.java b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserLoginRequest.java
similarity index 97%
rename from inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/LoginUser.java
rename to inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserLoginRequest.java
index 4583dfe55..8e6fd4930 100644
--- a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/LoginUser.java
+++ b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserLoginRequest.java
@@ -28,7 +28,7 @@ import javax.validation.constraints.NotBlank;
*/
@Data
@ApiModel("Login user and password")
-public class LoginUser {
+public class UserLoginRequest {
@NotBlank
@ApiModelProperty(value = "username", required = true)
diff --git a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserInfo.java b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserRequest.java
similarity index 62%
copy from inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserInfo.java
copy to inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserRequest.java
index c514915ec..b58f95fa0 100644
--- a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserInfo.java
+++ b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserRequest.java
@@ -22,7 +22,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
+import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
+import org.apache.inlong.manager.common.beans.PageRequest;
import org.apache.inlong.manager.common.enums.UserTypeEnum;
import org.apache.inlong.manager.common.validation.InEnumInt;
@@ -31,47 +33,52 @@ import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
- * User info, including username, password, etc.
+ * User info request
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
-@ApiModel("User info")
-public class UserInfo {
+@EqualsAndHashCode(callSuper = false)
+@ApiModel("User info request")
+public class UserRequest extends PageRequest {
+ @ApiModelProperty(value = "Primary key")
private Integer id;
- /**
- * User type {@link UserTypeEnum}
- */
- @NotNull(message = "type cannot be null")
- @InEnumInt(UserTypeEnum.class)
- @ApiModelProperty(value = "type: 0 - manager, 1 - operator", required = true)
- private Integer type;
+ @NotBlank(message = "User name cannot be blank")
+ @ApiModelProperty(value = "User name", required = true)
+ private String name;
- @NotBlank(message = "username cannot be blank")
- @ApiModelProperty(value = "username", required = true)
- private String username;
+ @ApiModelProperty(value = "Keyword, can be user name")
+ private String keyword;
- @ApiModelProperty(value = "password")
+ @ApiModelProperty(value = "User password")
private String password;
- @ApiModelProperty(value = "newPassword")
+ @ApiModelProperty(value = "New password, is required if needs updated")
private String newPassword;
- @ApiModelProperty("secret key")
+ @ApiModelProperty("Secret key")
private String secretKey;
- @ApiModelProperty("public key")
+ @ApiModelProperty("Public key")
private String publicKey;
- @ApiModelProperty("private key")
+ @ApiModelProperty("Private key")
private String privateKey;
+ @ApiModelProperty("Encryption key version")
+ private Integer encryptVersion;
+
+ @NotNull(message = "accountType cannot be null")
+ @InEnumInt(UserTypeEnum.class)
+ @ApiModelProperty(value = "Account type: 0 - manager, 1 - operator", required = true)
+ private Integer accountType;
+
@Min(1)
@NotNull(message = "validDays cannot be null")
- @ApiModelProperty(value = "valid days", required = true)
+ @ApiModelProperty(value = "Valid days", required = true)
private Integer validDays;
@ApiModelProperty(value = "Version number")
diff --git a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserRoleCode.java b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserRoleCode.java
index aea10be85..1ced91ec5 100644
--- a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserRoleCode.java
+++ b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/user/UserRoleCode.java
@@ -24,4 +24,5 @@ public class UserRoleCode {
public static final String ADMIN = "ADMIN";
public static final String OPERATOR = "OPERATE";
+
}
diff --git a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/util/LoginUserUtils.java b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/util/LoginUserUtils.java
index 9b6621dfc..2ff999ac4 100644
--- a/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/util/LoginUserUtils.java
+++ b/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/util/LoginUserUtils.java
@@ -18,7 +18,7 @@
package org.apache.inlong.manager.common.util;
import lombok.extern.slf4j.Slf4j;
-import org.apache.inlong.manager.common.pojo.user.UserDetail;
+import org.apache.inlong.manager.common.pojo.user.UserInfo;
/**
* User info for login
@@ -29,15 +29,15 @@ public class LoginUserUtils {
/**
* ThreadLocal for user info
*/
- private static final ThreadLocal<UserDetail> LOGIN_USER_DETAIL_TL = new ThreadLocal<>();
+ private static final ThreadLocal<UserInfo> LOGIN_USER_DETAIL_TL = new ThreadLocal<>();
- public static UserDetail getLoginUserDetail() {
+ public static UserInfo getLoginUser() {
return LOGIN_USER_DETAIL_TL.get();
}
- public static void setUserLoginInfo(UserDetail userDetail) {
- log.debug("user login: {}", userDetail.getUsername());
- LOGIN_USER_DETAIL_TL.set(userDetail);
+ public static void setUserLoginInfo(UserInfo userInfo) {
+ log.debug("user login: {}", userInfo.getName());
+ LOGIN_USER_DETAIL_TL.set(userInfo);
}
public static void removeUserLoginInfo() {
diff --git a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/UserEntity.java b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/UserEntity.java
index 38cddbad0..e1cf5c3a3 100644
--- a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/UserEntity.java
+++ b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/UserEntity.java
@@ -38,9 +38,12 @@ public class UserEntity implements Serializable {
private Integer encryptVersion;
private Integer accountType;
private Date dueDate;
+
+ private Integer status;
+ private Integer isDeleted;
+ private String creator;
+ private String modifier;
private Date createTime;
- private Date updateTime;
- private String createBy;
- private String updateBy;
+ private Date modifyTime;
private Integer version;
}
diff --git a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/UserEntityExample.java b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/UserEntityExample.java
deleted file mode 100644
index 1e7d5e6a7..000000000
--- a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/UserEntityExample.java
+++ /dev/null
@@ -1,801 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.inlong.manager.dao.entity;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-public class UserEntityExample {
-
- protected String orderByClause;
-
- protected boolean distinct;
-
- protected List<Criteria> oredCriteria;
-
- public UserEntityExample() {
- oredCriteria = new ArrayList<>();
- }
-
- public String getOrderByClause() {
- return orderByClause;
- }
-
- public void setOrderByClause(String orderByClause) {
- this.orderByClause = orderByClause;
- }
-
- public boolean isDistinct() {
- return distinct;
- }
-
- public void setDistinct(boolean distinct) {
- this.distinct = distinct;
- }
-
- public List<Criteria> getOredCriteria() {
- return oredCriteria;
- }
-
- public void or(Criteria criteria) {
- oredCriteria.add(criteria);
- }
-
- public Criteria or() {
- Criteria criteria = createCriteriaInternal();
- oredCriteria.add(criteria);
- return criteria;
- }
-
- public Criteria createCriteria() {
- Criteria criteria = createCriteriaInternal();
- if (oredCriteria.size() == 0) {
- oredCriteria.add(criteria);
- }
- return criteria;
- }
-
- protected Criteria createCriteriaInternal() {
- Criteria criteria = new Criteria();
- return criteria;
- }
-
- public void clear() {
- oredCriteria.clear();
- orderByClause = null;
- distinct = false;
- }
-
- protected abstract static class GeneratedCriteria {
-
- protected List<Criterion> criteria;
-
- protected GeneratedCriteria() {
- super();
- criteria = new ArrayList<>();
- }
-
- public boolean isValid() {
- return criteria.size() > 0;
- }
-
- public List<Criterion> getAllCriteria() {
- return criteria;
- }
-
- public List<Criterion> getCriteria() {
- return criteria;
- }
-
- protected void addCriterion(String condition) {
- if (condition == null) {
- throw new RuntimeException("Value for condition cannot be null");
- }
- criteria.add(new Criterion(condition));
- }
-
- protected void addCriterion(String condition, Object value, String property) {
- if (value == null) {
- throw new RuntimeException("Value for " + property + " cannot be null");
- }
- criteria.add(new Criterion(condition, value));
- }
-
- protected void addCriterion(String condition, Object value1, Object value2, String property) {
- if (value1 == null || value2 == null) {
- throw new RuntimeException("Between values for " + property + " cannot be null");
- }
- criteria.add(new Criterion(condition, value1, value2));
- }
-
- public Criteria andIdIsNull() {
- addCriterion("id is null");
- return (Criteria) this;
- }
-
- public Criteria andIdIsNotNull() {
- addCriterion("id is not null");
- return (Criteria) this;
- }
-
- public Criteria andIdEqualTo(Integer value) {
- addCriterion("id =", value, "id");
- return (Criteria) this;
- }
-
- public Criteria andIdNotEqualTo(Integer value) {
- addCriterion("id <>", value, "id");
- return (Criteria) this;
- }
-
- public Criteria andIdGreaterThan(Integer value) {
- addCriterion("id >", value, "id");
- return (Criteria) this;
- }
-
- public Criteria andIdGreaterThanOrEqualTo(Integer value) {
- addCriterion("id >=", value, "id");
- return (Criteria) this;
- }
-
- public Criteria andIdLessThan(Integer value) {
- addCriterion("id <", value, "id");
- return (Criteria) this;
- }
-
- public Criteria andIdLessThanOrEqualTo(Integer value) {
- addCriterion("id <=", value, "id");
- return (Criteria) this;
- }
-
- public Criteria andIdIn(List<Integer> values) {
- addCriterion("id in", values, "id");
- return (Criteria) this;
- }
-
- public Criteria andIdNotIn(List<Integer> values) {
- addCriterion("id not in", values, "id");
- return (Criteria) this;
- }
-
- public Criteria andIdBetween(Integer value1, Integer value2) {
- addCriterion("id between", value1, value2, "id");
- return (Criteria) this;
- }
-
- public Criteria andIdNotBetween(Integer value1, Integer value2) {
- addCriterion("id not between", value1, value2, "id");
- return (Criteria) this;
- }
-
- public Criteria andNameIsNull() {
- addCriterion("name is null");
- return (Criteria) this;
- }
-
- public Criteria andNameIsNotNull() {
- addCriterion("name is not null");
- return (Criteria) this;
- }
-
- public Criteria andNameEqualTo(String value) {
- addCriterion("name =", value, "name");
- return (Criteria) this;
- }
-
- public Criteria andNameNotEqualTo(String value) {
- addCriterion("name <>", value, "name");
- return (Criteria) this;
- }
-
- public Criteria andNameGreaterThan(String value) {
- addCriterion("name >", value, "name");
- return (Criteria) this;
- }
-
- public Criteria andNameGreaterThanOrEqualTo(String value) {
- addCriterion("name >=", value, "name");
- return (Criteria) this;
- }
-
- public Criteria andNameLessThan(String value) {
- addCriterion("name <", value, "name");
- return (Criteria) this;
- }
-
- public Criteria andNameLessThanOrEqualTo(String value) {
- addCriterion("name <=", value, "name");
- return (Criteria) this;
- }
-
- public Criteria andNameLike(String value) {
- addCriterion("name like", value, "name");
- return (Criteria) this;
- }
-
- public Criteria andNameNotLike(String value) {
- addCriterion("name not like", value, "name");
- return (Criteria) this;
- }
-
- public Criteria andNameIn(List<String> values) {
- addCriterion("name in", values, "name");
- return (Criteria) this;
- }
-
- public Criteria andNameNotIn(List<String> values) {
- addCriterion("name not in", values, "name");
- return (Criteria) this;
- }
-
- public Criteria andNameBetween(String value1, String value2) {
- addCriterion("name between", value1, value2, "name");
- return (Criteria) this;
- }
-
- public Criteria andNameNotBetween(String value1, String value2) {
- addCriterion("name not between", value1, value2, "name");
- return (Criteria) this;
- }
-
- public Criteria andPasswordIsNull() {
- addCriterion("password is null");
- return (Criteria) this;
- }
-
- public Criteria andPasswordIsNotNull() {
- addCriterion("password is not null");
- return (Criteria) this;
- }
-
- public Criteria andPasswordEqualTo(String value) {
- addCriterion("password =", value, "password");
- return (Criteria) this;
- }
-
- public Criteria andPasswordNotEqualTo(String value) {
- addCriterion("password <>", value, "password");
- return (Criteria) this;
- }
-
- public Criteria andPasswordGreaterThan(String value) {
- addCriterion("password >", value, "password");
- return (Criteria) this;
- }
-
- public Criteria andPasswordGreaterThanOrEqualTo(String value) {
- addCriterion("password >=", value, "password");
- return (Criteria) this;
- }
-
- public Criteria andPasswordLessThan(String value) {
- addCriterion("password <", value, "password");
- return (Criteria) this;
- }
-
- public Criteria andPasswordLessThanOrEqualTo(String value) {
- addCriterion("password <=", value, "password");
- return (Criteria) this;
- }
-
- public Criteria andPasswordLike(String value) {
- addCriterion("password like", value, "password");
- return (Criteria) this;
- }
-
- public Criteria andPasswordNotLike(String value) {
- addCriterion("password not like", value, "password");
- return (Criteria) this;
- }
-
- public Criteria andPasswordIn(List<String> values) {
- addCriterion("password in", values, "password");
- return (Criteria) this;
- }
-
- public Criteria andPasswordNotIn(List<String> values) {
- addCriterion("password not in", values, "password");
- return (Criteria) this;
- }
-
- public Criteria andPasswordBetween(String value1, String value2) {
- addCriterion("password between", value1, value2, "password");
- return (Criteria) this;
- }
-
- public Criteria andPasswordNotBetween(String value1, String value2) {
- addCriterion("password not between", value1, value2, "password");
- return (Criteria) this;
- }
-
- public Criteria andAccountTypeIsNull() {
- addCriterion("account_type is null");
- return (Criteria) this;
- }
-
- public Criteria andAccountTypeIsNotNull() {
- addCriterion("account_type is not null");
- return (Criteria) this;
- }
-
- public Criteria andAccountTypeEqualTo(Integer value) {
- addCriterion("account_type =", value, "accountType");
- return (Criteria) this;
- }
-
- public Criteria andAccountTypeNotEqualTo(Integer value) {
- addCriterion("account_type <>", value, "accountType");
- return (Criteria) this;
- }
-
- public Criteria andAccountTypeGreaterThan(Integer value) {
- addCriterion("account_type >", value, "accountType");
- return (Criteria) this;
- }
-
- public Criteria andAccountTypeGreaterThanOrEqualTo(Integer value) {
- addCriterion("account_type >=", value, "accountType");
- return (Criteria) this;
- }
-
- public Criteria andAccountTypeLessThan(Integer value) {
- addCriterion("account_type <", value, "accountType");
- return (Criteria) this;
- }
-
- public Criteria andAccountTypeLessThanOrEqualTo(Integer value) {
- addCriterion("account_type <=", value, "accountType");
- return (Criteria) this;
- }
-
- public Criteria andAccountTypeIn(List<Integer> values) {
- addCriterion("account_type in", values, "accountType");
- return (Criteria) this;
- }
-
- public Criteria andAccountTypeNotIn(List<Integer> values) {
- addCriterion("account_type not in", values, "accountType");
- return (Criteria) this;
- }
-
- public Criteria andAccountTypeBetween(Integer value1, Integer value2) {
- addCriterion("account_type between", value1, value2, "accountType");
- return (Criteria) this;
- }
-
- public Criteria andAccountTypeNotBetween(Integer value1, Integer value2) {
- addCriterion("account_type not between", value1, value2, "accountType");
- return (Criteria) this;
- }
-
- public Criteria andDueDateIsNull() {
- addCriterion("due_date is null");
- return (Criteria) this;
- }
-
- public Criteria andDueDateIsNotNull() {
- addCriterion("due_date is not null");
- return (Criteria) this;
- }
-
- public Criteria andDueDateEqualTo(Date value) {
- addCriterion("due_date =", value, "dueDate");
- return (Criteria) this;
- }
-
- public Criteria andDueDateNotEqualTo(Date value) {
- addCriterion("due_date <>", value, "dueDate");
- return (Criteria) this;
- }
-
- public Criteria andDueDateGreaterThan(Date value) {
- addCriterion("due_date >", value, "dueDate");
- return (Criteria) this;
- }
-
- public Criteria andDueDateGreaterThanOrEqualTo(Date value) {
- addCriterion("due_date >=", value, "dueDate");
- return (Criteria) this;
- }
-
- public Criteria andDueDateLessThan(Date value) {
- addCriterion("due_date <", value, "dueDate");
- return (Criteria) this;
- }
-
- public Criteria andDueDateLessThanOrEqualTo(Date value) {
- addCriterion("due_date <=", value, "dueDate");
- return (Criteria) this;
- }
-
- public Criteria andDueDateIn(List<Date> values) {
- addCriterion("due_date in", values, "dueDate");
- return (Criteria) this;
- }
-
- public Criteria andDueDateNotIn(List<Date> values) {
- addCriterion("due_date not in", values, "dueDate");
- return (Criteria) this;
- }
-
- public Criteria andDueDateBetween(Date value1, Date value2) {
- addCriterion("due_date between", value1, value2, "dueDate");
- return (Criteria) this;
- }
-
- public Criteria andDueDateNotBetween(Date value1, Date value2) {
- addCriterion("due_date not between", value1, value2, "dueDate");
- return (Criteria) this;
- }
-
- public Criteria andCreateTimeIsNull() {
- addCriterion("create_time is null");
- return (Criteria) this;
- }
-
- public Criteria andCreateTimeIsNotNull() {
- addCriterion("create_time is not null");
- return (Criteria) this;
- }
-
- public Criteria andCreateTimeEqualTo(Date value) {
- addCriterion("create_time =", value, "createTime");
- return (Criteria) this;
- }
-
- public Criteria andCreateTimeNotEqualTo(Date value) {
- addCriterion("create_time <>", value, "createTime");
- return (Criteria) this;
- }
-
- public Criteria andCreateTimeGreaterThan(Date value) {
- addCriterion("create_time >", value, "createTime");
- return (Criteria) this;
- }
-
- public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
- addCriterion("create_time >=", value, "createTime");
- return (Criteria) this;
- }
-
- public Criteria andCreateTimeLessThan(Date value) {
- addCriterion("create_time <", value, "createTime");
- return (Criteria) this;
- }
-
- public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
- addCriterion("create_time <=", value, "createTime");
- return (Criteria) this;
- }
-
- public Criteria andCreateTimeIn(List<Date> values) {
- addCriterion("create_time in", values, "createTime");
- return (Criteria) this;
- }
-
- public Criteria andCreateTimeNotIn(List<Date> values) {
- addCriterion("create_time not in", values, "createTime");
- return (Criteria) this;
- }
-
- public Criteria andCreateTimeBetween(Date value1, Date value2) {
- addCriterion("create_time between", value1, value2, "createTime");
- return (Criteria) this;
- }
-
- public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
- addCriterion("create_time not between", value1, value2, "createTime");
- return (Criteria) this;
- }
-
- public Criteria andUpdateTimeIsNull() {
- addCriterion("update_time is null");
- return (Criteria) this;
- }
-
- public Criteria andUpdateTimeIsNotNull() {
- addCriterion("update_time is not null");
- return (Criteria) this;
- }
-
- public Criteria andUpdateTimeEqualTo(Date value) {
- addCriterion("update_time =", value, "updateTime");
- return (Criteria) this;
- }
-
- public Criteria andUpdateTimeNotEqualTo(Date value) {
- addCriterion("update_time <>", value, "updateTime");
- return (Criteria) this;
- }
-
- public Criteria andUpdateTimeGreaterThan(Date value) {
- addCriterion("update_time >", value, "updateTime");
- return (Criteria) this;
- }
-
- public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
- addCriterion("update_time >=", value, "updateTime");
- return (Criteria) this;
- }
-
- public Criteria andUpdateTimeLessThan(Date value) {
- addCriterion("update_time <", value, "updateTime");
- return (Criteria) this;
- }
-
- public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
- addCriterion("update_time <=", value, "updateTime");
- return (Criteria) this;
- }
-
- public Criteria andUpdateTimeIn(List<Date> values) {
- addCriterion("update_time in", values, "updateTime");
- return (Criteria) this;
- }
-
- public Criteria andUpdateTimeNotIn(List<Date> values) {
- addCriterion("update_time not in", values, "updateTime");
- return (Criteria) this;
- }
-
- public Criteria andUpdateTimeBetween(Date value1, Date value2) {
- addCriterion("update_time between", value1, value2, "updateTime");
- return (Criteria) this;
- }
-
- public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
- addCriterion("update_time not between", value1, value2, "updateTime");
- return (Criteria) this;
- }
-
- public Criteria andCreateByIsNull() {
- addCriterion("create_by is null");
- return (Criteria) this;
- }
-
- public Criteria andCreateByIsNotNull() {
- addCriterion("create_by is not null");
- return (Criteria) this;
- }
-
- public Criteria andCreateByEqualTo(String value) {
- addCriterion("create_by =", value, "createBy");
- return (Criteria) this;
- }
-
- public Criteria andCreateByNotEqualTo(String value) {
- addCriterion("create_by <>", value, "createBy");
- return (Criteria) this;
- }
-
- public Criteria andCreateByGreaterThan(String value) {
- addCriterion("create_by >", value, "createBy");
- return (Criteria) this;
- }
-
- public Criteria andCreateByGreaterThanOrEqualTo(String value) {
- addCriterion("create_by >=", value, "createBy");
- return (Criteria) this;
- }
-
- public Criteria andCreateByLessThan(String value) {
- addCriterion("create_by <", value, "createBy");
- return (Criteria) this;
- }
-
- public Criteria andCreateByLessThanOrEqualTo(String value) {
- addCriterion("create_by <=", value, "createBy");
- return (Criteria) this;
- }
-
- public Criteria andCreateByLike(String value) {
- addCriterion("create_by like", value, "createBy");
- return (Criteria) this;
- }
-
- public Criteria andCreateByNotLike(String value) {
- addCriterion("create_by not like", value, "createBy");
- return (Criteria) this;
- }
-
- public Criteria andCreateByIn(List<String> values) {
- addCriterion("create_by in", values, "createBy");
- return (Criteria) this;
- }
-
- public Criteria andCreateByNotIn(List<String> values) {
- addCriterion("create_by not in", values, "createBy");
- return (Criteria) this;
- }
-
- public Criteria andCreateByBetween(String value1, String value2) {
- addCriterion("create_by between", value1, value2, "createBy");
- return (Criteria) this;
- }
-
- public Criteria andCreateByNotBetween(String value1, String value2) {
- addCriterion("create_by not between", value1, value2, "createBy");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByIsNull() {
- addCriterion("update_by is null");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByIsNotNull() {
- addCriterion("update_by is not null");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByEqualTo(String value) {
- addCriterion("update_by =", value, "updateBy");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByNotEqualTo(String value) {
- addCriterion("update_by <>", value, "updateBy");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByGreaterThan(String value) {
- addCriterion("update_by >", value, "updateBy");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByGreaterThanOrEqualTo(String value) {
- addCriterion("update_by >=", value, "updateBy");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByLessThan(String value) {
- addCriterion("update_by <", value, "updateBy");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByLessThanOrEqualTo(String value) {
- addCriterion("update_by <=", value, "updateBy");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByLike(String value) {
- addCriterion("update_by like", value, "updateBy");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByNotLike(String value) {
- addCriterion("update_by not like", value, "updateBy");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByIn(List<String> values) {
- addCriterion("update_by in", values, "updateBy");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByNotIn(List<String> values) {
- addCriterion("update_by not in", values, "updateBy");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByBetween(String value1, String value2) {
- addCriterion("update_by between", value1, value2, "updateBy");
- return (Criteria) this;
- }
-
- public Criteria andUpdateByNotBetween(String value1, String value2) {
- addCriterion("update_by not between", value1, value2, "updateBy");
- return (Criteria) this;
- }
- }
-
- public static class Criteria extends GeneratedCriteria {
-
- protected Criteria() {
- super();
- }
- }
-
- public static class Criterion {
-
- private String condition;
-
- private Object value;
-
- private Object secondValue;
-
- private boolean noValue;
-
- private boolean singleValue;
-
- private boolean betweenValue;
-
- private boolean listValue;
-
- private String typeHandler;
-
- protected Criterion(String condition) {
- super();
- this.condition = condition;
- this.typeHandler = null;
- this.noValue = true;
- }
-
- protected Criterion(String condition, Object value, String typeHandler) {
- super();
- this.condition = condition;
- this.value = value;
- this.typeHandler = typeHandler;
- if (value instanceof List<?>) {
- this.listValue = true;
- } else {
- this.singleValue = true;
- }
- }
-
- protected Criterion(String condition, Object value) {
- this(condition, value, null);
- }
-
- protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
- super();
- this.condition = condition;
- this.value = value;
- this.secondValue = secondValue;
- this.typeHandler = typeHandler;
- this.betweenValue = true;
- }
-
- protected Criterion(String condition, Object value, Object secondValue) {
- this(condition, value, secondValue, null);
- }
-
- public String getCondition() {
- return condition;
- }
-
- public Object getValue() {
- return value;
- }
-
- public Object getSecondValue() {
- return secondValue;
- }
-
- public boolean isNoValue() {
- return noValue;
- }
-
- public boolean isSingleValue() {
- return singleValue;
- }
-
- public boolean isBetweenValue() {
- return betweenValue;
- }
-
- public boolean isListValue() {
- return listValue;
- }
-
- public String getTypeHandler() {
- return typeHandler;
- }
- }
-}
\ No newline at end of file
diff --git a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/UserEntityMapper.java b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/UserEntityMapper.java
index 51b282909..9cd23a631 100644
--- a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/UserEntityMapper.java
+++ b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/UserEntityMapper.java
@@ -17,27 +17,25 @@
package org.apache.inlong.manager.dao.mapper;
-import java.util.List;
+import org.apache.inlong.manager.common.pojo.user.UserRequest;
import org.apache.inlong.manager.dao.entity.UserEntity;
-import org.apache.inlong.manager.dao.entity.UserEntityExample;
import org.springframework.stereotype.Repository;
+import java.util.List;
+
@Repository
public interface UserEntityMapper {
- long countByExample(UserEntityExample example);
-
- int deleteByPrimaryKey(Integer id);
-
int insert(UserEntity record);
- int insertSelective(UserEntity record);
+ UserEntity selectById(Integer id);
+
+ UserEntity selectByName(String name);
- List<UserEntity> selectByExample(UserEntityExample example);
+ List<UserEntity> selectByCondition(UserRequest request);
- UserEntity selectByPrimaryKey(Integer id);
+ int updateById(UserEntity record);
- int updateByPrimaryKeySelective(UserEntity record);
+ int deleteById(Integer id);
- int updateByPrimaryKey(UserEntity record);
}
\ No newline at end of file
diff --git a/inlong-manager/manager-dao/src/main/resources/mappers/UserEntityMapper.xml b/inlong-manager/manager-dao/src/main/resources/mappers/UserEntityMapper.xml
index 8be6445d7..7e8315ac6 100644
--- a/inlong-manager/manager-dao/src/main/resources/mappers/UserEntityMapper.xml
+++ b/inlong-manager/manager-dao/src/main/resources/mappers/UserEntityMapper.xml
@@ -30,201 +30,64 @@
<result column="encrypt_version" jdbcType="INTEGER" property="encryptVersion"/>
<result column="account_type" jdbcType="INTEGER" property="accountType"/>
<result column="due_date" jdbcType="TIMESTAMP" property="dueDate"/>
+ <result column="status" jdbcType="INTEGER" property="status"/>
+ <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
+ <result column="creator" jdbcType="VARCHAR" property="creator"/>
+ <result column="modifier" jdbcType="VARCHAR" property="modifier"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
- <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
- <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
+ <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
<result column="version" jdbcType="INTEGER" property="version"/>
</resultMap>
- <sql id="Example_Where_Clause">
- <where>
- <foreach collection="oredCriteria" item="criteria" separator="or">
- <if test="criteria.valid">
- <trim prefix="(" prefixOverrides="and" suffix=")">
- <foreach collection="criteria.criteria" item="criterion">
- <choose>
- <when test="criterion.noValue">
- and ${criterion.condition}
- </when>
- <when test="criterion.singleValue">
- and ${criterion.condition} #{criterion.value}
- </when>
- <when test="criterion.betweenValue">
- and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
- </when>
- <when test="criterion.listValue">
- and ${criterion.condition}
- <foreach close=")" collection="criterion.value" item="listItem" open="("
- separator=",">
- #{listItem}
- </foreach>
- </when>
- </choose>
- </foreach>
- </trim>
- </if>
- </foreach>
- </where>
- </sql>
<sql id="Base_Column_List">
- id, name, password, secret_key, public_key, private_key, encrypt_version,
- account_type, due_date, create_time, update_time, create_by, update_by, version
+ id, account_type, name, password, secret_key, public_key, private_key, encrypt_version,
+ due_date, status, is_deleted, creator, modifier, create_time, modify_time, version
</sql>
- <select id="selectByExample" parameterType="org.apache.inlong.manager.dao.entity.UserEntityExample"
- resultMap="BaseResultMap">
+
+ <insert id="insert" useGeneratedKeys="true" keyProperty="id"
+ parameterType="org.apache.inlong.manager.dao.entity.UserEntity">
+ insert into user (id, name, password,
+ secret_key, public_key, private_key,
+ encrypt_version, account_type, due_date,
+ status, creator, modifier)
+ values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
+ #{secretKey,jdbcType=VARCHAR}, #{publicKey,jdbcType=VARCHAR}, #{privateKey,jdbcType=VARCHAR},
+ #{encryptVersion,jdbcType=INTEGER}, #{accountType,jdbcType=INTEGER}, #{dueDate,jdbcType=TIMESTAMP},
+ #{status,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
+ </insert>
+
+ <select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
- <if test="distinct">
- distinct
- </if>
<include refid="Base_Column_List"/>
from user
- <if test="_parameter != null">
- <include refid="Example_Where_Clause"/>
- </if>
- <if test="orderByClause != null">
- order by ${orderByClause}
- </if>
+ where id = #{id,jdbcType=INTEGER}
</select>
- <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+ <select id="selectByName" resultType="org.apache.inlong.manager.dao.entity.UserEntity">
select
<include refid="Base_Column_List"/>
from user
- where id = #{id,jdbcType=INTEGER}
+ where is_deleted = 0
+ and name = #{name, jdbcType=VARCHAR}
</select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
- delete
+ <select id="selectByCondition" parameterType="org.apache.inlong.manager.common.pojo.user.UserRequest"
+ resultType="org.apache.inlong.manager.dao.entity.UserEntity">
+ select
+ <include refid="Base_Column_List"/>
from user
- where id = #{id,jdbcType=INTEGER}
- </delete>
- <insert id="insert" parameterType="org.apache.inlong.manager.dao.entity.UserEntity">
- insert into user (id, name, password,
- secret_key, public_key, private_key,
- encrypt_version, account_type, due_date,
- create_by, update_by)
- values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
- #{secretKey,jdbcType=VARCHAR}, #{publicKey,jdbcType=VARCHAR}, #{privateKey,jdbcType=VARCHAR},
- #{encryptVersion,jdbcType=INTEGER}, #{accountType,jdbcType=INTEGER}, #{dueDate,jdbcType=TIMESTAMP},
- #{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR})
- </insert>
- <insert id="insertSelective" parameterType="org.apache.inlong.manager.dao.entity.UserEntity">
- insert into user
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">
- id,
- </if>
- <if test="name != null">
- name,
- </if>
- <if test="password != null">
- password,
- </if>
- <if test="secretKey != null">
- secret_key,
- </if>
- <if test="publicKey != null">
- public_key,
- </if>
- <if test="privateKey != null">
- private_key,
- </if>
- <if test="encryptVersion != null">
- encrypt_version,
- </if>
- <if test="accountType != null">
- account_type,
- </if>
- <if test="dueDate != null">
- due_date,
- </if>
- <if test="createBy != null">
- create_by,
- </if>
- <if test="updateBy != null">
- update_by,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">
- #{id,jdbcType=INTEGER},
- </if>
- <if test="name != null">
- #{name,jdbcType=VARCHAR},
- </if>
- <if test="password != null">
- #{password,jdbcType=VARCHAR},
- </if>
- <if test="secretKey != null">
- #{secretKey,jdbcType=VARCHAR},
- </if>
- <if test="publicKey != null">
- #{publicKey,jdbcType=VARCHAR},
- </if>
- <if test="privateKey != null">
- #{privateKey,jdbcType=VARCHAR},
- </if>
- <if test="encryptVersion != null">
- #{encryptVersion,jdbcType=INTEGER},
- </if>
- <if test="accountType != null">
- #{accountType,jdbcType=INTEGER},
- </if>
- <if test="dueDate != null">
- #{dueDate,jdbcType=TIMESTAMP},
+ <where>
+ is_deleted = 0
+ <if test="accountType != null and accountType != ''">
+ and account_type = #{accountType, jdbcType=INTEGER}
</if>
- <if test="createBy != null">
- #{createBy,jdbcType=VARCHAR},
+ <if test="name != null and name != ''">
+ and name = #{name, jdbcType=VARCHAR}
</if>
- <if test="updateBy != null">
- #{updateBy,jdbcType=VARCHAR},
+ <if test="keyword != null and keyword != ''">
+ and name like CONCAT('%', #{keyword},'%')
</if>
- </trim>
- </insert>
- <select id="countByExample" parameterType="org.apache.inlong.manager.dao.entity.UserEntityExample"
- resultType="java.lang.Long">
- select count(*) from user
- <if test="_parameter != null">
- <include refid="Example_Where_Clause"/>
- </if>
+ </where>
</select>
- <update id="updateByPrimaryKeySelective" parameterType="org.apache.inlong.manager.dao.entity.UserEntity">
- update user
- <set>
- <if test="name != null">
- name = #{name,jdbcType=VARCHAR},
- </if>
- <if test="password != null">
- password = #{password,jdbcType=VARCHAR},
- </if>
- <if test="secretKey != null">
- secret_key = #{secretKey,jdbcType=VARCHAR},
- </if>
- <if test="publicKey != null">
- public_key = #{publicKey,jdbcType=VARCHAR},
- </if>
- <if test="privateKey != null">
- private_key = #{privateKey,jdbcType=VARCHAR},
- </if>
- <if test="encryptVersion != null">
- encrypt_version = #{encryptVersion,jdbcType=INTEGER},
- </if>
- <if test="accountType != null">
- account_type = #{accountType,jdbcType=INTEGER},
- </if>
- <if test="dueDate != null">
- due_date = #{dueDate,jdbcType=TIMESTAMP},
- </if>
- <if test="createBy != null">
- create_by = #{createBy,jdbcType=VARCHAR},
- </if>
- <if test="updateBy != null">
- update_by = #{updateBy,jdbcType=VARCHAR},
- </if>
- version = #{version,jdbcType=INTEGER} + 1
- </set>
- where id = #{id,jdbcType=INTEGER}
- and version = #{version,jdbcType=INTEGER}
- </update>
- <update id="updateByPrimaryKey" parameterType="org.apache.inlong.manager.dao.entity.UserEntity">
+
+ <update id="updateById" parameterType="org.apache.inlong.manager.dao.entity.UserEntity">
update user
set name = #{name,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
@@ -234,10 +97,17 @@
encrypt_version = #{encryptVersion,jdbcType=INTEGER},
account_type = #{accountType,jdbcType=INTEGER},
due_date = #{dueDate,jdbcType=TIMESTAMP},
- create_by = #{createBy,jdbcType=VARCHAR},
- update_by = #{updateBy,jdbcType=VARCHAR},
+ status = #{status,jdbcType=INTEGER},
+ is_deleted = #{isDeleted,jdbcType=INTEGER},
+ modifier = #{modifier,jdbcType=VARCHAR},
version = #{version,jdbcType=INTEGER} + 1
where id = #{id,jdbcType=INTEGER}
- and version = #{version,jdbcType=INTEGER}
+ and version = #{version,jdbcType=INTEGER}
</update>
+
+ <delete id="deleteById" parameterType="java.lang.Integer">
+ delete
+ from user
+ where id = #{id,jdbcType=INTEGER}
+ </delete>
</mapper>
diff --git a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/InlongClusterServiceImpl.java b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/InlongClusterServiceImpl.java
index 5ccaa64a0..7457736ac 100644
--- a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/InlongClusterServiceImpl.java
+++ b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/InlongClusterServiceImpl.java
@@ -64,7 +64,7 @@ import org.apache.inlong.manager.dao.mapper.InlongClusterNodeEntityMapper;
import org.apache.inlong.manager.dao.mapper.InlongClusterTagEntityMapper;
import org.apache.inlong.manager.dao.mapper.InlongGroupEntityMapper;
import org.apache.inlong.manager.dao.mapper.InlongStreamEntityMapper;
-import org.apache.inlong.manager.service.core.UserService;
+import org.apache.inlong.manager.dao.mapper.UserEntityMapper;
import org.apache.inlong.manager.service.repository.DataProxyConfigRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -93,6 +93,8 @@ public class InlongClusterServiceImpl implements InlongClusterService {
private static final Logger LOGGER = LoggerFactory.getLogger(InlongClusterServiceImpl.class);
private static final Gson GSON = new Gson();
+ @Autowired
+ private UserEntityMapper userMapper;
@Autowired
private InlongGroupEntityMapper groupMapper;
@Autowired
@@ -105,11 +107,9 @@ public class InlongClusterServiceImpl implements InlongClusterService {
private InlongClusterEntityMapper clusterMapper;
@Autowired
private InlongClusterNodeEntityMapper clusterNodeMapper;
- @Autowired
@Lazy
- private DataProxyConfigRepository proxyRepository;
@Autowired
- private UserService userService;
+ private DataProxyConfigRepository proxyRepository;
@Override
public Integer saveTag(ClusterTagRequest request, String operator) {
@@ -142,7 +142,7 @@ public class InlongClusterServiceImpl implements InlongClusterService {
LOGGER.error("inlong cluster tag not found by id={}", id);
throw new BusinessException(ErrorCodeEnum.CLUSTER_NOT_FOUND);
}
- UserEntity userEntity = userService.getByUsername(currentUser);
+ UserEntity userEntity = userMapper.selectByName(currentUser);
boolean isInCharge = Preconditions.inSeparatedString(currentUser, entity.getInCharges(), InlongConstants.COMMA);
Preconditions.checkTrue(isInCharge || userEntity.getAccountType().equals(UserTypeEnum.ADMIN.getCode()),
"Current user does not have permission to get cluster tag");
@@ -187,7 +187,7 @@ public class InlongClusterServiceImpl implements InlongClusterService {
throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED);
}
- UserEntity userEntity = userService.getByUsername(operator);
+ UserEntity userEntity = userMapper.selectByName(operator);
boolean isInCharge = Preconditions.inSeparatedString(operator, exist.getInCharges(), InlongConstants.COMMA);
Preconditions.checkTrue(isInCharge || userEntity.getAccountType().equals(UserTypeEnum.ADMIN.getCode()),
"Current user does not have permission to update cluster tag");
@@ -244,7 +244,7 @@ public class InlongClusterServiceImpl implements InlongClusterService {
LOGGER.error("inlong cluster tag not found by id={}", id);
return false;
}
- UserEntity userEntity = userService.getByUsername(operator);
+ UserEntity userEntity = userMapper.selectByName(operator);
boolean isInCharge = Preconditions.inSeparatedString(operator, exist.getInCharges(), InlongConstants.COMMA);
Preconditions.checkTrue(isInCharge || userEntity.getAccountType().equals(UserTypeEnum.ADMIN.getCode()),
"Current user does not have permission to delete cluster tag");
@@ -304,7 +304,7 @@ public class InlongClusterServiceImpl implements InlongClusterService {
LOGGER.error("inlong cluster not found by id={}", id);
throw new BusinessException(ErrorCodeEnum.CLUSTER_NOT_FOUND);
}
- UserEntity userEntity = userService.getByUsername(currentUser);
+ UserEntity userEntity = userMapper.selectByName(currentUser);
boolean isInCharge = Preconditions.inSeparatedString(currentUser, entity.getInCharges(), InlongConstants.COMMA);
Preconditions.checkTrue(isInCharge || userEntity.getAccountType().equals(UserTypeEnum.ADMIN.getCode()),
"Current user does not have permission to get cluster info");
@@ -374,7 +374,7 @@ public class InlongClusterServiceImpl implements InlongClusterService {
request.getName(), request.getType(), request.getVersion());
throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED);
}
- UserEntity userEntity = userService.getByUsername(operator);
+ UserEntity userEntity = userMapper.selectByName(operator);
boolean isInCharge = Preconditions.inSeparatedString(operator, entity.getInCharges(), InlongConstants.COMMA);
Preconditions.checkTrue(isInCharge || userEntity.getAccountType().equals(UserTypeEnum.ADMIN.getCode()),
"Current user does not have permission to update cluster info");
@@ -392,7 +392,7 @@ public class InlongClusterServiceImpl implements InlongClusterService {
String clusterTag = request.getClusterTag();
Preconditions.checkNotNull(clusterTag, "cluster tag cannot be empty");
InlongClusterTagEntity exist = clusterTagMapper.selectByTag(clusterTag);
- UserEntity userEntity = userService.getByUsername(operator);
+ UserEntity userEntity = userMapper.selectByName(operator);
boolean isInCharge = Preconditions.inSeparatedString(operator, exist.getInCharges(), InlongConstants.COMMA);
Preconditions.checkTrue(isInCharge || userEntity.getAccountType().equals(UserTypeEnum.ADMIN.getCode()),
"Current user does not have permission to bind or unbind cluster tag");
@@ -433,7 +433,7 @@ public class InlongClusterServiceImpl implements InlongClusterService {
LOGGER.error("inlong cluster not found by id={}, or was already deleted", id);
return false;
}
- UserEntity userEntity = userService.getByUsername(operator);
+ UserEntity userEntity = userMapper.selectByName(operator);
boolean isInCharge = Preconditions.inSeparatedString(operator, entity.getInCharges(), InlongConstants.COMMA);
Preconditions.checkTrue(isInCharge || userEntity.getAccountType().equals(UserTypeEnum.ADMIN.getCode()),
"Current user does not have permission to delete cluster info");
@@ -489,7 +489,7 @@ public class InlongClusterServiceImpl implements InlongClusterService {
throw new BusinessException(ErrorCodeEnum.CLUSTER_NOT_FOUND);
}
InlongClusterEntity cluster = clusterMapper.selectById(entity.getParentId());
- UserEntity userEntity = userService.getByUsername(currentUser);
+ UserEntity userEntity = userMapper.selectByName(currentUser);
boolean isInCharge = Preconditions.inSeparatedString(currentUser, cluster.getInCharges(),
InlongConstants.COMMA);
Preconditions.checkTrue(isInCharge || userEntity.getAccountType().equals(UserTypeEnum.ADMIN.getCode()),
@@ -504,7 +504,7 @@ public class InlongClusterServiceImpl implements InlongClusterService {
Integer parentId = request.getParentId();
Preconditions.checkNotNull(parentId, "Cluster id cannot be empty");
InlongClusterEntity cluster = clusterMapper.selectById(parentId);
- UserEntity userEntity = userService.getByUsername(currentUser);
+ UserEntity userEntity = userMapper.selectByName(currentUser);
boolean isInCharge = Preconditions.inSeparatedString(currentUser, cluster.getInCharges(),
InlongConstants.COMMA);
Preconditions.checkTrue(isInCharge || userEntity.getAccountType().equals(UserTypeEnum.ADMIN.getCode()),
@@ -567,7 +567,7 @@ public class InlongClusterServiceImpl implements InlongClusterService {
throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED);
}
InlongClusterEntity cluster = clusterMapper.selectById(entity.getParentId());
- UserEntity userEntity = userService.getByUsername(operator);
+ UserEntity userEntity = userMapper.selectByName(operator);
boolean isInCharge = Preconditions.inSeparatedString(operator, cluster.getInCharges(), InlongConstants.COMMA);
Preconditions.checkTrue(isInCharge || userEntity.getAccountType().equals(UserTypeEnum.ADMIN.getCode()),
"Current user does not have permission to update cluster node");
@@ -592,7 +592,7 @@ public class InlongClusterServiceImpl implements InlongClusterService {
return false;
}
InlongClusterEntity cluster = clusterMapper.selectById(entity.getParentId());
- UserEntity userEntity = userService.getByUsername(operator);
+ UserEntity userEntity = userMapper.selectByName(operator);
boolean isInCharge = Preconditions.inSeparatedString(operator, cluster.getInCharges(), InlongConstants.COMMA);
Preconditions.checkTrue(isInCharge || userEntity.getAccountType().equals(UserTypeEnum.ADMIN.getCode()),
"Current user does not have permission to delete cluster node");
diff --git a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/UserService.java b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/UserService.java
index bdba94c74..2559d1184 100644
--- a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/UserService.java
+++ b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/UserService.java
@@ -18,10 +18,8 @@
package org.apache.inlong.manager.service.core;
import com.github.pagehelper.PageInfo;
-import org.apache.inlong.manager.common.pojo.user.UserDetailListVO;
-import org.apache.inlong.manager.common.pojo.user.UserDetailPageRequest;
+import org.apache.inlong.manager.common.pojo.user.UserRequest;
import org.apache.inlong.manager.common.pojo.user.UserInfo;
-import org.apache.inlong.manager.dao.entity.UserEntity;
/**
* User service interface
@@ -29,40 +27,48 @@ import org.apache.inlong.manager.dao.entity.UserEntity;
public interface UserService {
/**
- * Get user info by user name
+ * Save user info
*
- * @param username username
- * @return user info
+ * @param request user info request
+ * @return user id after saving
*/
- UserEntity getByUsername(String username);
+ Integer save(UserRequest request);
/**
* Get user info by user id
*
- * @param userId user id
+ * @param id user id
* @return user info
*/
- UserInfo getById(Integer userId, String currentUser);
+ UserInfo getById(Integer id, String currentUser);
/**
- * Create user
+ * Get user by name
*
- * @param userInfo user info
- * @return whether succeed
+ * @param name username
+ * @return user info
+ */
+ UserInfo getByName(String name);
+
+ /**
+ * List all users basic info by request condition
+ *
+ * @param request request
+ * @return user info list
*/
- boolean create(UserInfo userInfo);
+ PageInfo<UserInfo> list(UserRequest request);
/**
* Update user info
*
- * @param userInfo user info
+ * @param request user info request
* @param currentUser current user name
- * @return rows updated
+ * @return user id
*/
- int update(UserInfo userInfo, String currentUser);
+ Integer update(UserRequest request, String currentUser);
/**
- * Delete user by user id
+ * Delete user by id
*
* @param userId user id
* @param currentUser current user name
@@ -70,12 +76,4 @@ public interface UserService {
*/
Boolean delete(Integer userId, String currentUser);
- /**
- * List all users basic info by request condition
- *
- * @param request request
- * @return user info list
- */
- PageInfo<UserDetailListVO> list(UserDetailPageRequest request);
-
}
diff --git a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/ConsumptionServiceImpl.java b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/ConsumptionServiceImpl.java
index 32de9185d..9e818cdc9 100644
--- a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/ConsumptionServiceImpl.java
+++ b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/ConsumptionServiceImpl.java
@@ -112,7 +112,7 @@ public class ConsumptionServiceImpl implements ConsumptionService {
@Override
public PageInfo<ConsumptionListVo> list(ConsumptionQuery query) {
PageHelper.startPage(query.getPageNum(), query.getPageSize());
- query.setIsAdminRole(LoginUserUtils.getLoginUserDetail().getRoles().contains(UserRoleCode.ADMIN));
+ query.setIsAdminRole(LoginUserUtils.getLoginUser().getRoles().contains(UserRoleCode.ADMIN));
Page<ConsumptionEntity> pageResult = (Page<ConsumptionEntity>) consumptionMapper.listByQuery(query);
PageInfo<ConsumptionListVo> pageInfo = pageResult
.toPageInfo(entity -> CommonBeanUtils.copyProperties(entity, ConsumptionListVo::new));
diff --git a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/UserServiceImpl.java b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/UserServiceImpl.java
index 30dff2ea7..e1f52fc6d 100644
--- a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/UserServiceImpl.java
+++ b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/UserServiceImpl.java
@@ -26,9 +26,8 @@ import org.apache.inlong.manager.common.consts.InlongConstants;
import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
import org.apache.inlong.manager.common.enums.UserTypeEnum;
import org.apache.inlong.manager.common.exceptions.BusinessException;
-import org.apache.inlong.manager.common.pojo.user.UserDetailListVO;
-import org.apache.inlong.manager.common.pojo.user.UserDetailPageRequest;
import org.apache.inlong.manager.common.pojo.user.UserInfo;
+import org.apache.inlong.manager.common.pojo.user.UserRequest;
import org.apache.inlong.manager.common.util.AESUtils;
import org.apache.inlong.manager.common.util.CommonBeanUtils;
import org.apache.inlong.manager.common.util.DateUtils;
@@ -37,8 +36,6 @@ import org.apache.inlong.manager.common.util.MD5Utils;
import org.apache.inlong.manager.common.util.Preconditions;
import org.apache.inlong.manager.common.util.RSAUtils;
import org.apache.inlong.manager.dao.entity.UserEntity;
-import org.apache.inlong.manager.dao.entity.UserEntityExample;
-import org.apache.inlong.manager.dao.entity.UserEntityExample.Criteria;
import org.apache.inlong.manager.dao.mapper.UserEntityMapper;
import org.apache.inlong.manager.service.core.UserService;
import org.slf4j.Logger;
@@ -66,28 +63,58 @@ public class UserServiceImpl implements UserService {
private UserEntityMapper userMapper;
@Override
- public UserEntity getByUsername(String username) {
- UserEntityExample example = new UserEntityExample();
- example.createCriteria().andNameEqualTo(username);
- List<UserEntity> list = userMapper.selectByExample(example);
- return list.isEmpty() ? null : list.get(0);
+ public Integer save(UserRequest request) {
+ String username = request.getName();
+ UserEntity userExists = userMapper.selectByName(username);
+ String password = request.getPassword();
+ Preconditions.checkNull(userExists, "username [" + username + "] already exists");
+ Preconditions.checkTrue(StringUtils.isNotBlank(password), "password cannot be blank");
+
+ UserEntity entity = new UserEntity();
+ entity.setName(username);
+ entity.setPassword(MD5Utils.encrypt(password));
+ entity.setAccountType(request.getAccountType());
+ entity.setDueDate(DateUtils.getExpirationDate(request.getValidDays()));
+ String currentUser = LoginUserUtils.getLoginUser().getName();
+ entity.setCreator(currentUser);
+ entity.setModifier(currentUser);
+ try {
+ Map<String, String> keyPairs = RSAUtils.generateRSAKeyPairs();
+ String publicKey = keyPairs.get(RSAUtils.PUBLIC_KEY);
+ String privateKey = keyPairs.get(RSAUtils.PRIVATE_KEY);
+ String secretKey = RandomStringUtils.randomAlphanumeric(SECRET_KEY_SIZE);
+ Integer encryptVersion = AESUtils.getCurrentVersion(null);
+ entity.setEncryptVersion(encryptVersion);
+ entity.setPublicKey(AESUtils.encryptToString(publicKey.getBytes(StandardCharsets.UTF_8), encryptVersion));
+ entity.setPrivateKey(AESUtils.encryptToString(privateKey.getBytes(StandardCharsets.UTF_8), encryptVersion));
+ entity.setSecretKey(AESUtils.encryptToString(secretKey.getBytes(StandardCharsets.UTF_8), encryptVersion));
+ } catch (Exception e) {
+ String errMsg = String.format("generate rsa key error: %s", e.getMessage());
+ LOGGER.error(errMsg, e);
+ throw new BusinessException(errMsg);
+ }
+
+ Preconditions.checkTrue(userMapper.insert(entity) > 0, "Create user failed");
+ LOGGER.debug("success to create user info={}", request);
+ return entity.getId();
}
@Override
public UserInfo getById(Integer userId, String currentUser) {
- Preconditions.checkNotNull(userId, "User id should not be empty");
- UserEntity entity = userMapper.selectByPrimaryKey(userId);
- UserEntity curUser = getByUsername(currentUser);
+ Preconditions.checkNotNull(userId, "User id cannot be null");
+ UserEntity entity = userMapper.selectById(userId);
Preconditions.checkNotNull(entity, "User not exists with id " + userId);
+
+ UserEntity curUser = userMapper.selectByName(currentUser);
Preconditions.checkTrue(Objects.equals(UserTypeEnum.ADMIN.getCode(), curUser.getAccountType())
|| Objects.equals(entity.getName(), currentUser),
"Current user does not have permission to get other users' info");
UserInfo result = new UserInfo();
result.setId(entity.getId());
- result.setUsername(entity.getName());
+ result.setName(entity.getName());
result.setValidDays(DateUtils.getValidDays(entity.getCreateTime(), entity.getDueDate()));
- result.setType(entity.getAccountType());
+ result.setAccountType(entity.getAccountType());
result.setVersion(entity.getVersion());
if (StringUtils.isNotBlank(entity.getSecretKey()) && StringUtils.isNotBlank(entity.getPublicKey())) {
@@ -111,102 +138,88 @@ public class UserServiceImpl implements UserService {
}
@Override
- public boolean create(UserInfo userInfo) {
- String username = userInfo.getUsername();
- UserEntity userExists = getByUsername(username);
- String password = userInfo.getPassword();
- Preconditions.checkNull(userExists, "username [" + username + "] already exists");
- Preconditions.checkTrue(StringUtils.isNotBlank(password), "password cannot be blank");
+ public UserInfo getByName(String name) {
+ Preconditions.checkNotNull(name, "User name cannot be null");
+ UserEntity entity = userMapper.selectByName(name);
+ return CommonBeanUtils.copyProperties(entity, UserInfo::new);
+ }
- UserEntity entity = new UserEntity();
- entity.setAccountType(userInfo.getType());
- entity.setPassword(MD5Utils.encrypt(password));
- entity.setDueDate(DateUtils.getExpirationDate(userInfo.getValidDays()));
- String currentUser = LoginUserUtils.getLoginUserDetail().getUsername();
- entity.setCreateBy(currentUser);
- entity.setUpdateBy(currentUser);
- entity.setName(username);
- try {
- Map<String, String> keyPairs = RSAUtils.generateRSAKeyPairs();
- String publicKey = keyPairs.get(RSAUtils.PUBLIC_KEY);
- String privateKey = keyPairs.get(RSAUtils.PRIVATE_KEY);
- String secretKey = RandomStringUtils.randomAlphanumeric(SECRET_KEY_SIZE);
- Integer encryptVersion = AESUtils.getCurrentVersion(null);
- entity.setEncryptVersion(encryptVersion);
- entity.setPublicKey(AESUtils.encryptToString(publicKey.getBytes(StandardCharsets.UTF_8), encryptVersion));
- entity.setPrivateKey(AESUtils.encryptToString(privateKey.getBytes(StandardCharsets.UTF_8), encryptVersion));
- entity.setSecretKey(AESUtils.encryptToString(secretKey.getBytes(StandardCharsets.UTF_8), encryptVersion));
- } catch (Exception e) {
- String errMsg = String.format("generate rsa key error: %s", e.getMessage());
- LOGGER.error(errMsg, e);
- throw new BusinessException(errMsg);
- }
+ @Override
+ public PageInfo<UserInfo> list(UserRequest request) {
+ PageHelper.startPage(request.getPageNum(), request.getPageSize());
+ Page<UserEntity> entityPage = (Page<UserEntity>) userMapper.selectByCondition(request);
+ List<UserInfo> userList = CommonBeanUtils.copyListProperties(entityPage, UserInfo::new);
- Preconditions.checkTrue(userMapper.insert(entity) > 0, "Create user failed");
+ // Check whether the user account has expired
+ userList.forEach(entity -> entity.setStatus(entity.getDueDate().after(new Date()) ? "valid" : "invalid"));
+ PageInfo<UserInfo> page = new PageInfo<>(userList);
+ page.setTotal(entityPage.getTotal());
- LOGGER.debug("success to create user info={}", userInfo);
- return true;
+ LOGGER.debug("success to list users for request={}, result size={}", request, page.getTotal());
+ return page;
}
@Override
- public int update(UserInfo updateUser, String currentUser) {
- LOGGER.debug("begin to update user info={} by {}", updateUser, currentUser);
- Preconditions.checkNotNull(updateUser, "Userinfo cannot be null");
- Preconditions.checkNotNull(updateUser.getId(), "User id cannot be null");
+ public Integer update(UserRequest request, String currentUser) {
+ LOGGER.debug("begin to update user info={} by {}", request, currentUser);
+ Preconditions.checkNotNull(request, "Userinfo cannot be null");
+ Preconditions.checkNotNull(request.getId(), "User id cannot be null");
// Whether the current user is a manager
- UserEntity currentUserEntity = getByUsername(currentUser);
+ UserEntity currentUserEntity = userMapper.selectByName(currentUser);
+ String updateName = request.getName();
boolean isAdmin = Objects.equals(UserTypeEnum.ADMIN.getCode(), currentUserEntity.getAccountType());
- Preconditions.checkTrue(isAdmin || Objects.equals(updateUser.getUsername(), currentUser),
+ Preconditions.checkTrue(isAdmin || Objects.equals(updateName, currentUser),
"You are not a manager and do not have permission to update other users");
// manager cannot set himself as an ordinary
boolean managerToOrdinary = isAdmin
- && Objects.equals(UserTypeEnum.OPERATOR.getCode(), updateUser.getType())
- && Objects.equals(currentUser, updateUser.getUsername());
+ && Objects.equals(UserTypeEnum.OPERATOR.getCode(), request.getAccountType())
+ && Objects.equals(currentUser, updateName);
Preconditions.checkFalse(managerToOrdinary, "You are a manager and you cannot change to an ordinary user");
// target username must not exist
- UserEntity updateUserEntity = userMapper.selectByPrimaryKey(updateUser.getId());
- Preconditions.checkNotNull(updateUserEntity, "User not exists with id=" + updateUser.getId());
- UserEntity targetUserEntity = getByUsername(updateUser.getUsername());
- Preconditions.checkTrue(Objects.isNull(targetUserEntity)
- || Objects.equals(targetUserEntity.getId(), updateUserEntity.getId()),
- "Username [" + updateUser.getUsername() + "] already exists");
+ UserEntity updateUserEntity = userMapper.selectById(request.getId());
+ Preconditions.checkNotNull(updateUserEntity, "User not exists with id=" + request.getId());
String errMsg = String.format("user has already updated with username=%s, curVersion=%s",
- updateUser.getUsername(), updateUser.getVersion());
- if (!Objects.equals(updateUserEntity.getVersion(), updateUser.getVersion())) {
+ updateName, request.getVersion());
+ if (!Objects.equals(updateUserEntity.getVersion(), request.getVersion())) {
LOGGER.error(errMsg);
throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED);
}
+ UserEntity targetUserEntity = userMapper.selectByName(updateName);
+ Preconditions.checkTrue(Objects.isNull(targetUserEntity)
+ || Objects.equals(targetUserEntity.getName(), updateUserEntity.getName()),
+ "Username [" + updateName + "] already exists");
+
// if the current user is not a manager, needs to check the password before updating user info
if (!isAdmin) {
- String oldPassword = updateUser.getPassword();
+ String oldPassword = request.getPassword();
String oldPasswordMd = MD5Utils.encrypt(oldPassword);
Preconditions.checkTrue(oldPasswordMd.equals(updateUserEntity.getPassword()), "Old password is wrong");
Integer validDays = DateUtils.getValidDays(updateUserEntity.getCreateTime(), updateUserEntity.getDueDate());
- Preconditions.checkTrue((updateUser.getValidDays() <= validDays),
+ Preconditions.checkTrue((request.getValidDays() <= validDays),
"Ordinary users are not allowed to add valid days");
- Preconditions.checkTrue(Objects.equals(updateUserEntity.getAccountType(), updateUser.getType()),
+ Preconditions.checkTrue(Objects.equals(updateUserEntity.getAccountType(), request.getAccountType()),
"Ordinary users are not allowed to update account type");
}
// update password
- if (!StringUtils.isBlank(updateUser.getNewPassword())) {
- String newPasswordMd5 = MD5Utils.encrypt(updateUser.getNewPassword());
+ if (!StringUtils.isBlank(request.getNewPassword())) {
+ String newPasswordMd5 = MD5Utils.encrypt(request.getNewPassword());
updateUserEntity.setPassword(newPasswordMd5);
}
- updateUserEntity.setDueDate(DateUtils.getExpirationDate(updateUser.getValidDays()));
- updateUserEntity.setAccountType(updateUser.getType());
- updateUserEntity.setName(updateUser.getUsername());
+ updateUserEntity.setDueDate(DateUtils.getExpirationDate(request.getValidDays()));
+ updateUserEntity.setAccountType(request.getAccountType());
+ updateUserEntity.setName(updateName);
- int rowCount = userMapper.updateByPrimaryKeySelective(updateUserEntity);
+ int rowCount = userMapper.updateById(updateUserEntity);
if (rowCount != InlongConstants.AFFECTED_ONE_ROW) {
LOGGER.error(errMsg);
throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED);
}
- LOGGER.debug("success to update user info={} by {}", updateUser, currentUser);
+ LOGGER.debug("success to update user info={} by {}", request, currentUser);
return updateUserEntity.getId();
}
@@ -215,36 +228,16 @@ public class UserServiceImpl implements UserService {
Preconditions.checkNotNull(userId, "User id should not be empty");
// Whether the current user is an administrator
- UserEntity curUser = getByUsername(currentUser);
- UserEntity entity = userMapper.selectByPrimaryKey(userId);
+ UserEntity curUser = userMapper.selectByName(currentUser);
+ UserEntity entity = userMapper.selectById(userId);
Preconditions.checkTrue(curUser.getAccountType().equals(UserTypeEnum.ADMIN.getCode()),
"Current user is not a manager and does not have permission to delete users");
Preconditions.checkTrue(!Objects.equals(entity.getName(), currentUser),
"Current user does not have permission to delete himself");
- userMapper.deleteByPrimaryKey(userId);
+ userMapper.deleteById(userId);
LOGGER.debug("success to delete user by id={}, current user={}", userId, currentUser);
return true;
}
- @Override
- public PageInfo<UserDetailListVO> list(UserDetailPageRequest request) {
- PageHelper.startPage(request.getPageNum(), request.getPageSize());
- UserEntityExample example = new UserEntityExample();
- Criteria criteria = example.createCriteria();
- if (request.getUsername() != null) {
- criteria.andNameLike(request.getUsername() + "%");
- }
-
- Page<UserEntity> entityPage = (Page<UserEntity>) userMapper.selectByExample(example);
- List<UserDetailListVO> detailList = CommonBeanUtils.copyListProperties(entityPage, UserDetailListVO::new);
- // Check whether the user account has expired
- detailList.forEach(entity -> entity.setStatus(entity.getDueDate().after(new Date()) ? "valid" : "invalid"));
- PageInfo<UserDetailListVO> page = new PageInfo<>(detailList);
- page.setTotal(entityPage.getTotal());
-
- LOGGER.debug("success to list users, result size={}", page.getTotal());
- return page;
- }
-
}
diff --git a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/operationlog/OperationLogRecorder.java b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/operationlog/OperationLogRecorder.java
index 7faa8c011..0a2b121b4 100644
--- a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/operationlog/OperationLogRecorder.java
+++ b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/operationlog/OperationLogRecorder.java
@@ -22,7 +22,7 @@ import com.google.gson.GsonBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.inlong.manager.common.enums.OperationType;
-import org.apache.inlong.manager.common.pojo.user.UserDetail;
+import org.apache.inlong.manager.common.pojo.user.UserInfo;
import org.apache.inlong.manager.common.util.LoginUserUtils;
import org.apache.inlong.manager.common.util.NetworkUtils;
import org.apache.inlong.manager.dao.entity.OperationLogEntity;
@@ -54,10 +54,8 @@ public class OperationLogRecorder {
}
HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
-
- UserDetail userDetail = Optional.ofNullable(LoginUserUtils.getLoginUserDetail())
- .orElseGet(UserDetail::new);
- String operator = userDetail.getUsername();
+ UserInfo userInfo = Optional.ofNullable(LoginUserUtils.getLoginUser()).orElseGet(UserInfo::new);
+ String operator = userInfo.getName();
operator = StringUtils.isBlank(operator) ? ANONYMOUS_USER : operator;
String requestUrl = request.getRequestURI();
@@ -66,8 +64,6 @@ public class OperationLogRecorder {
String param = GSON.toJson(request.getParameterMap());
String body = GSON.toJson(joinPoint.getArgs());
- OperationType operationType = operationLog.operation();
-
long start = System.currentTimeMillis();
boolean success = true;
String errMsg = "";
@@ -79,6 +75,7 @@ public class OperationLogRecorder {
throw throwable;
} finally {
long costTime = System.currentTimeMillis() - start;
+ OperationType operationType = operationLog.operation();
OperationLogEntity operationLogEntity = new OperationLogEntity();
operationLogEntity.setOperationType(operationType.name());
operationLogEntity.setHttpMethod(httpMethod);
diff --git a/inlong-manager/manager-test/src/main/resources/h2/apache_inlong_manager.sql b/inlong-manager/manager-test/src/main/resources/h2/apache_inlong_manager.sql
index 45661365d..a3217db98 100644
--- a/inlong-manager/manager-test/src/main/resources/h2/apache_inlong_manager.sql
+++ b/inlong-manager/manager-test/src/main/resources/h2/apache_inlong_manager.sql
@@ -558,11 +558,13 @@ CREATE TABLE IF NOT EXISTS `user`
`private_key` text DEFAULT NULL COMMENT 'Private key for asymmetric data encryption',
`encrypt_version` int(11) DEFAULT NULL COMMENT 'Encryption key version',
`account_type` int(11) NOT NULL DEFAULT '1' COMMENT 'Account type, 0-manager 1-normal',
- `due_date` datetime DEFAULT NULL COMMENT 'Due date for account',
- `create_by` varchar(256) NOT NULL COMMENT 'Creator name',
- `update_by` varchar(256) DEFAULT NULL COMMENT 'Modifier name',
+ `due_date` datetime DEFAULT NULL COMMENT 'Due date for user',
+ `status` int(11) DEFAULT '100' COMMENT 'Status',
+ `is_deleted` int(11) DEFAULT '0' COMMENT 'Whether to delete, 0 is not deleted, if greater than 0, delete',
+ `creator` varchar(256) NOT NULL COMMENT 'Creator name',
+ `modifier` varchar(256) DEFAULT NULL COMMENT 'Modifier name',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Create time',
- `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
+ `modify_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
`version` int(11) NOT NULL DEFAULT '1' COMMENT 'Version number, which will be incremented by 1 after modification',
PRIMARY KEY (`id`),
UNIQUE KEY `unique_user_name` (`name`)
diff --git a/inlong-manager/manager-test/src/main/resources/h2/data.sql b/inlong-manager/manager-test/src/main/resources/h2/data.sql
index 1a4944c9a..e39d20851 100644
--- a/inlong-manager/manager-test/src/main/resources/h2/data.sql
+++ b/inlong-manager/manager-test/src/main/resources/h2/data.sql
@@ -14,12 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-INSERT INTO `user` (`id`, `name`, `password`, `account_type`, `due_date`, `create_time`,
- `update_time`, `create_by`, `update_by`)
-VALUES (1, 'admin', '628ed559bff5ae36bd2184d4216973cf', 0, '2099-12-31 23:59:59', '2022-06-05 08:58:06',
- '2022-06-05 08:58:06', 'inlong_init', 'inlong_init');
+INSERT INTO `user` (`id`, `name`, `password`, `account_type`, `due_date`, `creator`, `modifier`)
+VALUES (1, 'admin', '628ed559bff5ae36bd2184d4216973cf', 0, '2099-12-31 23:59:59', 'inlong_init', 'inlong_init');
-INSERT INTO `user` (`id`, `name`, `password`, `account_type`, `due_date`, `create_time`,
- `update_time`, `create_by`, `update_by`)
-VALUES (2, 'operator', '628ed559bff5ae36bd2184d4216973cf', 1, '2099-12-31 23:59:59', '2022-06-05 08:58:06',
- '2022-06-05 08:58:06', 'inlong_init', 'inlong_init');
+INSERT INTO `user` (`id`, `name`, `password`, `account_type`, `due_date`, `creator`, `modifier`)
+VALUES (2, 'operator', '628ed559bff5ae36bd2184d4216973cf', 1, '2099-12-31 23:59:59', 'inlong_init', 'inlong_init');
diff --git a/inlong-manager/manager-web/sql/apache_inlong_manager.sql b/inlong-manager/manager-web/sql/apache_inlong_manager.sql
index dcc8d393d..af5100f52 100644
--- a/inlong-manager/manager-web/sql/apache_inlong_manager.sql
+++ b/inlong-manager/manager-web/sql/apache_inlong_manager.sql
@@ -586,11 +586,13 @@ CREATE TABLE IF NOT EXISTS `user`
`private_key` text DEFAULT NULL COMMENT 'Private key for asymmetric data encryption',
`encrypt_version` int(11) DEFAULT NULL COMMENT 'Encryption key version',
`account_type` int(11) NOT NULL DEFAULT '1' COMMENT 'Account type, 0-manager 1-normal',
- `due_date` datetime DEFAULT NULL COMMENT 'Due date for account',
- `create_by` varchar(256) NOT NULL COMMENT 'Creator name',
- `update_by` varchar(256) DEFAULT NULL COMMENT 'Modifier name',
+ `due_date` datetime DEFAULT NULL COMMENT 'Due date for user',
+ `status` int(11) DEFAULT '100' COMMENT 'Status',
+ `is_deleted` int(11) DEFAULT '0' COMMENT 'Whether to delete, 0 is not deleted, if greater than 0, delete',
+ `creator` varchar(256) NOT NULL COMMENT 'Creator name',
+ `modifier` varchar(256) DEFAULT NULL COMMENT 'Modifier name',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Create time',
- `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
+ `modify_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
`version` int(11) NOT NULL DEFAULT '1' COMMENT 'Version number, which will be incremented by 1 after modification',
PRIMARY KEY (`id`),
UNIQUE KEY `unique_user_name` (`name`)
@@ -598,9 +600,10 @@ CREATE TABLE IF NOT EXISTS `user`
DEFAULT CHARSET = utf8mb4 COMMENT ='User table';
-- create default admin user, username is 'admin', password is 'inlong'
-INSERT INTO `user` (name, password, secret_key, account_type, due_date, create_time, update_time, create_by, update_by, encrypt_version)
-VALUES ('admin', '628ed559bff5ae36bd2184d4216973cf', '9B5DCE950F284141D5493A2DAFEBD1BFEECE075FC5F426E8B67F33F14876E2D0', 0, '2099-12-31 23:59:59',
- CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'inlong_init', 'inlong_init', 1);
+INSERT INTO `user` (name, password, secret_key, account_type, encrypt_version,
+ due_date, creator, modifier)
+VALUES ('admin', '628ed559bff5ae36bd2184d4216973cf', '9B5DCE950F284141D5493A2DAFEBD1BFEECE075FC5F426E8B67F33F14876E2D0',
+ 0, 1, '2099-12-31 23:59:59', 'inlong_init', 'inlong_init');
-- ----------------------------
-- Table structure for user_role
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/openapi/OpenAPIAuthenticatingRealm.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/openapi/OpenAPIAuthenticatingRealm.java
index 834d2bec1..ece8e1962 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/openapi/OpenAPIAuthenticatingRealm.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/openapi/OpenAPIAuthenticatingRealm.java
@@ -18,9 +18,9 @@
package org.apache.inlong.manager.web.auth.openapi;
import lombok.extern.slf4j.Slf4j;
+import org.apache.inlong.manager.common.pojo.user.UserInfo;
import org.apache.inlong.manager.common.util.AESUtils;
import org.apache.inlong.manager.common.util.Preconditions;
-import org.apache.inlong.manager.dao.entity.UserEntity;
import org.apache.inlong.manager.service.core.UserService;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
@@ -50,12 +50,12 @@ public class OpenAPIAuthenticatingRealm extends AuthenticatingRealm {
throws AuthenticationException {
SecretToken upToken = (SecretToken) authenticationToken;
String username = upToken.getSecretId();
- UserEntity userEntity = userService.getByUsername(username);
- Preconditions.checkNotNull(userEntity, "User doesn't exist");
- Preconditions.checkTrue(userEntity.getDueDate().after(new Date()), "user has expired");
+ UserInfo userInfo = userService.getByName(username);
+ Preconditions.checkNotNull(userInfo, "User doesn't exist");
+ Preconditions.checkTrue(userInfo.getDueDate().after(new Date()), "user has expired");
try {
String secretKey = new String(
- AESUtils.decryptAsString(userEntity.getSecretKey(), userEntity.getEncryptVersion()));
+ AESUtils.decryptAsString(userInfo.getSecretKey(), userInfo.getEncryptVersion()));
return new SimpleAuthenticationInfo(username, secretKey, getName());
} catch (Exception e) {
log.error("decrypt secret key fail: ", e);
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/web/AuthenticationFilter.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/web/AuthenticationFilter.java
index 229f0648b..f77bd2728 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/web/AuthenticationFilter.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/web/AuthenticationFilter.java
@@ -18,7 +18,7 @@
package org.apache.inlong.manager.web.auth.web;
import lombok.extern.slf4j.Slf4j;
-import org.apache.inlong.manager.common.pojo.user.UserDetail;
+import org.apache.inlong.manager.common.pojo.user.UserInfo;
import org.apache.inlong.manager.common.util.LoginUserUtils;
import org.apache.inlong.manager.common.util.Preconditions;
import org.apache.shiro.SecurityUtils;
@@ -61,8 +61,8 @@ public class AuthenticationFilter implements Filter {
Subject subject = SecurityUtils.getSubject();
if (subject.isAuthenticated()) {
- UserDetail loginUserDetail = (UserDetail) subject.getPrincipal();
- doFilter(servletRequest, servletResponse, filterChain, loginUserDetail);
+ UserInfo loginuserInfo = (UserInfo) subject.getPrincipal();
+ doFilter(servletRequest, servletResponse, filterChain, loginuserInfo);
return;
}
@@ -81,12 +81,12 @@ public class AuthenticationFilter implements Filter {
((HttpServletResponse) servletResponse).sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
- doFilter(servletRequest, servletResponse, filterChain, (UserDetail) subject.getPrincipal());
+ doFilter(servletRequest, servletResponse, filterChain, (UserInfo) subject.getPrincipal());
}
private void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain,
- UserDetail userDetail) throws IOException, ServletException {
- LoginUserUtils.setUserLoginInfo(userDetail);
+ UserInfo userInfo) throws IOException, ServletException {
+ LoginUserUtils.setUserLoginInfo(userInfo);
try {
filterChain.doFilter(servletRequest, servletResponse);
} finally {
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/web/WebAuthorizingRealm.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/web/WebAuthorizingRealm.java
index 098cf0bf0..33285b0a3 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/web/WebAuthorizingRealm.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/web/WebAuthorizingRealm.java
@@ -19,9 +19,8 @@ package org.apache.inlong.manager.web.auth.web;
import com.google.common.collect.Sets;
import org.apache.inlong.manager.common.enums.UserTypeEnum;
-import org.apache.inlong.manager.common.pojo.user.UserDetail;
+import org.apache.inlong.manager.common.pojo.user.UserInfo;
import org.apache.inlong.manager.common.util.Preconditions;
-import org.apache.inlong.manager.dao.entity.UserEntity;
import org.apache.inlong.manager.service.core.UserService;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
@@ -50,18 +49,15 @@ public class WebAuthorizingRealm extends AuthorizingRealm {
* Login authentication
*/
@Override
- protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken)
- throws AuthenticationException {
- UsernamePasswordToken upToken = (UsernamePasswordToken) authenticationToken;
+ protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
+ UsernamePasswordToken upToken = (UsernamePasswordToken) token;
String username = upToken.getUsername();
- UserEntity userEntity = userService.getByUsername(username);
- Preconditions.checkNotNull(userEntity, "User doesn't exist");
- Preconditions.checkTrue(userEntity.getDueDate().after(new Date()), "user has expired");
- UserDetail userDetail = new UserDetail();
- userDetail.setUsername(username);
- userDetail.setRoles(Sets.newHashSet(userEntity.getAccountType() == 0
+ UserInfo userInfo = userService.getByName(username);
+ Preconditions.checkNotNull(userInfo, "User not exist with name=" + username);
+ Preconditions.checkTrue(userInfo.getDueDate().after(new Date()), "User " + username + " was expired");
+ userInfo.setRoles(Sets.newHashSet(userInfo.getAccountType() == 0
? UserTypeEnum.ADMIN.name() : UserTypeEnum.OPERATOR.name()));
- return new SimpleAuthenticationInfo(userDetail, userEntity.getPassword(), getName());
+ return new SimpleAuthenticationInfo(userInfo, userInfo.getPassword(), getName());
}
/**
@@ -70,9 +66,9 @@ public class WebAuthorizingRealm extends AuthorizingRealm {
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo();
- UserDetail userDetail = (UserDetail) getAvailablePrincipal(principalCollection);
- if (userDetail != null) {
- simpleAuthorizationInfo.setRoles(userDetail.getRoles());
+ UserInfo userInfo = (UserInfo) getAvailablePrincipal(principalCollection);
+ if (userInfo != null) {
+ simpleAuthorizationInfo.setRoles(userInfo.getRoles());
}
return simpleAuthorizationInfo;
}
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/config/ControllerExceptionHandler.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/config/ControllerExceptionHandler.java
index 1bbee2007..f888d820a 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/config/ControllerExceptionHandler.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/config/ControllerExceptionHandler.java
@@ -21,7 +21,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.inlong.manager.common.beans.Response;
import org.apache.inlong.manager.common.exceptions.BusinessException;
import org.apache.inlong.manager.common.exceptions.WorkflowException;
-import org.apache.inlong.manager.common.pojo.user.UserDetail;
+import org.apache.inlong.manager.common.pojo.user.UserInfo;
import org.apache.inlong.manager.common.util.LoginUserUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authz.AuthorizationException;
@@ -50,8 +50,8 @@ public class ControllerExceptionHandler {
@ExceptionHandler(ConstraintViolationException.class)
public Response<String> handleConstraintViolationException(HttpServletRequest request,
ConstraintViolationException e) {
- UserDetail userDetail = LoginUserUtils.getLoginUserDetail();
- String username = userDetail != null ? userDetail.getUsername() : "";
+ UserInfo userInfo = LoginUserUtils.getLoginUser();
+ String username = userInfo != null ? userInfo.getName() : "";
log.error(String.format(ERROR_MSG, request.getRequestURI(), username), e);
Set<ConstraintViolation<?>> violations = e.getConstraintViolations();
@@ -66,8 +66,8 @@ public class ControllerExceptionHandler {
@ExceptionHandler(MethodArgumentNotValidException.class)
public Response<String> handleMethodArgumentNotValidException(HttpServletRequest request,
MethodArgumentNotValidException e) {
- UserDetail userDetail = LoginUserUtils.getLoginUserDetail();
- String username = userDetail != null ? userDetail.getUsername() : "";
+ UserInfo userInfo = LoginUserUtils.getLoginUser();
+ String username = userInfo != null ? userInfo.getName() : "";
log.error(String.format(ERROR_MSG, request.getRequestURI(), username), e);
StringBuilder builder = new StringBuilder();
@@ -86,16 +86,16 @@ public class ControllerExceptionHandler {
@ExceptionHandler(value = IllegalArgumentException.class)
public Response<String> handleIllegalArgumentException(HttpServletRequest request, IllegalArgumentException e) {
- UserDetail userDetail = LoginUserUtils.getLoginUserDetail();
- String username = userDetail != null ? userDetail.getUsername() : "";
+ UserInfo userInfo = LoginUserUtils.getLoginUser();
+ String username = userInfo != null ? userInfo.getName() : "";
log.error(String.format(ERROR_MSG, request.getRequestURI(), username), e);
return Response.fail(e.getMessage());
}
@ExceptionHandler(value = BindException.class)
public Response<String> handleBindExceptionHandler(HttpServletRequest request, BindException e) {
- UserDetail userDetail = LoginUserUtils.getLoginUserDetail();
- String username = userDetail != null ? userDetail.getUsername() : "";
+ UserInfo userInfo = LoginUserUtils.getLoginUser();
+ String username = userInfo != null ? userInfo.getName() : "";
log.error(String.format(ERROR_MSG, request.getRequestURI(), username), e);
StringBuilder builder = new StringBuilder();
@@ -109,24 +109,24 @@ public class ControllerExceptionHandler {
@ExceptionHandler(value = HttpMessageConversionException.class)
public Response<String> handleHttpMessageConversionExceptionHandler(HttpServletRequest request,
HttpMessageConversionException e) {
- UserDetail userDetail = LoginUserUtils.getLoginUserDetail();
- String username = userDetail != null ? userDetail.getUsername() : "";
+ UserInfo userInfo = LoginUserUtils.getLoginUser();
+ String username = userInfo != null ? userInfo.getName() : "";
log.error(String.format(ERROR_MSG, request.getRequestURI(), username), e);
return Response.fail("http message convert exception! pls check params");
}
@ExceptionHandler(value = WorkflowException.class)
public Response<String> handleWorkflowException(HttpServletRequest request, WorkflowException e) {
- UserDetail userDetail = LoginUserUtils.getLoginUserDetail();
- String username = userDetail != null ? userDetail.getUsername() : "";
+ UserInfo userInfo = LoginUserUtils.getLoginUser();
+ String username = userInfo != null ? userInfo.getName() : "";
log.error(String.format(ERROR_MSG, request.getRequestURI(), username), e);
return Response.fail(e.getMessage());
}
@ExceptionHandler(value = BusinessException.class)
public Response<String> handleBusinessExceptionHandler(HttpServletRequest request, BusinessException e) {
- UserDetail userDetail = LoginUserUtils.getLoginUserDetail();
- String username = userDetail != null ? userDetail.getUsername() : "";
+ UserInfo userInfo = LoginUserUtils.getLoginUser();
+ String username = userInfo != null ? userInfo.getName() : "";
log.error(String.format(ERROR_MSG, request.getRequestURI(), username), e);
return Response.fail(e.getMessage());
}
@@ -139,17 +139,17 @@ public class ControllerExceptionHandler {
@ExceptionHandler(value = UnauthorizedException.class)
public Response<String> handleUnauthorizedException(HttpServletRequest request, AuthorizationException e) {
- UserDetail userDetail = LoginUserUtils.getLoginUserDetail();
- String username = userDetail != null ? userDetail.getUsername() : "";
+ UserInfo userInfo = LoginUserUtils.getLoginUser();
+ String username = userInfo != null ? userInfo.getName() : "";
log.error(String.format(ERROR_MSG, request.getRequestURI(), username), e);
return Response.fail(String.format("Current user [%s] has no permission to access URL",
- (userDetail != null ? userDetail.getUsername() : "")));
+ (userInfo != null ? userInfo.getName() : "")));
}
@ExceptionHandler(Exception.class)
public Response<String> handle(HttpServletRequest request, Exception e) {
- UserDetail userDetail = LoginUserUtils.getLoginUserDetail();
- String username = userDetail != null ? userDetail.getUsername() : "";
+ UserInfo userInfo = LoginUserUtils.getLoginUser();
+ String username = userInfo != null ? userInfo.getName() : "";
log.error(String.format(ERROR_MSG, request.getRequestURI(), username), e);
return Response.fail("There was an error in the service..."
+ "Please try again later! "
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/AnnoController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/AnnoController.java
index cd7181667..d01e7626d 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/AnnoController.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/AnnoController.java
@@ -20,8 +20,8 @@ package org.apache.inlong.manager.web.controller;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.inlong.manager.common.beans.Response;
-import org.apache.inlong.manager.common.pojo.user.LoginUser;
-import org.apache.inlong.manager.common.pojo.user.UserDetail;
+import org.apache.inlong.manager.common.pojo.user.UserLoginRequest;
+import org.apache.inlong.manager.common.pojo.user.UserRequest;
import org.apache.inlong.manager.common.pojo.user.UserInfo;
import org.apache.inlong.manager.common.util.LoginUserUtils;
import org.apache.inlong.manager.service.core.UserService;
@@ -44,28 +44,27 @@ import org.springframework.web.bind.annotation.RestController;
public class AnnoController {
@Autowired
- UserService userService;
+ private UserService userService;
@PostMapping("/anno/login")
- public Response<String> login(@Validated @RequestBody LoginUser loginUser) {
-
+ public Response<Boolean> login(@Validated @RequestBody UserLoginRequest loginRequest) {
Subject subject = SecurityUtils.getSubject();
- UsernamePasswordToken token = new UsernamePasswordToken(loginUser.getUsername(), loginUser.getPassword());
+ UsernamePasswordToken token = new UsernamePasswordToken(loginRequest.getUsername(), loginRequest.getPassword());
subject.login(token);
- LoginUserUtils.setUserLoginInfo((UserDetail) subject.getPrincipal());
+ LoginUserUtils.setUserLoginInfo((UserInfo) subject.getPrincipal());
- return Response.success("success");
+ return Response.success(true);
}
- @PostMapping("/anno/doRegister")
- public Response<Boolean> doRegister(@Validated @RequestBody UserInfo userInfo) {
- return Response.success(userService.create(userInfo));
+ @PostMapping("/anno/register")
+ public Response<Integer> register(@Validated @RequestBody UserRequest request) {
+ return Response.success(userService.save(request));
}
@GetMapping("/anno/logout")
- public Response<String> logout() {
+ public Response<Boolean> logout() {
SecurityUtils.getSubject().logout();
- return Response.success("success");
+ return Response.success(true);
}
}
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/ConsumptionController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/ConsumptionController.java
index 60796cdeb..fc132649b 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/ConsumptionController.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/ConsumptionController.java
@@ -56,14 +56,14 @@ public class ConsumptionController {
@GetMapping("/consumption/summary")
@ApiOperation(value = "Get data consumption summary")
public Response<ConsumptionSummary> getSummary(ConsumptionQuery query) {
- query.setUsername(LoginUserUtils.getLoginUserDetail().getUsername());
+ query.setUsername(LoginUserUtils.getLoginUser().getName());
return Response.success(consumptionService.getSummary(query));
}
@GetMapping("/consumption/list")
@ApiOperation(value = "List data consumptions")
public Response<PageInfo<ConsumptionListVo>> list(ConsumptionQuery query) {
- query.setUsername(LoginUserUtils.getLoginUserDetail().getUsername());
+ query.setUsername(LoginUserUtils.getLoginUser().getName());
return Response.success(consumptionService.list(query));
}
@@ -79,7 +79,7 @@ public class ConsumptionController {
@ApiOperation(value = "Delete data consumption")
@ApiImplicitParam(name = "id", value = "Consumption ID", dataTypeClass = Integer.class, required = true)
public Response<Object> delete(@PathVariable(name = "id") Integer id) {
- this.consumptionService.delete(id, LoginUserUtils.getLoginUserDetail().getUsername());
+ this.consumptionService.delete(id, LoginUserUtils.getLoginUser().getName());
return Response.success();
}
@@ -87,7 +87,7 @@ public class ConsumptionController {
@OperationLog(operation = OperationType.UPDATE)
@ApiOperation(value = "Save data consumption", notes = "Full coverage")
public Response<Integer> save(@Validated @RequestBody ConsumptionInfo consumptionInfo) {
- String currentUser = LoginUserUtils.getLoginUserDetail().getUsername();
+ String currentUser = LoginUserUtils.getLoginUser().getName();
return Response.success(consumptionService.save(consumptionInfo, currentUser));
}
@@ -97,7 +97,7 @@ public class ConsumptionController {
public Response<String> update(@PathVariable(name = "id") Integer id,
@Validated @RequestBody ConsumptionInfo consumptionInfo) {
consumptionInfo.setId(id);
- consumptionService.update(consumptionInfo, LoginUserUtils.getLoginUserDetail().getUsername());
+ consumptionService.update(consumptionInfo, LoginUserUtils.getLoginUser().getName());
return Response.success();
}
@@ -106,7 +106,7 @@ public class ConsumptionController {
@ApiOperation(value = "Start approval process")
@ApiImplicitParam(name = "id", value = "Consumption ID", dataTypeClass = Integer.class, required = true)
public Response<WorkflowResult> startProcess(@PathVariable(name = "id") Integer id) {
- String username = LoginUserUtils.getLoginUserDetail().getUsername();
+ String username = LoginUserUtils.getLoginUser().getName();
return Response.success(processOperation.startProcess(id, username));
}
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/DataNodeController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/DataNodeController.java
index 976206c69..191bc7c99 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/DataNodeController.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/DataNodeController.java
@@ -56,7 +56,7 @@ public class DataNodeController {
@OperationLog(operation = OperationType.CREATE)
@RequiresRoles(value = UserRoleCode.ADMIN)
public Response<Integer> save(@Validated @RequestBody DataNodeRequest request) {
- String currentUser = LoginUserUtils.getLoginUserDetail().getUsername();
+ String currentUser = LoginUserUtils.getLoginUser().getName();
return Response.success(dataNodeService.save(request, currentUser));
}
@@ -77,7 +77,7 @@ public class DataNodeController {
@OperationLog(operation = OperationType.UPDATE)
@ApiOperation(value = "Update data node")
public Response<Boolean> update(@Validated(UpdateValidation.class) @RequestBody DataNodeRequest request) {
- String username = LoginUserUtils.getLoginUserDetail().getUsername();
+ String username = LoginUserUtils.getLoginUser().getName();
return Response.success(dataNodeService.update(request, username));
}
@@ -87,7 +87,7 @@ public class DataNodeController {
@ApiImplicitParam(name = "id", value = "Data node ID", dataTypeClass = Integer.class, required = true)
@RequiresRoles(value = UserRoleCode.ADMIN)
public Response<Boolean> delete(@PathVariable Integer id) {
- return Response.success(dataNodeService.delete(id, LoginUserUtils.getLoginUserDetail().getUsername()));
+ return Response.success(dataNodeService.delete(id, LoginUserUtils.getLoginUser().getName()));
}
@PostMapping("/node/testConnection")
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongClusterController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongClusterController.java
index 3f827e138..9028a288b 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongClusterController.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongClusterController.java
@@ -64,7 +64,7 @@ public class InlongClusterController {
@OperationLog(operation = OperationType.CREATE)
@RequiresRoles(value = UserRoleCode.ADMIN)
public Response<Integer> saveTag(@Validated @RequestBody ClusterTagRequest request) {
- String currentUser = LoginUserUtils.getLoginUserDetail().getUsername();
+ String currentUser = LoginUserUtils.getLoginUser().getName();
return Response.success(clusterService.saveTag(request, currentUser));
}
@@ -72,14 +72,14 @@ public class InlongClusterController {
@ApiOperation(value = "Get cluster tag by id")
@ApiImplicitParam(name = "id", value = "Cluster ID", dataTypeClass = Integer.class, required = true)
public Response<ClusterTagResponse> getTag(@PathVariable Integer id) {
- String currentUser = LoginUserUtils.getLoginUserDetail().getUsername();
+ String currentUser = LoginUserUtils.getLoginUser().getName();
return Response.success(clusterService.getTag(id, currentUser));
}
@PostMapping(value = "/cluster/tag/list")
@ApiOperation(value = "List cluster tags")
public Response<PageInfo<ClusterTagResponse>> listTag(@RequestBody ClusterTagPageRequest request) {
- request.setCurrentUser(LoginUserUtils.getLoginUserDetail().getUsername());
+ request.setCurrentUser(LoginUserUtils.getLoginUser().getName());
return Response.success(clusterService.listTag(request));
}
@@ -87,7 +87,7 @@ public class InlongClusterController {
@OperationLog(operation = OperationType.UPDATE)
@ApiOperation(value = "Update cluster tag")
public Response<Boolean> updateTag(@Validated(UpdateValidation.class) @RequestBody ClusterTagRequest request) {
- String username = LoginUserUtils.getLoginUserDetail().getUsername();
+ String username = LoginUserUtils.getLoginUser().getName();
return Response.success(clusterService.updateTag(request, username));
}
@@ -97,7 +97,7 @@ public class InlongClusterController {
@ApiImplicitParam(name = "id", value = "Cluster tag ID", dataTypeClass = Integer.class, required = true)
@RequiresRoles(value = UserRoleCode.ADMIN)
public Response<Boolean> deleteTag(@PathVariable Integer id) {
- return Response.success(clusterService.deleteTag(id, LoginUserUtils.getLoginUserDetail().getUsername()));
+ return Response.success(clusterService.deleteTag(id, LoginUserUtils.getLoginUser().getName()));
}
@PostMapping(value = "/cluster/save")
@@ -105,7 +105,7 @@ public class InlongClusterController {
@OperationLog(operation = OperationType.CREATE)
@RequiresRoles(value = UserRoleCode.ADMIN)
public Response<Integer> save(@Validated @RequestBody ClusterRequest request) {
- String currentUser = LoginUserUtils.getLoginUserDetail().getUsername();
+ String currentUser = LoginUserUtils.getLoginUser().getName();
return Response.success(clusterService.save(request, currentUser));
}
@@ -113,7 +113,7 @@ public class InlongClusterController {
@ApiOperation(value = "Get cluster by id")
@ApiImplicitParam(name = "id", value = "Cluster ID", dataTypeClass = Integer.class, required = true)
public Response<ClusterInfo> get(@PathVariable Integer id) {
- String currentUser = LoginUserUtils.getLoginUserDetail().getUsername();
+ String currentUser = LoginUserUtils.getLoginUser().getName();
return Response.success(clusterService.get(id, currentUser));
}
@@ -127,7 +127,7 @@ public class InlongClusterController {
@OperationLog(operation = OperationType.UPDATE)
@ApiOperation(value = "Update cluster")
public Response<Boolean> update(@Validated(UpdateValidation.class) @RequestBody ClusterRequest request) {
- String username = LoginUserUtils.getLoginUserDetail().getUsername();
+ String username = LoginUserUtils.getLoginUser().getName();
return Response.success(clusterService.update(request, username));
}
@@ -135,7 +135,7 @@ public class InlongClusterController {
@OperationLog(operation = OperationType.UPDATE)
@ApiOperation(value = "Bind or unbind cluster tag")
public Response<Boolean> bindTag(@Validated @RequestBody BindTagRequest request) {
- String username = LoginUserUtils.getLoginUserDetail().getUsername();
+ String username = LoginUserUtils.getLoginUser().getName();
return Response.success(clusterService.bindTag(request, username));
}
@@ -145,14 +145,14 @@ public class InlongClusterController {
@ApiImplicitParam(name = "id", value = "Cluster ID", dataTypeClass = Integer.class, required = true)
@RequiresRoles(value = UserRoleCode.ADMIN)
public Response<Boolean> delete(@PathVariable Integer id) {
- return Response.success(clusterService.delete(id, LoginUserUtils.getLoginUserDetail().getUsername()));
+ return Response.success(clusterService.delete(id, LoginUserUtils.getLoginUser().getName()));
}
@PostMapping(value = "/cluster/node/save")
@ApiOperation(value = "Save cluster node")
@OperationLog(operation = OperationType.CREATE)
public Response<Integer> saveNode(@Validated @RequestBody ClusterNodeRequest request) {
- String currentUser = LoginUserUtils.getLoginUserDetail().getUsername();
+ String currentUser = LoginUserUtils.getLoginUser().getName();
return Response.success(clusterService.saveNode(request, currentUser));
}
@@ -160,14 +160,14 @@ public class InlongClusterController {
@ApiOperation(value = "Get cluster node by id")
@ApiImplicitParam(name = "id", value = "Cluster node ID", dataTypeClass = Integer.class, required = true)
public Response<ClusterNodeResponse> getNode(@PathVariable Integer id) {
- String currentUser = LoginUserUtils.getLoginUserDetail().getUsername();
+ String currentUser = LoginUserUtils.getLoginUser().getName();
return Response.success(clusterService.getNode(id, currentUser));
}
@PostMapping(value = "/cluster/node/list")
@ApiOperation(value = "List cluster nodes")
public Response<PageInfo<ClusterNodeResponse>> listNode(@RequestBody ClusterPageRequest request) {
- String currentUser = LoginUserUtils.getLoginUserDetail().getUsername();
+ String currentUser = LoginUserUtils.getLoginUser().getName();
return Response.success(clusterService.listNode(request, currentUser));
}
@@ -175,7 +175,7 @@ public class InlongClusterController {
@OperationLog(operation = OperationType.UPDATE)
@ApiOperation(value = "Update cluster node")
public Response<Boolean> updateNode(@Validated(UpdateValidation.class) @RequestBody ClusterNodeRequest request) {
- String username = LoginUserUtils.getLoginUserDetail().getUsername();
+ String username = LoginUserUtils.getLoginUser().getName();
return Response.success(clusterService.updateNode(request, username));
}
@@ -184,7 +184,7 @@ public class InlongClusterController {
@OperationLog(operation = OperationType.DELETE)
@ApiImplicitParam(name = "id", value = "Cluster node ID", dataTypeClass = Integer.class, required = true)
public Response<Boolean> deleteNode(@PathVariable Integer id) {
- return Response.success(clusterService.deleteNode(id, LoginUserUtils.getLoginUserDetail().getUsername()));
+ return Response.success(clusterService.deleteNode(id, LoginUserUtils.getLoginUser().getName()));
}
}
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongGroupController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongGroupController.java
index fbba322c2..2ae736fcd 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongGroupController.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongGroupController.java
@@ -62,7 +62,7 @@ public class InlongGroupController {
@OperationLog(operation = OperationType.CREATE)
@ApiOperation(value = "Save inlong group")
public Response<String> save(@Validated @RequestBody InlongGroupRequest groupRequest) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(groupService.save(groupRequest, operator));
}
@@ -76,8 +76,8 @@ public class InlongGroupController {
@RequestMapping(value = "/group/list", method = RequestMethod.POST)
@ApiOperation(value = "Get inlong group list by paginating")
public Response<PageInfo<InlongGroupBriefInfo>> listBrief(@RequestBody InlongGroupPageRequest request) {
- request.setCurrentUser(LoginUserUtils.getLoginUserDetail().getUsername());
- request.setIsAdminRole(LoginUserUtils.getLoginUserDetail().getRoles().contains(UserTypeEnum.ADMIN.name()));
+ request.setCurrentUser(LoginUserUtils.getLoginUser().getName());
+ request.setIsAdminRole(LoginUserUtils.getLoginUser().getRoles().contains(UserTypeEnum.ADMIN.name()));
return Response.success(groupService.listBrief(request));
}
@@ -85,7 +85,7 @@ public class InlongGroupController {
@OperationLog(operation = OperationType.UPDATE)
@ApiOperation(value = "Update inlong group")
public Response<String> update(@Validated(UpdateValidation.class) @RequestBody InlongGroupRequest groupRequest) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(groupService.update(groupRequest, operator));
}
@@ -99,7 +99,7 @@ public class InlongGroupController {
@RequestMapping(value = "/group/countByStatus", method = RequestMethod.GET)
@ApiOperation(value = "Count inlong group status for current user")
public Response<InlongGroupCountResponse> countGroupByUser() {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(groupService.countGroupByUser(operator));
}
@@ -107,7 +107,7 @@ public class InlongGroupController {
@ApiOperation(value = "Start inlong approval process")
@ApiImplicitParam(name = "groupId", value = "Inlong group id", dataTypeClass = String.class)
public Response<WorkflowResult> startProcess(@PathVariable String groupId) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(groupProcessOperation.startProcess(groupId, operator));
}
@@ -115,7 +115,7 @@ public class InlongGroupController {
@ApiOperation(value = "Suspend inlong group process")
@ApiImplicitParam(name = "groupId", value = "Inlong group id", dataTypeClass = String.class)
public Response<WorkflowResult> suspendProcess(@PathVariable String groupId) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(groupProcessOperation.suspendProcess(groupId, operator));
}
@@ -123,7 +123,7 @@ public class InlongGroupController {
@ApiOperation(value = "Restart inlong group process")
@ApiImplicitParam(name = "groupId", value = "Inlong group id", dataTypeClass = String.class)
public Response<WorkflowResult> restartProcess(@PathVariable String groupId) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(groupProcessOperation.restartProcess(groupId, operator));
}
@@ -132,7 +132,7 @@ public class InlongGroupController {
@OperationLog(operation = OperationType.DELETE)
@ApiImplicitParam(name = "groupId", value = "Inlong group id", dataTypeClass = String.class, required = true)
public Response<Boolean> delete(@PathVariable String groupId) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(groupProcessOperation.deleteProcess(groupId, operator));
}
@@ -140,7 +140,7 @@ public class InlongGroupController {
@ApiOperation(value = "Suspend inlong group process")
@ApiImplicitParam(name = "groupId", value = "Inlong group id", dataTypeClass = String.class)
public Response<String> suspendProcessAsync(@PathVariable String groupId) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(groupProcessOperation.suspendProcessAsync(groupId, operator));
}
@@ -148,7 +148,7 @@ public class InlongGroupController {
@ApiOperation(value = "Restart inlong group process")
@ApiImplicitParam(name = "groupId", value = "Inlong group id", dataTypeClass = String.class)
public Response<String> restartProcessAsync(@PathVariable String groupId) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(groupProcessOperation.restartProcessAsync(groupId, operator));
}
@@ -157,7 +157,7 @@ public class InlongGroupController {
@OperationLog(operation = OperationType.DELETE)
@ApiImplicitParam(name = "groupId", value = "Inlong group id", dataTypeClass = String.class, required = true)
public Response<String> deleteAsync(@PathVariable String groupId) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(groupProcessOperation.deleteProcessAsync(groupId, operator));
}
@@ -170,7 +170,7 @@ public class InlongGroupController {
@PostMapping(value = "/group/reset")
@ApiOperation(value = "Reset group status when group is in CONFIG_ING|SUSPENDING|RESTARTING|DELETING")
public Response<Boolean> reset(@RequestBody @Validated InlongGroupResetRequest request) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(groupProcessOperation.resetGroupStatus(request, operator));
}
}
\ No newline at end of file
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongStreamController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongStreamController.java
index fca18cf89..ee851eb88 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongStreamController.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongStreamController.java
@@ -58,7 +58,7 @@ public class InlongStreamController {
@OperationLog(operation = OperationType.CREATE)
@ApiOperation(value = "Save inlong stream")
public Response<Integer> save(@RequestBody InlongStreamRequest request) {
- int result = streamService.save(request, LoginUserUtils.getLoginUserDetail().getUsername());
+ int result = streamService.save(request, LoginUserUtils.getLoginUser().getName());
return Response.success(result);
}
@@ -85,16 +85,16 @@ public class InlongStreamController {
@RequestMapping(value = "/stream/list", method = RequestMethod.POST)
@ApiOperation(value = "Get inlong stream brief info by paginating")
public Response<PageInfo<InlongStreamBriefInfo>> listByCondition(@RequestBody InlongStreamPageRequest request) {
- request.setCurrentUser(LoginUserUtils.getLoginUserDetail().getUsername());
- request.setIsAdminRole(LoginUserUtils.getLoginUserDetail().getRoles().contains(UserRoleCode.ADMIN));
+ request.setCurrentUser(LoginUserUtils.getLoginUser().getName());
+ request.setIsAdminRole(LoginUserUtils.getLoginUser().getRoles().contains(UserRoleCode.ADMIN));
return Response.success(streamService.listBrief(request));
}
@RequestMapping(value = "/stream/listAll", method = RequestMethod.POST)
@ApiOperation(value = "Get inlong stream with all sources and sinks by paginating")
public Response<PageInfo<InlongStreamInfo>> listAllWithGroupId(@RequestBody InlongStreamPageRequest request) {
- request.setCurrentUser(LoginUserUtils.getLoginUserDetail().getUsername());
- request.setIsAdminRole(LoginUserUtils.getLoginUserDetail().getRoles().contains(UserRoleCode.ADMIN));
+ request.setCurrentUser(LoginUserUtils.getLoginUser().getName());
+ request.setIsAdminRole(LoginUserUtils.getLoginUser().getRoles().contains(UserRoleCode.ADMIN));
return Response.success(streamService.listAll(request));
}
@@ -102,7 +102,7 @@ public class InlongStreamController {
@OperationLog(operation = OperationType.UPDATE)
@ApiOperation(value = "Update inlong stream")
public Response<Boolean> update(@RequestBody InlongStreamRequest request) {
- String username = LoginUserUtils.getLoginUserDetail().getUsername();
+ String username = LoginUserUtils.getLoginUser().getName();
return Response.success(streamService.update(request, username));
}
@@ -114,7 +114,7 @@ public class InlongStreamController {
})
public Response<Boolean> startProcess(@PathVariable String groupId, @PathVariable String streamId,
@RequestParam boolean sync) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(streamProcessOperation.startProcess(groupId, streamId, operator, sync));
}
@@ -126,7 +126,7 @@ public class InlongStreamController {
})
public Response<Boolean> suspendProcess(@PathVariable String groupId, @PathVariable String streamId,
@RequestParam boolean sync) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(streamProcessOperation.suspendProcess(groupId, streamId, operator, sync));
}
@@ -138,7 +138,7 @@ public class InlongStreamController {
})
public Response<Boolean> restartProcess(@PathVariable String groupId, @PathVariable String streamId,
@RequestParam boolean sync) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(streamProcessOperation.restartProcess(groupId, streamId, operator, sync));
}
@@ -150,7 +150,7 @@ public class InlongStreamController {
})
public Response<Boolean> deleteProcess(@PathVariable String groupId, @PathVariable String streamId,
@RequestParam boolean sync) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(streamProcessOperation.deleteProcess(groupId, streamId, operator, sync));
}
@@ -163,7 +163,7 @@ public class InlongStreamController {
@ApiImplicitParam(name = "streamId", dataTypeClass = String.class, required = true)
})
public Response<Boolean> delete(@RequestParam String groupId, @RequestParam String streamId) {
- String username = LoginUserUtils.getLoginUserDetail().getUsername();
+ String username = LoginUserUtils.getLoginUser().getName();
return Response.success(streamService.delete(groupId, streamId, username));
}
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/StreamSinkController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/StreamSinkController.java
index 8473f88cc..1d8c96417 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/StreamSinkController.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/StreamSinkController.java
@@ -52,7 +52,7 @@ public class StreamSinkController {
@OperationLog(operation = OperationType.CREATE)
@ApiOperation(value = "Save stream sink")
public Response<Integer> save(@Validated @RequestBody SinkRequest request) {
- return Response.success(sinkService.save(request, LoginUserUtils.getLoginUserDetail().getUsername()));
+ return Response.success(sinkService.save(request, LoginUserUtils.getLoginUser().getName()));
}
@RequestMapping(value = "/sink/get/{id}", method = RequestMethod.GET)
@@ -72,7 +72,7 @@ public class StreamSinkController {
@OperationLog(operation = OperationType.UPDATE)
@ApiOperation(value = "Update stream sink")
public Response<Boolean> update(@Validated(UpdateValidation.class) @RequestBody SinkRequest request) {
- return Response.success(sinkService.update(request, LoginUserUtils.getLoginUserDetail().getUsername()));
+ return Response.success(sinkService.update(request, LoginUserUtils.getLoginUser().getName()));
}
@RequestMapping(value = "/sink/delete/{id}", method = RequestMethod.DELETE)
@@ -80,7 +80,7 @@ public class StreamSinkController {
@ApiOperation(value = "Delete stream sink")
@ApiImplicitParam(name = "id", dataTypeClass = Integer.class, required = true)
public Response<Boolean> delete(@PathVariable Integer id) {
- boolean result = sinkService.delete(id, LoginUserUtils.getLoginUserDetail().getUsername());
+ boolean result = sinkService.delete(id, LoginUserUtils.getLoginUser().getName());
return Response.success(result);
}
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/StreamSourceController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/StreamSourceController.java
index 76cfe838f..06f8dc49e 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/StreamSourceController.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/StreamSourceController.java
@@ -52,7 +52,7 @@ public class StreamSourceController {
@OperationLog(operation = OperationType.CREATE)
@ApiOperation(value = "Save stream source")
public Response<Integer> save(@Validated @RequestBody SourceRequest request) {
- return Response.success(sourceService.save(request, LoginUserUtils.getLoginUserDetail().getUsername()));
+ return Response.success(sourceService.save(request, LoginUserUtils.getLoginUser().getName()));
}
@RequestMapping(value = "/source/get/{id}", method = RequestMethod.GET)
@@ -72,7 +72,7 @@ public class StreamSourceController {
@OperationLog(operation = OperationType.UPDATE)
@ApiOperation(value = "Update stream source")
public Response<Boolean> update(@Validated(UpdateValidation.class) @RequestBody SourceRequest request) {
- return Response.success(sourceService.update(request, LoginUserUtils.getLoginUserDetail().getUsername()));
+ return Response.success(sourceService.update(request, LoginUserUtils.getLoginUser().getName()));
}
@RequestMapping(value = "/source/delete/{id}", method = RequestMethod.DELETE)
@@ -80,7 +80,7 @@ public class StreamSourceController {
@ApiOperation(value = "Delete stream source")
@ApiImplicitParam(name = "id", dataTypeClass = Integer.class, required = true)
public Response<Boolean> delete(@PathVariable Integer id) {
- boolean result = sourceService.delete(id, LoginUserUtils.getLoginUserDetail().getUsername());
+ boolean result = sourceService.delete(id, LoginUserUtils.getLoginUser().getName());
return Response.success(result);
}
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/StreamTransformController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/StreamTransformController.java
index 94046be67..cef11ca39 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/StreamTransformController.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/StreamTransformController.java
@@ -53,7 +53,7 @@ public class StreamTransformController {
@ApiOperation(value = "Save stream transform")
public Response<Integer> save(@Validated @RequestBody TransformRequest request) {
return Response.success(
- streamTransformService.save(request, LoginUserUtils.getLoginUserDetail().getUsername()));
+ streamTransformService.save(request, LoginUserUtils.getLoginUser().getName()));
}
@RequestMapping(value = "/transform/list", method = RequestMethod.GET)
@@ -67,7 +67,7 @@ public class StreamTransformController {
@OperationLog(operation = OperationType.UPDATE)
@ApiOperation(value = "Update stream transform")
public Response<Boolean> update(@Validated(UpdateValidation.class) @RequestBody TransformRequest request) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(streamTransformService.update(request, operator));
}
@@ -75,7 +75,7 @@ public class StreamTransformController {
@OperationLog(operation = OperationType.UPDATE)
@ApiOperation(value = "Delete stream transform")
public Response<Boolean> delete(@Validated DeleteTransformRequest request) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(streamTransformService.delete(request, operator));
}
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/UserController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/UserController.java
index 6616e4f23..1f43eaf31 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/UserController.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/UserController.java
@@ -21,9 +21,7 @@ import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.inlong.manager.common.beans.Response;
-import org.apache.inlong.manager.common.pojo.user.UserDetail;
-import org.apache.inlong.manager.common.pojo.user.UserDetailListVO;
-import org.apache.inlong.manager.common.pojo.user.UserDetailPageRequest;
+import org.apache.inlong.manager.common.pojo.user.UserRequest;
import org.apache.inlong.manager.common.pojo.user.UserInfo;
import org.apache.inlong.manager.common.pojo.user.UserRoleCode;
import org.apache.inlong.manager.common.util.LoginUserUtils;
@@ -50,44 +48,44 @@ public class UserController {
@Autowired
UserService userService;
- @PostMapping("/user/loginUser")
+ @PostMapping("/user/currentUser")
@ApiOperation(value = "Get the logged-in user")
- public Response<UserDetail> currentUser() {
- return Response.success(LoginUserUtils.getLoginUserDetail());
+ public Response<UserInfo> currentUser() {
+ return Response.success(LoginUserUtils.getLoginUser());
}
@PostMapping("/user/register")
@ApiOperation(value = "Register user")
@RequiresRoles(value = UserRoleCode.ADMIN)
- public Response<Boolean> register(@Validated @RequestBody UserInfo userInfo) {
- return Response.success(userService.create(userInfo));
+ public Response<Integer> register(@Validated @RequestBody UserRequest userInfo) {
+ return Response.success(userService.save(userInfo));
}
@GetMapping("/user/get/{id}")
@ApiOperation(value = "Get user info")
public Response<UserInfo> getById(@PathVariable Integer id) {
- String currentUser = LoginUserUtils.getLoginUserDetail().getUsername();
+ String currentUser = LoginUserUtils.getLoginUser().getName();
return Response.success(userService.getById(id, currentUser));
}
+ @GetMapping("/user/listAll")
+ @ApiOperation(value = "List all users")
+ public Response<PageInfo<UserInfo>> list(UserRequest request) {
+ return Response.success(userService.list(request));
+ }
+
@PostMapping("/user/update")
@ApiOperation(value = "Update user info")
- public Response<Integer> update(@Validated @RequestBody UserInfo userInfo) {
- String currentUser = LoginUserUtils.getLoginUserDetail().getUsername();
+ public Response<Integer> update(@Validated @RequestBody UserRequest userInfo) {
+ String currentUser = LoginUserUtils.getLoginUser().getName();
return Response.success(userService.update(userInfo, currentUser));
}
- @GetMapping("/user/listAllUsers")
- @ApiOperation(value = "List all users")
- public Response<PageInfo<UserDetailListVO>> list(UserDetailPageRequest request) {
- return Response.success(userService.list(request));
- }
-
@DeleteMapping("/user/delete")
@ApiOperation(value = "Delete user by id")
@RequiresRoles(value = UserRoleCode.ADMIN)
public Response<Boolean> delete(@RequestParam("id") Integer id) {
- String currentUser = LoginUserUtils.getLoginUserDetail().getUsername();
+ String currentUser = LoginUserUtils.getLoginUser().getName();
return Response.success(userService.delete(id, currentUser));
}
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/WorkflowApproverController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/WorkflowApproverController.java
index 73142d82b..110d14475 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/WorkflowApproverController.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/WorkflowApproverController.java
@@ -58,7 +58,7 @@ public class WorkflowApproverController {
@OperationLog(operation = OperationType.CREATE)
@ApiOperation(value = "Add approver configuration")
public Response<Object> add(@RequestBody WorkflowApprover config) {
- this.workflowApproverService.add(config, LoginUserUtils.getLoginUserDetail().getUsername());
+ this.workflowApproverService.add(config, LoginUserUtils.getLoginUser().getName());
return Response.success();
}
@@ -66,7 +66,7 @@ public class WorkflowApproverController {
@OperationLog(operation = OperationType.UPDATE)
@ApiOperation(value = "Update approver configuration")
public Response<Object> update(@RequestBody WorkflowApprover config) {
- this.workflowApproverService.update(config, LoginUserUtils.getLoginUserDetail().getUsername());
+ this.workflowApproverService.update(config, LoginUserUtils.getLoginUser().getName());
return Response.success();
}
@@ -75,7 +75,7 @@ public class WorkflowApproverController {
@ApiOperation(value = "Delete approver configuration")
@ApiParam(value = "Configuration item ID", required = true)
public Response<Object> delete(@PathVariable Integer id) {
- this.workflowApproverService.delete(id, LoginUserUtils.getLoginUserDetail().getUsername());
+ this.workflowApproverService.delete(id, LoginUserUtils.getLoginUser().getName());
return Response.success();
}
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/WorkflowController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/WorkflowController.java
index edf21c2e3..4fef244f2 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/WorkflowController.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/WorkflowController.java
@@ -65,7 +65,7 @@ public class WorkflowController {
@OperationLog(operation = OperationType.CREATE)
@ApiOperation(value = "Initiation process")
public Response<WorkflowResult> start(@RequestBody WorkflowOperation operation) {
- String applicant = LoginUserUtils.getLoginUserDetail().getUsername();
+ String applicant = LoginUserUtils.getLoginUser().getName();
return Response.success(workflowService.start(operation.getName(), applicant, operation.getForm()));
}
@@ -74,7 +74,7 @@ public class WorkflowController {
@ApiOperation(value = "Cancellation process")
@ApiImplicitParam(name = "id", value = "Process ID", dataTypeClass = Integer.class, required = true)
public Response<WorkflowResult> cancel(@PathVariable Integer id, @RequestBody WorkflowOperation operation) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(workflowService.cancel(id, operator, operation.getRemark()));
}
@@ -84,7 +84,7 @@ public class WorkflowController {
@ApiImplicitParam(name = "id", value = "Process ID", dataTypeClass = Integer.class, required = true)
public Response<WorkflowResult> continueProcess(@PathVariable Integer id,
@RequestBody WorkflowOperation operation) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(workflowService.continueProcess(id, operator, operation.getRemark()));
}
@@ -93,7 +93,7 @@ public class WorkflowController {
@ApiOperation(value = "Approval and consent")
@ApiImplicitParam(name = "id", value = "Task ID", dataTypeClass = Integer.class, required = true)
public Response<WorkflowResult> approve(@PathVariable Integer id, @RequestBody WorkflowTaskRequest operation) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(workflowService.approve(id, operation.getRemark(), operation.getForm(), operator));
}
@@ -102,7 +102,7 @@ public class WorkflowController {
@ApiOperation(value = "Approval rejected")
@ApiImplicitParam(name = "id", value = "Task ID", dataTypeClass = Integer.class, required = true)
public Response<WorkflowResult> reject(@PathVariable Integer id, @RequestBody WorkflowTaskRequest operation) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(workflowService.reject(id, operation.getRemark(), operator));
}
@@ -111,7 +111,7 @@ public class WorkflowController {
@ApiOperation(value = "Turn to another approver", notes = "Change approver")
@ApiImplicitParam(name = "id", value = "Task ID", dataTypeClass = Integer.class, required = true)
public Response<WorkflowResult> transfer(@PathVariable Integer id, @RequestBody WorkflowTaskRequest operation) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(workflowService.transfer(id, operation.getRemark(),
operation.getTransferTo(), operator));
}
@@ -121,7 +121,7 @@ public class WorkflowController {
@ApiOperation(value = "Complete task by ID")
@ApiImplicitParam(name = "id", value = "Task ID", dataTypeClass = Integer.class, required = true)
public Response<WorkflowResult> complete(@PathVariable Integer id, @RequestBody WorkflowTaskRequest request) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(workflowService.complete(id, request.getRemark(), operator));
}
@@ -133,35 +133,35 @@ public class WorkflowController {
})
public Response<ProcessDetailResponse> detail(@PathVariable(name = "id") Integer id,
@RequestParam(required = false) Integer taskId) {
- String operator = LoginUserUtils.getLoginUserDetail().getUsername();
+ String operator = LoginUserUtils.getLoginUser().getName();
return Response.success(workflowService.detail(id, taskId, operator));
}
@GetMapping("/workflow/listProcess")
@ApiOperation(value = "Get process list by paginating")
public Response<PageInfo<ProcessResponse>> listProcess(ProcessQuery query) {
- query.setApplicant(LoginUserUtils.getLoginUserDetail().getUsername());
+ query.setApplicant(LoginUserUtils.getLoginUser().getName());
return Response.success(workflowService.listProcess(query));
}
@GetMapping("/workflow/listTask")
@ApiOperation(value = "Get task list by paginating")
public Response<PageInfo<TaskResponse>> listTask(TaskQuery query) {
- query.setApprover(LoginUserUtils.getLoginUserDetail().getUsername());
+ query.setApprover(LoginUserUtils.getLoginUser().getName());
return Response.success(workflowService.listTask(query));
}
@GetMapping("/workflow/processSummary")
@ApiOperation(value = "Get process statistics")
public Response<ProcessCountResponse> processSummary(ProcessCountQuery query) {
- query.setApplicant(LoginUserUtils.getLoginUserDetail().getUsername());
+ query.setApplicant(LoginUserUtils.getLoginUser().getName());
return Response.success(workflowService.countProcess(query));
}
@GetMapping("/workflow/taskSummary")
@ApiOperation(value = "Get task statistics")
public Response<TaskCountResponse> taskSummary(TaskCountQuery query) {
- query.setApprover(LoginUserUtils.getLoginUserDetail().getUsername());
+ query.setApprover(LoginUserUtils.getLoginUser().getName());
return Response.success(workflowService.countTask(query));
}
diff --git a/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/WebBaseTest.java b/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/WebBaseTest.java
index bed3738f0..a0d58ee6c 100644
--- a/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/WebBaseTest.java
+++ b/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/WebBaseTest.java
@@ -21,7 +21,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.SneakyThrows;
import org.apache.inlong.manager.common.beans.Response;
-import org.apache.inlong.manager.common.pojo.user.LoginUser;
+import org.apache.inlong.manager.common.pojo.user.UserLoginRequest;
import org.apache.inlong.manager.common.util.JsonUtils;
import org.apache.inlong.manager.test.BaseTest;
import org.apache.shiro.SecurityUtils;
@@ -84,7 +84,7 @@ public abstract class WebBaseTest extends BaseTest {
}
protected void adminLogin() throws Exception {
- LoginUser loginUser = new LoginUser();
+ UserLoginRequest loginUser = new UserLoginRequest();
loginUser.setUsername("admin");
loginUser.setPassword("inlong");
@@ -138,7 +138,7 @@ public abstract class WebBaseTest extends BaseTest {
}
protected void operatorLogin() throws Exception {
- LoginUser loginUser = new LoginUser();
+ UserLoginRequest loginUser = new UserLoginRequest();
loginUser.setUsername("operator");
loginUser.setPassword("inlong");
diff --git a/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/controller/AnnoControllerTest.java b/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/controller/AnnoControllerTest.java
index d9243e6ac..ea69c6ec3 100644
--- a/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/controller/AnnoControllerTest.java
+++ b/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/controller/AnnoControllerTest.java
@@ -19,8 +19,8 @@ package org.apache.inlong.manager.web.controller;
import org.apache.inlong.manager.common.beans.Response;
import org.apache.inlong.manager.common.enums.UserTypeEnum;
-import org.apache.inlong.manager.common.pojo.user.LoginUser;
-import org.apache.inlong.manager.common.pojo.user.UserInfo;
+import org.apache.inlong.manager.common.pojo.user.UserLoginRequest;
+import org.apache.inlong.manager.common.pojo.user.UserRequest;
import org.apache.inlong.manager.common.util.JsonUtils;
import org.apache.inlong.manager.web.WebBaseTest;
import org.apache.shiro.SecurityUtils;
@@ -54,7 +54,7 @@ class AnnoControllerTest extends WebBaseTest {
@Test
void testLoginFailByWrongPwd() throws Exception {
- LoginUser loginUser = new LoginUser();
+ UserLoginRequest loginUser = new UserLoginRequest();
loginUser.setUsername("admin");
// Wrong pwd
loginUser.setPassword("test_wrong_pwd");
@@ -75,15 +75,15 @@ class AnnoControllerTest extends WebBaseTest {
@Test
void testRegister() throws Exception {
- UserInfo userInfo = UserInfo.builder()
- .username("test_name")
+ UserRequest userInfo = UserRequest.builder()
+ .name("test_name")
.password(TEST_PWD)
- .type(UserTypeEnum.ADMIN.getCode())
+ .accountType(UserTypeEnum.ADMIN.getCode())
.validDays(88888)
.build();
MvcResult mvcResult = mockMvc.perform(
- post("/anno/doRegister")
+ post("/anno/register")
.content(JsonUtils.toJsonString(userInfo))
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
@@ -91,22 +91,22 @@ class AnnoControllerTest extends WebBaseTest {
.andExpect(status().isOk())
.andReturn();
- Response<Boolean> resBody = getResBody(mvcResult, Boolean.class);
- Assertions.assertTrue(resBody.isSuccess() && resBody.getData());
+ Response<Integer> resBody = getResBody(mvcResult, Integer.class);
+ Assertions.assertTrue(resBody.isSuccess() && resBody.getData() > 0);
}
@Test
void testRegisterFailByExistName() throws Exception {
- UserInfo userInfo = UserInfo.builder()
+ UserRequest userInfo = UserRequest.builder()
// Username already exists in the init sql
- .username("admin")
+ .name("admin")
.password(TEST_PWD)
- .type(UserTypeEnum.ADMIN.getCode())
+ .accountType(UserTypeEnum.ADMIN.getCode())
.validDays(88888)
.build();
MvcResult mvcResult = mockMvc.perform(
- post("/anno/doRegister")
+ post("/anno/register")
.content(JsonUtils.toJsonString(userInfo))
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
@@ -114,7 +114,7 @@ class AnnoControllerTest extends WebBaseTest {
.andExpect(status().isOk())
.andReturn();
- Response<Boolean> resBody = getResBody(mvcResult, Boolean.class);
+ Response<Integer> resBody = getResBody(mvcResult, Integer.class);
Assertions.assertFalse(resBody.isSuccess());
Assertions.assertTrue(resBody.getErrMsg().contains("already exists"));
}
@@ -138,16 +138,16 @@ class AnnoControllerTest extends WebBaseTest {
@Test
void testRegisterFailByInvalidType() throws Exception {
- UserInfo userInfo = UserInfo.builder()
- .username("admin11")
+ UserRequest userInfo = UserRequest.builder()
+ .name("admin11")
.password(TEST_PWD)
// invalidType
- .type(3)
+ .accountType(3)
.validDays(88888)
.build();
MvcResult mvcResult = mockMvc.perform(
- post("/anno/doRegister")
+ post("/anno/register")
.content(JsonUtils.toJsonString(userInfo))
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
@@ -155,9 +155,9 @@ class AnnoControllerTest extends WebBaseTest {
.andExpect(status().isOk())
.andReturn();
- Response<Boolean> resBody = getResBody(mvcResult, Boolean.class);
+ Response<Integer> resBody = getResBody(mvcResult, Integer.class);
Assertions.assertFalse(resBody.isSuccess());
- Assertions.assertEquals("type: must in 0,1\n", resBody.getErrMsg());
+ Assertions.assertTrue(resBody.getErrMsg().contains("must in 0,1"));
}
}