Ver código fonte

Merge remote-tracking branch 'origin/dev' into dev

LT32820A 2 meses atrás
pai
commit
28c2b86e3d
15 arquivos alterados com 238 adições e 18 exclusões
  1. 40 0
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysRoleController.java
  2. 36 0
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
  3. 2 1
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysRoleMapper.java
  4. 2 0
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java
  5. 8 0
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysRoleMapper.xml
  6. 30 0
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml
  7. 2 1
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysRoleService.java
  8. 5 0
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java
  9. 4 0
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysRoleServiceImpl.java
  10. 17 0
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
  11. 23 5
      jeecgboot-vue3/src/views/system/role/components/RoleUserTable.vue
  12. 25 8
      jeecgboot-vue3/src/views/system/role/components/UseSelectModal.vue
  13. 4 0
      jeecgboot-vue3/src/views/system/role/role.api.ts
  14. 24 0
      jeecgboot-vue3/src/views/system/role/role.data.ts
  15. 16 3
      jeecgboot-vue3/src/views/system/user/user.api.ts

+ 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;
+	}
 	
 	/**
 	  * 校验角色编码唯一

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

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.models.auth.In;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.catalina.User;
 import org.apache.commons.lang.StringUtils;
@@ -2018,5 +2019,40 @@ public class SysUserController {
         sysUserService.userComplexCondition(null,null,null, null, filteruserids, 1);
     }
 
+    /**
+     * 用户符合查询2
+     */
+//    @PostMapping("/userComplexConditionTwo")
+//    public Result<IPage<SysUser>> userComplexConditionTwo(
+//            @RequestParam(name = "roleId", required = false) String roleId,
+//            @RequestParam(name = "deptId", required = false) String deptId,
+//            @RequestParam(name = "appId", required = false) String appId,
+//            @RequestParam(name = "relName", required = false) String relName,
+//            @RequestParam(name = "username", required = false) String username,
+//            @RequestParam(name = "pageNo", required = false) Integer pageNo,
+//            @RequestParam(name = "pageSize", required = false) Integer pageSize) {
+//
+//        Result<IPage<SysUser>> iPageResult = sysUserService.userComplexConditionTwoService(roleId, deptId, appId, relName, username, pageNo, pageSize);
+//
+//        return iPageResult;
+//
+//
+//    }
+
+    @PostMapping("/userComplexConditionTwo")
+    public Result<IPage<SysUser>> userComplexConditionTwo(@RequestBody Map<String, String> requestParam) {
+        String roleId = requestParam.get("roleId");
+        String deptId = requestParam.get("deptId");
+        String appId = requestParam.get("appId");
+        String relName = requestParam.get("realname");
+        String username = requestParam.get("username");
+        String pageNo = requestParam.get("pageNo");
+        String pageSize = requestParam.get("pageSize");
+        Result<IPage<SysUser>> iPageResult = sysUserService.userComplexConditionTwoService(roleId, deptId, appId, relName, username, pageNo, pageSize);
+        return iPageResult;
+
+
+    }
+
 
 }

+ 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();
     /**
      * 查询角色是否存在不做租户隔离
      *

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

@@ -248,4 +248,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
 	List<Map<String, Object>> userComplexCondition(@Param("userIds") List<String> userIds, @Param("usernames") List<String> usernames, @Param("relNames") List<String> relNames, @Param("deptIds") List<String> deptIds, @Param("filteruserids") List<String> filteruserids,@Param("offset") Integer offset, @Param("pageNo") Integer pageNo);
 
 	Integer userComplexConditionTotal(@Param("userIds") List<String> userIds, @Param("usernames") List<String> usernames, @Param("relNames") List<String> relNames, @Param("deptIds") List<String> deptIds, @Param("filteruserids") List<String> filteruserids,@Param("offset") Integer offset, @Param("pageNo") Integer pageNo);
+
+	Page<SysUser> userComplexConditionTwoMapper(@Param("page") Page<SysUser> page,@Param("roleId") String roleId,@Param("deptId") String deptId,@Param("appId") String appId,@Param("relName") String relName,@Param("username") String username);
 }

+ 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">

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

@@ -403,5 +403,35 @@
 		</if>
 	</select>
 
+	<select id="userComplexConditionTwoMapper" resultType="org.jeecg.modules.system.entity.SysUser">
+		SELECT
+		DISTINCT
+			su.*
+		FROM
+			sys_user AS su
+				LEFT JOIN sys_user_depart AS sud ON su.id = sud.user_id
+				LEFT JOIN sys_user_role AS sur ON su.id = sur.user_id
+				LEFT JOIN app_user_info AS aui ON aui.userid = su.id
+				LEFT JOIN sys_depart AS sd ON sud.dep_id = sd.id
+				LEFT JOIN sys_role AS sr ON sur.role_id = sr.id
+		WHERE
+		  1 = 1
+		  <if test="roleId != null">
+			AND sr.id = #{roleId}
+		  </if>
+		  <if test="deptId != null">
+			AND sd.id = #{deptId}
+		  </if>
+		  <if test="appId != null">
+		  	AND aui.appid = #{appId}
+		  </if>
+		  <if test="username != null">
+			AND su.username LIKE concat('%',#{username},'%')
+		  </if>
+		  <if test="relName != null">
+			AND su.realname LIKE concat('%',#{relName},'%')
+		  </if>
+	</select>
+
 
 </mapper>

+ 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();
     /**
      * 查询角色是否存在不做租户隔离
      *

+ 5 - 0
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import io.swagger.models.auth.In;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.system.vo.SysUserCacheInfo;
@@ -472,4 +473,8 @@ public interface ISysUserService extends IService<SysUser> {
 	 */
 	List<Map<String, Object>> userComplexCondition(List<String> userIds, List<String> usernames, List<String> relNames, List<String> deptIds, List<String> filteruserids, Integer pageNo);
 
+	/**
+	 * 用户复合查询2
+	 */
+	Result<IPage<SysUser>> userComplexConditionTwoService(String roleId, String deptId, String appId, String relName, String username, String pageNo, String pageSize);
 }

+ 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) {

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

@@ -2267,4 +2267,21 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 		Page<SysUser> sysUserPage = userMapper.selectPage(page, sysUserQueryWrapper);
 		return sysUserPage;
 	}
+
+
+	@Override
+	public Result<IPage<SysUser>> userComplexConditionTwoService(String roleId, String deptId, String appId, String relName, String username, String pageNo, String pageSize) {
+		Page<SysUser> sysUserPage = new Page<>();
+		if (pageNo != null) {
+			sysUserPage.setCurrent(Long.parseLong(pageNo));
+		}
+		if (pageSize != null) {
+			sysUserPage.setSize(Long.parseLong(pageSize));
+		}
+		Page<SysUser> sysUserPageList = userMapper.userComplexConditionTwoMapper(sysUserPage, roleId, deptId, appId, relName, username);
+		Result<IPage<SysUser>> result = new Result<>();
+		result.setSuccess(true);
+		result.setResult(sysUserPageList);
+		return result;
+	}
 }

+ 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 });
+};