Преглед изворни кода

1、添加查看全部角色(按照应用分组)接口 2、修改角色分配用户列表前台接口、用户添加角色下拉框

ZL пре 2 месеци
родитељ
комит
a23210ff2e

+ 40 - 0
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysRoleController.java

@@ -340,6 +340,46 @@ public class SysRoleController {
 		}
 		return result;
 	}
+
+	/**
+	 * 查询全部系统角色(根据应用分组)
+	 * @return
+	 */
+	@RequiresPermissions("system:role:queryallGroupByApp")
+	@RequestMapping(value = "/queryallGroupByApp", method = RequestMethod.GET)
+	public Result<List<Map>> queryallGroupByApp() {
+		Result<List<Map>> result = new Result<>();
+		List<SysRole> list = sysRoleService.listAllSysRoleNoPage();
+		if(list==null||list.size()<=0) {
+			result.error500("未找到角色信息");
+		}else {
+			List<Map> objects = new ArrayList<>();
+			Map<String, List<SysRole>> listMap = list.stream().collect(Collectors.groupingBy(SysRole::getAppName));
+			listMap.forEach((appName, roleList) -> {
+				Map<String, Object> map = new HashMap<>();
+				List<Map<String, String>> extractedList = roleList.stream()
+						.map(sysRole -> {
+							Map<String, String> roleInfo = new HashMap<>();
+							roleInfo.put("value", sysRole.getId());
+							roleInfo.put("label", sysRole.getRoleName());
+							return roleInfo;
+						})
+						.collect(Collectors.toList());
+				map.put("label",appName);
+				map.put("options", extractedList);
+				objects.add(map);
+			});
+			//排序,基础平台永远在首位
+			List<Map> resultList = new ArrayList<>();
+			objects.stream().filter(map -> "基础平台".equals(map.get("label")))
+					.forEach(resultList::add);
+			objects.stream().filter(map -> !"基础平台".equals(map.get("label")))
+					.forEach(resultList::add);
+			result.setResult(resultList);
+			result.setSuccess(true);
+		}
+		return result;
+	}
 	
 	/**
 	  * 校验角色编码唯一

+ 2 - 1
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysRoleMapper.java

@@ -28,7 +28,8 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
      */
     @InterceptorIgnore(tenantLine = "true")
     List<SysRole> listAllSysRole(@Param("page") Page<SysRole> page, @Param("role") SysRole role);
-
+    //查询全部的角色(不分页)
+    List<SysRole> listAllSysRoleNoPage();
     /**
      * 查询角色是否存在不做租户隔离
      *

+ 8 - 0
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysRoleMapper.xml

@@ -22,6 +22,14 @@
         </if>
         order by r.create_time desc
     </select>
+    <select id="listAllSysRoleNoPage" resultType="org.jeecg.modules.system.entity.SysRole">
+        SELECT * ,
+        sa.name as app_name
+        from sys_role r
+        INNER JOIN
+        app_base_info sa ON r.app_id = sa.id
+        order by r.create_time desc
+    </select>
    
 
     <select id="getRoleNoTenant" resultType="org.jeecg.modules.system.entity.SysRole">

+ 2 - 1
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysRoleService.java

@@ -28,7 +28,8 @@ public interface ISysRoleService extends IService<SysRole> {
      * @return
      */
     Page<SysRole> listAllSysRole(@Param("page") Page<SysRole> page, SysRole role);
