+5
-5
@@ -88,7 +88,7 @@ const bStats = await api("GET", "/api/building/Stats", { params: { campusId } })
|
|||||||
ok("building Stats total=6", bStats.code === 0 && bStats.data.some(b => b.serID === buildingId && b.total === 6));
|
ok("building Stats total=6", bStats.code === 0 && bStats.data.some(b => b.serID === buildingId && b.total === 6));
|
||||||
|
|
||||||
// 7. 教室编辑(含设备全量替换)+ 编号守卫
|
// 7. 教室编辑(含设备全量替换)+ 编号守卫
|
||||||
const edit = await api("POST", "/api/classroom/Edit", { json: { serID: room1, roomName: `冒烟教室${stamp}`, status: "closed", capacity: 50, seatCount: 45, equipmentIds: [] } });
|
const edit = await api("POST", "/api/classroom/Edit", { json: { serID: room1, roomName: `冒烟教室${stamp}`, status: "closed", seatCount: 45, equipmentIds: [] } });
|
||||||
ok("classroom Edit(清空设备)", edit.code === 0, edit.msg);
|
ok("classroom Edit(清空设备)", edit.code === 0, edit.msg);
|
||||||
const roomsAfterEdit = await api("GET", "/api/classroom/List", { params: { buildingId, page: 1, count: 20 } });
|
const roomsAfterEdit = await api("GET", "/api/classroom/List", { params: { buildingId, page: 1, count: 20 } });
|
||||||
const room1After = roomsAfterEdit.data.list.find(r => r.serID === room1);
|
const room1After = roomsAfterEdit.data.list.find(r => r.serID === room1);
|
||||||
@@ -114,13 +114,13 @@ ok("equipment Delete 被引用守卫拒绝", eqDelGuarded.code !== 0);
|
|||||||
|
|
||||||
// 9. 新增接口:列表排序 / 楼栋楼层分布 / 教室批量编辑
|
// 9. 新增接口:列表排序 / 楼栋楼层分布 / 教室批量编辑
|
||||||
const sortedDesc = await api("GET", "/api/classroom/List", {
|
const sortedDesc = await api("GET", "/api/classroom/List", {
|
||||||
params: { buildingId, page: 1, count: 20, sortField: "capacity", order: "desc" },
|
params: { buildingId, page: 1, count: 20, sortField: "seatCount", order: "desc" },
|
||||||
});
|
});
|
||||||
ok(
|
ok(
|
||||||
"List 排序 capacity desc",
|
"List 排序 seatCount desc",
|
||||||
sortedDesc.code === 0 &&
|
sortedDesc.code === 0 &&
|
||||||
sortedDesc.data.list[0].capacity >= sortedDesc.data.list[sortedDesc.data.list.length - 1].capacity,
|
sortedDesc.data.list[0].seatCount >= sortedDesc.data.list[sortedDesc.data.list.length - 1].seatCount,
|
||||||
JSON.stringify(sortedDesc.data && sortedDesc.data.list.map(r => r.capacity))
|
JSON.stringify(sortedDesc.data && sortedDesc.data.list.map(r => r.seatCount))
|
||||||
);
|
);
|
||||||
|
|
||||||
const sortedFloorDesc = await api("GET", "/api/classroom/List", {
|
const sortedFloorDesc = await api("GET", "/api/classroom/List", {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class ClassroomController {
|
|||||||
return classroomService.batchAdd(req);
|
return classroomService.batchAdd(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 编辑教室(类型/名称/编号/状态/容纳人数/座位数)。 */
|
/** 编辑教室(类型/名称/编号/状态/座位数)。 */
|
||||||
@PostMapping("Edit")
|
@PostMapping("Edit")
|
||||||
@OperationLog(module = "教室管理-教室", type = "UPDATE")
|
@OperationLog(module = "教室管理-教室", type = "UPDATE")
|
||||||
public void edit(@RequestBody ClassroomEditRequest req) {
|
public void edit(@RequestBody ClassroomEditRequest req) {
|
||||||
|
|||||||
@@ -44,10 +44,6 @@ public class Classroom extends BaseEntity {
|
|||||||
@Column(name = "status", nullable = false, length = 8)
|
@Column(name = "status", nullable = false, length = 8)
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/** 教室容纳人数 */
|
|
||||||
@Column(name = "capacity")
|
|
||||||
private Integer capacity;
|
|
||||||
|
|
||||||
/** 座位数 */
|
/** 座位数 */
|
||||||
@Column(name = "seat_count")
|
@Column(name = "seat_count")
|
||||||
private Integer seatCount;
|
private Integer seatCount;
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ public class ClassroomBatchAddRequest {
|
|||||||
/** 教室类型 id */
|
/** 教室类型 id */
|
||||||
private Integer typeId;
|
private Integer typeId;
|
||||||
|
|
||||||
|
/** 座位数(0~100000,缺省 0) */
|
||||||
|
private Integer seatCount;
|
||||||
|
|
||||||
/** 编号/名称前缀(缺省用楼栋编号) */
|
/** 编号/名称前缀(缺省用楼栋编号) */
|
||||||
private String namePrefix;
|
private String namePrefix;
|
||||||
|
|
||||||
@@ -86,6 +89,14 @@ public class ClassroomBatchAddRequest {
|
|||||||
this.typeId = typeId;
|
this.typeId = typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getSeatCount() {
|
||||||
|
return seatCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeatCount(Integer seatCount) {
|
||||||
|
this.seatCount = seatCount;
|
||||||
|
}
|
||||||
|
|
||||||
public String getNamePrefix() {
|
public String getNamePrefix() {
|
||||||
return namePrefix;
|
return namePrefix;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* 用于列表页多选后的批量操作:只允许修改「教室状态」与「教室类型」两项;
|
* 用于列表页多选后的批量操作:只允许修改「教室状态」与「教室类型」两项;
|
||||||
* 两者均为可空——为 null 表示该项不改动,至少需要指定其中一项。
|
* 两者均为可空——为 null 表示该项不改动,至少需要指定其中一项。
|
||||||
* 名称/编号/容纳人数/座位数等逐间差异字段不在批量范围(避免误覆盖)。
|
* 名称/编号/座位数等逐间差异字段不在批量范围(避免误覆盖)。
|
||||||
*/
|
*/
|
||||||
public class ClassroomBatchEditRequest {
|
public class ClassroomBatchEditRequest {
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ public class ClassroomEditRequest {
|
|||||||
/** open 开放 / closed 关闭 */
|
/** open 开放 / closed 关闭 */
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
private Integer capacity;
|
|
||||||
|
|
||||||
private Integer seatCount;
|
private Integer seatCount;
|
||||||
|
|
||||||
/** 关联设备 id 集合(null=不改动;数组(含空)=全量替换该教室的设备,数量按 1)。优先级低于 equipments */
|
/** 关联设备 id 集合(null=不改动;数组(含空)=全量替换该教室的设备,数量按 1)。优先级低于 equipments */
|
||||||
@@ -82,14 +80,6 @@ public class ClassroomEditRequest {
|
|||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getCapacity() {
|
|
||||||
return capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCapacity(Integer capacity) {
|
|
||||||
this.capacity = capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getSeatCount() {
|
public Integer getSeatCount() {
|
||||||
return seatCount;
|
return seatCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public interface IClassroomService {
|
|||||||
* @param bindStatus 绑定状态过滤 bound/unbound(可空)
|
* @param bindStatus 绑定状态过滤 bound/unbound(可空)
|
||||||
* @param page 页码(1 起)
|
* @param page 页码(1 起)
|
||||||
* @param count 每页条数
|
* @param count 每页条数
|
||||||
* @param sortField 排序字段 floor/roomCode/roomName/status/capacity/seatCount(可空=默认序:楼层升序+编号升序)
|
* @param sortField 排序字段 floor/roomCode/roomName/status/seatCount(可空=默认序:楼层升序+编号升序)
|
||||||
* @param order asc/desc(可空=asc)
|
* @param order asc/desc(可空=asc)
|
||||||
*/
|
*/
|
||||||
Map<String, Object> list(Integer buildingId, Integer campusId, Integer floor, Integer typeId, String status,
|
Map<String, Object> list(Integer buildingId, Integer campusId, Integer floor, Integer typeId, String status,
|
||||||
@@ -42,7 +42,7 @@ public interface IClassroomService {
|
|||||||
/** 批量添加教室,返回 {created, skipped, total}。 */
|
/** 批量添加教室,返回 {created, skipped, total}。 */
|
||||||
Map<String, Object> batchAdd(ClassroomBatchAddRequest req);
|
Map<String, Object> batchAdd(ClassroomBatchAddRequest req);
|
||||||
|
|
||||||
/** 编辑教室(类型/名称/编号/状态/容纳人数/座位数)。 */
|
/** 编辑教室(类型/名称/编号/状态/座位数)。 */
|
||||||
void edit(ClassroomEditRequest req);
|
void edit(ClassroomEditRequest req);
|
||||||
|
|
||||||
/** 批量编辑教室(仅状态 / 教室类型,可只改其一),返回 {updated, skipped, total}。 */
|
/** 批量编辑教室(仅状态 / 教室类型,可只改其一),返回 {updated, skipped, total}。 */
|
||||||
|
|||||||
@@ -246,6 +246,14 @@ public class ClassroomService implements IClassroomService {
|
|||||||
String prefix = req.getNamePrefix() != null && !req.getNamePrefix().trim().isEmpty()
|
String prefix = req.getNamePrefix() != null && !req.getNamePrefix().trim().isEmpty()
|
||||||
? req.getNamePrefix().trim() : building.getBuildingCode();
|
? req.getNamePrefix().trim() : building.getBuildingCode();
|
||||||
|
|
||||||
|
Integer seatCount = req.getSeatCount();
|
||||||
|
if (seatCount == null) {
|
||||||
|
seatCount = 0;
|
||||||
|
}
|
||||||
|
if (seatCount < 0 || seatCount > 100000) {
|
||||||
|
throw new BizException(ErrorCode.PARAM_ERROR, "座位数不正确");
|
||||||
|
}
|
||||||
|
|
||||||
// 校验设备 id 均属本校(批量添加:设备按数量应用到本次新建的教室)
|
// 校验设备 id 均属本校(批量添加:设备按数量应用到本次新建的教室)
|
||||||
Map<Integer, Integer> equipmentMap = sanitizeEquipmentMap(req.getEquipments(), req.getEquipmentIds(), building.getSchId());
|
Map<Integer, Integer> equipmentMap = sanitizeEquipmentMap(req.getEquipments(), req.getEquipmentIds(), building.getSchId());
|
||||||
|
|
||||||
@@ -268,8 +276,7 @@ public class ClassroomService implements IClassroomService {
|
|||||||
r.setRoomCode(code);
|
r.setRoomCode(code);
|
||||||
r.setTypeId(req.getTypeId());
|
r.setTypeId(req.getTypeId());
|
||||||
r.setStatus(STATUS_OPEN);
|
r.setStatus(STATUS_OPEN);
|
||||||
r.setCapacity(0);
|
r.setSeatCount(seatCount);
|
||||||
r.setSeatCount(0);
|
|
||||||
r.setSchId(building.getSchId());
|
r.setSchId(building.getSchId());
|
||||||
createdRooms.add(classroomRepository.save(r));
|
createdRooms.add(classroomRepository.save(r));
|
||||||
created++;
|
created++;
|
||||||
@@ -334,12 +341,6 @@ public class ClassroomService implements IClassroomService {
|
|||||||
if (req.getStatus() != null) {
|
if (req.getStatus() != null) {
|
||||||
r.setStatus(req.getStatus());
|
r.setStatus(req.getStatus());
|
||||||
}
|
}
|
||||||
if (req.getCapacity() != null) {
|
|
||||||
if (req.getCapacity() < 0 || req.getCapacity() > 100000) {
|
|
||||||
throw new BizException(ErrorCode.PARAM_ERROR, "容纳人数不正确");
|
|
||||||
}
|
|
||||||
r.setCapacity(req.getCapacity());
|
|
||||||
}
|
|
||||||
if (req.getSeatCount() != null) {
|
if (req.getSeatCount() != null) {
|
||||||
if (req.getSeatCount() < 0 || req.getSeatCount() > 100000) {
|
if (req.getSeatCount() < 0 || req.getSeatCount() > 100000) {
|
||||||
throw new BizException(ErrorCode.PARAM_ERROR, "座位数不正确");
|
throw new BizException(ErrorCode.PARAM_ERROR, "座位数不正确");
|
||||||
@@ -546,7 +547,7 @@ public class ClassroomService implements IClassroomService {
|
|||||||
* 教室列表排序。
|
* 教室列表排序。
|
||||||
* sortField 为空或未知时**原样返回**(保持仓储层默认序:楼层升序 + 编号升序),
|
* sortField 为空或未知时**原样返回**(保持仓储层默认序:楼层升序 + 编号升序),
|
||||||
* 因此不传排序参数的既有调用方行为完全不变。
|
* 因此不传排序参数的既有调用方行为完全不变。
|
||||||
* 支持字段:floor / roomCode / roomName / status / capacity / seatCount;order:asc(默认)/ desc。
|
* 支持字段:floor / roomCode / roomName / status / seatCount;order:asc(默认)/ desc。
|
||||||
*/
|
*/
|
||||||
private List<Classroom> applySort(List<Classroom> rooms, String sortField, String order) {
|
private List<Classroom> applySort(List<Classroom> rooms, String sortField, String order) {
|
||||||
if (rooms == null || rooms.isEmpty() || sortField == null || sortField.trim().isEmpty()) {
|
if (rooms == null || rooms.isEmpty() || sortField == null || sortField.trim().isEmpty()) {
|
||||||
@@ -565,9 +566,6 @@ public class ClassroomService implements IClassroomService {
|
|||||||
case "status":
|
case "status":
|
||||||
cmp = Comparator.comparing((Classroom r) -> r.getStatus(), strCmp);
|
cmp = Comparator.comparing((Classroom r) -> r.getStatus(), strCmp);
|
||||||
break;
|
break;
|
||||||
case "capacity":
|
|
||||||
cmp = Comparator.comparing((Classroom r) -> r.getCapacity(), intCmp);
|
|
||||||
break;
|
|
||||||
case "seatCount":
|
case "seatCount":
|
||||||
cmp = Comparator.comparing((Classroom r) -> r.getSeatCount(), intCmp);
|
cmp = Comparator.comparing((Classroom r) -> r.getSeatCount(), intCmp);
|
||||||
break;
|
break;
|
||||||
@@ -594,7 +592,6 @@ public class ClassroomService implements IClassroomService {
|
|||||||
vo.put("typeId", r.getTypeId());
|
vo.put("typeId", r.getTypeId());
|
||||||
vo.put("typeName", r.getTypeId() != null ? typeNames.getOrDefault(r.getTypeId(), "") : "");
|
vo.put("typeName", r.getTypeId() != null ? typeNames.getOrDefault(r.getTypeId(), "") : "");
|
||||||
vo.put("status", r.getStatus());
|
vo.put("status", r.getStatus());
|
||||||
vo.put("capacity", r.getCapacity());
|
|
||||||
vo.put("seatCount", r.getSeatCount());
|
vo.put("seatCount", r.getSeatCount());
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ public class UserCenterService implements IUserCenterService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 将扁平模块列表组装为树。
|
* 将扁平模块列表组装为树。
|
||||||
* 顶层取 parentId=0 或父节点不在列表中的节点,保持 SDK(用户中心)返回顺序。
|
* 顶层取 parentId=0 或父节点不在列表中的节点;各层按 orderNumber 升序(左侧菜单顺序)。
|
||||||
*/
|
*/
|
||||||
private List<Map<String, Object>> buildModuleTree(List<BoaModule> modules) {
|
private List<Map<String, Object>> buildModuleTree(List<BoaModule> modules) {
|
||||||
Set<Integer> moduleIds = new HashSet<>();
|
Set<Integer> moduleIds = new HashSet<>();
|
||||||
@@ -201,6 +201,20 @@ public class UserCenterService implements IUserCenterService {
|
|||||||
if (roots.isEmpty()) {
|
if (roots.isEmpty()) {
|
||||||
log.warn("[GetUserMod] 模块列表无根节点, count={}", modules.size());
|
log.warn("[GetUserMod] 模块列表无根节点, count={}", modules.size());
|
||||||
}
|
}
|
||||||
|
sortByOrderNumber(roots);
|
||||||
return roots;
|
return roots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 按 orderNumber 升序排序(含各级 children);稳定排序,同序号保持用户中心返回顺序。 */
|
||||||
|
private void sortByOrderNumber(List<Map<String, Object>> nodes) {
|
||||||
|
nodes.sort(Comparator.comparingInt(
|
||||||
|
n -> n.get("orderNumber") instanceof Number ? ((Number) n.get("orderNumber")).intValue() : 0));
|
||||||
|
for (Map<String, Object> node : nodes) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<Map<String, Object>> children = (List<Map<String, Object>>) node.get("children");
|
||||||
|
if (children != null && !children.isEmpty()) {
|
||||||
|
sortByOrderNumber(children);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user