diff --git a/snowy-admin-web/package.json b/snowy-admin-web/package.json index be827e55..71828d0a 100644 --- a/snowy-admin-web/package.json +++ b/snowy-admin-web/package.json @@ -27,7 +27,7 @@ "@vue-office/docx": "1.6.2", "@vue-office/excel": "1.7.11", "@vue-office/pdf": "2.0.2", - "ant-design-vue": "4.2.5", + "ant-design-vue": "4.2.6", "axios": "1.7.7", "cropperjs": "1.6.2", "dayjs": "1.11.13", @@ -48,7 +48,7 @@ "snowflake-id": "1.1.0", "sortablejs": "1.15.3", "tinymce": "7.3.0", - "vue": "3.5.10", + "vue": "3.5.13", "vue-cropper": "1.1.4", "vue-i18n": "10.0.0", "vue-router": "4.4.5", @@ -57,7 +57,7 @@ "vuedraggable-es": "4.1.1" }, "devDependencies": { - "@babel/eslint-parser": "7.19.1", + "@babel/eslint-parser": "7.25.9", "@vitejs/plugin-legacy": "6.0.0", "@vitejs/plugin-vue": "5.2.1", "@vitejs/plugin-vue-jsx": "4.1.1", @@ -65,10 +65,10 @@ "@vue/eslint-config-standard": "8.0.1", "antd-less-to-css-variable": "1.0.5", "autoprefixer": "10.4.20", - "eslint": "8.57.0", + "eslint": "8.57.1", "eslint-config-prettier": "9.1.0", - "eslint-plugin-prettier": "5.0.1", - "eslint-plugin-vue": "9.7.0", + "eslint-plugin-prettier": "5.2.1", + "eslint-plugin-vue": "9.32.0", "less": "4.2.0", "postcss": "8.4.47", "prettier": "3.3.3", diff --git a/snowy-admin-web/src/api/sys/userCenterApi.js b/snowy-admin-web/src/api/sys/userCenterApi.js index e66105ce..b60485cb 100644 --- a/snowy-admin-web/src/api/sys/userCenterApi.js +++ b/snowy-admin-web/src/api/sys/userCenterApi.js @@ -98,6 +98,10 @@ export default { userCenterGetRoleListByIdList(data) { return request('getRoleListByIdList', data) }, + // 根据id集合获取用户组集合 + userCenterGetGroupListByIdList(data) { + return request('getGroupListByIdList', data) + }, // 根据id获取头像 userCenterGtAvatarById(data) { return request('getAvatarById', data) diff --git a/snowy-admin-web/src/components/XnGroupSelector/index.vue b/snowy-admin-web/src/components/XnGroupSelector/index.vue new file mode 100644 index 00000000..28d4bf8a --- /dev/null +++ b/snowy-admin-web/src/components/XnGroupSelector/index.vue @@ -0,0 +1,486 @@ + + + + + diff --git a/snowy-admin-web/src/components/XnOrgSelector/index.vue b/snowy-admin-web/src/components/XnOrgSelector/index.vue index c5df64e0..e9493e8f 100644 --- a/snowy-admin-web/src/components/XnOrgSelector/index.vue +++ b/snowy-admin-web/src/components/XnOrgSelector/index.vue @@ -172,6 +172,10 @@ type: Boolean, default: () => false }, + selectorConverterKey: { + type: String, + default: () => 'ORG' + }, orgTreeApi: { type: Function }, @@ -502,7 +506,7 @@ value = value + data[i].id + ',' } } - obj.key = 'ORG' + obj.key = props.selectorConverterKey obj.label = label obj.value = value obj.extJson = '' @@ -548,6 +552,9 @@ const ids = goDataConverter(newValue) recordIds.value = ids getDataNameById(ids) + } else { + dataArray.value = [] + selectedData.value = [] } }, { diff --git a/snowy-admin-web/src/components/XnPositionSelector/index.vue b/snowy-admin-web/src/components/XnPositionSelector/index.vue index 81aa5875..2c645f9c 100644 --- a/snowy-admin-web/src/components/XnPositionSelector/index.vue +++ b/snowy-admin-web/src/components/XnPositionSelector/index.vue @@ -548,6 +548,9 @@ const ids = goDataConverter(newValue) recordIds.value = ids getDataNameById(ids) + } else { + dataArray.value = [] + selectedData.value = [] } }, { diff --git a/snowy-admin-web/src/components/XnRoleSelector/index.vue b/snowy-admin-web/src/components/XnRoleSelector/index.vue index 86c55279..0226ae07 100644 --- a/snowy-admin-web/src/components/XnRoleSelector/index.vue +++ b/snowy-admin-web/src/components/XnRoleSelector/index.vue @@ -576,6 +576,9 @@ const ids = goDataConverter(newValue) recordIds.value = ids getDataNameById(ids) + } else { + dataArray.value = [] + selectedData.value = [] } }, { diff --git a/snowy-admin-web/src/components/XnUserSelector/index.vue b/snowy-admin-web/src/components/XnUserSelector/index.vue index 3c6cb356..e2cb610a 100644 --- a/snowy-admin-web/src/components/XnUserSelector/index.vue +++ b/snowy-admin-web/src/components/XnUserSelector/index.vue @@ -556,6 +556,9 @@ const ids = goDataConverter(newValue) recordIds.value = ids getUserAvatarById(ids) + } else { + userObj.value = [] + selectedData.value = [] } }, { diff --git a/snowy-plugin-api/snowy-plugin-sys-api/src/main/java/vip/xiaonuo/sys/api/SysGroupApi.java b/snowy-plugin-api/snowy-plugin-sys-api/src/main/java/vip/xiaonuo/sys/api/SysGroupApi.java index 75a1bbe8..99131e21 100644 --- a/snowy-plugin-api/snowy-plugin-sys-api/src/main/java/vip/xiaonuo/sys/api/SysGroupApi.java +++ b/snowy-plugin-api/snowy-plugin-sys-api/src/main/java/vip/xiaonuo/sys/api/SysGroupApi.java @@ -12,24 +12,26 @@ */ package vip.xiaonuo.sys.api; +import cn.hutool.json.JSONObject; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + import java.util.List; /** - * 用户Api + * 用户组Api * * @author xuyuxiang * @date 2022/6/6 11:33 **/ public interface SysGroupApi { - /** * 获取用户组拥有人员 * * @author xuyuxiang * @date 2022/5/13 21:00 */ - List ownUser(String userId); + List ownUser(String groupId); /** * 给用户组授权用户 @@ -38,4 +40,12 @@ public interface SysGroupApi { * @date 2022/8/1 18:28 */ void grantUser(String groupId, List userIdList); + + /** + * 获取用户组选择器 + * + * @author yubaoshan + * @date 2025/1/12 02:36 + */ + Page groupSelector(String searchKey, int current, int size); } diff --git a/snowy-plugin-api/snowy-plugin-sys-api/src/main/java/vip/xiaonuo/sys/api/SysRelationApi.java b/snowy-plugin-api/snowy-plugin-sys-api/src/main/java/vip/xiaonuo/sys/api/SysRelationApi.java index fbe2fc2d..8a639b4f 100644 --- a/snowy-plugin-api/snowy-plugin-sys-api/src/main/java/vip/xiaonuo/sys/api/SysRelationApi.java +++ b/snowy-plugin-api/snowy-plugin-sys-api/src/main/java/vip/xiaonuo/sys/api/SysRelationApi.java @@ -30,6 +30,14 @@ public interface SysRelationApi { **/ List getUserIdListByRoleIdList(List roleIdList); + /** + * 根据用户组id集合获取用户组下用户id集合 + * + * @author xuyuxiang + * @date 2022/6/6 11:43 + **/ + List getUserIdListByGroupIdList(List groupIdList); + /** * 根据移动端菜单Id集合移除角色和移动端菜单关系 * diff --git a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/param/SysGroupSelectorParam.java b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/param/SysGroupSelectorParam.java new file mode 100644 index 00000000..8b13dfa8 --- /dev/null +++ b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/param/SysGroupSelectorParam.java @@ -0,0 +1,40 @@ +/* + * Copyright [2022] [https://www.xiaonuo.vip] + * + * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + * + * 1.请不要删除和修改根目录下的LICENSE文件。 + * 2.请不要删除和修改Snowy源码头部的版权声明。 + * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。 + * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip + * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。 + * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip + */ +package vip.xiaonuo.sys.modular.group.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; + +/** + * 用户组选择器参数 + * + * @author yubaoshan + * @date 2025/1/12 02:36 + **/ +@Getter +@Setter +public class SysGroupSelectorParam { + + /** 当前页 */ + @Schema(description = "当前页码") + private Integer current; + + /** 每页条数 */ + @Schema(description = "每页条数") + private Integer size; + + /** 姓名关键词 */ + @Schema(description = "姓名关键词") + private String searchKey; +} diff --git a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/provider/SysGroupApiProvider.java b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/provider/SysGroupApiProvider.java index 00188fe7..7cfaed6b 100644 --- a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/provider/SysGroupApiProvider.java +++ b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/provider/SysGroupApiProvider.java @@ -12,11 +12,15 @@ */ package vip.xiaonuo.sys.modular.group.provider; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.json.JSONObject; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import vip.xiaonuo.sys.api.SysGroupApi; import vip.xiaonuo.sys.modular.group.param.SysGroupGrantUserParam; import vip.xiaonuo.sys.modular.group.param.SysGroupIdParam; +import vip.xiaonuo.sys.modular.group.param.SysGroupSelectorParam; import vip.xiaonuo.sys.modular.group.service.SysGroupService; import java.util.List; @@ -46,4 +50,14 @@ public class SysGroupApiProvider implements SysGroupApi { sysGroupGrantUserParam.setGrantInfoList(userIdList); sysGroupService.grantUser(sysGroupGrantUserParam); } + + @SuppressWarnings("ALL") + @Override + public Page groupSelector(String searchKey, int current, int size) { + SysGroupSelectorParam sysGroupSelectorParam = new SysGroupSelectorParam(); + sysGroupSelectorParam.setCurrent(current); + sysGroupSelectorParam.setSize(size); + sysGroupSelectorParam.setSearchKey(searchKey); + return BeanUtil.toBean(sysGroupService.groupSelector(sysGroupSelectorParam), Page.class); + } } diff --git a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/service/SysGroupService.java b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/service/SysGroupService.java index dddb583b..bc3a2a1b 100644 --- a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/service/SysGroupService.java +++ b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/service/SysGroupService.java @@ -108,4 +108,12 @@ public interface SysGroupService extends IService { * @date 2024/12/21 01:25 */ void grantUser(SysGroupGrantUserParam sysGroupGrantUserParam); + + /** + * 获取用户组选择器 + * + * @author yubaoshan + * @date 2024/12/21 01:25 + */ + Page groupSelector(SysGroupSelectorParam sysGroupSelectorParam); } diff --git a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/service/impl/SysGroupServiceImpl.java b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/service/impl/SysGroupServiceImpl.java index d1c27fdf..43194d38 100644 --- a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/service/impl/SysGroupServiceImpl.java +++ b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/group/service/impl/SysGroupServiceImpl.java @@ -171,4 +171,19 @@ public class SysGroupServiceImpl extends ServiceImpl i return sysRelation; }).collect(Collectors.toList())); } + + @Override + public Page groupSelector(SysGroupSelectorParam sysGroupSelectorParam) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + // 只查询部分字段,排掉extJson + lambdaQueryWrapper.select(SysGroup::getId, SysGroup::getName, SysGroup::getSortCode, SysGroup::getRemark); + lambdaQueryWrapper.orderByAsc(SysGroup::getSortCode); + // 如果查询条件为空,则直接查询 + if (!ObjectUtil.isAllEmpty(sysGroupSelectorParam.getSearchKey())) { + if (ObjectUtil.isNotEmpty(sysGroupSelectorParam.getSearchKey())) { + lambdaQueryWrapper.like(SysGroup::getName, sysGroupSelectorParam.getSearchKey()); + } + } + return this.page(CommonPageRequest.defaultPage(), lambdaQueryWrapper); + } } diff --git a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/relation/provider/SysRelationApiProvider.java b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/relation/provider/SysRelationApiProvider.java index aee8022f..465e16c3 100644 --- a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/relation/provider/SysRelationApiProvider.java +++ b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/relation/provider/SysRelationApiProvider.java @@ -47,6 +47,12 @@ public class SysRelationApiProvider implements SysRelationApi { SysRelationCategoryEnum.SYS_USER_HAS_ROLE.getValue()); } + @Override + public List getUserIdListByGroupIdList(List groupIdList) { + return sysRelationService.getRelationObjectIdListByTargetIdListAndCategory(groupIdList, + SysRelationCategoryEnum.SYS_USER_HAS_GROUP.getValue()); + } + @Override public void removeRoleHasMobileMenuRelation(List targetIdList) { sysRelationService.remove(new LambdaQueryWrapper().in(SysRelation::getTargetId, targetIdList) diff --git a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/controller/SysUserCenterController.java b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/controller/SysUserCenterController.java index c46c62d1..fab0d88e 100644 --- a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/controller/SysUserCenterController.java +++ b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/controller/SysUserCenterController.java @@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import vip.xiaonuo.common.annotation.CommonLog; import vip.xiaonuo.common.pojo.CommonResult; +import vip.xiaonuo.sys.modular.group.entity.SysGroup; import vip.xiaonuo.sys.modular.org.entity.SysOrg; import vip.xiaonuo.sys.modular.position.entity.SysPosition; import vip.xiaonuo.sys.modular.role.entity.SysRole; @@ -325,4 +326,28 @@ public class SysUserCenterController { public CommonResult> getRoleListByIdList(@RequestBody @Valid SysUserIdListParam sysUserIdListParam) { return CommonResult.data(sysUserService.getRoleListByIdList(sysUserIdListParam)); } + + /** + * 根据id集合获取用户组集合 + * + * @author xuyuxiang + * @date 2022/4/24 20:00 + */ + @Operation(summary = "根据id集合获取用户组集合") + @PostMapping("/sys/userCenter/getGroupListByIdList") + public CommonResult> getGroupListByIdList(@RequestBody @Valid SysUserGroupIdListParam sysUserGroupIdListParam) { + return CommonResult.data(sysUserService.getGroupListByIdList(sysUserGroupIdListParam)); + } + + /** + * 根据id获取头像 + * + * @author xuyuxiang + * @date 2022/4/24 20:00 + */ + @Operation(summary = "根据id获取头像") + @PostMapping("/sys/userCenter/getAvatarById") + public CommonResult getAvatarById(@RequestBody @javax.validation.Valid SysUserIdParam sysUserIdParam) { + return CommonResult.data(sysUserService.getAvatarById(sysUserIdParam)); + } } diff --git a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/param/SysUserGroupIdListParam.java b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/param/SysUserGroupIdListParam.java new file mode 100644 index 00000000..56366a86 --- /dev/null +++ b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/param/SysUserGroupIdListParam.java @@ -0,0 +1,36 @@ +/* + * Copyright [2022] [https://www.xiaonuo.vip] + * + * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + * + * 1.请不要删除和修改根目录下的LICENSE文件。 + * 2.请不要删除和修改Snowy源码头部的版权声明。 + * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。 + * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip + * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。 + * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip + */ +package vip.xiaonuo.sys.modular.user.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * 用户组id集合参数 + * + * @author yubaoshan + * @date 2025/1/12 02:36 + **/ +@Getter +@Setter +public class SysUserGroupIdListParam { + + /** id集合 */ + @Schema(description = "id集合") + @NotNull(message = "idList不能为空") + private List idList; +} diff --git a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/service/SysUserService.java b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/service/SysUserService.java index 8e214db4..09617a68 100644 --- a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/service/SysUserService.java +++ b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/service/SysUserService.java @@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import jakarta.servlet.http.HttpServletResponse; import org.springframework.web.multipart.MultipartFile; +import vip.xiaonuo.sys.modular.group.entity.SysGroup; import vip.xiaonuo.sys.modular.org.entity.SysOrg; import vip.xiaonuo.sys.modular.position.entity.SysPosition; import vip.xiaonuo.sys.modular.role.entity.SysRole; @@ -470,6 +471,14 @@ public interface SysUserService extends IService { **/ List getPositionListByIdList(SysUserIdListParam sysUserIdListParam); + /** + * 根据id集合获取用户组集合 + * + * @author yubaoshan + * @date 2025/1/12 02:36 + */ + List getGroupListByIdList(SysUserGroupIdListParam sysUserGroupIdListParam); + /** * 根据id集合获取角色集合 * diff --git a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/service/impl/SysUserServiceImpl.java b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/service/impl/SysUserServiceImpl.java index 04a28c1e..71963542 100644 --- a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/service/impl/SysUserServiceImpl.java +++ b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/user/service/impl/SysUserServiceImpl.java @@ -79,6 +79,8 @@ import vip.xiaonuo.mobile.api.MobileButtonApi; import vip.xiaonuo.mobile.api.MobileMenuApi; import vip.xiaonuo.sys.core.enums.SysBuildInEnum; import vip.xiaonuo.sys.core.enums.SysDataTypeEnum; +import vip.xiaonuo.sys.modular.group.entity.SysGroup; +import vip.xiaonuo.sys.modular.group.service.SysGroupService; import vip.xiaonuo.sys.modular.org.entity.SysOrg; import vip.xiaonuo.sys.modular.org.service.SysOrgService; import vip.xiaonuo.sys.modular.position.entity.SysPosition; @@ -174,6 +176,9 @@ public class SysUserServiceImpl extends ServiceImpl impl @Resource private MobileButtonApi mobileButtonApi; + @Resource + private SysGroupService sysGroupService; + @Override public SysLoginUser getUserById(String id) { SysUser sysUser = this.getById(id); @@ -1565,6 +1570,18 @@ public class SysUserServiceImpl extends ServiceImpl impl return sysPositionService.list(lambdaQueryWrapper); } + @Override + public List getGroupListByIdList(SysUserGroupIdListParam sysUserGroupIdListParam) { + if (ObjectUtil.isEmpty(sysUserGroupIdListParam.getIdList())) { + return CollectionUtil.newArrayList(); + } + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + // 查询部分字段 + lambdaQueryWrapper.select(SysGroup::getId, SysGroup::getName, SysGroup::getRemark, SysGroup::getSortCode) + .in(SysGroup::getId, sysUserGroupIdListParam.getIdList()).orderByAsc(SysGroup::getSortCode); + return sysGroupService.list(lambdaQueryWrapper); + } + @Override public List getRoleListByIdList(SysUserIdListParam sysUserIdListParam) { if (ObjectUtil.isEmpty(sysUserIdListParam.getIdList())) {