Crystal.Sea 4 år sedan
förälder
incheckning
7ad3130371

+ 25 - 0
maxkey-core/src/main/java/org/maxkey/domain/Groups.java

@@ -48,6 +48,11 @@ public class Groups extends JpaBaseDomain implements Serializable {
     
     @Column
     String orgIdsList;
+    @Column
+    String resumeTime; 
+    
+    @Column
+    String suspendTime;
     
     @Column
     int isdefault;
@@ -181,6 +186,22 @@ public class Groups extends JpaBaseDomain implements Serializable {
         this.orgIdsList = orgIdsList;
     }
 
+    public String getResumeTime() {
+        return resumeTime;
+    }
+
+    public void setResumeTime(String resumeTime) {
+        this.resumeTime = resumeTime;
+    }
+
+    public String getSuspendTime() {
+        return suspendTime;
+    }
+
+    public void setSuspendTime(String suspendTime) {
+        this.suspendTime = suspendTime;
+    }
+
     @Override
     public String toString() {
         StringBuilder builder = new StringBuilder();
@@ -194,6 +215,10 @@ public class Groups extends JpaBaseDomain implements Serializable {
         builder.append(filters);
         builder.append(", orgIdsList=");
         builder.append(orgIdsList);
+        builder.append(", resumeTime=");
+        builder.append(resumeTime);
+        builder.append(", suspendTime=");
+        builder.append(suspendTime);
         builder.append(", isdefault=");
         builder.append(isdefault);
         builder.append(", description=");

+ 32 - 2
maxkey-persistence/src/main/java/org/maxkey/persistence/service/GroupsService.java

@@ -17,6 +17,8 @@
 
 package org.maxkey.persistence.service;
 
+import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.util.List;
 
 import org.apache.mybatis.jpa.persistence.JpaBaseService;
@@ -62,6 +64,25 @@ public class GroupsService  extends JpaBaseService<Groups>{
 	
 	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(",", "','")+"'");
     	    }
@@ -76,8 +97,17 @@ public class GroupsService  extends JpaBaseService<Groups>{
     	    
     	    dynamicGroup.setFilters(filters);
     	    
-    	    groupMemberService.deleteDynamicGroupMember(dynamicGroup);
-    	    groupMemberService.addDynamicGroupMember(dynamicGroup);
+    	    if(isDynamicTimeSupport) {
+    	        if(isBetweenEffectiveTime) {
+    	            groupMemberService.deleteDynamicGroupMember(dynamicGroup);
+                    groupMemberService.addDynamicGroupMember(dynamicGroup);
+    	        }else {
+    	            groupMemberService.deleteDynamicGroupMember(dynamicGroup);
+    	        }
+    	    }else{
+                groupMemberService.deleteDynamicGroupMember(dynamicGroup);
+                groupMemberService.addDynamicGroupMember(dynamicGroup);
+            }
 	    }
     }
 	

+ 17 - 0
maxkey-web-manage/src/main/java/org/maxkey/jobs/DynamicGroupsJob.java

@@ -1,3 +1,20 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
 package org.maxkey.jobs;
 
 import java.util.List;

+ 17 - 0
maxkey-web-manage/src/main/java/org/maxkey/jobs/DynamicRolesJob.java

@@ -1,3 +1,20 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
 package org.maxkey.jobs;
 
 public class DynamicRolesJob {

+ 2 - 0
maxkey-web-manage/src/main/resources/messages/message.properties

@@ -416,6 +416,8 @@ group.name=\u7528\u6237\u7ec4
 group.dynamic=\u52a8\u6001\u7ec4
 group.filters=\u8fc7\u6ee4\u5668
 group.orgidslist=\u673a\u6784\u5217\u8868
+group.resumeTime=\u52a8\u6001\u65f6\u95f4
+group.suspendTime=\u6302\u8d77\u65f6\u95f4
 
 #role
 role.id=\u89d2\u8272\u7f16\u7801

+ 2 - 0
maxkey-web-manage/src/main/resources/messages/message_en.properties

@@ -415,6 +415,8 @@ group.name=name
 group.dynamic=dynamic
 group.filters=filters
 group.orgidslist=orgIdsList
+group.resumeTime=resumeTime
+group.suspendTime=suspendTime
 
 #role
 role.id=id

+ 2 - 0
maxkey-web-manage/src/main/resources/messages/message_zh_CN.properties

@@ -417,6 +417,8 @@ group.name=\u7528\u6237\u7ec4
 group.dynamic=\u52a8\u6001\u7ec4
 group.filters=\u8fc7\u6ee4\u5668
 group.orgidslist=\u673a\u6784\u5217\u8868
+group.resumeTime=\u52a8\u6001\u65f6\u95f4
+group.suspendTime=\u6302\u8d77\u65f6\u95f4
 
 #role
 role.id=\u89d2\u8272\u7f16\u7801

+ 14 - 2
maxkey-web-manage/src/main/resources/templates/views/groups/groupAdd.ftl

@@ -185,6 +185,18 @@ function showOrgsTree() {
 				</td>
 			</tr>
 			<tr>
+				<th><@locale code="group.resumeTime" />:</th>
+				<td nowrap>
+					<input type="text" id="resumeTime" name="resumeTime" class="form-control timepicker" title="" value=""  required="" />
+				</td>
+			</tr>
+			<tr>
+				<th><@locale code="group.suspendTime" />:</th>
+				<td nowrap>
+					<input type="text" id="suspendTime" name="suspendTime" class="form-control timepicker" title="" value=""  required="" />
+				</td>
+			</tr>
+			<tr>
 				<th><@locale code="group.orgidslist" />:</th>
 				<td nowrap>
 					<input type="text" id="orgIdsListName" name="orgIdsListName"   readonly  class="form-control" title="" value=""   onclick="showOrgsTree();"/>
@@ -194,13 +206,13 @@ function showOrgsTree() {
 			<tr>
 				<th><@locale code="group.filters" />:</th>
 				<td nowrap>
-					<textarea id="filters" name="filters" class="form-control"  rows="7" cols="20"></textarea>
+					<textarea id="filters" name="filters" class="form-control"  rows="6" cols="20"></textarea>
 				</td>
 			</tr>
 			<tr>
                 <th><@locale code="common.text.description" />:</th>
                 <td nowrap>
-                    <textarea id="description" name="description" class="form-control"  rows="6" cols="20"></textarea>
+                    <textarea id="description" name="description" class="form-control"  rows="4" cols="20"></textarea>
                 </td>
             </tr>
 			<tr>

+ 14 - 2
maxkey-web-manage/src/main/resources/templates/views/groups/groupUpdate.ftl

@@ -199,6 +199,18 @@ function showOrgsTree() {
 			</td>
 		</tr>
 		<tr>
+				<th><@locale code="group.resumeTime" />:</th>
+				<td nowrap>
+					<input type="text" id="resumeTime" name="resumeTime" class="form-control timepicker" title="" value="${model.resumeTime!}"  required="" />
+				</td>
+			</tr>
+			<tr>
+				<th><@locale code="group.suspendTime" />:</th>
+				<td nowrap>
+					<input type="text" id="suspendTime" name="suspendTime" class="form-control timepicker" title="" value="${model.suspendTime!}"  required="" />
+				</td>
+		</tr>
+		<tr>
 				<th><@locale code="group.orgidslist" />:</th>
 				<td nowrap>
 					<input type="text" id="orgIdsListName" name="orgIdsListName"   readonly  class="form-control" title="" value=""   onclick="showOrgsTree();"/>
@@ -208,13 +220,13 @@ function showOrgsTree() {
 		<tr>
 			<th><@locale code="group.filters" />:</th>
 			<td nowrap>
-				<textarea id="filters" name="filters" class="form-control"  rows="7" cols="20">${model.filters!}</textarea>
+				<textarea id="filters" name="filters" class="form-control"  rows="6" cols="20">${model.filters!}</textarea>
 			</td>
 		</tr>
 		<tr>
                 <th><@locale code="common.text.description" />:</th>
                 <td nowrap>
-                	<textarea id="description" name="description" class="form-control"  rows="6" cols="20">${model.description!}</textarea>
+                	<textarea id="description" name="description" class="form-control"  rows="4" cols="20">${model.description!}</textarea>
                 </td>
         </tr>
 		<tr>