-
+    //查询全部的角色(不分页)
+    List<SysRole> listAllSysRoleNoPage();
     /**
      * 查询角色是否存在不做租户隔离
      *

+ 4 - 0
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysRoleServiceImpl.java

@@ -44,6 +44,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
     public Page<SysRole> listAllSysRole(Page<SysRole> page, SysRole role) {
         return page.setRecords(sysRoleMapper.listAllSysRole(page,role));
     }
+    @Override
+    public List<SysRole> listAllSysRoleNoPage() {
+        return sysRoleMapper.listAllSysRoleNoPage();
+    }
 
     @Override
     public SysRole getRoleNoTenant(String roleCode,String appId) {

+ 23 - 5
jeecgboot-vue3/src/views/system/role/components/RoleUserTable.vue

@@ -39,7 +39,7 @@
   import UseSelectModal from './UseSelectModal.vue';
   import { userList, deleteUserRole, batchDeleteUserRole, addUserRole } from '../role.api';
   import { userColumns, searchUserFormSchema } from '../role.data';
-  import { getUserRoles } from '../../user/user.api';
+  import { getUserRoles,userComplexConditionTwo } from '../../user/user.api';
 
   const emit = defineEmits(['register', 'hideUserList']);
   const props = defineProps({
@@ -48,8 +48,10 @@
   
   const checkedKeys = ref<Array<string | number>>([]);
   const roleId = ref('');
+  const appId = ref('');
   const [registerBaseDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
     roleId.value = data.id;
+    appId.value = data.appId;
     setProps({ searchInfo: { roleId: data.id } });
     reload();
   });
@@ -59,7 +61,7 @@
   const [registerModal, { openModal }] = useModal();
   const [registerTable, { reload, updateTableDataRecord, setProps,getDataSource }] = useTable({
     title: '用户列表',
-    api: userList,
+    api: userComplexConditionTwo,
     columns: userColumns,
     formConfig: {
       //update-begin---author:wangshuai ---date:20230703  for:【QQYUN-5685】3、租户角色下,查询居左显示
@@ -67,8 +69,24 @@
       //update-end---author:wangshuai ---date:20230703  for:【QQYUN-5685】3、租户角色下,查询居左显示
       schemas: searchUserFormSchema,
       autoSubmitOnEnter: true,
-      showAdvancedButton: false,
-      showSubmitButton:false
+      baseColProps: {
+        xs: 24,
+        sm: 10,
+        md: 10,
+        lg: 10,
+        xl: 10,
+        xxl: 10,
+      },
+      actionColOptions: {
+        push: 3,
+        xs: 24,
+        sm: 8,
+        md: 8,
+        lg: 8,
+        xl: 8,
+        xxl: 8,
+      },
+
     },
     striped: true,
     useSearchForm: true,
@@ -162,7 +180,7 @@
   function handleSelect() {
     const list = getDataSource();
     console.log('list', list);
-    openModal(true,{list:list});
+    openModal(true,{list:list,appId:ref(appId)});
   }
   /**
    * 添加已有用户

+ 25 - 8
jeecgboot-vue3/src/views/system/role/components/UseSelectModal.vue

@@ -1,5 +1,5 @@
 <template>
-  <BasicModal v-bind="$attrs" @register="registerModal" title="用户选择列表" width="1000px" @ok="handleSubmit" destroyOnClose>
+  <BasicModal v-bind="$attrs" @register="registerModal" title="用户选择列表" width="900px" @ok="handleSubmit" destroyOnClose>
     <BasicTable @register="registerTable" :rowSelection="rowSelection" />
   </BasicModal>
 </template>
@@ -8,34 +8,51 @@ import { ref, unref, toRaw } from 'vue';
 import { BasicModal, useModalInner } from '/src/components/Modal';
 import { BasicTable, useTable, TableAction } from '/src/components/Table';
 import { userColumns, searchUsermodelSchema } from '../role.data';
-import { list } from '../../user/user.api';
+import { listNoCareTenant, userComplexConditionTwo } from '../../user/user.api';
 // 声明Emits
 const emit = defineEmits(['select', 'register']);
 const checkedKeys = ref<Array<string | number>>([]);
 const [registerModal, { setModalProps, closeModal }] = useModalInner((data) => {
   const list = data.list || [];
   checkedKeys.value = list.map((item) => item.id);
+  let appId = data.appId;
+  setProps({ searchInfo: { appId: appId ==='0'?null:data.appId } });
 });
 //注册table数据
-const [registerTable] = useTable({
-  api: list,
+const [registerTable, { setProps }] = useTable({
+  api: userComplexConditionTwo,
   rowKey: 'id',
   columns: userColumns,
   formConfig: {
-    labelWidth: 60,
     schemas: searchUsermodelSchema,
-    baseRowStyle: { maxHeight: '20px' },
     autoSubmitOnEnter: true,
-    showAdvancedButton: false,
-    // showSubmitButton:false
+    baseColProps: {
+      xs: 24,
+      sm: 10,
+      md: 10,
+      lg: 10,
+      xl: 10,
+      xxl: 10,
+    },
+    actionColOptions: {
+      push: 5,
+      xs: 24,
+      sm: 8,
+      md: 8,
+      lg: 8,
+      xl: 8,
+      xxl: 8,
+    },
   },
   striped: true,
+  size: 'small',
   useSearchForm: true,
   showTableSetting: false,
   bordered: true,
   showIndexColumn: false,
   canResize: false,
 });
+
 /**
  * 选择列配置
  */

