From 2c79bf6c808a7301823179bb95baba2e19e9771d Mon Sep 17 00:00:00 2001 From: sudarshan-doiphode Date: Tue, 11 Apr 2023 08:58:42 +0530 Subject: [PATCH] Removed Unused Setters and Getters also Added Lombok to add Setters and Getters through Annotation and Refractored Code --- maxkey-core/build.gradle | 4 + .../main/java/org/maxkey/entity/Accounts.java | 166 ++------------- .../org/maxkey/entity/AccountsStrategy.java | 193 ++---------------- .../org/maxkey/web/ConfigurerFreeMarker.java | 5 +- 4 files changed, 47 insertions(+), 321 deletions(-) diff --git a/maxkey-core/build.gradle b/maxkey-core/build.gradle index 80bcadc64..b59e1085d 100644 --- a/maxkey-core/build.gradle +++ b/maxkey-core/build.gradle @@ -2,6 +2,10 @@ description = "maxkey-core" dependencies { implementation project(":maxkey-common") + + // https://projectlombok.org + compileOnly 'org.projectlombok:lombok:1.18.4' + annotationProcessor 'org.projectlombok:lombok:1.18.4' //local jars implementation fileTree(dir: '../maxkey-lib/', include: '*/*.jar') diff --git a/maxkey-core/src/main/java/org/maxkey/entity/Accounts.java b/maxkey-core/src/main/java/org/maxkey/entity/Accounts.java index b9bf8fc34..bb451ac98 100644 --- a/maxkey-core/src/main/java/org/maxkey/entity/Accounts.java +++ b/maxkey-core/src/main/java/org/maxkey/entity/Accounts.java @@ -1,19 +1,19 @@ /* * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ - + package org.maxkey.entity; @@ -27,6 +27,9 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; + +import lombok.Getter; +import lombok.Setter; import org.apache.mybatis.jpa.persistence.JpaBaseEntity; import org.hibernate.validator.constraints.Length; @@ -43,11 +46,13 @@ import com.fasterxml.jackson.annotation.JsonIgnore; */ @Entity @Table(name = "MXK_ACCOUNTS") +@Setter +@Getter public class Accounts extends JpaBaseEntity implements Serializable { private static final long serialVersionUID = 6829592256223630307L; - - public static final String DEFAULT_PASSWORD_SUFFIX = UserInfo.DEFAULT_PASSWORD_SUFFIX; - + + public static final String DEFAULT_PASSWORD_SUFFIX = UserInfo.DEFAULT_PASSWORD_SUFFIX; + @Id @Column @GeneratedValue(strategy = GenerationType.AUTO, generator = "snowflakeid") @@ -76,16 +81,16 @@ public class Accounts extends JpaBaseEntity implements Serializable { private String strategyName; @Column private int status; - + @Column private String instId; - + private String instName; - + UserInfo userInfo; - + @JsonIgnore - private HashMap orgCast =new HashMap(); + private HashMap orgCast = new HashMap(); public Accounts() { super(); @@ -106,144 +111,13 @@ public class Accounts extends JpaBaseEntity implements Serializable { this.relatedPassword = password; } - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getDisplayName() { - return displayName; - } - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - public String getAppId() { - return appId; - } - - public void setAppId(String appId) { - this.appId = appId; - } - - public String getAppName() { - return appName; - } - - public void setAppName(String appName) { - this.appName = appName; - } - - public String getRelatedUsername() { - return relatedUsername; - } - - public void setRelatedUsername(String relatedUsername) { - this.relatedUsername = relatedUsername; - } - - public String getRelatedPassword() { - return relatedPassword; - } - - public void setRelatedPassword(String relatedPassword) { - this.relatedPassword = relatedPassword; - } - - - public String getId() { - return id; - } - - - public void setId(String id) { - this.id = id; - } - - public UserInfo getUserInfo() { - return userInfo; - } - - public void setUserInfo(UserInfo userInfo) { - this.userInfo = userInfo; - } - - - public String getCreateType() { - return createType; - } - - public void setCreateType(String createType) { - this.createType = createType; - } - - public String getStrategyId() { - return strategyId; - } - - public void setStrategyId(String strategyId) { - this.strategyId = strategyId; - } - - public int getStatus() { - return status; - } - - public void setStatus(int status) { - this.status = status; - } - - public HashMap getOrgCast() { - return orgCast; - } - - public void setOrgCast(HashMap orgCast) { - this.orgCast = orgCast; - } - - public void setOrgCast(List listOrgCast) { - for(OrganizationsCast cast : listOrgCast) { + public void setOrgCast(List listOrgCast) { + for (OrganizationsCast cast : listOrgCast) { this.orgCast.put(cast.getProvider(), cast); } } - public String getStrategyName() { - return strategyName; - } - - public void setStrategyName(String strategyName) { - this.strategyName = strategyName; - } - - public String getInstId() { - return instId; - } - - public void setInstId(String instId) { - this.instId = instId; - } - - public String getInstName() { - return instName; - } - - public void setInstName(String instName) { - this.instName = instName; - } - - @Override + @Override public String toString() { return "AppAccounts [uid=" + userId + ", username=" + username + ", displayName=" + displayName + ", appId=" + appId + ", appName=" + appName + ", relatedUsername=" + relatedUsername + ", relatedPassword=" diff --git a/maxkey-core/src/main/java/org/maxkey/entity/AccountsStrategy.java b/maxkey-core/src/main/java/org/maxkey/entity/AccountsStrategy.java index 88bc0c84c..0ff5270a8 100644 --- a/maxkey-core/src/main/java/org/maxkey/entity/AccountsStrategy.java +++ b/maxkey-core/src/main/java/org/maxkey/entity/AccountsStrategy.java @@ -1,19 +1,19 @@ /* * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ - + package org.maxkey.entity; @@ -26,19 +26,24 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; + +import lombok.Getter; +import lombok.Setter; import org.apache.mybatis.jpa.persistence.JpaBaseEntity; @Entity @Table(name = "MXK_ACCOUNTS_STRATEGY") +@Setter +@Getter public class AccountsStrategy extends JpaBaseEntity implements Serializable { - + /** - * + * */ private static final long serialVersionUID = -8743329570694948718L; @Id @Column - @GeneratedValue(strategy = GenerationType.AUTO,generator = "snowflakeid") + @GeneratedValue(strategy = GenerationType.AUTO, generator = "snowflakeid") private String id; @Column private String name; @@ -51,7 +56,7 @@ public class AccountsStrategy extends JpaBaseEntity implements Serializable { @Column private String mapping; @Column - String filters ; + String filters; @Column String orgIdsList; @Column @@ -70,178 +75,26 @@ public class AccountsStrategy extends JpaBaseEntity implements Serializable { String modifiedBy; @Column String modifiedDate; - + @Column private String instId; - + private String instName; public AccountsStrategy() { super(); } - public String getId() { - return id; + + public void transIconBase64() { + if (this.appIcon != null) { + this.appIconBase64 = "data:image/png;base64," + + Base64.getEncoder().encodeToString(appIcon); + } } - public void setId(String id) { - this.id = id; - } - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreatedBy() { - return createdBy; - } - - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - public String getCreatedDate() { - return createdDate; - } - - public void setCreatedDate(String createdDate) { - this.createdDate = createdDate; - } - - public String getModifiedBy() { - return modifiedBy; - } - - public void setModifiedBy(String modifiedBy) { - this.modifiedBy = modifiedBy; - } - - public String getModifiedDate() { - return modifiedDate; - } - - public void setModifiedDate(String modifiedDate) { - this.modifiedDate = modifiedDate; - } - - public String getFilters() { - return filters; - } - - public void setFilters(String filters) { - this.filters = filters; - } - - public String getOrgIdsList() { - return orgIdsList; - } - - public void setOrgIdsList(String orgIdsList) { - this.orgIdsList = orgIdsList; - } - - public String getAppId() { - return appId; - } - - public void setAppId(String appId) { - this.appId = appId; - } - - public String getAppName() { - return appName; - } - - public void setAppName(String appName) { - this.appName = appName; - } - - public String getMapping() { - return mapping; - } - - public void setMapping(String mapping) { - this.mapping = mapping; - } - - public byte[] getAppIcon() { - return appIcon; - } - - public String getAppIconBase64() { - return appIconBase64; - } - - public void setAppIconBase64(String appIconBase64) { - this.appIconBase64 = appIconBase64; - } - - public void setAppIcon(byte[] appIcon) { - this.appIcon = appIcon; - } - - public String getCreateType() { - return createType; - } - - public void setCreateType(String createType) { - this.createType = createType; - } - - public String getSuffixes() { - return suffixes; - } - - public void setSuffixes(String suffixes) { - this.suffixes = suffixes; - } - - public String getInstId() { - return instId; - } - - public void setInstId(String instId) { - this.instId = instId; - } - - public String getInstName() { - return instName; - } - - public void setInstName(String instName) { - this.instName = instName; - } - - - public void transIconBase64() { - if(this.appIcon !=null) { - this.appIconBase64 = "data:image/png;base64," + - Base64.getEncoder().encodeToString(appIcon); - } - } - - - @Override + @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("AccountsStrategy [id="); @@ -273,7 +126,5 @@ public class AccountsStrategy extends JpaBaseEntity implements Serializable { builder.append("]"); return builder.toString(); } - - } diff --git a/maxkey-core/src/main/java/org/maxkey/web/ConfigurerFreeMarker.java b/maxkey-core/src/main/java/org/maxkey/web/ConfigurerFreeMarker.java index 7ab6150a9..b3d429d26 100644 --- a/maxkey-core/src/main/java/org/maxkey/web/ConfigurerFreeMarker.java +++ b/maxkey-core/src/main/java/org/maxkey/web/ConfigurerFreeMarker.java @@ -41,8 +41,7 @@ public class ConfigurerFreeMarker implements ApplicationContextAware { ApplicationContext applicationContext ; @Autowired - Configuration configuration; - + Configuration configuration; @PostConstruct // 在项目启动时执行方法 public void setSharedVariable() throws IOException, TemplateException { @@ -52,13 +51,11 @@ public class ConfigurerFreeMarker implements ApplicationContextAware { configuration.setSharedVariable(key, map.get(key)); _logger.trace("FreeMarker Template "+key); } - } @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; - } }