支持店长维护员工账号状态
This commit is contained in:
+31
@@ -16,6 +16,7 @@ import com.xiaowang.jayucloud.core.modules.artist.vo.ArtistScheduleRuleVO;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.vo.ArtistScheduleVO;
|
||||
import com.xiaowang.jayucloud.core.modules.manager.dto.ManagerCustomerCreateDTO;
|
||||
import com.xiaowang.jayucloud.core.modules.manager.dto.ManagerCustomerUpdateDTO;
|
||||
import com.xiaowang.jayucloud.core.modules.manager.dto.ManagerEmployeeStatusDTO;
|
||||
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentCreateDTO;
|
||||
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentImageDTO;
|
||||
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentMoveDTO;
|
||||
@@ -311,6 +312,36 @@ public class AdminManagerController {
|
||||
return Result.success(userService.unbindUserInShopWithOperator(userId, shopId, currentUser.getType()));
|
||||
}
|
||||
|
||||
@PutMapping("/employees/{userId}/status")
|
||||
@RequirePermission("user:edit")
|
||||
@OperationGuard(action = "manager-employee-status-update", ttlSeconds = 10, message = "员工状态更新处理中,请勿重复点击")
|
||||
public Result<Boolean> updateEmployeeStatus(HttpServletRequest request,
|
||||
@PathVariable Long userId,
|
||||
@RequestBody ManagerEmployeeStatusDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
if (dto == null || dto.getStatus() == null) {
|
||||
throw new RuntimeException("员工状态不能为空");
|
||||
}
|
||||
Integer normalizedStatus = Integer.valueOf(1).equals(dto.getStatus()) ? 1 : 0;
|
||||
if (currentUser != null && userId.equals(currentUser.getId()) && normalizedStatus == 0) {
|
||||
throw new RuntimeException("不能停用自己的账号");
|
||||
}
|
||||
UserVO targetUser = userService.getUserById(userId);
|
||||
if (targetUser == null) {
|
||||
throw new RuntimeException("目标员工不存在");
|
||||
}
|
||||
if (!adminScopeHelper.isPlatformAdmin(currentUser)) {
|
||||
adminScopeHelper.ensureUserAccessibleInCurrentShop(currentUser, userId, "无权修改其他店铺员工状态");
|
||||
}
|
||||
adminScopeHelper.ensureAssignableUserType(currentUser, targetUser.getType());
|
||||
if (!Integer.valueOf(3).equals(targetUser.getType())) {
|
||||
throw new RuntimeException("只能修改员工状态");
|
||||
}
|
||||
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||
adminScopeHelper.requireShopContext(currentUser, "请先选择店铺后再修改员工状态");
|
||||
return Result.success(userService.updateUserStatusInShop(userId, normalizedStatus, shopId));
|
||||
}
|
||||
|
||||
@GetMapping("/employees/schedules")
|
||||
@RequirePermission("schedule:view")
|
||||
public Result<List<ArtistScheduleVO>> schedules(HttpServletRequest request,
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.xiaowang.jayucloud.core.modules.manager.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ManagerEmployeeStatusDTO {
|
||||
private Integer status;
|
||||
}
|
||||
Reference in New Issue
Block a user