+ 4 - 0
jeecgboot-vue3/src/views/system/role/role.api.ts

@@ -25,6 +25,7 @@ enum Api {
   saveRoleIndex = '/sys/sysRoleIndex/add',
   editRoleIndex = '/sys/sysRoleIndex/edit',
   queryIndexByCode = '/sys/sysRoleIndex/queryByCode',
+  addAppUserRoleInfos = '/sys/applicationInfo/addAppUserRoleInfos'
 }
 /**
  * 导出api
@@ -178,6 +179,9 @@ export const batchDeleteUser = (params) => {
  */
 export const addUserRole = (params, handleSuccess) => {
   return defHttp.post({ url: Api.addUserRole, params }).then(() => {
+    //同步更新应用用户关联表
+    console.log('添加成功啦');
+    // defHttp.post({ url: Api.addAppUserRoleInfos, params })
     handleSuccess();
   });
 };

+ 24 - 0
jeecgboot-vue3/src/views/system/role/role.data.ts

@@ -46,6 +46,7 @@ export const userColumns = [
     width: 80,
   },
 ];
+
 export const searchFormSchema: FormSchema[] = [
   {
     label: '应用',
@@ -87,6 +88,17 @@ export const searchUserFormSchema: FormSchema[] = [
     component: 'Input',
     colProps: { span: 14 },
   },
+  {
+    field: 'deptId',
+    label: '部门',
+    component: 'JSelectDept',
+    componentProps:{
+      labelKey:'departName',
+      multiple:false,
+      rowKey:'id'
+  },
+    colProps: { span: 15 },
+  },
 ];
 /**
  * 角色用户搜索form
@@ -98,12 +110,24 @@ export const searchUsermodelSchema: FormSchema[] = [
     component: 'Input',
     colProps: { span: 12 },
   },
+  {
+    field: 'deptId',
+    label: '部门',
+    component: 'JSelectDept',
+    componentProps:{
+      labelKey:'departName',
+      multiple:false,
+      rowKey:'id'
+  },
+    colProps: { span: 12, },
+  },
   {
     field: 'realname',
     label: '用户姓名',
     component: 'Input',
     colProps: { span: 12 },
   },
+  
 ];
 
 export const onCleanCode = (formRef: any) => {

+ 16 - 3
jeecgboot-vue3/src/views/system/user/user.api.ts

@@ -19,6 +19,7 @@ enum Api {
   deleteRecycleBin = '/sys/user/deleteRecycleBin',
   allRolesList = '/sys/role/queryall',
   allRolesListNoByTenant = '/sys/role/queryallNoByTenant',
+  queryallGroupByApp = '/sys/role/queryallGroupByApp', 
   allTenantList = '/sys/tenant/queryList',
   allPostList = '/sys/position/list',
   userDepartList = '/sys/user/userDepartList',
@@ -28,9 +29,10 @@ enum Api {
   userQuitAgent = '/sys/user/userQuitAgent',
   getQuitList = '/sys/user/getQuitList',
   putCancelQuit = '/sys/user/putCancelQuit',
-  updateUserTenantStatus='/sys/tenant/updateUserTenantStatus',
-  getUserTenantPageList='/sys/tenant/getUserTenantPageList',
-  getDeptList="/sys/sysDepart/listAll",
+  updateUserTenantStatus = '/sys/tenant/updateUserTenantStatus',
+  getUserTenantPageList = '/sys/tenant/getUserTenantPageList',
+  getDeptList = "/sys/sysDepart/listAll",
+  userComplexConditionTwo = '/sys/user/userComplexConditionTwo',
 }
 /**
  * 导出api
@@ -125,6 +127,11 @@ export const duplicateCheckDelay = (params) => {
  * @param params
  */
 export const getAllRolesList = (params) => defHttp.get({ url: Api.allRolesList, params });
+
+/**
+ * 获取全部角色(根据应用分组)
+ */
+export const queryallGroupByApp = () => defHttp.get({ url: Api.queryallGroupByApp });
 /**
  * 获取全部角色(不租户隔离)
  * @param params
@@ -253,3 +260,9 @@ export const exportUserList = (params) => {
 
   return defHttp.get({ url: Api.exportXls, params, responseType: 'blob' });
 };
+/**
+ * 用户复合查询2
+ */
+export const userComplexConditionTwo = (params) => {
+  return defHttp.post({ url: Api.userComplexConditionTwo, params });
+};