From fecc3fc5a1d7022f8136cbe8b81244e080140b4c Mon Sep 17 00:00:00 2001 From: Vinjor Date: Sat, 26 Oct 2024 16:07:35 +0800 Subject: [PATCH] 1 --- .../cn/iocoder/yudao/common/RepairCons.java | 2 + .../module/base/entity/RepairWorker.java | 7 ++ .../service/impl/RepairWorkerServiceImpl.java | 25 +++- .../app/ApiRepairBookingController.java | 57 +++++++++ .../booking/entity/DlRepairBooking.java | 6 +- .../service/DlRepairBookingService.java | 19 +++ .../impl/DlRepairBookingServiceImpl.java | 116 +++++++++++++++++- .../yudao/module/booking/vo/BookingVO.java | 22 ++++ .../module/system/api/permission/RoleApi.java | 7 ++ .../system/api/permission/RoleApiImpl.java | 13 +- .../dal/mysql/permission/UserRoleMapper.java | 3 + .../service/permission/RoleService.java | 11 +- .../service/permission/RoleServiceImpl.java | 18 ++- .../main/resources/mapper/UserRoleMapper.xml | 22 ++++ 14 files changed, 316 insertions(+), 12 deletions(-) create mode 100644 dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/controller/app/ApiRepairBookingController.java create mode 100644 dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/vo/BookingVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/UserRoleMapper.xml diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/common/RepairCons.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/common/RepairCons.java index c1c3a3b7..3efdec5f 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/common/RepairCons.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/common/RepairCons.java @@ -18,4 +18,6 @@ public class RepairCons { public static final String DICT_REPAIR_TYPE = "repair_type"; /**数据字典常量-repair_unit-*/ public static final String DICT_REPAIR_UNIT = "repair_unit"; + /**数据字典常量-repair_unit-*/ + public static final String DICT_REPAIR_WORK_TYPE = "repair_work_type"; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/entity/RepairWorker.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/entity/RepairWorker.java index 196a01ce..1e838b07 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/entity/RepairWorker.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/entity/RepairWorker.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.base.entity; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; @@ -46,4 +47,10 @@ public class RepairWorker extends TenantBaseDO { */ private String remark; + /** + * 工种字典翻译 + */ + @TableField(exist = false) + private String workTypeText; + } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java index 3fc5a4dd..3c96809e 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairWorkerServiceImpl.java @@ -11,9 +11,10 @@ import cn.iocoder.yudao.module.base.service.RepairWorkerService; import cn.iocoder.yudao.module.base.vo.RepairWorkerPageReqVO; import cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO; import cn.iocoder.yudao.module.base.vo.RepairWorkerSaveReqVO; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; +import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem; import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService; @@ -32,6 +33,7 @@ import java.util.*; import java.util.stream.Collectors; import static cn.iocoder.yudao.common.BaseConstants.TICKET_EMPLOY; +import static cn.iocoder.yudao.common.RepairCons.DICT_REPAIR_WORK_TYPE; /** * 维修工人 Service 实现类 @@ -53,7 +55,7 @@ public class RepairWorkerServiceImpl extends ServiceImpl queryListPage(RepairWorkerPageReqVO pageReqVO, Page page) { - return workerMapper.queryListPage(pageReqVO, page); + IPage respVOIPage= workerMapper.queryListPage(pageReqVO, page); + if(!respVOIPage.getRecords().isEmpty()){ + // 单位字典 + List recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_WORK_TYPE); + Map typeMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel)); + respVOIPage.getRecords().stream().peek(item->item.setWorkTypeText(typeMap.get(item.getWorkType()))).collect(Collectors.toList()); + } + return respVOIPage; } /** @@ -133,7 +142,15 @@ public class RepairWorkerServiceImpl extends ServiceImpl ids = titems.stream().flatMap(item -> Arrays.stream(item.getRepairIds().split(","))).collect(Collectors.toSet()); - return baseMapper.selectList(new LambdaQueryWrapper().in(RepairWorker::getUserId, ids)); + List repairWorkerList = baseMapper.selectList(new LambdaQueryWrapper().in(RepairWorker::getUserId, ids)); + if(!repairWorkerList.isEmpty()){ + // 单位字典 + List recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_WORK_TYPE); + Map typeMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel)); + repairWorkerList.stream().peek(item->item.setWorkTypeText(typeMap.get(item.getWorkType()))).collect(Collectors.toList()); + } + //翻译工种 + return repairWorkerList; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/controller/app/ApiRepairBookingController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/controller/app/ApiRepairBookingController.java new file mode 100644 index 00000000..0a397dae --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/controller/app/ApiRepairBookingController.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.booking.controller.app; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.booking.service.DlRepairBookingService; +import io.swagger.v3.oas.annotations.Operation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +/** + * 小程序端维修预约控制层 + * @author vinjor-M + * @date 14:25 2024/10/26 +**/ +@RestController +@RequestMapping("/repair/booking") +public class ApiRepairBookingController { + /** + * 服务对象 + */ + @Resource + private DlRepairBookingService dlRepairBookingService; + + + /** + * 获取可以预约的时间 --小程序用 + * @author vinjor-M + * @date 15:03 2024/10/26 + * @param tenantId 租户ID + * @return cn.iocoder.yudao.framework.common.pojo.CommonResult + **/ + @GetMapping("/getBookingTime") + @Operation(summary = "获取可以预约的时间") + public CommonResult getBookingTime(@RequestParam("tenantId") Long tenantId){ + return success(dlRepairBookingService.getBookingTime(tenantId)); + } + + /** + * 获取所有服务顾问 + * @author vinjor-M + * @date 15:03 2024/10/26 + * @param tenantId 租户ID + * @return cn.iocoder.yudao.framework.common.pojo.CommonResult + **/ + @GetMapping("/getAllServicer") + @Operation(summary = "获取所有服务顾问") + public CommonResult getAllServicer(@RequestParam("tenantId") Long tenantId){ + return success(dlRepairBookingService.getAllServicer(tenantId)); + } + +} + diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/entity/DlRepairBooking.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/entity/DlRepairBooking.java index 03719d26..0f00d431 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/entity/DlRepairBooking.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/entity/DlRepairBooking.java @@ -7,10 +7,8 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; -import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; -import java.util.Date; /** * 维修预约表 @@ -60,6 +58,10 @@ public class DlRepairBooking extends TenantBaseDO { /** 工单ID */ private String ticketsId; + /** 服务顾问ID(system_users表的ID) */ + private String adviserId; + /** 服务顾问名字(system_user表的nickname) */ + private String adviserName; /** * 预约时间 diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/service/DlRepairBookingService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/service/DlRepairBookingService.java index 9b9e88d9..a71e7108 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/service/DlRepairBookingService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/service/DlRepairBookingService.java @@ -2,8 +2,10 @@ package cn.iocoder.yudao.module.booking.service; import cn.iocoder.yudao.module.app.booking.vo.BookingQueryVO; import cn.iocoder.yudao.module.booking.entity.DlRepairBooking; +import cn.iocoder.yudao.module.booking.vo.BookingVO; import cn.iocoder.yudao.module.booking.vo.DlRepairBookingReqVO; import cn.iocoder.yudao.module.booking.vo.DlRepairBookingRespVO; +import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; @@ -62,4 +64,21 @@ public interface DlRepairBookingService extends IService { * @param ids 预约记录ID **/ List getBookingMap(List ids); + + /** + * + * @author vinjor-M + * @date 15:03 2024/10/26 + * @param tenantId 租户ID + * @return java.util.List + **/ + List getBookingTime(Long tenantId); + + /** + * 获取所有服务顾问 + * @author vinjor-M + * @date 15:52 2024/10/26 + * @param tenantId 租户ID + **/ + List getAllServicer(Long tenantId); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/service/impl/DlRepairBookingServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/service/impl/DlRepairBookingServiceImpl.java index c96bd79a..2ffa989d 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/service/impl/DlRepairBookingServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/service/impl/DlRepairBookingServiceImpl.java @@ -2,22 +2,28 @@ package cn.iocoder.yudao.module.booking.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.date.DateUtil; +import cn.iocoder.yudao.common.RepairRoleEnum; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; import cn.iocoder.yudao.module.app.booking.vo.BookingQueryVO; import cn.iocoder.yudao.module.booking.entity.DlRepairBooking; import cn.iocoder.yudao.module.booking.mapper.DlRepairBookingMapper; import cn.iocoder.yudao.module.booking.service.DlRepairBookingService; +import cn.iocoder.yudao.module.booking.vo.BookingVO; import cn.iocoder.yudao.module.booking.vo.DlRepairBookingReqVO; import cn.iocoder.yudao.module.booking.vo.DlRepairBookingRespVO; import cn.iocoder.yudao.module.company.entity.Company; import cn.iocoder.yudao.module.company.service.CompanyService; +import cn.iocoder.yudao.module.system.api.permission.RoleApi; import cn.iocoder.yudao.module.system.api.service.ServicePackageApi; import cn.iocoder.yudao.module.system.api.service.dto.ServicePackageDto; +import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -25,8 +31,6 @@ import javax.annotation.Resource; import java.util.*; import java.util.stream.Collectors; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; - /** * 针对表【dl_repair_booking(维修预约表)】的数据库操作Service实现 * @@ -44,6 +48,8 @@ public class DlRepairBookingServiceImpl extends ServiceImpl + * @author vinjor-M + * @date 15:03 2024/10/26 + **/ + @Override + @TenantIgnore + public List getBookingTime(Long tenantId) { + Date nowDate = new Date(); + String[] timeList = "09:00,11:00,14:00,15:00,16:00,17:00".split(","); + List rtnList = new ArrayList<>(); + //先遍历日期 + for (int i = 0; i < 7; i++) { + BookingVO thisDay = new BookingVO(); + List timeVoList = new ArrayList<>(); + if(i==0){ + //今天 + String dayStr = DateUtil.formatDate(nowDate); + //周几 + int weekDay = DateUtil.dayOfWeek(nowDate); + System.out.println(dayStr.substring(5)); + thisDay.setDate(dayStr.substring(5)); + thisDay.setTitle(this.changeWeek(weekDay)); + thisDay.setDisabled(false); + //遍历时间 + for (String timeStr:timeList){ + BookingVO thisTime = new BookingVO(); + thisTime.setDate(timeStr); + //拼接时间 + String timeDateStr = dayStr+" "+timeStr+":00"; + //转时间戳,比对大小 + Date timeDate = DateUtil.parseDateTime(timeDateStr); + int compareResult = DateUtil.compare(nowDate, timeDate); + //nowDate 在 timeDate 之前,可以预约,否则不能预约 + thisTime.setDisabled(compareResult >= 0); + timeVoList.add(thisTime); + } + }else{ + //往后6天,每天、每个时间都能预约 + Date thisDate = DateUtil.offsetDay(nowDate, i); + String dayStr = DateUtil.formatDate(thisDate); + //周几 + int weekDay = DateUtil.dayOfWeek(thisDate); + thisDay.setDate(dayStr.substring(5)); + thisDay.setTitle(this.changeWeek(weekDay)); + thisDay.setDisabled(false); + //遍历时间 + for (String timeStr:timeList){ + BookingVO thisTime = new BookingVO(); + thisTime.setDate(timeStr); + thisTime.setDisabled(false); + timeVoList.add(thisTime); + } + } + thisDay.setTimeList(timeVoList); + rtnList.add(thisDay); + } + return rtnList; + } + + private String changeWeek(int weekNum){ + String weekStr=""; + switch (weekNum){ + case 1: + weekStr = "周日"; + break; + case 2: + weekStr = "周一"; + break; + case 3: + weekStr = "周二"; + break; + case 4: + weekStr = "周三"; + break; + case 5: + weekStr = "周四"; + break; + case 6: + weekStr = "周五"; + break; + case 7: + weekStr = "周六"; + break; + default: + break; + } + return weekStr; + } + + /** + * 获取所有服务顾问 + * + * @param tenantId 租户ID + * @return java.util.List + * @author vinjor-M + * @date 15:52 2024/10/26 + **/ + @Override + public List getAllServicer(Long tenantId) { + return roleApi.selectUserListByRoleCode(tenantId, RepairRoleEnum.ADVISOR.getCode()); + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/vo/BookingVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/vo/BookingVO.java new file mode 100644 index 00000000..4a7c534c --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/booking/vo/BookingVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.booking.vo; + +import lombok.Data; + +import java.util.List; + +/** + * 可预约日期和时间通用实体 + * @author vinjor-M + * @date 14:52 2024/10/26 +**/ +@Data +public class BookingVO { + /** 日期或时间 */ + private String date; + /** 周几 */ + private String title; + /** 是否可选 */ + private Boolean disabled; + /** 可选时间 */ + List timeList; +} diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApi.java index e843d1e5..28280248 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApi.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.system.api.permission; import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; +import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; import java.util.Collection; import java.util.List; @@ -33,4 +34,10 @@ public interface RoleApi { **/ RoleReqDTO getRoleInfo(String code); + /** + * 查询某个角色的用户 + * @author zcy + **/ + List selectUserListByRoleCode(Long tenantId,String code); + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApiImpl.java index c8e5e91c..3482f0a0 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApiImpl.java @@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.system.api.permission; import cn.hutool.core.bean.BeanUtil; import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; +import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; import cn.iocoder.yudao.module.system.service.permission.RoleService; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -53,4 +53,15 @@ public class RoleApiImpl implements RoleApi { roleReqDTO.setName(roleDO.getName()); return roleReqDTO; } + + /** + * 查询某个角色的用户 + * + * @param code + * @author zcy + */ + @Override + public List selectUserListByRoleCode(Long tenantId,String code) { + return roleService.selectByRoleCode(tenantId,code); + } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/UserRoleMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/UserRoleMapper.java index 12ff88a0..9b8f872a 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/UserRoleMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/UserRoleMapper.java @@ -1,9 +1,11 @@ package cn.iocoder.yudao.module.system.dal.mysql.permission; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.Collection; import java.util.List; @@ -33,4 +35,5 @@ public interface UserRoleMapper extends BaseMapperX { return selectList(UserRoleDO::getRoleId, roleIds); } + List selectByRoleCode(@Param("tenantId") Long tenantId, @Param("roleCode") String roleCode); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleService.java index 7d15d9ab..cf61888c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleService.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.service.permission; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; -import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; +import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; @@ -148,4 +148,13 @@ public interface RoleService { void validateRoleList(Collection ids); @TenantIgnore RoleDO getRoleByCodeWithoutTenant(String rescueOtherNotify); + + /** + * 查询某个角色的用户 + * @author vinjor-M + * @date 15:58 2024/10/26 + * @param roleCode 角色code + * @return java.util.List + **/ + List selectByRoleCode(Long tenantId,String roleCode); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java index 2e28d26d..2021e893 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java @@ -12,11 +12,12 @@ import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; -import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; +import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; import cn.iocoder.yudao.module.system.dal.mysql.permission.RoleMapper; +import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper; import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; import cn.iocoder.yudao.module.system.enums.permission.DataScopeEnum; import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum; @@ -55,6 +56,8 @@ public class RoleServiceImpl implements RoleService { @Resource private RoleMapper roleMapper; + @Resource + private UserRoleMapper userRoleMapper; @Override @Transactional(rollbackFor = Exception.class) @@ -320,6 +323,19 @@ public class RoleServiceImpl implements RoleService { return roleMapper.selectByCode(code); } + /** + * 查询某个角色的用户 + * + * @param roleCode 角色code + * @return java.util.List + * @author vinjor-M + * @date 15:58 2024/10/26 + **/ + @Override + public List selectByRoleCode(Long tenantId,String roleCode) { + return userRoleMapper.selectByRoleCode(tenantId,roleCode); + } + /** * 获得自身的代理对象,解决 AOP 生效问题 * diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/UserRoleMapper.xml b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/UserRoleMapper.xml new file mode 100644 index 00000000..e11d5129 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/UserRoleMapper.xml @@ -0,0 +1,22 @@ + + + + + +