yuhuitao 2 лет назад
Родитель
Сommit
60a57eb75e

+ 28 - 2
modules/sso/src/main/java/com/jeesite/modules/sso/web/SsoAppController.java

@@ -27,6 +27,7 @@ import com.jeesite.modules.sso.entity.SsoApp;
 import com.jeesite.modules.sso.service.SsoAppService;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
 import java.util.UUID;
 import java.util.stream.Collectors;
@@ -91,6 +92,9 @@ public class SsoAppController extends BaseController {
 	public Page<SsoApp> listData(SsoApp ssoApp, HttpServletRequest request, HttpServletResponse response) {
 		ssoApp.setPage(new Page<>(request, response));
 		Page<SsoApp> page = ssoAppService.findPage(ssoApp);
+		List<SsoApp> list = page.getList();
+		list=list.stream().sorted(Comparator.comparing(SsoApp::getCreateDate).reversed()).collect(Collectors.toList());
+		page.setList(list);
 		return page;
 	}
 
@@ -213,16 +217,38 @@ public class SsoAppController extends BaseController {
 		ssoApp.setAppStatus("0");
 		List<SsoApp> list = ssoAppService.findList(ssoApp);
 		List<SsoApp> list1=new ArrayList<>();
-		for (Role role : roleList) {
+
+		if(user.getUserCode().equals("system")){
+			return list;
+		}
 			for (SsoApp app : list) {
+				for (Role role : roleList) {
 				if(app.getAuthority().contains(role.getRoleCode())){
 					list1.add(app);
 				}
 			}
 		}
-
+		list1=list1.stream().distinct().collect(Collectors.toList());
 		return list1;
 	}
 
 
+	@RequestMapping("/findAuthority")
+	@ResponseBody
+	public List<String> findAuthority(String id){
+		SsoApp ssoApp=new SsoApp();
+		ssoApp.setId(id);
+		List<SsoApp> list = ssoAppService.findList(ssoApp);
+
+		List<String> result=new ArrayList<>();
+
+		String[] split = list.get(0).getAuthority().split(",");
+		for (String s : split) {
+			result.add(s);
+		}
+
+		return result;
+	}
+
+
 }

+ 25 - 0
modules/sso/src/main/resources/views/modules/sso/ssoAppForm.html

@@ -185,4 +185,29 @@ $("#inputForm").validate({
 		}, "json");
     }
 });
+
+$(function (){
+	$.ajax({
+		url: "${ctx}/sso/ssoApp/findAuthority?id="+'${ssoApp.id}',
+		type: 'get',
+		data: {},
+		success: function (res) {
+			/*$("[name='authority']").prop("checked",true);*/
+
+			$.each(res,function(index, item){
+			$("[name='authority']").each(function(){ //由于复选框一般选中的是多个,所以可以循环输出
+					if($(this).val()==item){
+						$(this).prop("checked",true)
+					}
+				})
+
+			});
+
+
+		}
+	});
+
+})
+
+
 </script>