2
0
shimingxy 5 сар өмнө
parent
commit
8c50c6e225
81 өөрчлөгдсөн 2934 нэмэгдсэн , 2171 устгасан
  1. BIN
      maxkey-lib/mybatis-jpa-extra-3.3.2.jar
  2. BIN
      maxkey-lib/mybatis-jpa-extra-spring-boot-starter-3.3.2.jar
  3. 3 19
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AccessService.java
  4. 13 229
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AccountsService.java
  5. 5 93
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AccountsStrategyService.java
  6. 3 17
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsAdaptersService.java
  7. 4 44
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsCasDetailsService.java
  8. 4 42
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsFormBasedDetailsService.java
  9. 4 42
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsJwtDetailsService.java
  10. 4 42
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsSaml20DetailsService.java
  11. 9 60
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsService.java
  12. 4 42
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsTokenBasedDetailsService.java
  13. 3 19
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/CnfEmailSendersService.java
  14. 3 19
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/CnfLdapContextService.java
  15. 3 18
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/CnfPasswordPolicyService.java
  16. 2 18
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/CnfSmsProviderService.java
  17. 3 20
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/ConnectorsService.java
  18. 2 16
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/FileUploadService.java
  19. 9 58
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/GroupMemberService.java
  20. 7 94
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/GroupsService.java
  21. 2 16
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/HistoryConnectorService.java
  22. 3 42
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/HistoryLoginAppsService.java
  23. 3 20
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/HistoryLoginService.java
  24. 3 17
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/HistorySynchronizerService.java
  25. 5 184
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/HistorySystemLogsService.java
  26. 4 22
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/InstitutionsService.java
  27. 3 26
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/OrganizationsCastService.java
  28. 7 159
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/OrganizationsService.java
  29. 5 27
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/PermissionRoleService.java
  30. 6 31
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/PermissionService.java
  31. 4 25
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/RegisterService.java
  32. 12 45
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/ReportService.java
  33. 4 21
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/ResourcesService.java
  34. 7 52
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/RoleMemberService.java
  35. 7 92
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/RolesService.java
  36. 3 21
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/SocialsAssociatesService.java
  37. 2 22
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/SocialsProviderService.java
  38. 7 49
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/SynchroRelatedService.java
  39. 2 24
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/SynchronizersService.java
  40. 31 344
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/UserInfoService.java
  41. 11 5
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AccessServiceImpl.java
  42. 255 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AccountsServiceImpl.java
  43. 99 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AccountsStrategyServiceImpl.java
  44. 28 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsAdaptersServiceImpl.java
  45. 54 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsCasDetailsServiceImpl.java
  46. 52 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsFormBasedDetailsServiceImpl.java
  47. 53 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsJwtDetailsServiceImpl.java
  48. 52 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsSaml20DetailsServiceImpl.java
  49. 79 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsServiceImpl.java
  50. 52 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsTokenBasedDetailsServiceImpl.java
  51. 30 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/CnfEmailSendersServiceImpl.java
  52. 29 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/CnfLdapContextServiceImpl.java
  53. 28 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/CnfPasswordPolicyServiceImpl.java
  54. 29 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/CnfSmsProviderServiceImpl.java
  55. 28 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/ConnectorsServiceImpl.java
  56. 28 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/FileUploadServiceImpl.java
  57. 77 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/GroupMemberServiceImpl.java
  58. 111 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/GroupsServiceImpl.java
  59. 28 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/HistoryConnectorServiceImpl.java
  60. 54 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/HistoryLoginAppsServiceImpl.java
  61. 32 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/HistoryLoginServiceImpl.java
  62. 28 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/HistorySynchronizerServiceImpl.java
  63. 199 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/HistorySystemLogsServiceImpl.java
  64. 33 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/InstitutionsServiceImpl.java
  65. 37 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/OrganizationsCastServiceImpl.java
  66. 176 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/OrganizationsServiceImpl.java
  67. 47 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/PermissionRoleServiceImpl.java
  68. 45 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/PermissionServiceImpl.java
  69. 36 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/RegisterServiceImpl.java
  70. 64 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/ReportServiceImpl.java
  71. 33 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/ResourcesServiceImpl.java
  72. 78 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/RoleMemberServiceImpl.java
  73. 115 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/RolesServiceImpl.java
  74. 36 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/SocialsAssociatesServiceImpl.java
  75. 31 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/SocialsProviderServiceImpl.java
  76. 65 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/SynchroRelatedServiceImpl.java
  77. 31 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/SynchronizersServiceImpl.java
  78. 420 0
      maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/UserInfoServiceImpl.java
  79. 8 34
      maxkey-synchronizers/maxkey-synchronizer/src/main/java/org/dromara/maxkey/synchronizer/service/SyncJobConfigFieldService.java
  80. 37 0
      maxkey-synchronizers/maxkey-synchronizer/src/main/java/org/dromara/maxkey/synchronizer/service/impl/SyncJobConfigFieldServiceImpl.java
  81. 1 1
      setEnvVars.bat

BIN
maxkey-lib/mybatis-jpa-extra-3.3.1.jar → maxkey-lib/mybatis-jpa-extra-3.3.2.jar


BIN
maxkey-lib/mybatis-jpa-extra-spring-boot-starter-3.3.1.jar → maxkey-lib/mybatis-jpa-extra-spring-boot-starter-3.3.2.jar


+ 3 - 19
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AccessService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -18,25 +18,9 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.Access;
-import org.dromara.maxkey.persistence.mapper.AccessMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class AccessService  extends JpaService<Access>{
-	
-	public AccessService() {
-		super(AccessMapper.class);
-	}
-	
 
-	
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public AccessMapper getMapper() {
-		return (AccessMapper)super.getMapper();
-	}
+public interface AccessService  extends IJpaService<Access>{
 
 }

+ 13 - 229
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AccountsService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -19,246 +19,30 @@ package org.dromara.maxkey.persistence.service;
 
 import java.util.List;
 
-import org.apache.commons.lang3.StringUtils;
-import org.dromara.maxkey.constants.ConstsStatus;
-import org.dromara.maxkey.crypto.password.PasswordReciprocal;
 import org.dromara.maxkey.entity.Accounts;
 import org.dromara.maxkey.entity.AccountsStrategy;
-import org.dromara.maxkey.entity.OrganizationsCast;
 import org.dromara.maxkey.entity.idm.UserInfo;
-import org.dromara.maxkey.persistence.mapper.AccountsMapper;
-import org.dromara.maxkey.provision.ProvisionAct;
-import org.dromara.maxkey.provision.ProvisionService;
-import org.dromara.maxkey.provision.ProvisionTopic;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-import net.sourceforge.pinyin4j.PinyinHelper;
-import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
-import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
-import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
-import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
-import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
+public interface AccountsService  extends IJpaService<Accounts>{
 
-@Repository
-public class AccountsService  extends JpaService<Accounts>{
-
-    @Autowired
-    ProvisionService provisionService;
-    
-    @Autowired
-    UserInfoService  userInfoService;
-    
-    @Autowired
-    AccountsStrategyService accountsStrategyService;
-    
-    @Autowired
-    OrganizationsCastService organizationsCastService;
-    
-	public AccountsService() {
-		super(AccountsMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public AccountsMapper getMapper() {
-		return (AccountsMapper)super.getMapper();
-	}
-	
-	@Override
-	 public boolean insert(Accounts account) {
-	     if (super.insert(account)) {
-	            if(provisionService.getApplicationConfig().isProvisionSupport()) {
-	                UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
-	                account.setUserInfo(loadUserInfo);
-	                OrganizationsCast cast = new OrganizationsCast();
-                    cast.setProvider(account.getAppId());
-                    cast.setOrgId(loadUserInfo.getDepartmentId());
-                    account.setOrgCast(organizationsCastService.query(cast));
-                    provisionService.send(
-	                        ProvisionTopic.ACCOUNT_TOPIC, 
-	                        account,
-	                        ProvisionAct.CREATE);
-	            }
-	            
-	            return true;
-	        }
-	     return false;
-	 }
-	 
-	@Override
-	public boolean update(Accounts account) {
-         if (super.update(account)) {
-        	 if(provisionService.getApplicationConfig().isProvisionSupport()) {
-                    UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
-                    account.setUserInfo(loadUserInfo);
-                    OrganizationsCast cast = new OrganizationsCast();
-                    cast.setProvider(account.getAppId());
-                    cast.setOrgId(loadUserInfo.getDepartmentId());
-                    account.setOrgCast(organizationsCastService.query(cast));
-                    provisionService.send(
-                            ProvisionTopic.ACCOUNT_TOPIC, 
-                            account,
-                            ProvisionAct.UPDATE);
-                }
-                
-                return true;
-            }
-         return false;
-     }
+   public boolean updateStatus(Accounts accounts) ;
    
-   public boolean updateStatus(Accounts accounts) {
-	   return this.getMapper().updateStatus(accounts) > 0;
-   }
+   public boolean remove(String id) ;
    
-   public boolean remove(String id) {
-       Accounts account = this.get(id);
-       if (super.delete(id)) {
-              UserInfo loadUserInfo = null;
-              if(provisionService.getApplicationConfig().isProvisionSupport()) {
-                  loadUserInfo = userInfoService.findUserRelated(account.getUserId());
-                  account.setUserInfo(loadUserInfo);
-                  provisionService.send(
-                          ProvisionTopic.ACCOUNT_TOPIC, 
-                          account,
-                          ProvisionAct.DELETE);
-              }
-              
-              return true;
-          }
-       return false;
-   }
+   public void refreshByStrategy(AccountsStrategy strategy) ;
    
-   public void refreshByStrategy(AccountsStrategy strategy) {
-       if(StringUtils.isNotBlank(strategy.getOrgIdsList())) {
-           strategy.setOrgIdsList("'"+strategy.getOrgIdsList().replace(",", "','")+"'");
-       }
-       List<UserInfo>  userList = queryUserNotInStrategy(strategy);
-       for(UserInfo user : userList) {
-           Accounts account = new Accounts();
-           account.setAppId(strategy.getAppId());
-           account.setAppName(strategy.getAppName());
-           
-           account.setUserId(user.getId());
-           account.setUsername(user.getUsername());
-           account.setDisplayName(user.getDisplayName());
-           account.setRelatedUsername(generateAccount(user,strategy));
-           account.setRelatedPassword(PasswordReciprocal.getInstance().encode(userInfoService.randomPassword()));
-           
-           account.setInstId(strategy.getInstId());
-           account.setCreateType("automatic");
-           account.setStatus(ConstsStatus.ACTIVE);
-           account.setStrategyId(strategy.getId());
-           
-           insert(account);
-       }
-       deleteByStrategy(strategy);
-   }
-   public void refreshAllByStrategy() {
-	   AccountsStrategy queryStrategy = new AccountsStrategy();
-	   queryStrategy.setCreateType("automatic");
-       for( AccountsStrategy strategy : accountsStrategyService.query(queryStrategy)) {
-           refreshByStrategy(strategy);
-       }
-   }
+   public void refreshAllByStrategy() ;
    
+   public List<UserInfo> queryUserNotInStrategy(AccountsStrategy strategy);
    
-   public List<UserInfo> queryUserNotInStrategy(AccountsStrategy strategy){
-       return getMapper().queryUserNotInStrategy(strategy);
-   }
-   
-   public long deleteByStrategy(AccountsStrategy strategy) {
-       return getMapper().deleteByStrategy(strategy);
-   }
-	
+   public long deleteByStrategy(AccountsStrategy strategy) ;
 	
-   public List<Accounts> queryByAppIdAndDate(Accounts account) {
-       return getMapper().queryByAppIdAndDate(account);
-   }
+   public List<Accounts> queryByAppIdAndDate(Accounts account) ;
    
-   public List<Accounts> queryByAppIdAndAccount(String appId,String relatedUsername){
-	   return getMapper().queryByAppIdAndAccount(appId,relatedUsername);
-   }
+   public List<Accounts> queryByAppIdAndAccount(String appId,String relatedUsername);
    
-   
-   public String generateAccount(UserInfo  userInfo,AccountsStrategy accountsStrategy) {
-   	String shortAccount = generateAccount(userInfo,accountsStrategy,true);
-   	String account = generateAccount(userInfo,accountsStrategy,false);
-   	String accountResult = shortAccount;
-   	List<Accounts> accountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),shortAccount +accountsStrategy.getSuffixes());
-   	if(!accountsList.isEmpty()) {
-   		if(accountsStrategy.getMapping().equalsIgnoreCase("email")) {
-   			accountResult = account;
-   			accountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),account + accountsStrategy.getSuffixes());
-   		}
-   		if(!accountsList.isEmpty()) {
-	    		for(int i =1 ;i < 100 ;i++) {
-	    			accountResult = account + i;
-	    			accountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),accountResult + accountsStrategy.getSuffixes());
-	    			if(accountsList.isEmpty()) {
-	    				break;
-	    			}
-	    		}
-   		}
-   	}
-   	if(StringUtils.isNotBlank(accountsStrategy.getSuffixes())){
-   		accountResult = accountResult + accountsStrategy.getSuffixes();
-   	}
-       return accountResult;
-   }
-   
-   
-	private String generateAccount(UserInfo  userInfo,AccountsStrategy strategy,boolean isShort) {
-		String account = "";
-    	if(strategy.getMapping().equalsIgnoreCase("username")) {
-    		account = userInfo.getUsername();
-    	}else if(strategy.getMapping().equalsIgnoreCase("mobile")) {
-    		account = userInfo.getMobile();
-    	}else if(strategy.getMapping().equalsIgnoreCase("email")) {
-    		try {
-	    		if(isShort) {
-	    			account = getPinYinShortName(userInfo.getDisplayName());
-	    		}else {
-	    			account = getPinYinName(userInfo.getDisplayName());
-	    		}
-    		}catch(Exception e) {
-    			e.printStackTrace();
-    		}
-    	}else if(strategy.getMapping().equalsIgnoreCase("employeeNumber")) {
-    		account = userInfo.getEmployeeNumber();
-    	}else if(strategy.getMapping().equalsIgnoreCase("windowsAccount")) {
-    		account = userInfo.getWindowsAccount();
-    	}else if(strategy.getMapping().equalsIgnoreCase("idCardNo")) {
-    		account = userInfo.getIdCardNo();
-    	}else {
-    		account = userInfo.getUsername();
-    	}
-    	
-        return account;
-	}
-	
-	public static String getPinYinName(String name) throws BadHanyuPinyinOutputFormatCombination {
-        HanyuPinyinOutputFormat pinyinFormat = new        HanyuPinyinOutputFormat();
-        pinyinFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
-        pinyinFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
-        pinyinFormat.setVCharType(HanyuPinyinVCharType.WITH_V);
-        return PinyinHelper.toHanYuPinyinString(name, pinyinFormat, "",false);
-    }
-	
-	public static String getPinYinShortName(String name) throws BadHanyuPinyinOutputFormatCombination {
-		char[] strs = name.toCharArray();
-		String pinyinName = "";
-		for(int i=0;i<strs.length;i++) {
-			if(i == 0) {
-				pinyinName += getPinYinName(strs[i]+"");
-			}else {
-				pinyinName += getPinYinName(strs[i]+"").charAt(0);
-			}
-		}
-		return pinyinName;
-    }
+   public String generateAccount(UserInfo  userInfo,AccountsStrategy accountsStrategy) ;
+  
 	
 }

+ 5 - 93
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AccountsStrategyService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -17,104 +17,16 @@
 
 package org.dromara.maxkey.persistence.service;
 
-import java.io.Serializable;
 import java.util.List;
 
 import org.dromara.maxkey.entity.AccountsStrategy;
 import org.dromara.maxkey.entity.permissions.Roles;
