kongzy
2024-07-01 47a751cb301d05276ae5d75145d57b2d090fe4e1
src/main/java/com/nanometer/smartlab/controller/RoleMngController.java
@@ -14,6 +14,7 @@
import org.springframework.stereotype.Controller;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -61,6 +62,34 @@
        RequestContext.getCurrentInstance().execute("PF('dialog').show()");
    }
    public void btnPermissionClick() {
        if (this.selectedList == null
                || this.selectedList.size() == 0) {
            FacesUtils.warn("请选择数据。");
            return;
        }
        if (this.selectedList.size() > 1) {
            FacesUtils.warn("只能选择一个数据进行修改。");
            return;
        }
        this.baseRole = this.baseRoleService.getBaseRole(this.selectedList.get(0).getId());
        RequestContext.getCurrentInstance().execute("PF('btnDialog').show()");
    }
    public void userPermissionClick() {
        if (this.selectedList == null
                || this.selectedList.size() == 0) {
            FacesUtils.warn("请选择数据。");
            return;
        }
        if (this.selectedList.size() > 1) {
            FacesUtils.warn("只能选择一个数据进行修改。");
            return;
        }
        this.baseRole = this.baseRoleService.getBaseRole(this.selectedList.get(0).getId());
        RequestContext.getCurrentInstance().execute("PF('userDialog').show()");
    }
    public void onSaveBtnClick() {
        try {
            // 新建
@@ -79,7 +108,8 @@
                    FacesUtils.warn("请选择角色权限。");
                    return;
                }
                baseRole.setUserPermission("自己");
                baseRole.setBtnPermission("新增,修改,删除,导入");
                this.baseRoleService.insertBaseRole(this.baseRole);
                FacesUtils.info("新建成功。");
@@ -106,6 +136,57 @@
                FacesUtils.info("修改成功。");
                RequestContext.getCurrentInstance().execute("PF('dialog').hide()");
            }
        } catch (Exception e) {
            logger.error("操作失败。", e);
            FacesUtils.warn("操作失败。");
        }
    }
    /**
    * 人员管理按钮权限修改
    */
    public void onSaveBtnPermission() {
        try {
                if (this.baseRole == null) {
                    FacesUtils.warn("修改对象为空。");
                    return;
                }
                if (this.baseRole.getBtnPermissions() == null || this.baseRole.getBtnPermissions().size() == 0) {
                    FacesUtils.warn("请选择功能。");
                    return;
                }
                this.baseRoleService.updateUserMngPageBtn(this.baseRole);
                FacesUtils.info("修改成功。");
                RequestContext.getCurrentInstance().execute("PF('btnDialog').hide()");
        } catch (Exception e) {
            logger.error("操作失败。", e);
            FacesUtils.warn("操作失败。");
        }
    }
    /**
     * 人员管理人员可见权限修改
     */
    public void onSaveUserPermission() {
        try {
            if (this.baseRole == null) {
                FacesUtils.warn("修改对象为空。");
                return;
            }
            if (this.baseRole.getUserPermission() == null) {
                FacesUtils.warn("请选择可见范围。");
                return;
            }
            this.baseRoleService.updateUserMngPageBtn(this.baseRole);
            FacesUtils.info("修改成功。");
            RequestContext.getCurrentInstance().execute("PF('userDialog').hide()");
        } catch (Exception e) {
            logger.error("操作失败。", e);
            FacesUtils.warn("操作失败。");
@@ -141,6 +222,7 @@
                        if (count > 0) {
                            list = baseRoleService.getBaseRoleList(null, null, first, pageSize);
                        }
                        selectedList = new ArrayList<>();
                    } catch (Exception e) {
                        logger.error(e);
                    }
@@ -149,17 +231,18 @@
                @Override
                public BaseRole getRowData(String rowKey) {
                    Iterator<BaseRole> iterator = this.iterator();
                    if (iterator != null) {
                        BaseRole br = null;
                        while (iterator.hasNext()) {
                            br = iterator.next();
                            if (rowKey.equals(br.getId())) {
                                return br;
                            }
                        }
                    }
                    return null;
//                    Iterator<BaseRole> iterator = this.iterator();
//                    if (iterator != null) {
//                        BaseRole br = null;
//                        while (iterator.hasNext()) {
//                            br = iterator.next();
//                            if (rowKey.equals(br.getId())) {
//                                return br;
//                            }
//                        }
//                    }
                    Long id=Long.valueOf(rowKey);
                    return baseRoleService.getBaseRole(id);
                }
            };
        }