完善店务端员工新增和删除

This commit is contained in:
2026-07-15 17:33:34 +08:00
parent ad1ae376f8
commit 00a435ecfb
12 changed files with 288 additions and 12 deletions
@@ -38,6 +38,7 @@ import com.xiaowang.jayucloud.core.modules.user.vo.UserVO;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@@ -259,9 +260,34 @@ public class AdminManagerController {
dto.setShopId(managedShopId);
dto.setShopIds(List.of(managedShopId));
}
if (!StringUtils.hasText(dto.getWechatId())) {
dto.setWechatId(dto.getPhone());
}
return Result.success(userService.createUser(dto));
}
@DeleteMapping("/employees/{userId}")
@RequirePermission("user:unbind")
@OperationGuard(action = "manager-employee-delete", ttlSeconds = 10, message = "员工删除处理中,请勿重复点击")
public Result<Boolean> deleteEmployee(HttpServletRequest request,
@PathVariable Long userId) {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
UserVO targetUser = userService.getUserById(userId);
if (targetUser == null) {
return Result.success(false);
}
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.unbindUserInShopWithOperator(userId, shopId, currentUser.getType()));
}
@GetMapping("/employees/schedules")
@RequirePermission("schedule:view")
public Result<List<ArtistScheduleVO>> schedules(HttpServletRequest request,