-import org.dromara.maxkey.persistence.mapper.AccountsStrategyMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class AccountsStrategyService  extends JpaService<AccountsStrategy> implements Serializable {
-    /**
-     * 
-     */
-    private static final long serialVersionUID = -921086134545225302L;
-    
-    static final  Logger _logger = LoggerFactory.getLogger(AccountsStrategyService.class);
-   /*
-    @Autowired
-    @Qualifier("groupMemberService")
-    GroupMemberService accountsStrategyService;
-    */
-	public AccountsStrategyService() {
-		super(AccountsStrategyMapper.class);
-	}
+public interface AccountsStrategyService  extends IJpaService<AccountsStrategy> {
 
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public AccountsStrategyMapper getMapper() {
-		return (AccountsStrategyMapper)super.getMapper();
-	}
+	public List<Roles> queryDynamicGroups(Roles groups);
 	
-	
-	public List<Roles> queryDynamicGroups(Roles groups){
-	    return this.getMapper().queryDynamicGroups(groups);
-	}
-	
-	public boolean deleteById(String groupId) {
-	    this.delete(groupId);
-	    //groupMemberService.deleteByGroupId(groupId);
-	    return true;
-	}
-	/*
-	public void refreshDynamicGroups(Groups dynamicGroup){
-	    if(dynamicGroup.getDynamic().equals("1")) {
-	        boolean isDynamicTimeSupport = false;
-	        boolean isBetweenEffectiveTime = false;
-	        if(dynamicGroup.getResumeTime()!=null&&dynamicGroup.getResumeTime().equals("")
-	                &&dynamicGroup.getSuspendTime()!=null&&dynamicGroup.getSuspendTime().equals("")) {
-	            LocalTime currentTime = LocalDateTime.now().toLocalTime();
-	            LocalTime resumeTime = LocalTime.parse(dynamicGroup.getResumeTime());
-	            LocalTime suspendTime = LocalTime.parse(dynamicGroup.getSuspendTime());
-	            
-	            _logger.info("currentTime: " + currentTime 
-                        + " , resumeTime : " + resumeTime 
-                        + " , suspendTime: " + suspendTime);
-	            isDynamicTimeSupport = true;
-	            
-	            if(resumeTime.isBefore(currentTime) && currentTime.isBefore(suspendTime)) {
-	                isBetweenEffectiveTime = true;
-	            }
-	            
-	        }
-	        
-    	    if(dynamicGroup.getOrgIdsList()!=null && !dynamicGroup.getOrgIdsList().equals("")) {
-    	        dynamicGroup.setOrgIdsList("'"+dynamicGroup.getOrgIdsList().replace(",", "','")+"'");
-    	    }
-    	    String filters = dynamicGroup.getFilters();
-    	    if(StringUtils.filtersSQLInjection(filters.toLowerCase())) {  
-    	        _logger.info("filters include SQL Injection Attack Risk.");
-    	        return;
-    	    }
-    	    
-    	    filters = filters.replace("&", " AND ");
-    	    filters = filters.replace("|", " OR ");
-    	    
-    	    dynamicGroup.setFilters(filters);
-    	    
-    	    if(isDynamicTimeSupport) {
-    	        if(isBetweenEffectiveTime) {
-    	            groupMemberService.deleteDynamicGroupMember(dynamicGroup);
-                    groupMemberService.addDynamicGroupMember(dynamicGroup);
-    	        }else {
-    	            groupMemberService.deleteDynamicGroupMember(dynamicGroup);
-    	        }
-    	    }else{
-                groupMemberService.deleteDynamicGroupMember(dynamicGroup);
-                groupMemberService.addDynamicGroupMember(dynamicGroup);
-            }
-	    }
-    }*/
-
-  
-	
-
+	public boolean deleteById(String groupId) ;
 	
 }

+ 3 - 17
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsAdaptersService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -18,22 +18,8 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.apps.AppsAdapters;
-import org.dromara.maxkey.persistence.mapper.AppsAdaptersMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class AppsAdaptersService  extends JpaService<AppsAdapters>{
+public interface AppsAdaptersService  extends IJpaService<AppsAdapters>{
 
-	public AppsAdaptersService() {
-		super(AppsAdaptersMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public AppsAdaptersMapper getMapper() {
-		return (AppsAdaptersMapper)super.getMapper();
-	}
 }

+ 4 - 44
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsCasDetailsService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -17,50 +17,10 @@
 
 package org.dromara.maxkey.persistence.service;
 
-import java.util.concurrent.TimeUnit;
-
 import org.dromara.maxkey.entity.apps.AppsCasDetails;
-import org.dromara.maxkey.persistence.mapper.AppsCasDetailsMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
-
-import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
-
-@Repository
-public class AppsCasDetailsService  extends JpaService<AppsCasDetails>{
+import org.dromara.mybatis.jpa.IJpaService;
 
-	protected static final   Cache<String, AppsCasDetails> detailsCache = 
-            Caffeine.newBuilder()
-                .expireAfterWrite(30, TimeUnit.MINUTES)
-                .maximumSize(200000)
-                .build();
-	
-	public AppsCasDetailsService() {
-		super(AppsCasDetailsMapper.class);
-	}
+public interface AppsCasDetailsService  extends IJpaService<AppsCasDetails>{
 
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public AppsCasDetailsMapper getMapper() {
-		return (AppsCasDetailsMapper)super.getMapper();
-	}
-	
-	public  AppsCasDetails  getAppDetails(String id , boolean cached) {
-		AppsCasDetails details = null;
-		if(cached) {
-			details = detailsCache.getIfPresent(id);
-			if(details == null) {
-				details = getMapper().getAppDetails(id);
-				if(details != null) {
-					detailsCache.put(id, details);
-				}
-			}
-		}else {
-			details = getMapper().getAppDetails(id);
-		}
-		return details;
-	}
+	public  AppsCasDetails  getAppDetails(String id , boolean cached) ;
 }

+ 4 - 42
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsFormBasedDetailsService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -17,48 +17,10 @@
 
 package org.dromara.maxkey.persistence.service;
 
-import java.util.concurrent.TimeUnit;
-
 import org.dromara.maxkey.entity.apps.AppsFormBasedDetails;
-import org.dromara.maxkey.persistence.mapper.AppsFormBasedDetailsMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
-
-import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
-
-@Repository
-public class AppsFormBasedDetailsService  extends JpaService<AppsFormBasedDetails>{
+import org.dromara.mybatis.jpa.IJpaService;
 
-	protected static final   Cache<String, AppsFormBasedDetails> detailsCache = 
-            Caffeine.newBuilder()
-                .expireAfterWrite(30, TimeUnit.MINUTES)
-                .maximumSize(200000)
-                .build();
-	
-	public AppsFormBasedDetailsService() {
-		super(AppsFormBasedDetailsMapper.class);
-	}
+public interface AppsFormBasedDetailsService  extends IJpaService<AppsFormBasedDetails>{
 
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public AppsFormBasedDetailsMapper getMapper() {
-		return (AppsFormBasedDetailsMapper)super.getMapper();
-	}
-	
-	public  AppsFormBasedDetails  getAppDetails(String id,boolean cached) {
-		AppsFormBasedDetails details = null;
-		if(cached) {
-			details = detailsCache.getIfPresent(id);
-			if(details == null) {
-				details = getMapper().getAppDetails(id);
-				detailsCache.put(id, details);
-			}
-		}else {
-			details = getMapper().getAppDetails(id);
-		}
-		return details;
-	}
+	public  AppsFormBasedDetails  getAppDetails(String id,boolean cached) ;
 }

+ 4 - 42
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsJwtDetailsService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -17,48 +17,10 @@
 
 package org.dromara.maxkey.persistence.service;
 
-import java.util.concurrent.TimeUnit;
-
 import org.dromara.maxkey.entity.apps.AppsJwtDetails;
-import org.dromara.maxkey.persistence.mapper.AppsJwtDetailsMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
-
-import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
-
-@Repository
-public class AppsJwtDetailsService  extends JpaService<AppsJwtDetails>{
+import org.dromara.mybatis.jpa.IJpaService;
 
-	protected static final   Cache<String, AppsJwtDetails> detailsCache = 
-            Caffeine.newBuilder()
-                .expireAfterWrite(30, TimeUnit.MINUTES)
-                .maximumSize(200000)
-                .build();
-	
-	public AppsJwtDetailsService() {
-		super(AppsJwtDetailsMapper.class);
-	}
+public interface AppsJwtDetailsService  extends IJpaService<AppsJwtDetails>{
 
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public AppsJwtDetailsMapper getMapper() {
-		return (AppsJwtDetailsMapper)super.getMapper();
-	}
-	
-	public  AppsJwtDetails  getAppDetails(String id , boolean cached) {
-		AppsJwtDetails details = null;
-		if(cached) {
-			details = detailsCache.getIfPresent(id);
-			if(details == null) {
-				details = getMapper().getAppDetails(id);
-				detailsCache.put(id, details);
-			}
-		}else {
-			details = getMapper().getAppDetails(id);
-		}
-		return details;
-	}
+	public  AppsJwtDetails  getAppDetails(String id , boolean cached) ;
 }

+ 4 - 42
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsSaml20DetailsService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -17,48 +17,10 @@
 
 package org.dromara.maxkey.persistence.service;
 
-import java.util.concurrent.TimeUnit;
-
 import org.dromara.maxkey.entity.apps.AppsSAML20Details;
-import org.dromara.maxkey.persistence.mapper.AppsSaml20DetailsMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
-
-import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
-
-@Repository
-public class AppsSaml20DetailsService  extends JpaService<AppsSAML20Details>{
+import org.dromara.mybatis.jpa.IJpaService;
 
-	protected static final   Cache<String, AppsSAML20Details> detailsCache = 
-            Caffeine.newBuilder()
-                .expireAfterWrite(30, TimeUnit.MINUTES)
-                .maximumSize(200000)
-                .build();
-	
-	public AppsSaml20DetailsService() {
-		super(AppsSaml20DetailsMapper.class);
-	}
+public interface AppsSaml20DetailsService  extends IJpaService<AppsSAML20Details>{
 
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public AppsSaml20DetailsMapper getMapper() {
-		return (AppsSaml20DetailsMapper)super.getMapper();
-	}
-	
-	public  AppsSAML20Details  getAppDetails(String id , boolean cached){
-		AppsSAML20Details details = null;
-		if(cached) {
-			details = detailsCache.getIfPresent(id);
-			if(details == null) {
-				details = getMapper().getAppDetails(id);
-				detailsCache.put(id, details);
-			}
-		}else {
-			details = getMapper().getAppDetails(id);
-		}
-		return details;
-	}
+	public  AppsSAML20Details  getAppDetails(String id , boolean cached);
 }

+ 9 - 60
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -18,74 +18,23 @@
 package org.dromara.maxkey.persistence.service;
 
 import java.util.List;
-import java.util.concurrent.TimeUnit;
-
 import org.dromara.maxkey.entity.apps.Apps;
 import org.dromara.maxkey.entity.apps.UserApps;
-import org.dromara.maxkey.persistence.mapper.AppsMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
-
-import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class AppsService extends JpaService<Apps>{
-	//maxkey-mgt
-	public static final  	String MGT_APP_ID 		= "622076759805923328";
-	
-	public static final  	String DETAIL_SUFFIX	=	"_detail";
+public interface AppsService extends IJpaService<Apps>{
 	
-	protected static final   Cache<String, Apps> detailsCacheStore = 
-										Caffeine.newBuilder()
-							                .expireAfterWrite(30, TimeUnit.MINUTES)
-							                .build();
-	
-	public AppsService() {
-		super(AppsMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public AppsMapper getMapper() {
-		return (AppsMapper)super.getMapper();
-	}
+	public boolean insertApp(Apps app) ;
 	
-	public boolean insertApp(Apps app) {
-		return ((AppsMapper)super.getMapper()).insertApp(app)>0;
-	};
-	public boolean updateApp(Apps app) {
-		return ((AppsMapper)super.getMapper()).updateApp(app)>0;
-	};
+	public boolean updateApp(Apps app) ;
 	
-	public boolean updateExtendAttr(Apps app) {
-		return ((AppsMapper)super.getMapper()).updateExtendAttr(app)>0;
-	}
+	public boolean updateExtendAttr(Apps app) ;
 	
-    public List<UserApps> queryMyApps(UserApps userApplications){
-        return getMapper().queryMyApps(userApplications);
-    }
+    public List<UserApps> queryMyApps(UserApps userApplications);
 
     //cache for running
-    public void put(String appId, Apps appDetails) {
-    	detailsCacheStore.put(appId + DETAIL_SUFFIX, appDetails);
-	}
+    public void put(String appId, Apps appDetails) ;
 	
-    public Apps get(String appId, boolean cached) {
-    	appId = appId.equalsIgnoreCase("maxkey_mgt") ? MGT_APP_ID : appId;
-    	Apps appDetails = null;
-    	if(cached) {
-    		appDetails = detailsCacheStore.getIfPresent(appId + DETAIL_SUFFIX); 
-    		if(appDetails == null) {
-    			appDetails = this.get(appId);
-    			detailsCacheStore.put(appId, appDetails);
-    		}
-    	}else {
-    		appDetails = this.get(appId);
-    	}
-        return appDetails;
-    }
+    public Apps get(String appId, boolean cached);
     
 }

+ 4 - 42
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/AppsTokenBasedDetailsService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -17,48 +17,10 @@
 
 package org.dromara.maxkey.persistence.service;
 
-import java.util.concurrent.TimeUnit;
-
 import org.dromara.maxkey.entity.apps.AppsTokenBasedDetails;
-import org.dromara.maxkey.persistence.mapper.AppsTokenBasedDetailsMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
-
-import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
-
-@Repository
-public class AppsTokenBasedDetailsService  extends JpaService<AppsTokenBasedDetails>{
+import org.dromara.mybatis.jpa.IJpaService;
 
-	protected static final   Cache<String, AppsTokenBasedDetails> detailsCache = 
-            Caffeine.newBuilder()
-                .expireAfterWrite(30, TimeUnit.MINUTES)
-                .maximumSize(200000)
-                .build();
-	
-	public AppsTokenBasedDetailsService() {
-		super(AppsTokenBasedDetailsMapper.class);
-	}
+public interface AppsTokenBasedDetailsService  extends IJpaService<AppsTokenBasedDetails>{
 
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public AppsTokenBasedDetailsMapper getMapper() {
-		return (AppsTokenBasedDetailsMapper)super.getMapper();
-	}
-	
-	public  AppsTokenBasedDetails  getAppDetails(String id , boolean cached) {
-		AppsTokenBasedDetails details = null;
-		if(cached) {
-			details = detailsCache.getIfPresent(id);
-			if(details == null) {
-				details = getMapper().getAppDetails(id);
-				detailsCache.put(id, details);
-			}
-		}else {
-			details = getMapper().getAppDetails(id);
-		}
-		return details;
-	}
+	public  AppsTokenBasedDetails  getAppDetails(String id , boolean cached) ;
 }

+ 3 - 19
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/CnfEmailSendersService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -19,25 +19,9 @@ package org.dromara.maxkey.persistence.service;
 
 
 import org.dromara.maxkey.entity.cnf.CnfEmailSenders;
-import org.dromara.maxkey.persistence.mapper.CnfEmailSendersMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
+public interface CnfEmailSendersService  extends IJpaService<CnfEmailSenders>{
 
-@Repository
-public class CnfEmailSendersService  extends JpaService<CnfEmailSenders>{
-	
-	public CnfEmailSendersService() {
-		super(CnfEmailSendersMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public CnfEmailSendersMapper getMapper() {
-		return (CnfEmailSendersMapper)super.getMapper();
-	}
- 
 	 
 }

+ 3 - 19
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/CnfLdapContextService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -18,25 +18,9 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.cnf.CnfLdapContext;
-import org.dromara.maxkey.persistence.mapper.CnfLdapContextMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
 
-@Repository
-public class CnfLdapContextService  extends JpaService<CnfLdapContext>{
-	
-	public CnfLdapContextService() {
-		super(CnfLdapContextMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public CnfLdapContextMapper getMapper() {
-		return (CnfLdapContextMapper)super.getMapper();
-	}
+public interface CnfLdapContextService  extends IJpaService<CnfLdapContext>{
  
-	 
 }

+ 3 - 18
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/CnfPasswordPolicyService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -18,23 +18,8 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.cnf.CnfPasswordPolicy;
-import org.dromara.maxkey.persistence.mapper.CnfPasswordPolicyMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class CnfPasswordPolicyService  extends JpaService<CnfPasswordPolicy>{
-
-	public CnfPasswordPolicyService() {
-		super(CnfPasswordPolicyMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public CnfPasswordPolicyMapper getMapper() {
-		return (CnfPasswordPolicyMapper)super.getMapper();
-	}
+public interface CnfPasswordPolicyService  extends IJpaService<CnfPasswordPolicy>{
 	
 }

+ 2 - 18
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/CnfSmsProviderService.java

@@ -18,25 +18,9 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.cnf.CnfSmsProvider;
-import org.dromara.maxkey.persistence.mapper.CnfSmsProviderMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
 
-@Repository
-public class CnfSmsProviderService  extends JpaService<CnfSmsProvider>{
+public interface CnfSmsProviderService  extends IJpaService<CnfSmsProvider>{ 
 	
-	public CnfSmsProviderService() {
-		super(CnfSmsProviderMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public CnfSmsProviderMapper getMapper() {
-		return (CnfSmsProviderMapper)super.getMapper();
-	}
- 
-	 
 }

+ 3 - 20
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/ConnectorsService.java

@@ -18,25 +18,8 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.Connectors;
-import org.dromara.maxkey.persistence.mapper.ConnectorsMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class ConnectorsService  extends JpaService<Connectors>{
-    static final  Logger _logger = LoggerFactory.getLogger(ConnectorsService.class);
-    
-	public ConnectorsService() {
-		super(ConnectorsMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public ConnectorsMapper getMapper() {
-		return (ConnectorsMapper)super.getMapper();
-	}
+public interface ConnectorsService  extends IJpaService<Connectors>{
+ 
 }

+ 2 - 16
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/FileUploadService.java

@@ -18,22 +18,8 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.FileUpload;
-import org.dromara.maxkey.persistence.mapper.FileUploadMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class FileUploadService  extends JpaService<FileUpload>{
+public interface FileUploadService  extends IJpaService<FileUpload>{
 
-	public FileUploadService() {
-		super(FileUploadMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public FileUploadMapper getMapper() {
-		return (FileUploadMapper)super.getMapper();
-	}
 }

+ 9 - 58
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/GroupMemberService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -22,68 +22,19 @@ import java.util.List;
 import org.dromara.maxkey.entity.idm.GroupMember;
 import org.dromara.maxkey.entity.idm.Groups;
 import org.dromara.maxkey.entity.idm.UserInfo;
-import org.dromara.maxkey.persistence.mapper.GroupMemberMapper;
-import org.dromara.mybatis.jpa.JpaService;
+import org.dromara.mybatis.jpa.IJpaService;
 import org.dromara.mybatis.jpa.entity.JpaPageResults;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Repository;
 
-@Repository
-public class GroupMemberService  extends JpaService<GroupMember>{
-	static final  Logger _logger = LoggerFactory.getLogger(GroupMemberService.class);
-	
-	public GroupMemberService() {
-		super(GroupMemberMapper.class);
-	}
-	
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public GroupMemberMapper getMapper() {
-		return (GroupMemberMapper)super.getMapper();
-	}
-	
-	public int addDynamicMember(Groups dynamicGroup) {
-	    return getMapper().addDynamicMember(dynamicGroup);
-	}
-	
-	public int deleteDynamicMember(Groups dynamicGroup) {
-	    return getMapper().deleteDynamicMember(dynamicGroup);
-	}
+public interface GroupMemberService  extends IJpaService<GroupMember>{
+
+	public int addDynamicMember(Groups dynamicGroup) ;
 	
-	public int deleteByGroupId(String groupId) {
-        return getMapper().deleteByGroupId(groupId);
-    }
+	public int deleteDynamicMember(Groups dynamicGroup) ;
 	
-	public List<UserInfo> queryMemberByGroupId(String groupId){
-		return getMapper().queryMemberByGroupId(groupId);
-	}
+	public int deleteByGroupId(String groupId);
 	
+	public List<UserInfo> queryMemberByGroupId(String groupId);
 	
-	public JpaPageResults<Groups> noMember(GroupMember entity) {
-		entity.setPageSelectId(entity.generateId());
-		entity.setStartRow(calculateStartRow(entity.getPageNumber() ,entity.getPageSize()));
-		
-		entity.setPageable(true);
-		List<Groups> resultslist = null;
-		try {
-			resultslist = getMapper().noMember(entity);
-		} catch (Exception e) {
-			_logger.error("queryPageResults Exception " , e);
-		}
-		entity.setPageable(false);
-		Integer totalPage = resultslist.size();
-		
-		Integer totalCount = 0;
-		if(entity.getPageNumber() == 1 && totalPage < entity.getPageSize()) {
-			totalCount = totalPage;
-		}else {
-			totalCount = parseCount(getMapper().fetchCount(entity));
-		}
-		
-		return new JpaPageResults<Groups>(entity.getPageNumber(),entity.getPageSize(),totalPage,totalCount,resultslist);
-	}
+	public JpaPageResults<Groups> noMember(GroupMember entity) ;
 	
 }

+ 7 - 94
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/GroupsService.java

@@ -17,108 +17,21 @@
 
 package org.dromara.maxkey.persistence.service;
 
-import java.sql.Types;
 import java.util.List;
 
-import org.apache.commons.lang3.StringUtils;
-import org.dromara.maxkey.constants.ConstsStatus;
-import org.dromara.maxkey.entity.Institutions;
 import org.dromara.maxkey.entity.idm.Groups;
-import org.dromara.maxkey.entity.permissions.Roles;
-import org.dromara.maxkey.persistence.mapper.GroupsMapper;
-import org.dromara.maxkey.util.StrUtils;
-import org.dromara.mybatis.jpa.JpaService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class GroupsService  extends JpaService<Groups>{
-    static final  Logger _logger = LoggerFactory.getLogger(GroupsService.class);
+public interface GroupsService  extends IJpaService<Groups>{
 
-    @Autowired
-    GroupMemberService groupMemberService;
-    
-    @Autowired
-    InstitutionsService institutionsService;
-    
-	public GroupsService() {
-		super(GroupsMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public GroupsMapper getMapper() {
-		return (GroupsMapper)super.getMapper();
-	}
-	
-	
-	public List<Groups> queryDynamicGroups(Groups groups){
-	    return this.getMapper().queryDynamic(groups);
-	}
+	public List<Groups> queryDynamicGroups(Groups groups);
 	
-	public boolean deleteById(String groupId) {
-	    this.delete(groupId);
-	    groupMemberService.deleteByGroupId(groupId);
-	    return true;
-	}
+	public boolean deleteById(String groupId) ;
 	
-	public List<Groups> queryByUserId(String userId){
-		return this.getMapper().queryByUserId(userId);
-	}
+	public List<Groups> queryByUserId(String userId);
 	
-	public void refreshDynamicGroups(Groups dynamicGroup){
-	    if(dynamicGroup.getCategory().equals(Roles.Category.DYNAMIC)) {
-	        
-	        if(StringUtils.isNotBlank(dynamicGroup.getOrgIdsList())) {
-    	    	String []orgIds = dynamicGroup.getOrgIdsList().split(",");
-    	    	StringBuffer orgIdFilters = new StringBuffer();
-    	    	for(String orgId : orgIds) {
-    	    		if(StringUtils.isNotBlank(orgId)) {
-	    	    		if(orgIdFilters.length() > 0) {
-	    	    			orgIdFilters.append(",");
-	    	    		}
-	    	    		orgIdFilters.append("'").append(orgId).append("'");
-    	    		}
-    	    	}
-    	    	if(orgIdFilters.length() > 0) {
-    	    		dynamicGroup.setOrgIdsList(orgIdFilters.toString());
-    	    	}
-    	    }
-	        
-    	    String filters = dynamicGroup.getFilters();
-    	    if(StringUtils.isNotBlank(filters)) {
-	    		if(StrUtils.filtersSQLInjection(filters.toLowerCase())) {  
-	    			_logger.info("filters include SQL Injection Attack Risk.");
-	    			return;
-	    		}
-	    		//replace & with AND, | with OR
-	    		filters = filters.replace("&", " AND ").replace("|", " OR ");
-	    	    
-	    	    dynamicGroup.setFilters(filters);
-    	    }
-	    
-	    	groupMemberService.deleteDynamicMember(dynamicGroup);
-	    	groupMemberService.addDynamicMember(dynamicGroup);
-            
-	    }
-    }
+	public void refreshDynamicGroups(Groups dynamicGroup);
 	
-	public void refreshAllDynamicGroups(){
-		List<Institutions> instList = 
-				institutionsService.find("where status = ? ", new Object[]{ConstsStatus.ACTIVE}, new int[]{Types.INTEGER});
-		for(Institutions inst : instList) {
-			Groups group = new Groups();
-			group.setInstId(inst.getId());
-		    List<Groups>  groupsList = queryDynamicGroups(group);
-	        for(Groups g : groupsList) {
-	            _logger.debug("role {}" , g);
-	            refreshDynamicGroups(g);
-	        }
-		}
-	}
+	public void refreshAllDynamicGroups();
 
 }

+ 2 - 16
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/HistoryConnectorService.java

@@ -18,22 +18,8 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.history.HistoryConnector;
-import org.dromara.maxkey.persistence.mapper.HistoryConnectorMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class HistoryConnectorService  extends JpaService<HistoryConnector>{
+public interface HistoryConnectorService  extends IJpaService<HistoryConnector>{
 
-	public HistoryConnectorService() {
-		super(HistoryConnectorMapper.class);
-	}
-	
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public HistoryConnectorMapper getMapper() {
-		return (HistoryConnectorMapper)super.getMapper();
-	}
 }

+ 3 - 42
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/HistoryLoginAppsService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -18,47 +18,8 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.history.HistoryLoginApps;
-import org.dromara.maxkey.persistence.mapper.HistoryLoginAppsMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class HistoryLoginAppsService  extends JpaService<HistoryLoginApps>{
+public interface HistoryLoginAppsService  extends IJpaService<HistoryLoginApps>{
 
-	public HistoryLoginAppsService() {
-		super(HistoryLoginAppsMapper.class);
-	}
-
-	
-	@Override
-	public HistoryLoginAppsMapper getMapper() {
-		return (HistoryLoginAppsMapper)super.getMapper();
-	}
-	
-	@Override
-	public boolean  insert(HistoryLoginApps loginAppsHistory){
-		//new Thread insert login app history
-		new Thread(new HistoryLoginAppsRunnable(getMapper(),loginAppsHistory)).start();
-		return true;
-	}
-	
-	public class HistoryLoginAppsRunnable implements Runnable{
-
-		HistoryLoginAppsMapper historyLoginAppsMapper;
-		
-		HistoryLoginApps loginAppsHistory;
-		
-		public HistoryLoginAppsRunnable(HistoryLoginAppsMapper historyLoginAppsMapper,
-				HistoryLoginApps loginAppsHistory) {
-			super();
-			this.historyLoginAppsMapper = historyLoginAppsMapper;
-			this.loginAppsHistory = loginAppsHistory;
-		}
-
-		@Override
-		public void run() {
-			historyLoginAppsMapper.insert(loginAppsHistory);
-		}
-		
-	}
 }

+ 3 - 20
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/HistoryLoginService.java

@@ -18,27 +18,10 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.history.HistoryLogin;
-import org.dromara.maxkey.persistence.mapper.HistoryLoginMapper;
-import org.dromara.mybatis.jpa.JpaService;
+import org.dromara.mybatis.jpa.IJpaService;
 import org.dromara.mybatis.jpa.entity.JpaPageResults;
-import org.springframework.stereotype.Repository;
 
-@Repository
-public class HistoryLoginService  extends JpaService<HistoryLogin>{
+public interface HistoryLoginService  extends IJpaService<HistoryLogin>{
 
-	public HistoryLoginService() {
-		super(HistoryLoginMapper.class);
-	}
-	
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public HistoryLoginMapper getMapper() {
-		return (HistoryLoginMapper)super.getMapper();
-	}
-	
-	public JpaPageResults<HistoryLogin> queryOnlineSession(HistoryLogin historyLogin) {
-	    return this.fetchPageResults("queryOnlineSession",historyLogin);
-	}
+	public JpaPageResults<HistoryLogin> queryOnlineSession(HistoryLogin historyLogin);
 }

+ 3 - 17
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/HistorySynchronizerService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -18,22 +18,8 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.history.HistorySynchronizer;
-import org.dromara.maxkey.persistence.mapper.HistorySynchronizerMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class HistorySynchronizerService  extends JpaService<HistorySynchronizer>{
+public interface HistorySynchronizerService  extends IJpaService<HistorySynchronizer>{
 
-	public HistorySynchronizerService() {
-		super(HistorySynchronizerMapper.class);
-	}
-	
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public HistorySynchronizerMapper getMapper() {
-		return (HistorySynchronizerMapper)super.getMapper();
-	}
 }

+ 5 - 184
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/HistorySystemLogsService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -17,193 +17,14 @@
 
 package org.dromara.maxkey.persistence.service;
 
-import org.dromara.maxkey.entity.Accounts;
-import org.dromara.maxkey.entity.ChangePassword;
-
-import java.util.Date;
-
-import org.dromara.maxkey.entity.Access;
-import org.dromara.maxkey.entity.SocialsProvider;
-import org.dromara.maxkey.entity.Synchronizers;
 import org.dromara.maxkey.entity.history.HistorySystemLogs;
-import org.dromara.maxkey.entity.idm.Organizations;
 import org.dromara.maxkey.entity.idm.UserInfo;
-import org.dromara.maxkey.entity.permissions.Permission;
-import org.dromara.maxkey.entity.permissions.Resources;
-import org.dromara.maxkey.entity.permissions.RoleMember;
-import org.dromara.maxkey.entity.permissions.Roles;
-import org.dromara.maxkey.persistence.mapper.HistorySystemLogsMapper;
-import org.dromara.maxkey.util.JsonUtils;
-import org.dromara.mybatis.jpa.JpaService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class HistorySystemLogsService  extends JpaService<HistorySystemLogs>{
-	static final Logger _logger = LoggerFactory.getLogger(HistorySystemLogsService.class);
-	
-	public HistorySystemLogsService() {
-		super(HistorySystemLogsMapper.class);
-		
-	}
-
-	@Override
-	public HistorySystemLogsMapper getMapper() {
-		return (HistorySystemLogsMapper)super.getMapper();
-	}
-	
-	public void insert(String topic,Object entity,String action,String result,UserInfo operator) {
-		String message = "";
-		if(entity != null) {
-			if(entity instanceof UserInfo userInfo) {
-				message = buildMsg(userInfo);
-			}else if(entity instanceof Organizations organization) {
-				message = buildMsg(organization);
-			}else if(entity instanceof ChangePassword changePassword) {
-				message = buildMsg(changePassword);
-			}else if(entity instanceof Accounts account) {
-				message = buildMsg(account);
-			}else if(entity instanceof Roles role) {
-				message = buildMsg(role);
-			}else if(entity instanceof RoleMember roleMember) {
-				message = buildMsg(roleMember);
-			}else if(entity instanceof Access access) {
-				message = buildMsg(access);
-			}else if(entity instanceof Resources resource) {
-				message = buildMsg(resource);
-			}else if(entity instanceof Synchronizers synchronizer) {
-				message = buildMsg(synchronizer);
-			}else if(entity instanceof SocialsProvider socialsProvider) {
-				message = buildMsg(socialsProvider);
-			}else if(entity instanceof Permission permission) {
-				message = buildMsg(permission);
-			}else if(entity instanceof String) {
-				message = entity.toString();
-			}
-			
-		}
-		
-		insert(topic,message,action,result,operator, entity);
-	}
-	
-	public void insert(String topic,String message,String action,String result,UserInfo operator,Object entity) {
-		HistorySystemLogs systemLog = new HistorySystemLogs();
-		systemLog.setId(systemLog.generateId());
-		systemLog.setTopic(topic);
-		systemLog.setMessage(message);
-		systemLog.setMessageAction(action);
-		systemLog.setMessageResult(result);
-		systemLog.setUserId(operator.getId());
-		systemLog.setUsername(operator.getUsername());
-		systemLog.setDisplayName(operator.getDisplayName());
-		systemLog.setInstId(operator.getInstId());
-		systemLog.setJsonCotent(JsonUtils.gsonToString(entity));
-		systemLog.setExecuteTime(new Date());
-		_logger.trace("System Log {}" ,systemLog);
-		getMapper().insert(systemLog);
-	}
-	
-	public String buildMsg(UserInfo userInfo) {
-		return new StringBuilder()
-				.append(userInfo.getDisplayName())
-				.append("[")
-				.append(userInfo.getUsername())
-				.append("]")
-				.toString();
-	}
-	
-	public String buildMsg(Organizations org) {
-		return new StringBuilder()
-				.append(org.getOrgName())
-				.append("[")
-				.append(org.getOrgCode())
-				.append("]")
-				.toString();
-	}
-	
-	public String buildMsg(Accounts account) {
-		return new StringBuilder()
-				.append(account.getRelatedUsername())
-				.append("[")
-				.append(account.getDisplayName()).append(",")
-				.append(account.getUsername()).append(",")
-				.append(account.getAppName())
-				.append("]")
-				.toString();
-	}
-	
-	public String buildMsg(ChangePassword changePassword) {
-		return new StringBuilder()
-				.append(changePassword.getDisplayName())
-				.append("[")
-				.append(changePassword.getUsername())
-				.append("]")
-				.toString();
-	}
-	
-	public String buildMsg(Roles g) {
-		return new StringBuilder()
-				.append(g.getRoleName())
-				.toString();
-	}
-	
-	public String buildMsg(RoleMember rm) {
-		return new StringBuilder()
-				.append(rm.getRoleName())
-				.append("[")
-				.append(rm.getUsername()).append(",")
-				.append(rm.getDisplayName())
-				.append("]")
-				.toString();
-	}
-	
-	public String buildMsg(Access permission) {
-		return new StringBuilder()
-				.append(permission.getGroupName())
-				.append("[")
-				.append(permission.getAppName())
-				.append("]")
-				.toString();
-	}
-	
-	public String buildMsg(Permission privilege) {
-		return new StringBuilder()
-				.append(privilege.getGroupId())
-				.append("[")
-				.append(privilege.getResourceId())
-				.append("]")
-				.toString();
-	}
-	
-	
-	public String buildMsg(Resources r) {
-		return new StringBuilder()
-				.append(r.getResourceName())
-				.append("[")
-				.append(r.getResourceType())
-				.append("]")
-				.toString();
-	}
-	
+public interface HistorySystemLogsService  extends IJpaService<HistorySystemLogs>{
 	
-	public String buildMsg(Synchronizers s) {
-		return new StringBuilder()
-				.append(s.getName())
-				.append("[")
-				.append(s.getSourceType()).append(",")
-				.append(s.getScheduler()).append(",")
-				.append("]")
-				.toString();
-	}
+	public void insert(String topic,Object entity,String action,String result,UserInfo operator) ;
 	
-	public String buildMsg(SocialsProvider s) {
-		return new StringBuilder()
-				.append(s.getProviderName())
-				.append("[")
-				.append(s.getProvider())
-				.append("]")
-				.toString();
-	}
+	public void insert(String topic,String message,String action,String result,UserInfo operator,Object entity) ;
 	
 }

+ 4 - 22
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/InstitutionsService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -18,28 +18,10 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.Institutions;
-import org.dromara.maxkey.persistence.mapper.InstitutionsMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
+public interface InstitutionsService  extends IJpaService<Institutions>{
 
-@Repository
-public class InstitutionsService  extends JpaService<Institutions>{
-	
-	public InstitutionsService() {
-		super(InstitutionsMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public InstitutionsMapper getMapper() {
-		return (InstitutionsMapper)super.getMapper();
-	}
- 
-	 public Institutions findByDomain(String domain) {
-		 return getMapper().findByDomain(domain);
-	 }
+	 public Institutions findByDomain(String domain) ;
 	 
 }

+ 3 - 26
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/OrganizationsCastService.java

@@ -18,33 +18,10 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.OrganizationsCast;
-import org.dromara.maxkey.persistence.mapper.OrganizationsCastMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
+public interface OrganizationsCastService  extends IJpaService<OrganizationsCast>{
 
-@Repository
-public class OrganizationsCastService  extends JpaService<OrganizationsCast>{
-
-	static final  Logger _logger = LoggerFactory.getLogger(OrganizationsCastService.class);
-
-    
-	public OrganizationsCastService() {
-		super(OrganizationsCastMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public OrganizationsCastMapper getMapper() {
-		return (OrganizationsCastMapper)super.getMapper();
-	}
-
-	public boolean updateCast(OrganizationsCast organizationsCast) {
-		return getMapper().updateCast(organizationsCast) > 0;
-	}
+	public boolean updateCast(OrganizationsCast organizationsCast) ;
 
 }

+ 7 - 159
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/OrganizationsService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -17,172 +17,20 @@
 
 package org.dromara.maxkey.persistence.service;
 
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 
-import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellType;
 import org.dromara.maxkey.entity.idm.Organizations;
-import org.dromara.maxkey.persistence.mapper.OrganizationsMapper;
-import org.dromara.maxkey.provision.ProvisionAct;
-import org.dromara.maxkey.provision.ProvisionService;
-import org.dromara.maxkey.provision.ProvisionTopic;
-import org.dromara.mybatis.jpa.JpaService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
 
-@Repository
-public class OrganizationsService  extends JpaService<Organizations>{
-	static final Logger _logger = LoggerFactory.getLogger(OrganizationsService.class);
-	
-    @Autowired
-    ProvisionService provisionService;
-    
-	public OrganizationsService() {
-		super(OrganizationsMapper.class);
-	}
+public interface OrganizationsService  extends IJpaService<Organizations>{
 
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public OrganizationsMapper getMapper() {
-		return (OrganizationsMapper)super.getMapper();
-	}
-	
-	 @Override
-	 public boolean insert(Organizations organization) {
-	     if(super.insert(organization)){
-	    	 provisionService.send(
-                     ProvisionTopic.ORG_TOPIC, organization, ProvisionAct.CREATE);
-             return true;
-         }
-         return false;
-	 }
+	 public void saveOrUpdate(Organizations organization) ;
 	 
-	 @Override
-	 public boolean update(Organizations organization) {
-	     if(super.update(organization)){
-	    	 provisionService.send(
-                     ProvisionTopic.ORG_TOPIC, organization, ProvisionAct.UPDATE);
-             return true;
-         }
-         return false;
-     }
- 
-	 public void saveOrUpdate(Organizations organization) {
-		 Organizations loadOrg =findOne(" id = ? and instid = ?", 
-					new Object[] { organization.getId(), organization.getInstId() },
-              new int[] { Types.VARCHAR, Types.VARCHAR });
-		 if( loadOrg == null) {
-				insert(organization);
-			}else {
-				organization.setId(organization.getId());
-				update(organization);
-			}
-	 }
-	 public List<Organizations> queryOrgs(Organizations organization){
-		 return getMapper().queryOrgs(organization);
-	 }
+	 public List<Organizations> queryOrgs(Organizations organization);
 	 
-	 public boolean delete(Organizations organization) {
-	     if(super.delete(organization.getId())){
-	    	 provisionService.send(
-                     ProvisionTopic.ORG_TOPIC, organization, ProvisionAct.DELETE);
-             return true;
-         }
-         return false;
-	 }
-
-
-	public void reorgNamePath(String instId) {
-		_logger.debug("instId {}", instId);
-		if (StringUtils.isBlank(instId)) {
-			instId = "1";
-		}
-
-		HashMap<String, Organizations> reorgOrgMap = new HashMap<>();
-		List<Organizations> orgList = find(" where instid ='" + instId + "'");
-		List<Organizations> originOrgList = new ArrayList<>();
-		Organizations rootOrg = null;
-		for (Organizations org : orgList) {
-			reorgOrgMap.put(org.getId(), org);
-			if (isRootOrg(org)) {
-				rootOrg = org;
-			}
-			Organizations cloneOrg = new Organizations();
-			BeanUtils.copyProperties(org, cloneOrg);
-			originOrgList.add(cloneOrg);
-		}
-		try {
-			reorg(reorgOrgMap, orgList, rootOrg);
-			_logger.debug("reorged .");
-			long reorgCount = 0;
-			for (Organizations originOrg : originOrgList) {
-				Organizations reorgOrg = reorgOrgMap.get(originOrg.getId());
-				_logger.trace("reorged Organization {}", reorgOrg);
-				if (originOrg.getNamePath() == null || !originOrg.getNamePath().equals(reorgOrg.getNamePath())) {
-					_logger.debug("update reorgCount {} , Organization {}", ++reorgCount, reorgOrg);
-					getMapper().updateNamePath(reorgOrg);
-				}
-			}
-			_logger.debug("reorg finished .");
-		} catch (Exception e) {
-			_logger.error("reorgNamePath Exception ", e);
-		}
-	}
-
-	boolean isRootOrg(Organizations rootOrg) {
-		if (rootOrg.getParentId() == null || rootOrg.getParentId().equalsIgnoreCase("-1")
-				|| rootOrg.getParentId().equalsIgnoreCase(rootOrg.getId())
-				|| rootOrg.getParentId().equalsIgnoreCase(rootOrg.getInstId())) {
-			return true;
-		}
-		return false;
-	}
+	 public boolean delete(Organizations organization) ;
 
-	void reorg(HashMap<String, Organizations> orgMap, List<Organizations> orgList, Organizations rootOrg) {
-		if (isRootOrg(rootOrg)) {
-			rootOrg.setCodePath("/" + rootOrg.getId() + "/");
-			rootOrg.setNamePath("/" + rootOrg.getOrgName() + "/");
-		} else {
-			Organizations parent = orgMap.get(rootOrg.getParentId());
-			rootOrg.setCodePath(parent.getCodePath() + rootOrg.getId() + "/");
-			rootOrg.setNamePath(parent.getNamePath() + rootOrg.getOrgName() + "/");
-		}
-		rootOrg.setReorgNamePath(true);
+	public void reorgNamePath(String instId) ;
 
-		for (Organizations org : orgList) {
-			if (org.isReorgNamePath())
-				continue;
-			if (org.getParentId().equalsIgnoreCase(rootOrg.getId())) {
-				reorg(orgMap, orgList, org);
-			}
-		}
-	}
-	 /**
-	     *       根据数据格式返回数据
-     *
-     * @param cell
-     * @return
-     */
-    public static String getValue(Cell cell) {
-        if (cell == null) {
-            return "";
-        } else if (cell.getCellType() == CellType.BOOLEAN) {
-            return String.valueOf(cell.getBooleanCellValue());
-        } else if (cell.getCellType() == CellType.NUMERIC) {
-            cell.setBlank();
-            return String.valueOf(cell.getStringCellValue().trim());
-        } else {
-            return String.valueOf(cell.getStringCellValue().trim());
-        }
-    }
 }

+ 5 - 27
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/PermissionRoleService.java

@@ -21,36 +21,14 @@ package org.dromara.maxkey.persistence.service;
 import java.util.List;
 
 import org.dromara.maxkey.entity.permissions.PermissionRole;
-import org.dromara.maxkey.persistence.mapper.PermissionRoleMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class PermissionRoleService  extends JpaService<PermissionRole>{
-	static final Logger _logger = LoggerFactory.getLogger(PermissionRoleService.class);
-   
-    
-	public PermissionRoleService() {
-		super(PermissionRoleMapper.class);
-	}
+public interface PermissionRoleService  extends IJpaService<PermissionRole>{
 
-	@Override
-	public PermissionRoleMapper getMapper() {
-		return (PermissionRoleMapper)super.getMapper();
-	}
-	
-	public boolean insertPermissionRoles(List<PermissionRole> permissionRolesList) {
-	    return getMapper().insertPermissionRoles(permissionRolesList)>0;
-	}
+	public boolean insertPermissionRoles(List<PermissionRole> permissionRolesList);
     
-	public boolean deletePermissionRoles(List<PermissionRole> permissionRolesList) {
-	     return getMapper().deletePermissionRoles(permissionRolesList)>=0;
-	 }
+	public boolean deletePermissionRoles(List<PermissionRole> permissionRolesList) ;
 	
-    public List<PermissionRole> queryPermissionRoles(PermissionRole permissionRole){
-        return getMapper().queryPermissionRoles(permissionRole);
-    }    
+    public List<PermissionRole> queryPermissionRoles(PermissionRole permissionRole);
 
 }

+ 6 - 31
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/PermissionService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -20,39 +20,14 @@ package org.dromara.maxkey.persistence.service;
 import java.util.List;
 
 import org.dromara.maxkey.entity.permissions.Permission;
-import org.dromara.maxkey.persistence.mapper.PermissionMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class PermissionService  extends JpaService<Permission>{
-	static final  Logger _logger = LoggerFactory.getLogger(PermissionService.class);
-   
-    
-	public PermissionService() {
-		super(PermissionMapper.class);
-	}
+public interface PermissionService  extends IJpaService<Permission>{
 
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public PermissionMapper getMapper() {
-		return (PermissionMapper)super.getMapper();
-	}
-	
-	public boolean insertGroupPrivileges(List<Permission> rolePermissionsList) {
-	    return getMapper().insertGroupPrivileges(rolePermissionsList)>0;
-	};
+	public boolean insertGroupPrivileges(List<Permission> rolePermissionsList) ;
     
-	public boolean deleteGroupPrivileges(List<Permission> rolePermissionsList) {
-	     return getMapper().deleteGroupPrivileges(rolePermissionsList)>=0;
-	 }
+	public boolean deleteGroupPrivileges(List<Permission> rolePermissionsList);
 	
-    public List<Permission> queryGroupPrivileges(Permission rolePermissions){
-        return getMapper().queryGroupPrivileges(rolePermissions);
-    }    
+    public List<Permission> queryGroupPrivileges(Permission rolePermissions);
 
 }

+ 4 - 25
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/RegisterService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -17,33 +17,12 @@
 
 package org.dromara.maxkey.persistence.service;
 
-import java.util.List;
-
 import org.dromara.maxkey.entity.Register;
 import org.dromara.maxkey.entity.idm.UserInfo;
-import org.dromara.maxkey.persistence.mapper.RegisterMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public class RegisterService  extends JpaService<Register>{
+import org.dromara.mybatis.jpa.IJpaService;
 
-	public RegisterService() {
-		super(RegisterMapper.class);
-	}
+public interface RegisterService  extends IJpaService<Register>{
 
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public RegisterMapper getMapper() {
-		return (RegisterMapper)super.getMapper();
-	}
-	
-	
-	public UserInfo findByEmail(String email){
-		List<UserInfo> listUserInfo=getMapper().findByEmail(email);
-		return listUserInfo.size()>0?listUserInfo.get(0):null;
-	}
+	public UserInfo findByEmail(String email);
 	
 }

+ 12 - 45
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/ReportService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -20,59 +20,26 @@ package org.dromara.maxkey.persistence.service;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import org.dromara.maxkey.persistence.mapper.ReportMapper;
-import org.dromara.mybatis.jpa.JpaService;
+import org.dromara.mybatis.jpa.IJpaService;
 import org.dromara.mybatis.jpa.entity.JpaEntity;
-import org.springframework.stereotype.Repository;
 
-@Repository
-public class ReportService  extends JpaService<JpaEntity>{
+public interface ReportService  extends IJpaService<JpaEntity>{
 
-	public Integer analysisDay(HashMap<String,Object> reportParameter) {
-		return getMapper().analysisDay(reportParameter);
-	};
+	public Integer analysisDay(HashMap<String,Object> reportParameter) ;
 	
-	public Integer analysisNewUsers(HashMap<String,Object> reportParameter) {
-		return getMapper().analysisNewUsers(reportParameter);
-	};
+	public Integer analysisNewUsers(HashMap<String,Object> reportParameter) ;
 	
-	public Integer analysisOnlineUsers(HashMap<String,Object> reportParameter) {
-		return getMapper().analysisOnlineUsers(reportParameter);
-	};
+	public Integer analysisOnlineUsers(HashMap<String,Object> reportParameter) ;
 	
-	public Integer analysisActiveUsers(HashMap<String,Object> reportParameter) {
-		return getMapper().analysisActiveUsers(reportParameter);
-	};
+	public Integer analysisActiveUsers(HashMap<String,Object> reportParameter);
 	
-	public List<Map<String,Object>> analysisDayHour(HashMap<String,Object> reportParameter){
-		return getMapper().analysisDayHour(reportParameter);
-	}
+	public List<Map<String,Object>> analysisDayHour(HashMap<String,Object> reportParameter);
 	
-	public List<Map<String,Object>> analysisMonth(HashMap<String,Object> reportParameter){
-		return getMapper().analysisMonth(reportParameter);
-	}
+	public List<Map<String,Object>> analysisMonth(HashMap<String,Object> reportParameter);
 	
 	
-	public List<Map<String,Object>> analysisBrowser(HashMap<String,Object> reportParameter){
-		return getMapper().analysisBrowser(reportParameter);
-	}
+	public List<Map<String,Object>> analysisBrowser(HashMap<String,Object> reportParameter);
 	
-	public List<Map<String,Object>> analysisApp(HashMap<String,Object> reportParameter){
-		return getMapper().analysisApp(reportParameter);
-	}
-	
-	
-	
-	public ReportService() {
-		super(ReportMapper.class);
-		
-	}
-	
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public ReportMapper getMapper() {
-		return (ReportMapper)super.getMapper();
-	}
+	public List<Map<String,Object>> analysisApp(HashMap<String,Object> reportParameter);
+
 }

+ 4 - 21
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/ResourcesService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -20,26 +20,9 @@ package org.dromara.maxkey.persistence.service;
 import java.util.List;
 
 import org.dromara.maxkey.entity.permissions.Resources;
-import org.dromara.maxkey.persistence.mapper.ResourcesMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class ResourcesService  extends JpaService<Resources>{
+public interface ResourcesService  extends IJpaService<Resources>{
 	
-	public ResourcesService() {
-		super(ResourcesMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public ResourcesMapper getMapper() {
-		return (ResourcesMapper)super.getMapper();
-	}
-	
-	public List<Resources> queryResourcesTree(Resources resource){
-	   return  getMapper().fetchPageResults(resource);
-	}
+	public List<Resources> queryResourcesTree(Resources resource);
 }

+ 7 - 52
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/RoleMemberService.java

@@ -23,65 +23,20 @@ import java.util.List;
 import org.dromara.maxkey.entity.idm.UserInfo;
 import org.dromara.maxkey.entity.permissions.RoleMember;
 import org.dromara.maxkey.entity.permissions.Roles;
-import org.dromara.maxkey.persistence.mapper.RoleMemberMapper;
-import org.dromara.mybatis.jpa.JpaService;
+import org.dromara.mybatis.jpa.IJpaService;
 import org.dromara.mybatis.jpa.entity.JpaPageResults;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Repository;
 
-@Repository
-public class RoleMemberService  extends JpaService<RoleMember>{
-	static final  Logger _logger = LoggerFactory.getLogger(RoleMemberService.class);
-	
-	public RoleMemberService() {
-		super(RoleMemberMapper.class);
-	}
+public interface RoleMemberService  extends IJpaService<RoleMember>{
 
-	@Override
-	public RoleMemberMapper getMapper() {
-		return (RoleMemberMapper)super.getMapper();
-	}
-	
-	public int addDynamicRoleMember(Roles dynamicGroup) {
-	    return getMapper().addDynamicRoleMember(dynamicGroup);
-	}
+	public int addDynamicRoleMember(Roles dynamicGroup);
 	
-	public int deleteDynamicRoleMember(Roles dynamicGroup) {
-	    return getMapper().deleteDynamicRoleMember(dynamicGroup);
-	}
+	public int deleteDynamicRoleMember(Roles dynamicGroup) ;
 	
-	public int deleteByRoleId(String groupId) {
-        return getMapper().deleteByRoleId(groupId);
-    }
+	public int deleteByRoleId(String groupId) ;
 	
-	public List<UserInfo> queryMemberByRoleId(String groupId){
-		return getMapper().queryMemberByRoleId(groupId);
-	}
+	public List<UserInfo> queryMemberByRoleId(String groupId);
 	
 	
-	public JpaPageResults<Roles> rolesNoMember(RoleMember entity) {
-		entity.setPageSelectId(entity.generateId());
-		entity.setStartRow(calculateStartRow(entity.getPageNumber() ,entity.getPageSize()));
-		
-		entity.setPageable(true);
-		List<Roles> resultslist = null;
-		try {
-			resultslist = getMapper().rolesNoMember(entity);
-		} catch (Exception e) {
-			_logger.error("fetchPageResults Exception " , e);
-		}
-		entity.setPageable(false);
-		Integer totalPage = resultslist.size();
-		
-		Integer totalCount = 0;
-		if(entity.getPageNumber() == 1 && totalPage < entity.getPageSize()) {
-			totalCount = totalPage;
-		}else {
-			totalCount = parseCount(getMapper().fetchCount(entity));
-		}
-		
-		return new JpaPageResults<Roles>(entity.getPageNumber(),entity.getPageSize(),totalPage,totalCount,resultslist);
-	}
+	public JpaPageResults<Roles> rolesNoMember(RoleMember entity) ;
 	
 }

+ 7 - 92
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/RolesService.java

@@ -19,106 +19,21 @@
 
 package org.dromara.maxkey.persistence.service;
 
-import java.sql.Types;
 import java.util.List;
 
-import org.apache.commons.lang3.StringUtils;
-import org.dromara.maxkey.constants.ConstsStatus;
-import org.dromara.maxkey.entity.Institutions;
 import org.dromara.maxkey.entity.permissions.Roles;
-import org.dromara.maxkey.persistence.mapper.RolesMapper;
-import org.dromara.maxkey.util.StrUtils;
-import org.dromara.mybatis.jpa.JpaService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class RolesService  extends JpaService<Roles> {
-    static final  Logger _logger = LoggerFactory.getLogger(RolesService.class);
-    
-    @Autowired
-    RoleMemberService roleMemberService;
-    
-    @Autowired
-    InstitutionsService institutionsService;
-    
-	public RolesService() {
-		super(RolesMapper.class);
-	}
+public interface RolesService  extends IJpaService<Roles> {
 
-	@Override
-	public RolesMapper getMapper() {
-		return (RolesMapper)super.getMapper();
-	}
+	public List<Roles> queryDynamicRoles(Roles groups);
 	
+	public boolean deleteById(String groupId);
 	
-	public List<Roles> queryDynamicRoles(Roles groups){
-	    return this.getMapper().queryDynamicRoles(groups);
-	}
+	public List<Roles> queryRolesByUserId(String userId);
 	
-	public boolean deleteById(String groupId) {
-	    this.delete(groupId);
-	    roleMemberService.deleteByRoleId(groupId);
-	    return true;
-	}
+	public void refreshDynamicRoles(Roles dynamicRole);
 	
-	public List<Roles> queryRolesByUserId(String userId){
-		return this.getMapper().queryRolesByUserId(userId);
-	}
-	
-	public void refreshDynamicRoles(Roles dynamicRole){
-	    if(dynamicRole.getCategory().equals(Roles.Category.DYNAMIC)) {
-	        
-	        if(StringUtils.isNotBlank(dynamicRole.getOrgIdsList())) {
-    	    	String []orgIds = dynamicRole.getOrgIdsList().split(",");
-    	    	StringBuffer orgIdFilters = new StringBuffer();
-    	    	for(String orgId : orgIds) {
-    	    		if(StringUtils.isNotBlank(orgId)) {
-	    	    		if(orgIdFilters.length() > 0) {
-	    	    			orgIdFilters.append(",");
-	    	    		}
-	    	    		orgIdFilters.append("'").append(orgId).append("'");
-    	    		}
-    	    	}
-    	    	if(orgIdFilters.length() > 0) {
-    	    		dynamicRole.setOrgIdsList(orgIdFilters.toString());
-    	    	}
-    	    }
-	        
-    	    String filters = dynamicRole.getFilters();
-    	    _logger.debug("filters {}" , filters);
-    	    if(StringUtils.isNotBlank(filters)) {
-	    		if(StrUtils.filtersSQLInjection(filters.toLowerCase())) {  
-	    			_logger.info("filters include SQL Injection Attack Risk.");
-	    			return;
-	    		}
-	    		//replace & with AND, | with OR
-	    		filters = filters.replace("&", " AND ").replace("\\|", " OR ");
-	    	    
-	    		_logger.debug("set filters {}" , filters);
-	    	    dynamicRole.setFilters(filters);
-    	    }
-	    
-	    	roleMemberService.deleteDynamicRoleMember(dynamicRole);
-	    	roleMemberService.addDynamicRoleMember(dynamicRole);
-        
-	    }
-    }
-	
-	public void refreshAllDynamicRoles(){
-		List<Institutions> instList = 
-				institutionsService.find("where status = ? ", new Object[]{ConstsStatus.ACTIVE}, new int[]{Types.INTEGER});
-		for(Institutions inst : instList) {
-			Roles role = new Roles();
-			role.setInstId(inst.getId());
-		    List<Roles>  rolesList = queryDynamicRoles(role);
-	        for(Roles r : rolesList) {
-	            _logger.debug("role {}" , r);
-	            refreshDynamicRoles(r);
-	        }
-		}
-	}
+	public void refreshAllDynamicRoles();
 
 }

+ 3 - 21
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/SocialsAssociatesService.java

@@ -21,29 +21,11 @@ import java.util.List;
 
 import org.dromara.maxkey.entity.SocialsAssociate;
 import org.dromara.maxkey.entity.idm.UserInfo;
-import org.dromara.maxkey.persistence.mapper.SocialsAssociateMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
 
-@Repository
-public class SocialsAssociatesService  extends JpaService<SocialsAssociate>{
-	
-	public SocialsAssociatesService() {
-		super(SocialsAssociateMapper.class);
-	}
+public interface SocialsAssociatesService  extends IJpaService<SocialsAssociate>{
 
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public SocialsAssociateMapper getMapper() {
-		return (SocialsAssociateMapper)super.getMapper();
-	}
- 
-	
-	public List<SocialsAssociate>  queryByUser(UserInfo user) {
-		return getMapper().queryByUser(user);
-	}
+	public List<SocialsAssociate>  queryByUser(UserInfo user);
 	 
 }

+ 2 - 22
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/SocialsProviderService.java

@@ -18,28 +18,8 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.SocialsProvider;
-import org.dromara.maxkey.persistence.mapper.SocialsProviderMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class SocialsProviderService  extends JpaService<SocialsProvider>{
-    static final  Logger _logger = LoggerFactory.getLogger(SocialsProviderService.class);
-    
-    
-	public SocialsProviderService() {
-		super(SocialsProviderMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public SocialsProviderMapper getMapper() {
-		return (SocialsProviderMapper)super.getMapper();
-	}
-	
+public interface SocialsProviderService  extends IJpaService<SocialsProvider>{
 
 }

+ 7 - 49
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/SynchroRelatedService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -17,61 +17,19 @@
 
 package org.dromara.maxkey.persistence.service;
 
-import java.sql.Types;
-import java.util.Date;
 import java.util.List;
 
 import org.dromara.maxkey.entity.SynchroRelated;
 import org.dromara.maxkey.entity.Synchronizers;
-import org.dromara.maxkey.entity.idm.Organizations;
-import org.dromara.maxkey.persistence.mapper.SynchroRelatedMapper;
-import org.dromara.maxkey.util.DateUtils;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Repository;
+import org.dromara.mybatis.jpa.IJpaService;
 
-@Repository
-public class SynchroRelatedService  extends JpaService<SynchroRelated>{
+public interface SynchroRelatedService  extends IJpaService<SynchroRelated>{
 
-	public SynchroRelatedService() {
-		super(SynchroRelatedMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public SynchroRelatedMapper getMapper() {
-		return (SynchroRelatedMapper)super.getMapper();
-	}
-	
-	public int updateSyncTime(SynchroRelated synchroRelated) {
-		return getMapper().updateSyncTime(synchroRelated);
-	}
+	public int updateSyncTime(SynchroRelated synchroRelated);
 	
-	public List<SynchroRelated> findOrgs(Synchronizers synchronizer) {
-		return find(
-				"instid = ? and syncid = ? and objecttype = ? ",
-		 		new Object[] { synchronizer.getInstId() ,synchronizer.getId(),Organizations.CLASS_TYPE},
-                new int[] { Types.VARCHAR,Types.VARCHAR,Types.VARCHAR}
-				);
-	}
+	public List<SynchroRelated> findOrgs(Synchronizers synchronizer) ;
 	
-	public SynchroRelated findByOriginId(Synchronizers synchronizer,String originId,String classType) {
-		return findOne("instid = ? and syncId = ? and originid = ? and objecttype = ? ",
-		 		new Object[] { synchronizer.getInstId(),synchronizer.getId(),originId,classType },
-                new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,Types.VARCHAR});
-	}
+	public SynchroRelated findByOriginId(Synchronizers synchronizer,String originId,String classType) ;
 	
-	public void updateSynchroRelated(Synchronizers synchronizer,SynchroRelated synchroRelated,String classType) {
-		SynchroRelated loadSynchroRelated = 
-				findByOriginId(
-						synchronizer,synchroRelated.getOriginId(),classType );
-		if(loadSynchroRelated == null) {
-			insert(synchroRelated);
-		}else {
-			synchroRelated.setId(loadSynchroRelated.getId());
-			synchroRelated.setSyncTime(DateUtils.formatDateTime(new Date()));
-			updateSyncTime(synchroRelated);
-		}
-	}
+	public void updateSynchroRelated(Synchronizers synchronizer,SynchroRelated synchroRelated,String classType) ;
 }

+ 2 - 24
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/SynchronizersService.java

@@ -18,30 +18,8 @@
 package org.dromara.maxkey.persistence.service;
 
 import org.dromara.maxkey.entity.Synchronizers;
-import org.dromara.maxkey.persistence.mapper.SynchronizersMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public class SynchronizersService  extends JpaService<Synchronizers>{
-    static final  Logger _logger = LoggerFactory.getLogger(SynchronizersService.class);
-    
-	public SynchronizersService() {
-		super(SynchronizersMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public SynchronizersMapper getMapper() {
-		return (SynchronizersMapper)super.getMapper();
-	}
-	
-	
-
+import org.dromara.mybatis.jpa.IJpaService;
 
+public interface SynchronizersService  extends IJpaService<Synchronizers>{
 	
 }

+ 31 - 344
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/UserInfoService.java

@@ -1,5 +1,5 @@
 /*
- * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * Copyright [2024] [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.
@@ -18,242 +18,42 @@
 package org.dromara.maxkey.persistence.service;
 
 
-import java.sql.Types;
-import java.util.Date;
-
-import org.apache.commons.lang3.StringUtils;
-import org.dromara.maxkey.constants.ConstsStatus;
-import org.dromara.maxkey.crypto.password.PasswordReciprocal;
-import org.dromara.maxkey.entity.Accounts;
 import org.dromara.maxkey.entity.ChangePassword;
 import org.dromara.maxkey.entity.idm.UserInfo;
-import org.dromara.maxkey.persistence.mapper.UserInfoMapper;
 import org.dromara.maxkey.persistence.repository.PasswordPolicyValidator;
-import org.dromara.maxkey.provision.ProvisionAct;
-import org.dromara.maxkey.provision.ProvisionService;
-import org.dromara.maxkey.provision.ProvisionTopic;
-import org.dromara.maxkey.web.WebContext;
-import org.dromara.mybatis.jpa.JpaService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.stereotype.Repository;
-
+import org.dromara.mybatis.jpa.IJpaService;
 
 /**
  * @author Crystal.Sea
  *
  */
-@Repository
-public class UserInfoService extends JpaService<UserInfo> {
-	static final  Logger _logger = LoggerFactory.getLogger(UserInfoService.class);
-	
-	@Autowired
-	private PasswordEncoder passwordEncoder;
-	
-	@Autowired
-	PasswordPolicyValidator passwordPolicyValidator;
-	
-	@Autowired
-	ProvisionService provisionService;
-
-	AccountsService accountsService;
-	
-	public UserInfoService() {
-		super(UserInfoMapper.class);
-	}
-
-	/* (non-Javadoc)
-	 * @see com.connsec.db.service.BaseService#getMapper()
-	 */
-	@Override
-	public UserInfoMapper getMapper() {
-		return (UserInfoMapper)super.getMapper();
-	}
+public interface UserInfoService extends IJpaService<UserInfo> {
 	
-	@Override
-    public boolean insert(UserInfo userInfo) {
-    	this.passwordEncoder(userInfo);
-        if (super.insert(userInfo)) {
-        	if(provisionService.getApplicationConfig().isProvisionSupport()) {
-                UserInfo loadUserInfo = findUserRelated(userInfo.getId());
-                provisionService.send(
-                        ProvisionTopic.USERINFO_TOPIC, 
-                        loadUserInfo,
-                        ProvisionAct.CREATE);
-            }
-            
-            return true;
-        }
-
-        return false;
-    }
-    
-    public boolean insert(UserInfo userInfo,boolean passwordEncoder) {
-    	if(passwordEncoder) {
-    		this.passwordEncoder(userInfo);
-    	}
-        if (super.insert(userInfo)) {
-        	if(provisionService.getApplicationConfig().isProvisionSupport()) {
-                UserInfo loadUserInfo = findUserRelated(userInfo.getId());
-                provisionService.send(
-                        ProvisionTopic.USERINFO_TOPIC, 
-                        loadUserInfo,
-                        ProvisionAct.CREATE);
-            }
-            
-            return true;
-        }
-
-        return false;
-    }
+    public boolean insert(UserInfo userInfo,boolean passwordEncoder) ;
 	
-    @Override
-    public boolean update(UserInfo userInfo) {
-    	ChangePassword changePassword = this.passwordEncoder(userInfo);
-        if (super.update(userInfo)) {
-        	if(provisionService.getApplicationConfig().isProvisionSupport()) {
-                UserInfo loadUserInfo = findUserRelated(userInfo.getId());
-                accountUpdate(loadUserInfo);
-                provisionService.send(
-                        ProvisionTopic.USERINFO_TOPIC, 
-                        loadUserInfo,
-                        ProvisionAct.UPDATE);
-            }
-            if(userInfo.getPassword() != null) {
-            	changePasswordProvisioning(changePassword);
-            }
-            return true;
-        }
-        return false;
-    }
-	
-	public boolean delete(UserInfo userInfo) {
-	    UserInfo loadUserInfo = null;
-	    if(provisionService.getApplicationConfig().isProvisionSupport()) {
-	        loadUserInfo = findUserRelated(userInfo.getId());
-	    }
-	    
-		if( super.delete(userInfo.getId())){
-			provisionService.send(
-		            ProvisionTopic.USERINFO_TOPIC, 
-		            loadUserInfo, 
-		            ProvisionAct.DELETE);
-			accountUpdate(loadUserInfo);
-			 return true;
-		}
-		return false;
-	}
+	public boolean delete(UserInfo userInfo) ;
 	
     //更新账号状态
-    public void accountUpdate(UserInfo userInfo) {
-        if(userInfo.getStatus() != ConstsStatus.ACTIVE) {
-            if(accountsService==null) {
-                accountsService = 
-                       WebContext.getBean("accountsService",AccountsService.class); 
-            }
-            Accounts queryAcount =new Accounts();
-            queryAcount.setUserId(userInfo.getId());
-            for (Accounts acount : accountsService.query(queryAcount)) {
-                acount.setStatus(ConstsStatus.INACTIVE);
-                accountsService.update(acount);
-            }
-        }
-    }
+    public void accountUpdate(UserInfo userInfo) ;
 
-	public UserInfo findUserRelated(String userId) {
-	    UserInfo loadUserInfo =this.get(userId);
-	    loadUserInfo.setDepts(getMapper().findDeptsByUserId(userId));
-	    return loadUserInfo;
-	}
+	public UserInfo findUserRelated(String userId) ;
 	
-	public boolean updateGridList(String gridList,UserInfo userInfo) {
-	    try {
-    	    if (gridList != null && !gridList.equals("")) {
-    	    	userInfo.setGridList(Integer.parseInt(gridList));
-                getMapper().updateGridList(userInfo);
-            }
-	    }catch(Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-	    return true;
-	}
+	public boolean updateGridList(String gridList,UserInfo userInfo);
 	
 	
-	public void saveOrUpdate(UserInfo userInfo) {
-		UserInfo loadUserInfo = findOne(" username = ? and instid = ?",
-				new Object[] { userInfo.getUsername(),userInfo.getInstId() },
-                new int[] { Types.VARCHAR,Types.VARCHAR});
-		if(loadUserInfo == null) {
-			insert(userInfo);
-		}else {
-			userInfo.setId(loadUserInfo.getId());
-			userInfo.setPassword(null);
-			update(userInfo);
-		}
-	}
+	public void saveOrUpdate(UserInfo userInfo) ;
 	
-	public boolean updateProtectedApps(UserInfo userinfo) {
-		try {
-			userinfo.setModifiedDate(new Date());
-			return getMapper().updateProtectedApps(userinfo) > 0;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return false;
-	}
+	public boolean updateProtectedApps(UserInfo userinfo) ;
 
-	public UserInfo findByUsername(String username) {
-		return getMapper().findByUsername(username);
-	}
+	public UserInfo findByUsername(String username) ;
 	
-    public UserInfo findByEmailMobile(String emailMobile) {
-        return getMapper().findByEmailMobile(emailMobile);
-    }
+    public UserInfo findByEmailMobile(String emailMobile) ;
 	
-	public UserInfo findByAppIdAndUsername(String appId,String username){
-		try {
-			UserInfo userinfo = new UserInfo();
-			userinfo.setUsername(username);
-			return getMapper().findByAppIdAndUsername(userinfo) ;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
+	public UserInfo findByAppIdAndUsername(String appId,String username);
 	
-	public ChangePassword passwordEncoder(UserInfo userInfo) {
-		ChangePassword changePassword = null;
-		if(StringUtils.isNotBlank(userInfo.getPassword())) {
-    		changePassword = new ChangePassword(userInfo);
-    		passwordEncoder(changePassword);
-    		userInfo.setPassword(changePassword.getPassword());
-    		userInfo.setDecipherable(changePassword.getDecipherable());
-    		userInfo.setPasswordLastSetTime(changePassword.getPasswordLastSetTime());
-    	}else {
-    		userInfo.setPassword(null);
-    		userInfo.setDecipherable(null);
-    	}
-		return changePassword;
-	}
+	public ChangePassword passwordEncoder(UserInfo userInfo) ;
 	
-	public ChangePassword passwordEncoder(ChangePassword changePassword) {
-	    //密码不为空,则需要进行加密处理
-	    if(StringUtils.isNotBlank(changePassword.getPassword())) {
-    	    String password = passwordEncoder.encode(changePassword.getPassword());
-    	    changePassword.setDecipherable(PasswordReciprocal.getInstance().encode(changePassword.getPassword()));
-            _logger.debug("decipherable : {}",changePassword.getDecipherable());
-            changePassword.setPassword(password);
-            changePassword.setPasswordLastSetTime(new Date());
-            
-	    }else {
-	    	changePassword.setPassword(null);
-	    	changePassword.setDecipherable(null);
-	    }
-        return changePassword;
-	}
+	public ChangePassword passwordEncoder(ChangePassword changePassword) ;
 	
 	/**
 	 * 认证密码修改
@@ -263,37 +63,7 @@ public class UserInfoService extends JpaService<UserInfo> {
 	 * @param passwordSetType
 	 * @return
 	 */
-	public boolean changePassword(  ChangePassword changePassword) {
-		try {
-		    WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, "");
-		    UserInfo userInfo = this.findByUsername(changePassword.getUsername());
-	        if(changePassword.getPassword().equals(changePassword.getConfirmPassword())){
-	            if(StringUtils.isNotBlank(changePassword.getOldPassword()) &&
-	                    passwordEncoder.matches(changePassword.getOldPassword(), userInfo.getPassword())){
-	                if(changePassword(changePassword,true) ){
-	                    return true;
-	                }
-	                return false;	               
-	            }else {
-	                if(StringUtils.isNotBlank(changePassword.getOldPassword())&&
-	                        passwordEncoder.matches(changePassword.getPassword(), userInfo.getPassword())) {
-	                    WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, 
-	                            WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_MATCH"));
-	                }else {
-	                    WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, 
-	                        WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_NOT_MATCH"));
-	                }
-	            }
-	        }else {
-	            WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, 
-	                    WebContext.getI18nValue("PasswordPolicy.CONFIRMPASSWORD_NOT_MATCH"));
-	        }
-		 } catch (Exception e) {
-             e.printStackTrace();
-         }    
-		    
-		return false;
-	}
+	public boolean changePassword(  ChangePassword changePassword) ;
 	
 	/**
 	 * 后台密码修改
@@ -301,130 +71,47 @@ public class UserInfoService extends JpaService<UserInfo> {
 	 * @param passwordPolicy
 	 * @return
 	 */
-    public boolean changePassword(ChangePassword changePassword,boolean passwordPolicy) {
-        try {
-            _logger.debug("decipherable old : {}" , changePassword.getDecipherable());
-            _logger.debug("decipherable new : {}" , PasswordReciprocal.getInstance().encode(changePassword.getDecipherable()));
-
-            if (passwordPolicy && !passwordPolicyValidator.validator(changePassword)) {
-                return false;
-            }
-
-            changePassword = passwordEncoder(changePassword);
-
-            if (getMapper().changePassword(changePassword) > 0) {
-                changePasswordProvisioning(changePassword);
-                return true;
-            }
-            return false;
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        return false;
-    }
+    public boolean changePassword(ChangePassword changePassword,boolean passwordPolicy) ;
 	
-	public String randomPassword() {
-	    return passwordPolicyValidator.generateRandomPassword();
-	}
+	public String randomPassword() ;
 	
-	public void changePasswordProvisioning(ChangePassword changePassworded) {
-	    if(changePassworded !=null && StringUtils.isNotBlank(changePassworded.getPassword())) {
-	    	UserInfo loadUserInfo = findByUsername(changePassworded.getUsername());
-    	    ChangePassword changePassword = new ChangePassword(loadUserInfo);
-    	    provisionService.send(ProvisionTopic.PASSWORD_TOPIC, changePassword, ProvisionAct.PASSWORD);
-	    }
-	}
+	public void changePasswordProvisioning(ChangePassword changePassworded) ;
 	
-	public boolean updateAppLoginPassword(UserInfo userinfo) {
-		try {
-			userinfo.setModifiedDate(new Date());
-			return getMapper().updateAppLoginPassword(userinfo) > 0;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return false;
-	}
+	public boolean updateAppLoginPassword(UserInfo userinfo) ;
 	
 	
 	/**
 	 * 锁定用户:islock:1 用户解锁 2 用户锁定
 	 * @param userInfo
 	 */
-	public void updateLocked(UserInfo userInfo) {
-		try {
-			if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
-				userInfo.setIsLocked(ConstsStatus.LOCK);
-				getMapper().updateLocked(userInfo);
-			}
-		} catch(Exception e) {
-			e.printStackTrace();
-		}
-	}
+	public void updateLocked(UserInfo userInfo) ;
 
 	/**
 	 * 用户登录成功后,重置错误密码次数和解锁用户
 	 * @param userInfo
 	 */
-	public void updateLockout(UserInfo userInfo) {
-		try {
-			if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
-				userInfo.setIsLocked(ConstsStatus.START);
-				userInfo.setBadPasswordCount(0);
-				getMapper().updateLockout(userInfo);
-			}
-		} catch(Exception e) {
-			e.printStackTrace();
-		}
-	}
+	public void updateLockout(UserInfo userInfo) ;
 
 	/**
 	 * 更新错误密码次数
 	 * @param userInfo
 	 */
-	public void updateBadPasswordCount(UserInfo userInfo) {
-		try {
-			if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
-				int updateBadPWDCount = userInfo.getBadPasswordCount() + 1;
-				userInfo.setBadPasswordCount(updateBadPWDCount);
-				getMapper().updateBadPWDCount(userInfo);
-			}
-		} catch(Exception e) {
-			e.printStackTrace();
-		}
-	}
+	public void updateBadPasswordCount(UserInfo userInfo) ;
 
-	public boolean updateSharedSecret(UserInfo userInfo){
-		return getMapper().updateSharedSecret(userInfo)>0;
-	}
+	public boolean updateSharedSecret(UserInfo userInfo);
 	
-	public boolean updatePasswordQuestion(UserInfo userInfo){
-		return getMapper().updatePasswordQuestion(userInfo)>0;
-	}
+	public boolean updatePasswordQuestion(UserInfo userInfo);
 	
-	public boolean updateAuthnType(UserInfo userInfo){
-		return getMapper().updateAuthnType(userInfo)>0;
-	}
+	public boolean updateAuthnType(UserInfo userInfo);
 	
-	public boolean updateEmail(UserInfo userInfo){
-		return getMapper().updateEmail(userInfo)>0;
-	}
+	public boolean updateEmail(UserInfo userInfo);
 	
-	public boolean updateMobile(UserInfo userInfo){
-		return getMapper().updateMobile(userInfo)>0;
-	}
+	public boolean updateMobile(UserInfo userInfo);
     
-    public int updateProfile(UserInfo userInfo){
-        return getMapper().updateProfile(userInfo);
-    }
+    public int updateProfile(UserInfo userInfo);
     
-    public boolean 	updateStatus(UserInfo userInfo) {
-    	return getMapper().updateStatus(userInfo) > 0;
-    }
+    public boolean 	updateStatus(UserInfo userInfo);
 
-    public void setPasswordPolicyValidator(PasswordPolicyValidator passwordPolicyValidator) {
-        this.passwordPolicyValidator = passwordPolicyValidator;
-    }
+    public void setPasswordPolicyValidator(PasswordPolicyValidator passwordPolicyValidator);
 
 }

+ 11 - 5
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/package-info.java → maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AccessServiceImpl.java

@@ -15,8 +15,14 @@
  */
  
 
-/**
- * 
- * Mysql DAO Mapper XML Configuration.
-*/
-package org.dromara.maxkey.persistence.service;
+package org.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.Access;
+import org.dromara.maxkey.persistence.mapper.AccessMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class AccessServiceImpl  extends JpaServiceImpl<AccessMapper,Access>{
+
+}

+ 255 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AccountsServiceImpl.java

@@ -0,0 +1,255 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.dromara.maxkey.constants.ConstsStatus;
+import org.dromara.maxkey.crypto.password.PasswordReciprocal;
+import org.dromara.maxkey.entity.Accounts;
+import org.dromara.maxkey.entity.AccountsStrategy;
+import org.dromara.maxkey.entity.OrganizationsCast;
+import org.dromara.maxkey.entity.idm.UserInfo;
+import org.dromara.maxkey.persistence.mapper.AccountsMapper;
+import org.dromara.maxkey.persistence.service.AccountsStrategyService;
+import org.dromara.maxkey.persistence.service.OrganizationsCastService;
+import org.dromara.maxkey.persistence.service.UserInfoService;
+import org.dromara.maxkey.provision.ProvisionAct;
+import org.dromara.maxkey.provision.ProvisionService;
+import org.dromara.maxkey.provision.ProvisionTopic;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+import net.sourceforge.pinyin4j.PinyinHelper;
+import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
+import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
+import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
+import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
+import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
+
+@Repository
+public class AccountsServiceImpl  extends JpaServiceImpl<AccountsMapper,Accounts>{
+
+    @Autowired
+    ProvisionService provisionService;
+    
+    @Autowired
+    UserInfoService  userInfoService;
+    
+    @Autowired
+    AccountsStrategyService accountsStrategyService;
+    
+    @Autowired
+    OrganizationsCastService organizationsCastService;
+    
+	@Override
+	 public boolean insert(Accounts account) {
+	     if (super.insert(account)) {
+	            if(provisionService.getApplicationConfig().isProvisionSupport()) {
+	                UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
+	                account.setUserInfo(loadUserInfo);
+	                OrganizationsCast cast = new OrganizationsCast();
+                    cast.setProvider(account.getAppId());
+                    cast.setOrgId(loadUserInfo.getDepartmentId());
+                    account.setOrgCast(organizationsCastService.query(cast));
+                    provisionService.send(
+	                        ProvisionTopic.ACCOUNT_TOPIC, 
+	                        account,
+	                        ProvisionAct.CREATE);
+	            }
+	            
+	            return true;
+	        }
+	     return false;
+	 }
+	 
+	@Override
+	public boolean update(Accounts account) {
+         if (super.update(account)) {
+        	 if(provisionService.getApplicationConfig().isProvisionSupport()) {
+                    UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
+                    account.setUserInfo(loadUserInfo);
+                    OrganizationsCast cast = new OrganizationsCast();
+                    cast.setProvider(account.getAppId());
+                    cast.setOrgId(loadUserInfo.getDepartmentId());
+                    account.setOrgCast(organizationsCastService.query(cast));
+                    provisionService.send(
+                            ProvisionTopic.ACCOUNT_TOPIC, 
+                            account,
+                            ProvisionAct.UPDATE);
+                }
+                
+                return true;
+            }
+         return false;
+     }
+   
+   public boolean updateStatus(Accounts accounts) {
+	   return this.getMapper().updateStatus(accounts) > 0;
+   }
+   
+   public boolean remove(String id) {
+       Accounts account = this.get(id);
+       if (super.delete(id)) {
+              UserInfo loadUserInfo = null;
+              if(provisionService.getApplicationConfig().isProvisionSupport()) {
+                  loadUserInfo = userInfoService.findUserRelated(account.getUserId());
+                  account.setUserInfo(loadUserInfo);
+                  provisionService.send(
+                          ProvisionTopic.ACCOUNT_TOPIC, 
+                          account,
+                          ProvisionAct.DELETE);
+              }
+              
+              return true;
+          }
+       return false;
+   }
+   
+   public void refreshByStrategy(AccountsStrategy strategy) {
+       if(StringUtils.isNotBlank(strategy.getOrgIdsList())) {
+           strategy.setOrgIdsList("'"+strategy.getOrgIdsList().replace(",", "','")+"'");
+       }
+       List<UserInfo>  userList = queryUserNotInStrategy(strategy);
+       for(UserInfo user : userList) {
+           Accounts account = new Accounts();
+           account.setAppId(strategy.getAppId());
+           account.setAppName(strategy.getAppName());
+           
+           account.setUserId(user.getId());
+           account.setUsername(user.getUsername());
+           account.setDisplayName(user.getDisplayName());
+           account.setRelatedUsername(generateAccount(user,strategy));
+           account.setRelatedPassword(PasswordReciprocal.getInstance().encode(userInfoService.randomPassword()));
+           
+           account.setInstId(strategy.getInstId());
+           account.setCreateType("automatic");
+           account.setStatus(ConstsStatus.ACTIVE);
+           account.setStrategyId(strategy.getId());
+           
+           insert(account);
+       }
+       deleteByStrategy(strategy);
+   }
+   public void refreshAllByStrategy() {
+	   AccountsStrategy queryStrategy = new AccountsStrategy();
+	   queryStrategy.setCreateType("automatic");
+       for( AccountsStrategy strategy : accountsStrategyService.query(queryStrategy)) {
+           refreshByStrategy(strategy);
+       }
+   }
+   
+   
+   public List<UserInfo> queryUserNotInStrategy(AccountsStrategy strategy){
+       return getMapper().queryUserNotInStrategy(strategy);
+   }
+   
+   public long deleteByStrategy(AccountsStrategy strategy) {
+       return getMapper().deleteByStrategy(strategy);
+   }
+	
+	
+   public List<Accounts> queryByAppIdAndDate(Accounts account) {
+       return getMapper().queryByAppIdAndDate(account);
+   }
+   
+   public List<Accounts> queryByAppIdAndAccount(String appId,String relatedUsername){
+	   return getMapper().queryByAppIdAndAccount(appId,relatedUsername);
+   }
+   
+   
+   public String generateAccount(UserInfo  userInfo,AccountsStrategy accountsStrategy) {
+   	String shortAccount = generateAccount(userInfo,accountsStrategy,true);
+   	String account = generateAccount(userInfo,accountsStrategy,false);
+   	String accountResult = shortAccount;
+   	List<Accounts> accountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),shortAccount +accountsStrategy.getSuffixes());
+   	if(!accountsList.isEmpty()) {
+   		if(accountsStrategy.getMapping().equalsIgnoreCase("email")) {
+   			accountResult = account;
+   			accountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),account + accountsStrategy.getSuffixes());
+   		}
+   		if(!accountsList.isEmpty()) {
+	    		for(int i =1 ;i < 100 ;i++) {
+	    			accountResult = account + i;
+	    			accountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),accountResult + accountsStrategy.getSuffixes());
+	    			if(accountsList.isEmpty()) {
+	    				break;
+	    			}
+	    		}
+   		}
+   	}
+   	if(StringUtils.isNotBlank(accountsStrategy.getSuffixes())){
+   		accountResult = accountResult + accountsStrategy.getSuffixes();
+   	}
+       return accountResult;
+   }
+   
+   
+	private String generateAccount(UserInfo  userInfo,AccountsStrategy strategy,boolean isShort) {
+		String account = "";
+    	if(strategy.getMapping().equalsIgnoreCase("username")) {
+    		account = userInfo.getUsername();
+    	}else if(strategy.getMapping().equalsIgnoreCase("mobile")) {
+    		account = userInfo.getMobile();
+    	}else if(strategy.getMapping().equalsIgnoreCase("email")) {
+    		try {
+	    		if(isShort) {
+	    			account = getPinYinShortName(userInfo.getDisplayName());
+	    		}else {
+	    			account = getPinYinName(userInfo.getDisplayName());
+	    		}
+    		}catch(Exception e) {
+    			e.printStackTrace();
+    		}
+    	}else if(strategy.getMapping().equalsIgnoreCase("employeeNumber")) {
+    		account = userInfo.getEmployeeNumber();
+    	}else if(strategy.getMapping().equalsIgnoreCase("windowsAccount")) {
+    		account = userInfo.getWindowsAccount();
+    	}else if(strategy.getMapping().equalsIgnoreCase("idCardNo")) {
+    		account = userInfo.getIdCardNo();
+    	}else {
+    		account = userInfo.getUsername();
+    	}
+    	
+        return account;
+	}
+	
+	public static String getPinYinName(String name) throws BadHanyuPinyinOutputFormatCombination {
+        HanyuPinyinOutputFormat pinyinFormat = new        HanyuPinyinOutputFormat();
+        pinyinFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
+        pinyinFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
+        pinyinFormat.setVCharType(HanyuPinyinVCharType.WITH_V);
+        return PinyinHelper.toHanYuPinyinString(name, pinyinFormat, "",false);
+    }
+	
+	public static String getPinYinShortName(String name) throws BadHanyuPinyinOutputFormatCombination {
+		char[] strs = name.toCharArray();
+		String pinyinName = "";
+		for(int i=0;i<strs.length;i++) {
+			if(i == 0) {
+				pinyinName += getPinYinName(strs[i]+"");
+			}else {
+				pinyinName += getPinYinName(strs[i]+"").charAt(0);
+			}
+		}
+		return pinyinName;
+    }
+	
+}

+ 99 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AccountsStrategyServiceImpl.java

@@ -0,0 +1,99 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.util.List;
+
+import org.dromara.maxkey.entity.AccountsStrategy;
+import org.dromara.maxkey.entity.permissions.Roles;
+import org.dromara.maxkey.persistence.mapper.AccountsStrategyMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class AccountsStrategyServiceImpl  extends JpaServiceImpl<AccountsStrategyMapper,AccountsStrategy> {
+    static final  Logger _logger = LoggerFactory.getLogger(AccountsStrategyServiceImpl.class);
+
+	
+	
+	public List<Roles> queryDynamicGroups(Roles groups){
+	    return this.getMapper().queryDynamicGroups(groups);
+	}
+	
+	public boolean deleteById(String groupId) {
+	    this.delete(groupId);
+	    //groupMemberService.deleteByGroupId(groupId);
+	    return true;
+	}
+	/*
+	public void refreshDynamicGroups(Groups dynamicGroup){
+	    if(dynamicGroup.getDynamic().equals("1")) {
+	        boolean isDynamicTimeSupport = false;
+	        boolean isBetweenEffectiveTime = false;
+	        if(dynamicGroup.getResumeTime()!=null&&dynamicGroup.getResumeTime().equals("")
+	                &&dynamicGroup.getSuspendTime()!=null&&dynamicGroup.getSuspendTime().equals("")) {
+	            LocalTime currentTime = LocalDateTime.now().toLocalTime();
+	            LocalTime resumeTime = LocalTime.parse(dynamicGroup.getResumeTime());
+	            LocalTime suspendTime = LocalTime.parse(dynamicGroup.getSuspendTime());
+	            
+	            _logger.info("currentTime: " + currentTime 
+                        + " , resumeTime : " + resumeTime 
+                        + " , suspendTime: " + suspendTime);
+	            isDynamicTimeSupport = true;
+	            
+	            if(resumeTime.isBefore(currentTime) && currentTime.isBefore(suspendTime)) {
+	                isBetweenEffectiveTime = true;
+	            }
+	            
+	        }
+	        
+    	    if(dynamicGroup.getOrgIdsList()!=null && !dynamicGroup.getOrgIdsList().equals("")) {
+    	        dynamicGroup.setOrgIdsList("'"+dynamicGroup.getOrgIdsList().replace(",", "','")+"'");
+    	    }
+    	    String filters = dynamicGroup.getFilters();
+    	    if(StringUtils.filtersSQLInjection(filters.toLowerCase())) {  
+    	        _logger.info("filters include SQL Injection Attack Risk.");
+    	        return;
+    	    }
+    	    
+    	    filters = filters.replace("&", " AND ");
+    	    filters = filters.replace("|", " OR ");
+    	    
+    	    dynamicGroup.setFilters(filters);
+    	    
+    	    if(isDynamicTimeSupport) {
+    	        if(isBetweenEffectiveTime) {
+    	            groupMemberService.deleteDynamicGroupMember(dynamicGroup);
+                    groupMemberService.addDynamicGroupMember(dynamicGroup);
+    	        }else {
+    	            groupMemberService.deleteDynamicGroupMember(dynamicGroup);
+    	        }
+    	    }else{
+                groupMemberService.deleteDynamicGroupMember(dynamicGroup);
+                groupMemberService.addDynamicGroupMember(dynamicGroup);
+            }
+	    }
+    }*/
+
+  
+	
+
+	
+}

+ 28 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsAdaptersServiceImpl.java

@@ -0,0 +1,28 @@
+/*
+ * Copyright [2021] [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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.apps.AppsAdapters;
+import org.dromara.maxkey.persistence.mapper.AppsAdaptersMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class AppsAdaptersServiceImpl  extends JpaServiceImpl<AppsAdaptersMapper,AppsAdapters>{
+
+}

+ 54 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsCasDetailsServiceImpl.java

@@ -0,0 +1,54 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.util.concurrent.TimeUnit;
+
+import org.dromara.maxkey.entity.apps.AppsCasDetails;
+import org.dromara.maxkey.persistence.mapper.AppsCasDetailsMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+
+@Repository
+public class AppsCasDetailsServiceImpl  extends JpaServiceImpl<AppsCasDetailsMapper,AppsCasDetails>{
+
+	protected static final   Cache<String, AppsCasDetails> detailsCache = 
+            Caffeine.newBuilder()
+                .expireAfterWrite(30, TimeUnit.MINUTES)
+                .maximumSize(200000)
+                .build();
+	
+	public  AppsCasDetails  getAppDetails(String id , boolean cached) {
+		AppsCasDetails details = null;
+		if(cached) {
+			details = detailsCache.getIfPresent(id);
+			if(details == null) {
+				details = getMapper().getAppDetails(id);
+				if(details != null) {
+					detailsCache.put(id, details);
+				}
+			}
+		}else {
+			details = getMapper().getAppDetails(id);
+		}
+		return details;
+	}
+}

+ 52 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsFormBasedDetailsServiceImpl.java

@@ -0,0 +1,52 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.util.concurrent.TimeUnit;
+
+import org.dromara.maxkey.entity.apps.AppsFormBasedDetails;
+import org.dromara.maxkey.persistence.mapper.AppsFormBasedDetailsMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+
+@Repository
+public class AppsFormBasedDetailsServiceImpl  extends JpaServiceImpl<AppsFormBasedDetailsMapper,AppsFormBasedDetails>{
+
+	protected static final   Cache<String, AppsFormBasedDetails> detailsCache = 
+            Caffeine.newBuilder()
+                .expireAfterWrite(30, TimeUnit.MINUTES)
+                .maximumSize(200000)
+                .build();
+
+	public  AppsFormBasedDetails  getAppDetails(String id,boolean cached) {
+		AppsFormBasedDetails details = null;
+		if(cached) {
+			details = detailsCache.getIfPresent(id);
+			if(details == null) {
+				details = getMapper().getAppDetails(id);
+				detailsCache.put(id, details);
+			}
+		}else {
+			details = getMapper().getAppDetails(id);
+		}
+		return details;
+	}
+}

+ 53 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsJwtDetailsServiceImpl.java

@@ -0,0 +1,53 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.util.concurrent.TimeUnit;
+
+import org.dromara.maxkey.entity.apps.AppsJwtDetails;
+import org.dromara.maxkey.persistence.mapper.AppsJwtDetailsMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+
+@Repository
+public class AppsJwtDetailsServiceImpl  extends JpaServiceImpl<AppsJwtDetailsMapper,AppsJwtDetails>{
+
+	protected static final   Cache<String, AppsJwtDetails> detailsCache = 
+            Caffeine.newBuilder()
+                .expireAfterWrite(30, TimeUnit.MINUTES)
+                .maximumSize(200000)
+                .build();
+
+	
+	public  AppsJwtDetails  getAppDetails(String id , boolean cached) {
+		AppsJwtDetails details = null;
+		if(cached) {
+			details = detailsCache.getIfPresent(id);
+			if(details == null) {
+				details = getMapper().getAppDetails(id);
+				detailsCache.put(id, details);
+			}
+		}else {
+			details = getMapper().getAppDetails(id);
+		}
+		return details;
+	}
+}

+ 52 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsSaml20DetailsServiceImpl.java

@@ -0,0 +1,52 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.util.concurrent.TimeUnit;
+
+import org.dromara.maxkey.entity.apps.AppsSAML20Details;
+import org.dromara.maxkey.persistence.mapper.AppsSaml20DetailsMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+
+@Repository
+public class AppsSaml20DetailsServiceImpl  extends JpaServiceImpl<AppsSaml20DetailsMapper,AppsSAML20Details>{
+
+	protected static final   Cache<String, AppsSAML20Details> detailsCache = 
+            Caffeine.newBuilder()
+                .expireAfterWrite(30, TimeUnit.MINUTES)
+                .maximumSize(200000)
+                .build();
+	
+	public  AppsSAML20Details  getAppDetails(String id , boolean cached){
+		AppsSAML20Details details = null;
+		if(cached) {
+			details = detailsCache.getIfPresent(id);
+			if(details == null) {
+				details = getMapper().getAppDetails(id);
+				detailsCache.put(id, details);
+			}
+		}else {
+			details = getMapper().getAppDetails(id);
+		}
+		return details;
+	}
+}

+ 79 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsServiceImpl.java

@@ -0,0 +1,79 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.dromara.maxkey.entity.apps.Apps;
+import org.dromara.maxkey.entity.apps.UserApps;
+import org.dromara.maxkey.persistence.mapper.AppsMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+
+@Repository
+public class AppsServiceImpl extends JpaServiceImpl<AppsMapper,Apps>{
+	//maxkey-mgt
+	public static final  	String MGT_APP_ID 		= "622076759805923328";
+	
+	public static final  	String DETAIL_SUFFIX	=	"_detail";
+	
+	protected static final   Cache<String, Apps> detailsCacheStore = 
+										Caffeine.newBuilder()
+							                .expireAfterWrite(30, TimeUnit.MINUTES)
+							                .build();
+	
+	public boolean insertApp(Apps app) {
+		return ((AppsMapper)super.getMapper()).insertApp(app)>0;
+	};
+	public boolean updateApp(Apps app) {
+		return ((AppsMapper)super.getMapper()).updateApp(app)>0;
+	};
+	
+	public boolean updateExtendAttr(Apps app) {
+		return ((AppsMapper)super.getMapper()).updateExtendAttr(app)>0;
+	}
+	
+    public List<UserApps> queryMyApps(UserApps userApplications){
+        return getMapper().queryMyApps(userApplications);
+    }
+
+    //cache for running
+    public void put(String appId, Apps appDetails) {
+    	detailsCacheStore.put(appId + DETAIL_SUFFIX, appDetails);
+	}
+	
+    public Apps get(String appId, boolean cached) {
+    	appId = appId.equalsIgnoreCase("maxkey_mgt") ? MGT_APP_ID : appId;
+    	Apps appDetails = null;
+    	if(cached) {
+    		appDetails = detailsCacheStore.getIfPresent(appId + DETAIL_SUFFIX); 
+    		if(appDetails == null) {
+    			appDetails = this.get(appId);
+    			detailsCacheStore.put(appId, appDetails);
+    		}
+    	}else {
+    		appDetails = this.get(appId);
+    	}
+        return appDetails;
+    }
+    
+}

+ 52 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/AppsTokenBasedDetailsServiceImpl.java

@@ -0,0 +1,52 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.util.concurrent.TimeUnit;
+
+import org.dromara.maxkey.entity.apps.AppsTokenBasedDetails;
+import org.dromara.maxkey.persistence.mapper.AppsTokenBasedDetailsMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+
+@Repository
+public class AppsTokenBasedDetailsServiceImpl  extends JpaServiceImpl<AppsTokenBasedDetailsMapper,AppsTokenBasedDetails>{
+
+	protected static final   Cache<String, AppsTokenBasedDetails> detailsCache = 
+            Caffeine.newBuilder()
+                .expireAfterWrite(30, TimeUnit.MINUTES)
+                .maximumSize(200000)
+                .build();
+
+	public  AppsTokenBasedDetails  getAppDetails(String id , boolean cached) {
+		AppsTokenBasedDetails details = null;
+		if(cached) {
+			details = detailsCache.getIfPresent(id);
+			if(details == null) {
+				details = getMapper().getAppDetails(id);
+				detailsCache.put(id, details);
+			}
+		}else {
+			details = getMapper().getAppDetails(id);
+		}
+		return details;
+	}
+}

+ 30 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/CnfEmailSendersServiceImpl.java

@@ -0,0 +1,30 @@
+/*
+ * Copyright [2022] [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.dromara.maxkey.persistence.service.impl;
+
+
+import org.dromara.maxkey.entity.cnf.CnfEmailSenders;
+import org.dromara.maxkey.persistence.mapper.CnfEmailSendersMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+
+@Repository
+public class CnfEmailSendersServiceImpl  extends JpaServiceImpl<CnfEmailSendersMapper,CnfEmailSenders>{
+	 
+}

+ 29 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/CnfLdapContextServiceImpl.java

@@ -0,0 +1,29 @@
+/*
+ * Copyright [2022] [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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.cnf.CnfLdapContext;
+import org.dromara.maxkey.persistence.mapper.CnfLdapContextMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+
+@Repository
+public class CnfLdapContextServiceImpl  extends JpaServiceImpl<CnfLdapContextMapper,CnfLdapContext>{
+ 
+}

+ 28 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/CnfPasswordPolicyServiceImpl.java

@@ -0,0 +1,28 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.cnf.CnfPasswordPolicy;
+import org.dromara.maxkey.persistence.mapper.CnfPasswordPolicyMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class CnfPasswordPolicyServiceImpl  extends JpaServiceImpl<CnfPasswordPolicyMapper,CnfPasswordPolicy>{
+
+}

+ 29 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/CnfSmsProviderServiceImpl.java

@@ -0,0 +1,29 @@
+/*
+ * Copyright [2022] [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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.cnf.CnfSmsProvider;
+import org.dromara.maxkey.persistence.mapper.CnfSmsProviderMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+
+@Repository
+public class CnfSmsProviderServiceImpl  extends JpaServiceImpl<CnfSmsProviderMapper,CnfSmsProvider>{
+ 
+}

+ 28 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/ConnectorsServiceImpl.java

@@ -0,0 +1,28 @@
+/*
+ * Copyright [2022] [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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.Connectors;
+import org.dromara.maxkey.persistence.mapper.ConnectorsMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class ConnectorsServiceImpl  extends JpaServiceImpl<ConnectorsMapper,Connectors>{
+  
+}

+ 28 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/FileUploadServiceImpl.java

@@ -0,0 +1,28 @@
+/*
+ * Copyright [2021] [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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.FileUpload;
+import org.dromara.maxkey.persistence.mapper.FileUploadMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class FileUploadServiceImpl  extends JpaServiceImpl<FileUploadMapper,FileUpload>{
+
+}

+ 77 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/GroupMemberServiceImpl.java

@@ -0,0 +1,77 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.util.List;
+
+import org.dromara.maxkey.entity.idm.GroupMember;
+import org.dromara.maxkey.entity.idm.Groups;
+import org.dromara.maxkey.entity.idm.UserInfo;
+import org.dromara.maxkey.persistence.mapper.GroupMemberMapper;
+import org.dromara.mybatis.jpa.entity.JpaPageResults;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class GroupMemberServiceImpl  extends JpaServiceImpl<GroupMemberMapper,GroupMember>{
+	static final  Logger _logger = LoggerFactory.getLogger(GroupMemberServiceImpl.class);
+
+	public int addDynamicMember(Groups dynamicGroup) {
+	    return getMapper().addDynamicMember(dynamicGroup);
+	}
+	
+	public int deleteDynamicMember(Groups dynamicGroup) {
+	    return getMapper().deleteDynamicMember(dynamicGroup);
+	}
+	
+	public int deleteByGroupId(String groupId) {
+        return getMapper().deleteByGroupId(groupId);
+    }
+	
+	public List<UserInfo> queryMemberByGroupId(String groupId){
+		return getMapper().queryMemberByGroupId(groupId);
+	}
+	
+	
+	public JpaPageResults<Groups> noMember(GroupMember entity) {
+		entity.setPageSelectId(entity.generateId());
+		entity.setStartRow(calculateStartRow(entity.getPageNumber() ,entity.getPageSize()));
+		
+		entity.setPageable(true);
+		List<Groups> resultslist = null;
+		try {
+			resultslist = getMapper().noMember(entity);
+		} catch (Exception e) {
+			_logger.error("queryPageResults Exception " , e);
+		}
+		entity.setPageable(false);
+		Integer totalPage = resultslist.size();
+		
+		Integer totalCount = 0;
+		if(entity.getPageNumber() == 1 && totalPage < entity.getPageSize()) {
+			totalCount = totalPage;
+		}else {
+			totalCount = parseCount(getMapper().fetchCount(entity));
+		}
+		
+		return new JpaPageResults<Groups>(entity.getPageNumber(),entity.getPageSize(),totalPage,totalCount,resultslist);
+	}
+	
+}

+ 111 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/GroupsServiceImpl.java

@@ -0,0 +1,111 @@
+/*
+ * Copyright [2022] [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.dromara.maxkey.persistence.service.impl;
+
+import java.sql.Types;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.dromara.maxkey.constants.ConstsStatus;
+import org.dromara.maxkey.entity.Institutions;
+import org.dromara.maxkey.entity.idm.Groups;
+import org.dromara.maxkey.entity.permissions.Roles;
+import org.dromara.maxkey.persistence.mapper.GroupsMapper;
+import org.dromara.maxkey.util.StrUtils;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class GroupsServiceImpl  extends JpaServiceImpl<GroupsMapper,Groups>{
+    static final  Logger _logger = LoggerFactory.getLogger(GroupsServiceImpl.class);
+
+    @Autowired
+    GroupMemberServiceImpl groupMemberService;
+    
+    @Autowired
+    InstitutionsServiceImpl institutionsService;
+    
+	public List<Groups> queryDynamicGroups(Groups groups){
+	    return this.getMapper().queryDynamic(groups);
+	}
+	
+	public boolean deleteById(String groupId) {
+	    this.delete(groupId);
+	    groupMemberService.deleteByGroupId(groupId);
+	    return true;
+	}
+	
+	public List<Groups> queryByUserId(String userId){
+		return this.getMapper().queryByUserId(userId);
+	}
+	
+	public void refreshDynamicGroups(Groups dynamicGroup){
+	    if(dynamicGroup.getCategory().equals(Roles.Category.DYNAMIC)) {
+	        
+	        if(StringUtils.isNotBlank(dynamicGroup.getOrgIdsList())) {
+    	    	String []orgIds = dynamicGroup.getOrgIdsList().split(",");
+    	    	StringBuffer orgIdFilters = new StringBuffer();
+    	    	for(String orgId : orgIds) {
+    	    		if(StringUtils.isNotBlank(orgId)) {
+	    	    		if(orgIdFilters.length() > 0) {
+	    	    			orgIdFilters.append(",");
+	    	    		}
+	    	    		orgIdFilters.append("'").append(orgId).append("'");
+    	    		}
+    	    	}
+    	    	if(orgIdFilters.length() > 0) {
+    	    		dynamicGroup.setOrgIdsList(orgIdFilters.toString());
+    	    	}
+    	    }
+	        
+    	    String filters = dynamicGroup.getFilters();
+    	    if(StringUtils.isNotBlank(filters)) {
+	    		if(StrUtils.filtersSQLInjection(filters.toLowerCase())) {  
+	    			_logger.info("filters include SQL Injection Attack Risk.");
+	    			return;
+	    		}
+	    		//replace & with AND, | with OR
+	    		filters = filters.replace("&", " AND ").replace("|", " OR ");
+	    	    
+	    	    dynamicGroup.setFilters(filters);
+    	    }
+	    
+	    	groupMemberService.deleteDynamicMember(dynamicGroup);
+	    	groupMemberService.addDynamicMember(dynamicGroup);
+            
+	    }
+    }
+	
+	public void refreshAllDynamicGroups(){
+		List<Institutions> instList = 
+				institutionsService.find("where status = ? ", new Object[]{ConstsStatus.ACTIVE}, new int[]{Types.INTEGER});
+		for(Institutions inst : instList) {
+			Groups group = new Groups();
+			group.setInstId(inst.getId());
+		    List<Groups>  groupsList = queryDynamicGroups(group);
+	        for(Groups g : groupsList) {
+	            _logger.debug("role {}" , g);
+	            refreshDynamicGroups(g);
+	        }
+		}
+	}
+
+}

+ 28 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/HistoryConnectorServiceImpl.java

@@ -0,0 +1,28 @@
+/*
+ * Copyright [2021] [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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.history.HistoryConnector;
+import org.dromara.maxkey.persistence.mapper.HistoryConnectorMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class HistoryConnectorServiceImpl  extends JpaServiceImpl<HistoryConnectorMapper,HistoryConnector>{
+
+}

+ 54 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/HistoryLoginAppsServiceImpl.java

@@ -0,0 +1,54 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.history.HistoryLoginApps;
+import org.dromara.maxkey.persistence.mapper.HistoryLoginAppsMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class HistoryLoginAppsServiceImpl  extends JpaServiceImpl<HistoryLoginAppsMapper,HistoryLoginApps>{
+
+	@Override
+	public boolean  insert(HistoryLoginApps loginAppsHistory){
+		//new Thread insert login app history
+		new Thread(new HistoryLoginAppsRunnable(getMapper(),loginAppsHistory)).start();
+		return true;
+	}
+	
+	public class HistoryLoginAppsRunnable implements Runnable{
+
+		HistoryLoginAppsMapper historyLoginAppsMapper;
+		
+		HistoryLoginApps loginAppsHistory;
+		
+		public HistoryLoginAppsRunnable(HistoryLoginAppsMapper historyLoginAppsMapper,
+				HistoryLoginApps loginAppsHistory) {
+			super();
+			this.historyLoginAppsMapper = historyLoginAppsMapper;
+			this.loginAppsHistory = loginAppsHistory;
+		}
+
+		@Override
+		public void run() {
+			historyLoginAppsMapper.insert(loginAppsHistory);
+		}
+		
+	}
+}

+ 32 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/HistoryLoginServiceImpl.java

@@ -0,0 +1,32 @@
+/*
+ * Copyright [2022] [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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.history.HistoryLogin;
+import org.dromara.maxkey.persistence.mapper.HistoryLoginMapper;
+import org.dromara.mybatis.jpa.entity.JpaPageResults;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class HistoryLoginServiceImpl  extends JpaServiceImpl<HistoryLoginMapper,HistoryLogin>{
+
+	public JpaPageResults<HistoryLogin> queryOnlineSession(HistoryLogin historyLogin) {
+	    return this.fetchPageResults("queryOnlineSession",historyLogin);
+	}
+}

+ 28 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/HistorySynchronizerServiceImpl.java

@@ -0,0 +1,28 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.history.HistorySynchronizer;
+import org.dromara.maxkey.persistence.mapper.HistorySynchronizerMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class HistorySynchronizerServiceImpl  extends JpaServiceImpl<HistorySynchronizerMapper,HistorySynchronizer>{
+
+}

+ 199 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/HistorySystemLogsServiceImpl.java

@@ -0,0 +1,199 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.Accounts;
+import org.dromara.maxkey.entity.ChangePassword;
+
+import java.util.Date;
+
+import org.dromara.maxkey.entity.Access;
+import org.dromara.maxkey.entity.SocialsProvider;
+import org.dromara.maxkey.entity.Synchronizers;
+import org.dromara.maxkey.entity.history.HistorySystemLogs;
+import org.dromara.maxkey.entity.idm.Organizations;
+import org.dromara.maxkey.entity.idm.UserInfo;
+import org.dromara.maxkey.entity.permissions.Permission;
+import org.dromara.maxkey.entity.permissions.Resources;
+import org.dromara.maxkey.entity.permissions.RoleMember;
+import org.dromara.maxkey.entity.permissions.Roles;
+import org.dromara.maxkey.persistence.mapper.HistorySystemLogsMapper;
+import org.dromara.maxkey.util.JsonUtils;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class HistorySystemLogsServiceImpl  extends JpaServiceImpl<HistorySystemLogsMapper,HistorySystemLogs>{
+	static final Logger _logger = LoggerFactory.getLogger(HistorySystemLogsServiceImpl.class);
+
+	public void insert(String topic,Object entity,String action,String result,UserInfo operator) {
+		String message = "";
+		if(entity != null) {
+			if(entity instanceof UserInfo userInfo) {
+				message = buildMsg(userInfo);
+			}else if(entity instanceof Organizations organization) {
+				message = buildMsg(organization);
+			}else if(entity instanceof ChangePassword changePassword) {
+				message = buildMsg(changePassword);
+			}else if(entity instanceof Accounts account) {
+				message = buildMsg(account);
+			}else if(entity instanceof Roles role) {
+				message = buildMsg(role);
+			}else if(entity instanceof RoleMember roleMember) {
+				message = buildMsg(roleMember);
+			}else if(entity instanceof Access access) {
+				message = buildMsg(access);
+			}else if(entity instanceof Resources resource) {
+				message = buildMsg(resource);
+			}else if(entity instanceof Synchronizers synchronizer) {
+				message = buildMsg(synchronizer);
+			}else if(entity instanceof SocialsProvider socialsProvider) {
+				message = buildMsg(socialsProvider);
+			}else if(entity instanceof Permission permission) {
+				message = buildMsg(permission);
+			}else if(entity instanceof String) {
+				message = entity.toString();
+			}
+			
+		}
+		
+		insert(topic,message,action,result,operator, entity);
+	}
+	
+	public void insert(String topic,String message,String action,String result,UserInfo operator,Object entity) {
+		HistorySystemLogs systemLog = new HistorySystemLogs();
+		systemLog.setId(systemLog.generateId());
+		systemLog.setTopic(topic);
+		systemLog.setMessage(message);
+		systemLog.setMessageAction(action);
+		systemLog.setMessageResult(result);
+		systemLog.setUserId(operator.getId());
+		systemLog.setUsername(operator.getUsername());
+		systemLog.setDisplayName(operator.getDisplayName());
+		systemLog.setInstId(operator.getInstId());
+		systemLog.setJsonCotent(JsonUtils.gsonToString(entity));
+		systemLog.setExecuteTime(new Date());
+		_logger.trace("System Log {}" ,systemLog);
+		getMapper().insert(systemLog);
+	}
+	
+	public String buildMsg(UserInfo userInfo) {
+		return new StringBuilder()
+				.append(userInfo.getDisplayName())
+				.append("[")
+				.append(userInfo.getUsername())
+				.append("]")
+				.toString();
+	}
+	
+	public String buildMsg(Organizations org) {
+		return new StringBuilder()
+				.append(org.getOrgName())
+				.append("[")
+				.append(org.getOrgCode())
+				.append("]")
+				.toString();
+	}
+	
+	public String buildMsg(Accounts account) {
+		return new StringBuilder()
+				.append(account.getRelatedUsername())
+				.append("[")
+				.append(account.getDisplayName()).append(",")
+				.append(account.getUsername()).append(",")
+				.append(account.getAppName())
+				.append("]")
+				.toString();
+	}
+	
+	public String buildMsg(ChangePassword changePassword) {
+		return new StringBuilder()
+				.append(changePassword.getDisplayName())
+				.append("[")
+				.append(changePassword.getUsername())
+				.append("]")
+				.toString();
+	}
+	
+	public String buildMsg(Roles g) {
+		return new StringBuilder()
+				.append(g.getRoleName())
+				.toString();
+	}
+	
+	public String buildMsg(RoleMember rm) {
+		return new StringBuilder()
+				.append(rm.getRoleName())
+				.append("[")
+				.append(rm.getUsername()).append(",")
+				.append(rm.getDisplayName())
+				.append("]")
+				.toString();
+	}
+	
+	public String buildMsg(Access permission) {
+		return new StringBuilder()
+				.append(permission.getGroupName())
+				.append("[")
+				.append(permission.getAppName())
+				.append("]")
+				.toString();
+	}
+	
+	public String buildMsg(Permission privilege) {
+		return new StringBuilder()
+				.append(privilege.getGroupId())
+				.append("[")
+				.append(privilege.getResourceId())
+				.append("]")
+				.toString();
+	}
+	
+	
+	public String buildMsg(Resources r) {
+		return new StringBuilder()
+				.append(r.getResourceName())
+				.append("[")
+				.append(r.getResourceType())
+				.append("]")
+				.toString();
+	}
+	
+	
+	public String buildMsg(Synchronizers s) {
+		return new StringBuilder()
+				.append(s.getName())
+				.append("[")
+				.append(s.getSourceType()).append(",")
+				.append(s.getScheduler()).append(",")
+				.append("]")
+				.toString();
+	}
+	
+	public String buildMsg(SocialsProvider s) {
+		return new StringBuilder()
+				.append(s.getProviderName())
+				.append("[")
+				.append(s.getProvider())
+				.append("]")
+				.toString();
+	}
+	
+}

+ 33 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/InstitutionsServiceImpl.java

@@ -0,0 +1,33 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.Institutions;
+import org.dromara.maxkey.persistence.mapper.InstitutionsMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+
+@Repository
+public class InstitutionsServiceImpl  extends JpaServiceImpl<InstitutionsMapper,Institutions>{
+
+	 public Institutions findByDomain(String domain) {
+		 return getMapper().findByDomain(domain);
+	 }
+	 
+}

+ 37 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/OrganizationsCastServiceImpl.java

@@ -0,0 +1,37 @@
+/*
+ * Copyright [2021] [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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.OrganizationsCast;
+import org.dromara.maxkey.persistence.mapper.OrganizationsCastMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Repository;
+
+
+@Repository
+public class OrganizationsCastServiceImpl  extends JpaServiceImpl<OrganizationsCastMapper,OrganizationsCast>{
+	static final  Logger _logger = LoggerFactory.getLogger(OrganizationsCastServiceImpl.class);
+
+
+	public boolean updateCast(OrganizationsCast organizationsCast) {
+		return getMapper().updateCast(organizationsCast) > 0;
+	}
+
+}

+ 176 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/OrganizationsServiceImpl.java

@@ -0,0 +1,176 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
+import org.dromara.maxkey.entity.idm.Organizations;
+import org.dromara.maxkey.persistence.mapper.OrganizationsMapper;
+import org.dromara.maxkey.provision.ProvisionAct;
+import org.dromara.maxkey.provision.ProvisionService;
+import org.dromara.maxkey.provision.ProvisionTopic;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+
+@Repository
+public class OrganizationsServiceImpl  extends JpaServiceImpl<OrganizationsMapper,Organizations>{
+	static final Logger _logger = LoggerFactory.getLogger(OrganizationsServiceImpl.class);
+	
+    @Autowired
+    ProvisionService provisionService;
+    
+	 @Override
+	 public boolean insert(Organizations organization) {
+	     if(super.insert(organization)){
+	    	 provisionService.send(
+                     ProvisionTopic.ORG_TOPIC, organization, ProvisionAct.CREATE);
+             return true;
+         }
+         return false;
+	 }
+	 
+	 @Override
+	 public boolean update(Organizations organization) {
+	     if(super.update(organization)){
+	    	 provisionService.send(
+                     ProvisionTopic.ORG_TOPIC, organization, ProvisionAct.UPDATE);
+             return true;
+         }
+         return false;
+     }
+ 
+	 public void saveOrUpdate(Organizations organization) {
+		 Organizations loadOrg =findOne(" id = ? and instid = ?", 
+					new Object[] { organization.getId(), organization.getInstId() },
+              new int[] { Types.VARCHAR, Types.VARCHAR });
+		 if( loadOrg == null) {
+				insert(organization);
+			}else {
+				organization.setId(organization.getId());
+				update(organization);
+			}
+	 }
+	 public List<Organizations> queryOrgs(Organizations organization){
+		 return getMapper().queryOrgs(organization);
+	 }
+	 
+	 public boolean delete(Organizations organization) {
+	     if(super.delete(organization.getId())){
+	    	 provisionService.send(
+                     ProvisionTopic.ORG_TOPIC, organization, ProvisionAct.DELETE);
+             return true;
+         }
+         return false;
+	 }
+
+
+	public void reorgNamePath(String instId) {
+		_logger.debug("instId {}", instId);
+		if (StringUtils.isBlank(instId)) {
+			instId = "1";
+		}
+
+		HashMap<String, Organizations> reorgOrgMap = new HashMap<>();
+		List<Organizations> orgList = find(" where instid ='" + instId + "'");
+		List<Organizations> originOrgList = new ArrayList<>();
+		Organizations rootOrg = null;
+		for (Organizations org : orgList) {
+			reorgOrgMap.put(org.getId(), org);
+			if (isRootOrg(org)) {
+				rootOrg = org;
+			}
+			Organizations cloneOrg = new Organizations();
+			BeanUtils.copyProperties(org, cloneOrg);
+			originOrgList.add(cloneOrg);
+		}
+		try {
+			reorg(reorgOrgMap, orgList, rootOrg);
+			_logger.debug("reorged .");
+			long reorgCount = 0;
+			for (Organizations originOrg : originOrgList) {
+				Organizations reorgOrg = reorgOrgMap.get(originOrg.getId());
+				_logger.trace("reorged Organization {}", reorgOrg);
+				if (originOrg.getNamePath() == null || !originOrg.getNamePath().equals(reorgOrg.getNamePath())) {
+					_logger.debug("update reorgCount {} , Organization {}", ++reorgCount, reorgOrg);
+					getMapper().updateNamePath(reorgOrg);
+				}
+			}
+			_logger.debug("reorg finished .");
+		} catch (Exception e) {
+			_logger.error("reorgNamePath Exception ", e);
+		}
+	}
+
+	boolean isRootOrg(Organizations rootOrg) {
+		if (rootOrg.getParentId() == null || rootOrg.getParentId().equalsIgnoreCase("-1")
+				|| rootOrg.getParentId().equalsIgnoreCase(rootOrg.getId())
+				|| rootOrg.getParentId().equalsIgnoreCase(rootOrg.getInstId())) {
+			return true;
+		}
+		return false;
+	}
+
+	void reorg(HashMap<String, Organizations> orgMap, List<Organizations> orgList, Organizations rootOrg) {
+		if (isRootOrg(rootOrg)) {
+			rootOrg.setCodePath("/" + rootOrg.getId() + "/");
+			rootOrg.setNamePath("/" + rootOrg.getOrgName() + "/");
+		} else {
+			Organizations parent = orgMap.get(rootOrg.getParentId());
+			rootOrg.setCodePath(parent.getCodePath() + rootOrg.getId() + "/");
+			rootOrg.setNamePath(parent.getNamePath() + rootOrg.getOrgName() + "/");
+		}
+		rootOrg.setReorgNamePath(true);
+
+		for (Organizations org : orgList) {
+			if (org.isReorgNamePath())
+				continue;
+			if (org.getParentId().equalsIgnoreCase(rootOrg.getId())) {
+				reorg(orgMap, orgList, org);
+			}
+		}
+	}
+	 /**
+	     *       根据数据格式返回数据
+     *
+     * @param cell
+     * @return
+     */
+    public static String getValue(Cell cell) {
+        if (cell == null) {
+            return "";
+        } else if (cell.getCellType() == CellType.BOOLEAN) {
+            return String.valueOf(cell.getBooleanCellValue());
+        } else if (cell.getCellType() == CellType.NUMERIC) {
+            cell.setBlank();
+            return String.valueOf(cell.getStringCellValue().trim());
+        } else {
+            return String.valueOf(cell.getStringCellValue().trim());
+        }
+    }
+}

+ 47 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/PermissionRoleServiceImpl.java

@@ -0,0 +1,47 @@
+/*
+ * Copyright [2024] [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.dromara.maxkey.persistence.service.impl;
+
+import java.util.List;
+
+import org.dromara.maxkey.entity.permissions.PermissionRole;
+import org.dromara.maxkey.persistence.mapper.PermissionRoleMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class PermissionRoleServiceImpl  extends JpaServiceImpl<PermissionRoleMapper,PermissionRole>{
+	static final Logger _logger = LoggerFactory.getLogger(PermissionRoleServiceImpl.class);
+ 
+	
+	public boolean insertPermissionRoles(List<PermissionRole> permissionRolesList) {
+	    return getMapper().insertPermissionRoles(permissionRolesList)>0;
+	}
+    
+	public boolean deletePermissionRoles(List<PermissionRole> permissionRolesList) {
+	     return getMapper().deletePermissionRoles(permissionRolesList)>=0;
+	 }
+	
+    public List<PermissionRole> queryPermissionRoles(PermissionRole permissionRole){
+        return getMapper().queryPermissionRoles(permissionRole);
+    }    
+
+}

+ 45 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/PermissionServiceImpl.java

@@ -0,0 +1,45 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.util.List;
+
+import org.dromara.maxkey.entity.permissions.Permission;
+import org.dromara.maxkey.persistence.mapper.PermissionMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class PermissionServiceImpl  extends JpaServiceImpl<PermissionMapper,Permission>{
+	static final  Logger _logger = LoggerFactory.getLogger(PermissionServiceImpl.class);
+
+	public boolean insertGroupPrivileges(List<Permission> rolePermissionsList) {
+	    return getMapper().insertGroupPrivileges(rolePermissionsList)>0;
+	};
+    
+	public boolean deleteGroupPrivileges(List<Permission> rolePermissionsList) {
+	     return getMapper().deleteGroupPrivileges(rolePermissionsList)>=0;
+	 }
+	
+    public List<Permission> queryGroupPrivileges(Permission rolePermissions){
+        return getMapper().queryGroupPrivileges(rolePermissions);
+    }    
+
+}

+ 36 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/RegisterServiceImpl.java

@@ -0,0 +1,36 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.util.List;
+
+import org.dromara.maxkey.entity.Register;
+import org.dromara.maxkey.entity.idm.UserInfo;
+import org.dromara.maxkey.persistence.mapper.RegisterMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class RegisterServiceImpl  extends JpaServiceImpl<RegisterMapper,Register>{
+	
+	public UserInfo findByEmail(String email){
+		List<UserInfo> listUserInfo=getMapper().findByEmail(email);
+		return listUserInfo.size()>0?listUserInfo.get(0):null;
+	}
+	
+}

+ 64 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/ReportServiceImpl.java

@@ -0,0 +1,64 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.dromara.maxkey.persistence.mapper.ReportMapper;
+import org.dromara.mybatis.jpa.entity.JpaEntity;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class ReportServiceImpl  extends JpaServiceImpl<ReportMapper,JpaEntity>{
+
+	public Integer analysisDay(HashMap<String,Object> reportParameter) {
+		return getMapper().analysisDay(reportParameter);
+	};
+	
+	public Integer analysisNewUsers(HashMap<String,Object> reportParameter) {
+		return getMapper().analysisNewUsers(reportParameter);
+	};
+	
+	public Integer analysisOnlineUsers(HashMap<String,Object> reportParameter) {
+		return getMapper().analysisOnlineUsers(reportParameter);
+	};
+	
+	public Integer analysisActiveUsers(HashMap<String,Object> reportParameter) {
+		return getMapper().analysisActiveUsers(reportParameter);
+	};
+	
+	public List<Map<String,Object>> analysisDayHour(HashMap<String,Object> reportParameter){
+		return getMapper().analysisDayHour(reportParameter);
+	}
+	
+	public List<Map<String,Object>> analysisMonth(HashMap<String,Object> reportParameter){
+		return getMapper().analysisMonth(reportParameter);
+	}
+	
+	
+	public List<Map<String,Object>> analysisBrowser(HashMap<String,Object> reportParameter){
+		return getMapper().analysisBrowser(reportParameter);
+	}
+	
+	public List<Map<String,Object>> analysisApp(HashMap<String,Object> reportParameter){
+		return getMapper().analysisApp(reportParameter);
+	}
+	
+}

+ 33 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/ResourcesServiceImpl.java

@@ -0,0 +1,33 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.util.List;
+
+import org.dromara.maxkey.entity.permissions.Resources;
+import org.dromara.maxkey.persistence.mapper.ResourcesMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class ResourcesServiceImpl  extends JpaServiceImpl<ResourcesMapper,Resources>{
+	
+	public List<Resources> queryResourcesTree(Resources resource){
+	   return  getMapper().fetchPageResults(resource);
+	}
+}

+ 78 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/RoleMemberServiceImpl.java

@@ -0,0 +1,78 @@
+/*
+ * Copyright [2024] [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.dromara.maxkey.persistence.service.impl;
+
+import java.util.List;
+
+import org.dromara.maxkey.entity.idm.UserInfo;
+import org.dromara.maxkey.entity.permissions.RoleMember;
+import org.dromara.maxkey.entity.permissions.Roles;
+import org.dromara.maxkey.persistence.mapper.RoleMemberMapper;
+import org.dromara.mybatis.jpa.entity.JpaPageResults;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class RoleMemberServiceImpl  extends JpaServiceImpl<RoleMemberMapper,RoleMember>{
+	static final  Logger _logger = LoggerFactory.getLogger(RoleMemberServiceImpl.class);
+
+	public int addDynamicRoleMember(Roles dynamicGroup) {
+	    return getMapper().addDynamicRoleMember(dynamicGroup);
+	}
+	
+	public int deleteDynamicRoleMember(Roles dynamicGroup) {
+	    return getMapper().deleteDynamicRoleMember(dynamicGroup);
+	}
+	
+	public int deleteByRoleId(String groupId) {
+        return getMapper().deleteByRoleId(groupId);
+    }
+	
+	public List<UserInfo> queryMemberByRoleId(String groupId){
+		return getMapper().queryMemberByRoleId(groupId);
+	}
+	
+	
+	public JpaPageResults<Roles> rolesNoMember(RoleMember entity) {
+		entity.setPageSelectId(entity.generateId());
+		entity.setStartRow(calculateStartRow(entity.getPageNumber() ,entity.getPageSize()));
+		
+		entity.setPageable(true);
+		List<Roles> resultslist = null;
+		try {
+			resultslist = getMapper().rolesNoMember(entity);
+		} catch (Exception e) {
+			_logger.error("fetchPageResults Exception " , e);
+		}
+		entity.setPageable(false);
+		Integer totalPage = resultslist.size();
+		
+		Integer totalCount = 0;
+		if(entity.getPageNumber() == 1 && totalPage < entity.getPageSize()) {
+			totalCount = totalPage;
+		}else {
+			totalCount = parseCount(getMapper().fetchCount(entity));
+		}
+		
+		return new JpaPageResults<Roles>(entity.getPageNumber(),entity.getPageSize(),totalPage,totalCount,resultslist);
+	}
+	
+}

+ 115 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/RolesServiceImpl.java

@@ -0,0 +1,115 @@
+/*
+ * Copyright [2024] [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.dromara.maxkey.persistence.service.impl;
+
+import java.sql.Types;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.dromara.maxkey.constants.ConstsStatus;
+import org.dromara.maxkey.entity.Institutions;
+import org.dromara.maxkey.entity.permissions.Roles;
+import org.dromara.maxkey.persistence.mapper.RolesMapper;
+import org.dromara.maxkey.util.StrUtils;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class RolesServiceImpl  extends JpaServiceImpl<RolesMapper,Roles> {
+    static final  Logger _logger = LoggerFactory.getLogger(RolesServiceImpl.class);
+    
+    @Autowired
+    RoleMemberServiceImpl roleMemberService;
+    
+    @Autowired
+    InstitutionsServiceImpl institutionsService;
+
+	
+	public List<Roles> queryDynamicRoles(Roles groups){
+	    return this.getMapper().queryDynamicRoles(groups);
+	}
+	
+	public boolean deleteById(String groupId) {
+	    this.delete(groupId);
+	    roleMemberService.deleteByRoleId(groupId);
+	    return true;
+	}
+	
+	public List<Roles> queryRolesByUserId(String userId){
+		return this.getMapper().queryRolesByUserId(userId);
+	}
+	
+	public void refreshDynamicRoles(Roles dynamicRole){
+	    if(dynamicRole.getCategory().equals(Roles.Category.DYNAMIC)) {
+	        
+	        if(StringUtils.isNotBlank(dynamicRole.getOrgIdsList())) {
+    	    	String []orgIds = dynamicRole.getOrgIdsList().split(",");
+    	    	StringBuffer orgIdFilters = new StringBuffer();
+    	    	for(String orgId : orgIds) {
+    	    		if(StringUtils.isNotBlank(orgId)) {
+	    	    		if(orgIdFilters.length() > 0) {
+	    	    			orgIdFilters.append(",");
+	    	    		}
+	    	    		orgIdFilters.append("'").append(orgId).append("'");
+    	    		}
+    	    	}
+    	    	if(orgIdFilters.length() > 0) {
+    	    		dynamicRole.setOrgIdsList(orgIdFilters.toString());
+    	    	}
+    	    }
+	        
+    	    String filters = dynamicRole.getFilters();
+    	    _logger.debug("filters {}" , filters);
+    	    if(StringUtils.isNotBlank(filters)) {
+	    		if(StrUtils.filtersSQLInjection(filters.toLowerCase())) {  
+	    			_logger.info("filters include SQL Injection Attack Risk.");
+	    			return;
+	    		}
+	    		//replace & with AND, | with OR
+	    		filters = filters.replace("&", " AND ").replace("\\|", " OR ");
+	    	    
+	    		_logger.debug("set filters {}" , filters);
+	    	    dynamicRole.setFilters(filters);
+    	    }
+	    
+	    	roleMemberService.deleteDynamicRoleMember(dynamicRole);
+	    	roleMemberService.addDynamicRoleMember(dynamicRole);
+        
+	    }
+    }
+	
+	public void refreshAllDynamicRoles(){
+		List<Institutions> instList = 
+				institutionsService.find("where status = ? ", new Object[]{ConstsStatus.ACTIVE}, new int[]{Types.INTEGER});
+		for(Institutions inst : instList) {
+			Roles role = new Roles();
+			role.setInstId(inst.getId());
+		    List<Roles>  rolesList = queryDynamicRoles(role);
+	        for(Roles r : rolesList) {
+	            _logger.debug("role {}" , r);
+	            refreshDynamicRoles(r);
+	        }
+		}
+	}
+
+}

+ 36 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/SocialsAssociatesServiceImpl.java

@@ -0,0 +1,36 @@
+/*
+ * Copyright [2022] [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.dromara.maxkey.persistence.service.impl;
+
+import java.util.List;
+
+import org.dromara.maxkey.entity.SocialsAssociate;
+import org.dromara.maxkey.entity.idm.UserInfo;
+import org.dromara.maxkey.persistence.mapper.SocialsAssociateMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+
+@Repository
+public class SocialsAssociatesServiceImpl  extends JpaServiceImpl<SocialsAssociateMapper,SocialsAssociate>{
+
+	public List<SocialsAssociate>  queryByUser(UserInfo user) {
+		return getMapper().queryByUser(user);
+	}
+	 
+}

+ 31 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/SocialsProviderServiceImpl.java

@@ -0,0 +1,31 @@
+/*
+ * Copyright [2021] [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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.SocialsProvider;
+import org.dromara.maxkey.persistence.mapper.SocialsProviderMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class SocialsProviderServiceImpl  extends JpaServiceImpl<SocialsProviderMapper,SocialsProvider>{
+    static final  Logger _logger = LoggerFactory.getLogger(SocialsProviderServiceImpl.class);
+    
+}

+ 65 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/SynchroRelatedServiceImpl.java

@@ -0,0 +1,65 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+import java.sql.Types;
+import java.util.Date;
+import java.util.List;
+
+import org.dromara.maxkey.entity.SynchroRelated;
+import org.dromara.maxkey.entity.Synchronizers;
+import org.dromara.maxkey.entity.idm.Organizations;
+import org.dromara.maxkey.persistence.mapper.SynchroRelatedMapper;
+import org.dromara.maxkey.util.DateUtils;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class SynchroRelatedServiceImpl  extends JpaServiceImpl<SynchroRelatedMapper,SynchroRelated>{
+
+	public int updateSyncTime(SynchroRelated synchroRelated) {
+		return getMapper().updateSyncTime(synchroRelated);
+	}
+	
+	public List<SynchroRelated> findOrgs(Synchronizers synchronizer) {
+		return find(
+				"instid = ? and syncid = ? and objecttype = ? ",
+		 		new Object[] { synchronizer.getInstId() ,synchronizer.getId(),Organizations.CLASS_TYPE},
+                new int[] { Types.VARCHAR,Types.VARCHAR,Types.VARCHAR}
+				);
+	}
+	
+	public SynchroRelated findByOriginId(Synchronizers synchronizer,String originId,String classType) {
+		return findOne("instid = ? and syncId = ? and originid = ? and objecttype = ? ",
+		 		new Object[] { synchronizer.getInstId(),synchronizer.getId(),originId,classType },
+                new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,Types.VARCHAR});
+	}
+	
+	public void updateSynchroRelated(Synchronizers synchronizer,SynchroRelated synchroRelated,String classType) {
+		SynchroRelated loadSynchroRelated = 
+				findByOriginId(
+						synchronizer,synchroRelated.getOriginId(),classType );
+		if(loadSynchroRelated == null) {
+			insert(synchroRelated);
+		}else {
+			synchroRelated.setId(loadSynchroRelated.getId());
+			synchroRelated.setSyncTime(DateUtils.formatDateTime(new Date()));
+			updateSyncTime(synchroRelated);
+		}
+	}
+}

+ 31 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/SynchronizersServiceImpl.java

@@ -0,0 +1,31 @@
+/*
+ * Copyright [2021] [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.dromara.maxkey.persistence.service.impl;
+
+import org.dromara.maxkey.entity.Synchronizers;
+import org.dromara.maxkey.persistence.mapper.SynchronizersMapper;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class SynchronizersServiceImpl  extends JpaServiceImpl<SynchronizersMapper,Synchronizers>{
+    static final  Logger _logger = LoggerFactory.getLogger(SynchronizersServiceImpl.class);
+	
+}

+ 420 - 0
maxkey-persistence/src/main/java/org/dromara/maxkey/persistence/service/impl/UserInfoServiceImpl.java

@@ -0,0 +1,420 @@
+/*
+ * 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.dromara.maxkey.persistence.service.impl;
+
+
+import java.sql.Types;
+import java.util.Date;
+
+import org.apache.commons.lang3.StringUtils;
+import org.dromara.maxkey.constants.ConstsStatus;
+import org.dromara.maxkey.crypto.password.PasswordReciprocal;
+import org.dromara.maxkey.entity.Accounts;
+import org.dromara.maxkey.entity.ChangePassword;
+import org.dromara.maxkey.entity.idm.UserInfo;
+import org.dromara.maxkey.persistence.mapper.UserInfoMapper;
+import org.dromara.maxkey.persistence.repository.PasswordPolicyValidator;
+import org.dromara.maxkey.persistence.service.AccountsService;
+import org.dromara.maxkey.provision.ProvisionAct;
+import org.dromara.maxkey.provision.ProvisionService;
+import org.dromara.maxkey.provision.ProvisionTopic;
+import org.dromara.maxkey.web.WebContext;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.stereotype.Repository;
+
+
+/**
+ * @author Crystal.Sea
+ *
+ */
+@Repository
+public class UserInfoServiceImpl extends JpaServiceImpl<UserInfoMapper,UserInfo> {
+	static final  Logger _logger = LoggerFactory.getLogger(UserInfoServiceImpl.class);
+	
+	@Autowired
+	private PasswordEncoder passwordEncoder;
+	
+	@Autowired
+	PasswordPolicyValidator passwordPolicyValidator;
+	
+	@Autowired
+	ProvisionService provisionService;
+
+	AccountsService accountsService;
+	
+	
+	@Override
+    public boolean insert(UserInfo userInfo) {
+    	this.passwordEncoder(userInfo);
+        if (super.insert(userInfo)) {
+        	if(provisionService.getApplicationConfig().isProvisionSupport()) {
+                UserInfo loadUserInfo = findUserRelated(userInfo.getId());
+                provisionService.send(
+                        ProvisionTopic.USERINFO_TOPIC, 
+                        loadUserInfo,
+                        ProvisionAct.CREATE);
+            }
+            
+            return true;
+        }
+
+        return false;
+    }
+    
+    public boolean insert(UserInfo userInfo,boolean passwordEncoder) {
+    	if(passwordEncoder) {
+    		this.passwordEncoder(userInfo);
+    	}
+        if (super.insert(userInfo)) {
+        	if(provisionService.getApplicationConfig().isProvisionSupport()) {
+                UserInfo loadUserInfo = findUserRelated(userInfo.getId());
+                provisionService.send(
+                        ProvisionTopic.USERINFO_TOPIC, 
+                        loadUserInfo,
+                        ProvisionAct.CREATE);
+            }
+            
+            return true;
+        }
+
+        return false;
+    }
+	
+    @Override
+    public boolean update(UserInfo userInfo) {
+    	ChangePassword changePassword = this.passwordEncoder(userInfo);
+        if (super.update(userInfo)) {
+        	if(provisionService.getApplicationConfig().isProvisionSupport()) {
+                UserInfo loadUserInfo = findUserRelated(userInfo.getId());
+                accountUpdate(loadUserInfo);
+                provisionService.send(
+                        ProvisionTopic.USERINFO_TOPIC, 
+                        loadUserInfo,
+                        ProvisionAct.UPDATE);
+            }
+            if(userInfo.getPassword() != null) {
+            	changePasswordProvisioning(changePassword);
+            }
+            return true;
+        }
+        return false;
+    }
+	
+	public boolean delete(UserInfo userInfo) {
+	    UserInfo loadUserInfo = null;
+	    if(provisionService.getApplicationConfig().isProvisionSupport()) {
+	        loadUserInfo = findUserRelated(userInfo.getId());
+	    }
+	    
+		if( super.delete(userInfo.getId())){
+			provisionService.send(
+		            ProvisionTopic.USERINFO_TOPIC, 
+		            loadUserInfo, 
+		            ProvisionAct.DELETE);
+			accountUpdate(loadUserInfo);
+			 return true;
+		}
+		return false;
+	}
+	
+    //更新账号状态
+    public void accountUpdate(UserInfo userInfo) {
+        if(userInfo.getStatus() != ConstsStatus.ACTIVE) {
+            if(accountsService==null) {
+                accountsService = 
+                       WebContext.getBean("accountsService",AccountsService.class); 
+            }
+            Accounts queryAcount =new Accounts();
+            queryAcount.setUserId(userInfo.getId());
+            for (Accounts acount : accountsService.query(queryAcount)) {
+                acount.setStatus(ConstsStatus.INACTIVE);
+                accountsService.update(acount);
+            }
+        }
+    }
+
+	public UserInfo findUserRelated(String userId) {
+	    UserInfo loadUserInfo =this.get(userId);
+	    loadUserInfo.setDepts(getMapper().findDeptsByUserId(userId));
+	    return loadUserInfo;
+	}
+	
+	public boolean updateGridList(String gridList,UserInfo userInfo) {
+	    try {
+    	    if (gridList != null && !gridList.equals("")) {
+    	    	userInfo.setGridList(Integer.parseInt(gridList));
+                getMapper().updateGridList(userInfo);
+            }
+	    }catch(Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+	    return true;
+	}
+	
+	
+	public void saveOrUpdate(UserInfo userInfo) {
+		UserInfo loadUserInfo = findOne(" username = ? and instid = ?",
+				new Object[] { userInfo.getUsername(),userInfo.getInstId() },
+                new int[] { Types.VARCHAR,Types.VARCHAR});
+		if(loadUserInfo == null) {
+			insert(userInfo);
+		}else {
+			userInfo.setId(loadUserInfo.getId());
+			userInfo.setPassword(null);
+			update(userInfo);
+		}
+	}
+	
+	public boolean updateProtectedApps(UserInfo userinfo) {
+		try {
+			userinfo.setModifiedDate(new Date());
+			return getMapper().updateProtectedApps(userinfo) > 0;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return false;
+	}
+
+	public UserInfo findByUsername(String username) {
+		return getMapper().findByUsername(username);
+	}
+	
+    public UserInfo findByEmailMobile(String emailMobile) {
+        return getMapper().findByEmailMobile(emailMobile);
+    }
+	
+	public UserInfo findByAppIdAndUsername(String appId,String username){
+		try {
+			UserInfo userinfo = new UserInfo();
+			userinfo.setUsername(username);
+			return getMapper().findByAppIdAndUsername(userinfo) ;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+	
+	public ChangePassword passwordEncoder(UserInfo userInfo) {
+		ChangePassword changePassword = null;
+		if(StringUtils.isNotBlank(userInfo.getPassword())) {
+    		changePassword = new ChangePassword(userInfo);
+    		passwordEncoder(changePassword);
+    		userInfo.setPassword(changePassword.getPassword());
+    		userInfo.setDecipherable(changePassword.getDecipherable());
+    		userInfo.setPasswordLastSetTime(changePassword.getPasswordLastSetTime());
+    	}else {
+    		userInfo.setPassword(null);
+    		userInfo.setDecipherable(null);
+    	}
+		return changePassword;
+	}
+	
+	public ChangePassword passwordEncoder(ChangePassword changePassword) {
+	    //密码不为空,则需要进行加密处理
+	    if(StringUtils.isNotBlank(changePassword.getPassword())) {
+    	    String password = passwordEncoder.encode(changePassword.getPassword());
+    	    changePassword.setDecipherable(PasswordReciprocal.getInstance().encode(changePassword.getPassword()));
+            _logger.debug("decipherable : {}",changePassword.getDecipherable());
+            changePassword.setPassword(password);
+            changePassword.setPasswordLastSetTime(new Date());
+            
+	    }else {
+	    	changePassword.setPassword(null);
+	    	changePassword.setDecipherable(null);
+	    }
+        return changePassword;
+	}
+	
+	/**
+	 * 认证密码修改
+	 * @param oldPassword
+	 * @param newPassword
+	 * @param confirmPassword
+	 * @param passwordSetType
+	 * @return
+	 */
+	public boolean changePassword(  ChangePassword changePassword) {
+		try {
+		    WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, "");
+		    UserInfo userInfo = this.findByUsername(changePassword.getUsername());
+	        if(changePassword.getPassword().equals(changePassword.getConfirmPassword())){
+	            if(StringUtils.isNotBlank(changePassword.getOldPassword()) &&
+	                    passwordEncoder.matches(changePassword.getOldPassword(), userInfo.getPassword())){
+	                if(changePassword(changePassword,true) ){
+	                    return true;
+	                }
+	                return false;	               
+	            }else {
+	                if(StringUtils.isNotBlank(changePassword.getOldPassword())&&
+	                        passwordEncoder.matches(changePassword.getPassword(), userInfo.getPassword())) {
+	                    WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, 
+	                            WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_MATCH"));
+	                }else {
+	                    WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, 
+	                        WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_NOT_MATCH"));
+	                }
+	            }
+	        }else {
+	            WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, 
+	                    WebContext.getI18nValue("PasswordPolicy.CONFIRMPASSWORD_NOT_MATCH"));
+	        }
+		 } catch (Exception e) {
+             e.printStackTrace();
+         }    
+		    
+		return false;
+	}
+	
+	/**
+	 * 后台密码修改
+	 * @param changeUserInfo
+	 * @param passwordPolicy
+	 * @return
+	 */
+    public boolean changePassword(ChangePassword changePassword,boolean passwordPolicy) {
+        try {
+            _logger.debug("decipherable old : {}" , changePassword.getDecipherable());
+            _logger.debug("decipherable new : {}" , PasswordReciprocal.getInstance().encode(changePassword.getDecipherable()));
+
+            if (passwordPolicy && !passwordPolicyValidator.validator(changePassword)) {
+                return false;
+            }
+
+            changePassword = passwordEncoder(changePassword);
+
+            if (getMapper().changePassword(changePassword) > 0) {
+                changePasswordProvisioning(changePassword);
+                return true;
+            }
+            return false;
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return false;
+    }
+	
+	public String randomPassword() {
+	    return passwordPolicyValidator.generateRandomPassword();
+	}
+	
+	public void changePasswordProvisioning(ChangePassword changePassworded) {
+	    if(changePassworded !=null && StringUtils.isNotBlank(changePassworded.getPassword())) {
+	    	UserInfo loadUserInfo = findByUsername(changePassworded.getUsername());
+    	    ChangePassword changePassword = new ChangePassword(loadUserInfo);
+    	    provisionService.send(ProvisionTopic.PASSWORD_TOPIC, changePassword, ProvisionAct.PASSWORD);
+	    }
+	}
+	
+	public boolean updateAppLoginPassword(UserInfo userinfo) {
+		try {
+			userinfo.setModifiedDate(new Date());
+			return getMapper().updateAppLoginPassword(userinfo) > 0;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return false;
+	}
+	
+	
+	/**
+	 * 锁定用户:islock:1 用户解锁 2 用户锁定
+	 * @param userInfo
+	 */
+	public void updateLocked(UserInfo userInfo) {
+		try {
+			if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
+				userInfo.setIsLocked(ConstsStatus.LOCK);
+				getMapper().updateLocked(userInfo);
+			}
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 用户登录成功后,重置错误密码次数和解锁用户
+	 * @param userInfo
+	 */
+	public void updateLockout(UserInfo userInfo) {
+		try {
+			if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
+				userInfo.setIsLocked(ConstsStatus.START);
+				userInfo.setBadPasswordCount(0);
+				getMapper().updateLockout(userInfo);
+			}
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 更新错误密码次数
+	 * @param userInfo
+	 */
+	public void updateBadPasswordCount(UserInfo userInfo) {
+		try {
+			if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
+				int updateBadPWDCount = userInfo.getBadPasswordCount() + 1;
+				userInfo.setBadPasswordCount(updateBadPWDCount);
+				getMapper().updateBadPWDCount(userInfo);
+			}
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	public boolean updateSharedSecret(UserInfo userInfo){
+		return getMapper().updateSharedSecret(userInfo)>0;
+	}
+	
+	public boolean updatePasswordQuestion(UserInfo userInfo){
+		return getMapper().updatePasswordQuestion(userInfo)>0;
+	}
+	
+	public boolean updateAuthnType(UserInfo userInfo){
+		return getMapper().updateAuthnType(userInfo)>0;
+	}
+	
+	public boolean updateEmail(UserInfo userInfo){
+		return getMapper().updateEmail(userInfo)>0;
+	}
+	
+	public boolean updateMobile(UserInfo userInfo){
+		return getMapper().updateMobile(userInfo)>0;
+	}
+    
+    public int updateProfile(UserInfo userInfo){
+        return getMapper().updateProfile(userInfo);
+    }
+    
+    public boolean 	updateStatus(UserInfo userInfo) {
+    	return getMapper().updateStatus(userInfo) > 0;
+    }
+
+    public void setPasswordPolicyValidator(PasswordPolicyValidator passwordPolicyValidator) {
+        this.passwordPolicyValidator = passwordPolicyValidator;
+    }
+
+}

+ 8 - 34
maxkey-synchronizers/maxkey-synchronizer/src/main/java/org/dromara/maxkey/synchronizer/service/SyncJobConfigFieldService.java

@@ -2,42 +2,16 @@ package org.dromara.maxkey.synchronizer.service;
 
 import org.dromara.maxkey.entity.SyncJobConfigField;
 
-import org.dromara.maxkey.persistence.mapper.SyncJobConfigFieldMapper;
-import org.dromara.mybatis.jpa.JpaService;
-import org.springframework.stereotype.Service;
-
-import java.sql.Types;
-import java.util.ArrayList;
+import org.dromara.mybatis.jpa.IJpaService;
 import java.util.List;
 
-@Service
-public class SyncJobConfigFieldService extends JpaService<SyncJobConfigField> {
-    public SyncJobConfigFieldService() {
-        super(SyncJobConfigFieldMapper.class);
-    }
-    @Override
-    public SyncJobConfigFieldMapper getMapper() {
-        return (SyncJobConfigFieldMapper)super.getMapper();
-    }
-
-    public List<SyncJobConfigField> findByJobIdAndObjectType(Long jobId, String objectType) {
-
-        return getMapper().findByJobIdAndObjectType(jobId,objectType);
-    }
-
-    public void deleteFieldMapById(Long id){
-        ArrayList<String> ids = new ArrayList<>();
-        ids.add(String.valueOf(id));
-        super.deleteBatch(ids);
-    }
-
-    public List<SyncJobConfigField> findByJobId(Long jobId) {
-        List<SyncJobConfigField> list = find(" jobid = ?",
-                new Object[]{jobId},
-                new int[]{Types.BIGINT});
-        return list;
-
-    }
+public interface SyncJobConfigFieldService extends IJpaService<SyncJobConfigField> {
+
+    public List<SyncJobConfigField> findByJobIdAndObjectType(Long jobId, String objectType) ;
+
+    public void deleteFieldMapById(Long id);
+
+    public List<SyncJobConfigField> findByJobId(Long jobId) ;
 
 
 }

+ 37 - 0
maxkey-synchronizers/maxkey-synchronizer/src/main/java/org/dromara/maxkey/synchronizer/service/impl/SyncJobConfigFieldServiceImpl.java

@@ -0,0 +1,37 @@
+package org.dromara.maxkey.synchronizer.service.impl;
+
+import org.dromara.maxkey.entity.SyncJobConfigField;
+
+import org.dromara.maxkey.persistence.mapper.SyncJobConfigFieldMapper;
+import org.dromara.maxkey.synchronizer.service.SyncJobConfigFieldService;
+import org.dromara.mybatis.jpa.service.impl.JpaServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class SyncJobConfigFieldServiceImpl extends JpaServiceImpl<SyncJobConfigFieldMapper,SyncJobConfigField>  implements SyncJobConfigFieldService {
+
+    public List<SyncJobConfigField> findByJobIdAndObjectType(Long jobId, String objectType) {
+
+        return getMapper().findByJobIdAndObjectType(jobId,objectType);
+    }
+
+    public void deleteFieldMapById(Long id){
+        ArrayList<String> ids = new ArrayList<>();
+        ids.add(String.valueOf(id));
+        super.deleteBatch(ids);
+    }
+
+    public List<SyncJobConfigField> findByJobId(Long jobId) {
+        List<SyncJobConfigField> list = find(" jobid = ?",
+                new Object[]{jobId},
+                new int[]{Types.BIGINT});
+        return list;
+
+    }
+
+
+}

+ 1 - 1
setEnvVars.bat

@@ -1,6 +1,6 @@
 echo off
 echo set env
-set JAVA_HOME=C:\IDE\jdk-17.0.2.8
+set JAVA_HOME=C:\ide\jdk-17.0.9+9
 set GRADLE_HOME=C:\ide\gradle-8.8
 
 set MXK_VERSION=4.1.2