@@ -0,0 +1,115 @@
|
||||
package com.yunhai.acaclassroom.controller.api;
|
||||
|
||||
import com.yunhai.acaclassroom.annotation.OperationLog;
|
||||
import com.yunhai.acaclassroom.config.Config;
|
||||
import com.yunhai.acaclassroom.model.ClassroomBatchAddRequest;
|
||||
import com.yunhai.acaclassroom.model.ClassroomBindRequest;
|
||||
import com.yunhai.acaclassroom.model.ClassroomBatchEditRequest;
|
||||
import com.yunhai.acaclassroom.model.ClassroomEditRequest;
|
||||
import com.yunhai.acaclassroom.service.IClassroomService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 教室管理接口(classroom/)。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = Config.API_PATH + "/classroom/")
|
||||
public class ClassroomController {
|
||||
|
||||
@Autowired
|
||||
private IClassroomService classroomService;
|
||||
|
||||
/**
|
||||
* 教室列表(空间作用域:楼栋或校区二选一,楼栋优先;
|
||||
* 支持楼层/类型/状态/关键字/年级/绑定状态过滤 + 排序 + 分页)。
|
||||
*/
|
||||
@GetMapping("List")
|
||||
public Map<String, Object> list(@RequestParam(value = "buildingId", required = false) Integer buildingId,
|
||||
@RequestParam(value = "campusId", required = false) Integer campusId,
|
||||
@RequestParam(value = "floor", required = false) Integer floor,
|
||||
@RequestParam(value = "typeId", required = false) Integer typeId,
|
||||
@RequestParam(value = "status", required = false) String status,
|
||||
@RequestParam(value = "keyword", required = false) String keyword,
|
||||
@RequestParam(value = "grade", required = false) Integer grade,
|
||||
@RequestParam(value = "bindStatus", required = false) String bindStatus,
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "count", defaultValue = "20") Integer count,
|
||||
@RequestParam(value = "sortField", required = false) String sortField,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
return classroomService.list(buildingId, campusId, floor, typeId, status, keyword, grade, bindStatus,
|
||||
page, count, sortField, order);
|
||||
}
|
||||
|
||||
/** 楼栋下已有教室的楼层列表(筛选项)。 */
|
||||
@GetMapping("Floors")
|
||||
public List<Integer> floors(@RequestParam("buildingId") Integer buildingId) {
|
||||
return classroomService.floors(buildingId);
|
||||
}
|
||||
|
||||
/** 全校教室扁平列表(教室管理页「空间筛选树」数据源,轻量字段)。 */
|
||||
@GetMapping("Tree")
|
||||
public List<Map<String, Object>> tree() {
|
||||
return classroomService.tree();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加教室:输入楼层区间(1~楼栋楼层数量)、每层教室数量、教室类型;
|
||||
* 编号默认 {前缀}{楼层2位}{序号2位},重复的跳过。
|
||||
*/
|
||||
@PostMapping("BatchAdd")
|
||||
@OperationLog(module = "教室管理-教室", type = "CREATE")
|
||||
public Map<String, Object> batchAdd(@RequestBody ClassroomBatchAddRequest req) {
|
||||
return classroomService.batchAdd(req);
|
||||
}
|
||||
|
||||
/** 编辑教室(类型/名称/编号/状态/容纳人数/座位数)。 */
|
||||
@PostMapping("Edit")
|
||||
@OperationLog(module = "教室管理-教室", type = "UPDATE")
|
||||
public void edit(@RequestBody ClassroomEditRequest req) {
|
||||
classroomService.edit(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量编辑教室:仅支持 教室状态 / 教室类型 两项(可只改其一),
|
||||
* 供列表页多选后的批量操作条使用;返回 {updated, skipped, total}。
|
||||
*/
|
||||
@PostMapping("BatchEdit")
|
||||
@OperationLog(module = "教室管理-教室", type = "UPDATE")
|
||||
public Map<String, Object> batchEdit(@RequestBody ClassroomBatchEditRequest req) {
|
||||
return classroomService.batchEdit(req);
|
||||
}
|
||||
|
||||
/** 批量删除教室(JSON id 数组)。 */
|
||||
@PostMapping("Delete")
|
||||
@OperationLog(module = "教室管理-教室", type = "DELETE")
|
||||
public void delete(@RequestBody List<Integer> ids) {
|
||||
classroomService.delete(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 教室绑定班级(JSON {serID, classId};一个班级同时只能绑一间教室)。
|
||||
*/
|
||||
@PostMapping("BindClass")
|
||||
@OperationLog(module = "教室管理-绑定班级", type = "UPDATE")
|
||||
public Map<String, Object> bindClass(@RequestBody ClassroomBindRequest req) {
|
||||
return classroomService.bindClass(req.getSerID(), req.getClassId());
|
||||
}
|
||||
|
||||
/** 教室解绑班级(表单 serid;未绑定时静默成功)。 */
|
||||
@PostMapping("UnbindClass")
|
||||
@OperationLog(module = "教室管理-绑定班级", type = "UPDATE")
|
||||
public void unbindClass(@RequestParam("serid") Integer serid) {
|
||||
classroomService.unbindClass(serid);
|
||||
}
|
||||
|
||||
/** 批量解绑(JSON id 数组;未绑定/无效教室计入 skipped)。 */
|
||||
@PostMapping("BatchUnbind")
|
||||
@OperationLog(module = "教室管理-绑定班级", type = "UPDATE")
|
||||
public Map<String, Object> batchUnbind(@RequestBody List<Integer> serIDs) {
|
||||
return classroomService.batchUnbind(serIDs);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user