员工详情返回角色名称

This commit is contained in:
张松
2025-02-20 10:02:39 +08:00
parent a16e322a3c
commit f1456ba34f
4 changed files with 22 additions and 5 deletions

View File

@@ -5,10 +5,7 @@ import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.staff.ShopStaffAddDTO;
import com.czg.account.dto.staff.ShopStaffEditDTO;
import com.czg.account.dto.staff.ShopStaffRemoveDTO;
import com.czg.account.entity.ShopPermission;
import com.czg.account.entity.ShopStaff;
import com.czg.account.entity.ShopStaffPermission;
import com.czg.account.entity.SysUser;
import com.czg.account.entity.*;
import com.czg.account.service.*;
import com.czg.exception.ApiNotPrintException;
import com.czg.sa.StpKit;
@@ -37,6 +34,8 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
@Resource
private SysUsersRolesService sysUsersRolesService;
@Resource
private SysRoleService sysRoleService;
@Resource
private ShopPermissionService shopPermissionService;
@Resource
private ShopStaffPermissionService shopStaffPermissionService;
@@ -128,4 +127,17 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
public List<Long> permission(Long id) {
return shopStaffPermissionService.getPermissionByStaffId(StpKit.USER.getShopId(), id, id).stream().map(ShopPermission::getId).toList();
}
@Override
public ShopStaff detail(Long shopId, Long id) {
ShopStaff shopStaff = queryChain().eq(ShopStaff::getId, id).eq(ShopStaff::getShopId, shopId).one();
if (shopStaff == null) {
throw new ApiNotPrintException("员工不存在");
}
SysUsersRoles sysUsersRoles = sysUsersRolesService.getOne(new QueryWrapper().eq(SysUsersRoles::getUserId, shopStaff.getId()));
SysRole role = sysRoleService.getById(sysUsersRoles.getRoleId());
shopStaff.setRoleName(role.getName());
return shopStaff;
}
}