2025年3月14日16:55:19
parent
5fcdc77d41
commit
2c6b5ae150
|
|
@ -7,6 +7,9 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import com.zhangmeng.online.exam.ui.api.model.PermissionDataLoad;
|
||||
import com.zhangmeng.online.exam.ui.api.model.QuestionDataLoad;
|
||||
import com.zhangmeng.online.exam.ui.api.model.RoleDataLoad;
|
||||
import com.zhangmeng.online.exam.ui.api.model.UserDataLoad;
|
||||
import com.zhangmeng.online.exam.ui.components.callBack.DynamicTableComponentCallBack;
|
||||
import com.zhangmeng.online.exam.ui.layouts.SideMenu;
|
||||
|
|
@ -25,6 +28,10 @@ public class ApiUtils {
|
|||
|
||||
public static final String API_URL = "http://localhost:8080";
|
||||
|
||||
public static final int PAGE_SIZE = 3;
|
||||
|
||||
public static final int PAGE_NUM = 1;
|
||||
|
||||
public static List<SideMenu.SideMenuItem> getMenuItems() {
|
||||
|
||||
List<SideMenu.SideMenuItem> menuItems = new ArrayList<>();
|
||||
|
|
@ -55,62 +62,22 @@ public class ApiUtils {
|
|||
|
||||
public static DataView getUserList() {
|
||||
DataLoad dataLoad = new UserDataLoad();
|
||||
return dataLoad.loadData(1,10);
|
||||
return dataLoad.loadData(PAGE_NUM,PAGE_SIZE);
|
||||
}
|
||||
|
||||
public static DataView getRoleList() {
|
||||
String userListData = HttpUtils.GET(API_URL + "/role/list");
|
||||
JSONObject jsonObject = JSON.parseObject(userListData);
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
List<Map<String, SimpleStringProperty>> roleMapList = new ArrayList<>();
|
||||
for (Object datum : data) {
|
||||
JSONObject role = (JSONObject) datum;
|
||||
Map<String, SimpleStringProperty> roleMap = new HashMap<>();
|
||||
roleMap.put("序号", new SimpleStringProperty(role.getString("id")));
|
||||
roleMap.put("角色名称", new SimpleStringProperty(role.getString("name")));
|
||||
roleMap.put("描述", new SimpleStringProperty(role.getString("desc")));
|
||||
roleMap.put("角色类型", new SimpleStringProperty(role.getString("type_name")));
|
||||
roleMapList.add(roleMap);
|
||||
}
|
||||
return new DataView(Arrays.asList("序号", "角色名称", "描述", "角色类型"), roleMapList);
|
||||
DataLoad dataLoad = new RoleDataLoad();
|
||||
return dataLoad.loadData(PAGE_NUM,PAGE_SIZE);
|
||||
}
|
||||
|
||||
public static DataView getPermissionList() {
|
||||
|
||||
String userListData = HttpUtils.GET(API_URL + "/permission/list");
|
||||
JSONObject jsonObject = JSON.parseObject(userListData);
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
|
||||
List<Map<String, SimpleStringProperty>> permissionMapList = new ArrayList<>();
|
||||
for (Object datum : data) {
|
||||
JSONObject permission = (JSONObject) datum;
|
||||
Map<String, SimpleStringProperty> userMap = new HashMap<>();
|
||||
userMap.put("序号", new SimpleStringProperty(permission.getString("id")));
|
||||
userMap.put("权限名称", new SimpleStringProperty(permission.getString("name")));
|
||||
userMap.put("描述", new SimpleStringProperty(permission.getString("desc")));
|
||||
userMap.put("权限路径", new SimpleStringProperty(permission.getString("url")));
|
||||
permissionMapList.add(userMap);
|
||||
}
|
||||
return new DataView(Arrays.asList("序号", "权限名称", "描述", "权限路径"), permissionMapList);
|
||||
DataLoad dataLoad = new PermissionDataLoad();
|
||||
return dataLoad.loadData(PAGE_NUM,PAGE_SIZE);
|
||||
}
|
||||
|
||||
public static DataView getQuestionList() {
|
||||
|
||||
String userListData = HttpUtils.GET(API_URL + "/question/list");
|
||||
JSONObject jsonObject = JSON.parseObject(userListData);
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
|
||||
List<Map<String, SimpleStringProperty>> questionMapList = new ArrayList<>();
|
||||
for (Object datum : data) {
|
||||
JSONObject permission = (JSONObject) datum;
|
||||
Map<String, SimpleStringProperty> userMap = new HashMap<>();
|
||||
userMap.put("序号", new SimpleStringProperty(permission.getString("id")));
|
||||
userMap.put("权限名称", new SimpleStringProperty(permission.getString("name")));
|
||||
userMap.put("描述", new SimpleStringProperty(permission.getString("desc")));
|
||||
userMap.put("权限路径", new SimpleStringProperty(permission.getString("url")));
|
||||
questionMapList.add(userMap);
|
||||
}
|
||||
return new DataView(Arrays.asList("序号", "权限名称", "描述", "权限路径"), questionMapList);
|
||||
DataLoad dataLoad = new QuestionDataLoad();
|
||||
return dataLoad.loadData(PAGE_NUM,PAGE_SIZE);
|
||||
}
|
||||
|
||||
public static class DataView {
|
||||
|
|
@ -131,8 +98,9 @@ public class ApiUtils {
|
|||
return dataLoad;
|
||||
}
|
||||
|
||||
public void setDataLoad(DataLoad dataLoad) {
|
||||
public DataView setDataLoad(DataLoad dataLoad) {
|
||||
this.dataLoad = dataLoad;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DynamicTableComponentCallBack getCallBack() {
|
||||
|
|
@ -155,24 +123,27 @@ public class ApiUtils {
|
|||
return pageNum;
|
||||
}
|
||||
|
||||
public void setPageNum(Integer pageNum) {
|
||||
public DataView setPageNum(Integer pageNum) {
|
||||
this.pageNum = pageNum;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
public DataView setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(Integer total) {
|
||||
public DataView setTotal(Integer total) {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataView(List<String> keys, List<Map<String, SimpleStringProperty>> dataList) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
package com.zhangmeng.online.exam.ui.api.model;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
||||
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
||||
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.zhangmeng.online.exam.ui.api.ApiUtils.API_URL;
|
||||
|
||||
/**
|
||||
* @author zm
|
||||
* @date 2025/3/14 16:19
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class PermissionDataLoad implements DataLoad {
|
||||
@Override
|
||||
public ApiUtils.DataView loadData(Integer pageNum, Integer pageSize) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("pageNum", pageNum.toString());
|
||||
params.put("pageSize", pageSize.toString());
|
||||
String userListData = HttpUtils.GET(API_URL + "/permission/list",params);
|
||||
JSONObject jsonObject = JSON.parseObject(userListData);
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
int total = jsonObject.getIntValue("total");
|
||||
|
||||
List<Map<String, SimpleStringProperty>> permissionMapList = new ArrayList<>();
|
||||
for (Object datum : data) {
|
||||
JSONObject permission = (JSONObject) datum;
|
||||
Map<String, SimpleStringProperty> userMap = new HashMap<>();
|
||||
userMap.put("序号", new SimpleStringProperty(permission.getString("id")));
|
||||
userMap.put("权限名称", new SimpleStringProperty(permission.getString("name")));
|
||||
userMap.put("描述", new SimpleStringProperty(permission.getString("desc")));
|
||||
userMap.put("权限路径", new SimpleStringProperty(permission.getString("url")));
|
||||
permissionMapList.add(userMap);
|
||||
}
|
||||
return new ApiUtils.DataView(Arrays.asList("序号", "权限名称", "描述", "权限路径"), permissionMapList).setDataLoad(this).setPageNum(pageNum).setPageSize(pageSize).setTotal(total);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.zhangmeng.online.exam.ui.api.model;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
||||
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
||||
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.zhangmeng.online.exam.ui.api.ApiUtils.API_URL;
|
||||
|
||||
/**
|
||||
* @author zm
|
||||
* @date 2025/3/14 16:20
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class QuestionDataLoad implements DataLoad {
|
||||
@Override
|
||||
public ApiUtils.DataView loadData(Integer pageNum, Integer pageSize) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("pageNum", pageNum.toString());
|
||||
params.put("pageSize", pageSize.toString());
|
||||
String userListData = HttpUtils.GET(API_URL + "/question/list",params);
|
||||
JSONObject jsonObject = JSON.parseObject(userListData);
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
|
||||
List<Map<String, SimpleStringProperty>> questionMapList = new ArrayList<>();
|
||||
for (Object datum : data) {
|
||||
JSONObject permission = (JSONObject) datum;
|
||||
Map<String, SimpleStringProperty> userMap = new HashMap<>();
|
||||
userMap.put("序号", new SimpleStringProperty(permission.getString("id")));
|
||||
userMap.put("权限名称", new SimpleStringProperty(permission.getString("name")));
|
||||
userMap.put("描述", new SimpleStringProperty(permission.getString("desc")));
|
||||
userMap.put("权限路径", new SimpleStringProperty(permission.getString("url")));
|
||||
questionMapList.add(userMap);
|
||||
}
|
||||
return new ApiUtils.DataView(Arrays.asList("序号", "权限名称", "描述", "权限路径"), questionMapList).setDataLoad(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.zhangmeng.online.exam.ui.api.model;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
||||
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
||||
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.zhangmeng.online.exam.ui.api.ApiUtils.API_URL;
|
||||
|
||||
/**
|
||||
* @author zm
|
||||
* @date 2025/3/14 16:19
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class RoleDataLoad implements DataLoad {
|
||||
@Override
|
||||
public ApiUtils.DataView loadData(Integer pageNum, Integer pageSize) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("pageNum", pageNum.toString());
|
||||
params.put("pageSize", pageSize.toString());
|
||||
|
||||
String userListData = HttpUtils.GET(API_URL + "/role/list",params);
|
||||
JSONObject jsonObject = JSON.parseObject(userListData);
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
List<Map<String, SimpleStringProperty>> roleMapList = new ArrayList<>();
|
||||
for (Object datum : data) {
|
||||
JSONObject role = (JSONObject) datum;
|
||||
Map<String, SimpleStringProperty> roleMap = new HashMap<>();
|
||||
roleMap.put("序号", new SimpleStringProperty(role.getString("id")));
|
||||
roleMap.put("角色名称", new SimpleStringProperty(role.getString("name")));
|
||||
roleMap.put("描述", new SimpleStringProperty(role.getString("desc")));
|
||||
roleMap.put("角色类型", new SimpleStringProperty(role.getString("type_name")));
|
||||
roleMapList.add(roleMap);
|
||||
}
|
||||
return new ApiUtils.DataView(Arrays.asList("序号", "角色名称", "描述", "角色类型"), roleMapList).setDataLoad(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -24,4 +24,12 @@ public class DynamicTableComponentCallBackImpl implements DynamicTableComponentC
|
|||
// System.out.println("刷新数据:" + pageNum + " " + pageSize);
|
||||
return dataLoad.loadData(pageNum, pageSize);
|
||||
}
|
||||
|
||||
public DataLoad getDataLoad() {
|
||||
return dataLoad;
|
||||
}
|
||||
|
||||
public void setDataLoad(DataLoad dataLoad) {
|
||||
this.dataLoad = dataLoad;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,9 +164,9 @@ public class SideMenu extends VBox {
|
|||
private void init_table(HBox hbox, ApiUtils.DataView dataView) {
|
||||
Scene scene = hbox.getScene();
|
||||
IndexPage root = (IndexPage) scene.getRoot();
|
||||
dataView.setPageNum(1);
|
||||
dataView.setPageSize(10);
|
||||
dataView.setTotal(100);
|
||||
dataView.setPageNum(dataView.getPageNum());
|
||||
dataView.setPageSize(dataView.getPageSize());
|
||||
dataView.setTotal(dataView.getTotal());
|
||||
DynamicTableComponent dynamicTableComponent = new DynamicTableComponent(dataView);
|
||||
dynamicTableComponent.setCallBack(new DynamicTableComponentCallBackImpl(dataView.getDataLoad()));
|
||||
dynamicTableComponent.setPadding(new Insets(15));
|
||||
|
|
|
|||
Loading…
Reference in New Issue