diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AbsentController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AbsentController.java deleted file mode 100644 index 11455d8..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AbsentController.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.ruoyi.system.controller; - -import java.util.List; -import javax.servlet.http.HttpServletResponse; - -import com.ruoyi.common.annotation.Anonymous; -import com.ruoyi.system.domain.DormitoryAdmin; -import com.ruoyi.system.vo.PageResult; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.system.domain.Absent; -import com.ruoyi.system.service.IAbsentService; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.common.core.page.TableDataInfo; - -/** - * 缺寝信息表Controller - * - * @author ruoyi - * @date 2024-12-26 - */ -@RestController -@RequestMapping("/system/absent") -public class AbsentController extends BaseController -{ - @Autowired - private IAbsentService absentService; - - /** - * 查询缺寝信息表列表 - */ -// @PreAuthorize("@ss.hasPermi('system:absent:list')") - @Anonymous - @GetMapping("/list") - public TableDataInfo list(Absent absent) - { - startPage(); - List list = absentService.selectAbsentList(absent); - return getDataTable(list); - } - - /** - * 导出缺寝信息表列表 - */ -// @PreAuthorize("@ss.hasPermi('system:absent:export')") - @Anonymous - @Log(title = "缺寝信息表", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, Absent absent) - { - List list = absentService.selectAbsentList(absent); - ExcelUtil util = new ExcelUtil(Absent.class); - util.exportExcel(response, list, "缺寝信息表数据"); - } - - /** - * 获取缺寝信息表详细信息 - */ -// @PreAuthorize("@ss.hasPermi('system:absent:query')") - @Anonymous - @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { - return success(absentService.selectAbsentById(id)); - } - - /** - * 新增缺寝信息表 - */ -// @PreAuthorize("@ss.hasPermi('system:absent:add')") - @Anonymous - @Log(title = "缺寝信息表", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody Absent absent) - { - return toAjax(absentService.insertAbsent(absent)); - } - - /** - * 修改缺寝信息表 - */ -// @PreAuthorize("@ss.hasPermi('system:absent:edit')") - @Anonymous - @Log(title = "缺寝信息表", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody Absent absent) - { - return toAjax(absentService.updateAbsent(absent)); - } - - /** - * 删除缺寝信息表 - */ -// @PreAuthorize("@ss.hasPermi('system:absent:remove')") - @Anonymous - @Log(title = "缺寝信息表", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { - return toAjax(absentService.deleteAbsentByIds(ids)); - } -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/BuildingController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/BuildingController.java index e695724..1e2ee9c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/BuildingController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/BuildingController.java @@ -2,6 +2,13 @@ package com.ruoyi.system.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.annotation.Anonymous; +import com.ruoyi.system.domain.Student; +import com.ruoyi.system.form.SearchForm; +import com.ruoyi.system.vo.PageResult; +import com.ruoyi.system.vo.ResultVo; +import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -33,7 +40,24 @@ public class BuildingController extends BaseController { @Autowired private IBuildingService buildingService; + @Anonymous + @GetMapping("/list/{page}/{size}") + public ResponseEntity> listBuilding( + @PathVariable("page") int page, // 使用 @PathVariable 而不是 @RequestParam + @PathVariable("size") int size) { // 同样使用 @PathVariable + // 注意:通常页码从 1 开始更合理,但这里保留您的默认值 0 + // 如果业务逻辑需要页码从 1 开始,您可能需要在服务层添加额外的处理 + + PageResult pageResult = buildingService.findAll(page-1, size); + return ResponseEntity.ok(pageResult); + } + + @Anonymous + @GetMapping("/search") + public PageResult search(SearchForm searchForm){ + return buildingService.search(searchForm); + } /** * 查询楼宇信息表列表 */ @@ -72,9 +96,10 @@ public class BuildingController extends BaseController /** * 新增楼宇信息表 */ - @PreAuthorize("@ss.hasPermi('system:building:add')") + /*@PreAuthorize("@ss.hasPermi('system:building:add')")*/ + @Anonymous @Log(title = "楼宇信息表", businessType = BusinessType.INSERT) - @PostMapping + @PostMapping("/save") public AjaxResult add(@RequestBody Building building) { return toAjax(buildingService.insertBuilding(building)); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/DormitoryController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/DormitoryController.java index 93bdf69..082cacc 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/DormitoryController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/DormitoryController.java @@ -3,7 +3,12 @@ package com.ruoyi.system.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.common.annotation.Anonymous; +import com.ruoyi.system.domain.DormitoryAdmin; +import com.ruoyi.system.vo.PageResult; +import com.ruoyi.system.vo.ResultVo; +import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -27,7 +32,7 @@ import com.ruoyi.common.core.page.TableDataInfo; * 宿舍表Controller * * @author ruoyi - * @date 2024-12-26 + * @date 2024-12-23 */ @RestController @RequestMapping("/system/dormitory") @@ -36,10 +41,32 @@ public class DormitoryController extends BaseController @Autowired private IDormitoryService dormitoryService; + @Anonymous + @GetMapping("/available") + public ResultVo availableList(){ + List list = dormitoryService.getAvailableDormitories(); + ResultVo resultVo = new ResultVo(); + resultVo.setData(list); + return resultVo; + } + + + @Anonymous + @GetMapping("/list/{page}/{size}") + public ResponseEntity> getAllDormitoryAdmins( + @PathVariable("page") int page, // 使用 @PathVariable 而不是 @RequestParam + @PathVariable("size") int size) { // 同样使用 @PathVariable + + // 注意:通常页码从 1 开始更合理,但这里保留您的默认值 0 + // 如果业务逻辑需要页码从 1 开始,您可能需要在服务层添加额外的处理 + + PageResult pageResult = dormitoryService.findAll(page-1, size); + return ResponseEntity.ok(pageResult); + } /** * 查询宿舍表列表 */ -// @PreAuthorize("@ss.hasPermi('system:dormitory:list')") + /* @PreAuthorize("@ss.hasPermi('system:dormitory:list')")*/ @Anonymous @GetMapping("/list") public TableDataInfo list(Dormitory dormitory) @@ -52,8 +79,7 @@ public class DormitoryController extends BaseController /** * 导出宿舍表列表 */ -// @PreAuthorize("@ss.hasPermi('system:dormitory:export')") - @Anonymous + @PreAuthorize("@ss.hasPermi('system:dormitory:export')") @Log(title = "宿舍表", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, Dormitory dormitory) @@ -66,8 +92,7 @@ public class DormitoryController extends BaseController /** * 获取宿舍表详细信息 */ -// @PreAuthorize("@ss.hasPermi('system:dormitory:query')") - @Anonymous + @PreAuthorize("@ss.hasPermi('system:dormitory:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { @@ -77,10 +102,9 @@ public class DormitoryController extends BaseController /** * 新增宿舍表 */ -// @PreAuthorize("@ss.hasPermi('system:dormitory:add')") - @Anonymous + @PreAuthorize("@ss.hasPermi('system:dormitory:add')") @Log(title = "宿舍表", businessType = BusinessType.INSERT) - @PostMapping + @PostMapping("/add") public AjaxResult add(@RequestBody Dormitory dormitory) { return toAjax(dormitoryService.insertDormitory(dormitory)); @@ -89,8 +113,7 @@ public class DormitoryController extends BaseController /** * 修改宿舍表 */ -// @PreAuthorize("@ss.hasPermi('system:dormitory:edit')") - @Anonymous + @PreAuthorize("@ss.hasPermi('system:dormitory:edit')") @Log(title = "宿舍表", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody Dormitory dormitory) @@ -101,8 +124,7 @@ public class DormitoryController extends BaseController /** * 删除宿舍表 */ -// @PreAuthorize("@ss.hasPermi('system:dormitory:remove')") - @Anonymous + @PreAuthorize("@ss.hasPermi('system:dormitory:remove')") @Log(title = "宿舍表", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/StudentController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/StudentController.java index 26cd8a9..d930f8b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/StudentController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/StudentController.java @@ -5,7 +5,12 @@ import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.annotation.Anonymous; import com.ruoyi.system.domain.DormitoryAdmin; +import com.ruoyi.system.form.SearchForm; +import com.ruoyi.system.form.StudentForm; import com.ruoyi.system.vo.PageResult; +import com.ruoyi.system.vo.ResultVo; +import com.ruoyi.system.vo.StudentVo; +import org.springframework.beans.BeanUtils; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; @@ -59,6 +64,11 @@ public class StudentController extends BaseController PageResult pageResult = studentService.findAll(page-1, size); return ResponseEntity.ok(pageResult); } + @Anonymous + @GetMapping("/search") + public PageResult search(SearchForm searchForm){ + return studentService.search(searchForm); + } /** * 查询学生表列表 */ @@ -71,12 +81,54 @@ public class StudentController extends BaseController List list = studentService.selectStudentList(student); return getDataTable(list); } + @Anonymous + @GetMapping("findById/{id}") + public ResultVo findById(@PathVariable("id") Long id){ + Student student = studentService.selectStudentById(id); + StudentForm studentForm = new StudentForm(); + studentForm.setId(student.getId()); + studentForm.setNumber(student.getNumber()); + studentForm.setName(student.getName()); + studentForm.setGender(student.getGender()); + studentForm.setDormitory_id(student.getDormitory_id()); + studentForm.setOldDormitoryId(student.getDormitory_id()); + studentForm.setState(student.getState()); + studentForm.setCreate_date(student.getCreate_date()); + ResultVo resultVo = new ResultVo(); + resultVo.setCode(0); + resultVo.setData(studentForm); + return resultVo; + } + @Anonymous + @PutMapping("/updateStudent") + public ResultVo update(@RequestBody StudentForm studentForm){ + Boolean update = this.studentService.update(studentForm); + ResultVo resultVo = new ResultVo(); + if(!update) { + resultVo.setCode(-1); + }else { + resultVo.setData(update); + resultVo.setCode(0); + } + return resultVo; + } + @Anonymous + @DeleteMapping("/deleteById/{id}") + public ResultVo deleteById(@PathVariable("id") Long id){ + Boolean delete = studentService.deleteById(id); + ResultVo resultVo = new ResultVo(); + if(!delete){ + resultVo.setCode(-1); + }else{ + resultVo.setCode(0); + } + return resultVo; + } /** * 导出学生表列表 */ -// @PreAuthorize("@ss.hasPermi('system:student:export')") - @Anonymous + @PreAuthorize("@ss.hasPermi('system:student:export')") @Log(title = "学生表", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, Student student) @@ -89,8 +141,7 @@ public class StudentController extends BaseController /** * 获取学生表详细信息 */ -// @PreAuthorize("@ss.hasPermi('system:student:query')") - @Anonymous + @PreAuthorize("@ss.hasPermi('system:student:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { @@ -100,10 +151,9 @@ public class StudentController extends BaseController /** * 新增学生表 */ -// @PreAuthorize("@ss.hasPermi('system:student:add')") - @Anonymous + @PreAuthorize("@ss.hasPermi('system:student:add')") @Log(title = "学生表", businessType = BusinessType.INSERT) - @PostMapping + @PostMapping("/add") public AjaxResult add(@RequestBody Student student) { return toAjax(studentService.insertStudent(student)); @@ -112,10 +162,10 @@ public class StudentController extends BaseController /** * 修改学生表 */ -// @PreAuthorize("@ss.hasPermi('system:student:edit')") @Anonymous + /*@PreAuthorize("@ss.hasPermi('system:student:edit')")*/ @Log(title = "学生表", businessType = BusinessType.UPDATE) - @PutMapping + @PutMapping("/update") public AjaxResult edit(@RequestBody Student student) { return toAjax(studentService.updateStudent(student)); @@ -124,8 +174,8 @@ public class StudentController extends BaseController /** * 删除学生表 */ -// @PreAuthorize("@ss.hasPermi('system:student:remove')") @Anonymous + /*@PreAuthorize("@ss.hasPermi('system:student:remove')")*/ @Log(title = "学生表", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Absent.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Absent.java deleted file mode 100644 index 3b7c537..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Absent.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.ruoyi.system.domain; - -import java.util.List; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 缺寝信息表对象 absent - * - * @author ruoyi - * @date 2024-12-26 - */ -public class Absent extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** id */ - private Long id; - - /** building_id */ - @Excel(name = "building_id") - private Long buildingId; - - /** dormitory_id */ - @Excel(name = "dormitory_id") - private Long dormitoryId; - - /** student_id */ - @Excel(name = "student_id") - private Long studentId; - - /** dormitory_admin_id */ - @Excel(name = "dormitory_admin_id") - private Long dormitoryAdminId; - - /** create_date */ - @Excel(name = "create_date") - private String createDate; - - /** reason */ - @Excel(name = "reason") - private String reason; - - /** 学生表信息 */ - private List studentList; - - public void setId(Long id) - { - this.id = id; - } - - public Long getId() - { - return id; - } - public void setBuildingId(Long buildingId) - { - this.buildingId = buildingId; - } - - public Long getBuildingId() - { - return buildingId; - } - public void setDormitoryId(Long dormitoryId) - { - this.dormitoryId = dormitoryId; - } - - public Long getDormitoryId() - { - return dormitoryId; - } - public void setStudentId(Long studentId) - { - this.studentId = studentId; - } - - public Long getStudentId() - { - return studentId; - } - public void setDormitoryAdminId(Long dormitoryAdminId) - { - this.dormitoryAdminId = dormitoryAdminId; - } - - public Long getDormitoryAdminId() - { - return dormitoryAdminId; - } - public void setCreateDate(String createDate) - { - this.createDate = createDate; - } - - public String getCreateDate() - { - return createDate; - } - public void setReason(String reason) - { - this.reason = reason; - } - - public String getReason() - { - return reason; - } - - public List getStudentList() - { - return studentList; - } - - public void setStudentList(List studentList) - { - this.studentList = studentList; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("buildingId", getBuildingId()) - .append("dormitoryId", getDormitoryId()) - .append("studentId", getStudentId()) - .append("dormitoryAdminId", getDormitoryAdminId()) - .append("createDate", getCreateDate()) - .append("reason", getReason()) - .append("studentList", getStudentList()) - .toString(); - } -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Dormitory.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Dormitory.java index eb4e591..957db5c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Dormitory.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Dormitory.java @@ -1,6 +1,5 @@ package com.ruoyi.system.domain; -import java.util.List; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; @@ -10,7 +9,7 @@ import com.ruoyi.common.core.domain.BaseEntity; * 宿舍表对象 dormitory * * @author ruoyi - * @date 2024-12-26 + * @date 2024-12-23 */ public class Dormitory extends BaseEntity { @@ -32,16 +31,13 @@ public class Dormitory extends BaseEntity private Long type; /** available */ - @Excel(name = "available") + @Excel(name = "availabe") private Long availabe; /** telephone */ @Excel(name = "telephone") private String telephone; - /** 学生表信息 */ - private List studentList; - public void setId(Long id) { this.id = id; @@ -97,16 +93,6 @@ public class Dormitory extends BaseEntity return telephone; } - public List getStudentList() - { - return studentList; - } - - public void setStudentList(List studentList) - { - this.studentList = studentList; - } - @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -116,7 +102,6 @@ public class Dormitory extends BaseEntity .append("type", getType()) .append("availabe", getAvailabe()) .append("telephone", getTelephone()) - .append("studentList", getStudentList()) .toString(); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Student.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Student.java index 41b5068..887ba5b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Student.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Student.java @@ -9,7 +9,7 @@ import com.ruoyi.common.core.domain.BaseEntity; * 学生表对象 student * * @author ruoyi - * @date 2024-12-26 + * @date 2024-12-23 */ public class Student extends BaseEntity { @@ -32,7 +32,7 @@ public class Student extends BaseEntity /** dormitory_id */ @Excel(name = "dormitory_id") - private Long dormitoryId; + private Long dormitory_id; /** state */ @Excel(name = "state") @@ -40,7 +40,9 @@ public class Student extends BaseEntity /** create_date */ @Excel(name = "create_date") - private String createDate; + private String create_date; + /** dormitoryName */ + private String dormitoryName; public void setId(Long id) { @@ -78,14 +80,14 @@ public class Student extends BaseEntity { return gender; } - public void setDormitoryId(Long dormitoryId) + public void setDormitory_id(Long dormitory_id) { - this.dormitoryId = dormitoryId; + this.dormitory_id = dormitory_id; } - public Long getDormitoryId() + public Long getDormitory_id() { - return dormitoryId; + return dormitory_id; } public void setState(String state) { @@ -96,14 +98,14 @@ public class Student extends BaseEntity { return state; } - public void setCreateDate(String createDate) + public void setCreate_date(String create_date) { - this.createDate = createDate; + this.create_date = create_date; } - public String getCreateDate() + public String getCreate_date() { - return createDate; + return create_date; } @Override @@ -113,9 +115,9 @@ public class Student extends BaseEntity .append("number", getNumber()) .append("name", getName()) .append("gender", getGender()) - .append("dormitoryId", getDormitoryId()) + .append("dormitory_id", getDormitory_id()) .append("state", getState()) - .append("createDate", getCreateDate()) + .append("create_date", getCreate_date()) .toString(); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/form/StudentForm.java b/ruoyi-system/src/main/java/com/ruoyi/system/form/StudentForm.java new file mode 100644 index 0000000..d142a88 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/form/StudentForm.java @@ -0,0 +1,16 @@ +package com.ruoyi.system.form; + +import com.ruoyi.common.annotation.Excel; +import lombok.Data; + +@Data +public class StudentForm { + private Long id; + private String number; + private String name; + private String gender; + private Long dormitory_id; + private Long oldDormitoryId; + private String state; + private String create_date; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/AbsentMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/AbsentMapper.java deleted file mode 100644 index a82e7e6..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/AbsentMapper.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import com.ruoyi.system.domain.Absent; -import com.ruoyi.system.domain.Student; - -/** - * 缺寝信息表Mapper接口 - * - * @author ruoyi - * @date 2024-12-26 - */ -public interface AbsentMapper -{ - /** - * 查询缺寝信息表 - * - * @param id 缺寝信息表主键 - * @return 缺寝信息表 - */ - public Absent selectAbsentById(Long id); - - /** - * 查询缺寝信息表列表 - * - * @param absent 缺寝信息表 - * @return 缺寝信息表集合 - */ - public List selectAbsentList(Absent absent); - - /** - * 新增缺寝信息表 - * - * @param absent 缺寝信息表 - * @return 结果 - */ - public int insertAbsent(Absent absent); - - /** - * 修改缺寝信息表 - * - * @param absent 缺寝信息表 - * @return 结果 - */ - public int updateAbsent(Absent absent); - - /** - * 删除缺寝信息表 - * - * @param id 缺寝信息表主键 - * @return 结果 - */ - public int deleteAbsentById(Long id); - - /** - * 批量删除缺寝信息表 - * - * @param ids 需要删除的数据主键集合 - * @return 结果 - */ - public int deleteAbsentByIds(Long[] ids); - - /** - * 批量删除学生表 - * - * @param ids 需要删除的数据主键集合 - * @return 结果 - */ - public int deleteStudentByNames(Long[] ids); - - /** - * 批量新增学生表 - * - * @param studentList 学生表列表 - * @return 结果 - */ - public int batchStudent(List studentList); - - - /** - * 通过缺寝信息表主键删除学生表信息 - * - * @param id 缺寝信息表ID - * @return 结果 - */ - public int deleteStudentByName(Long id); -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BuildingMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BuildingMapper.java index 0780935..9e14efb 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BuildingMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BuildingMapper.java @@ -2,6 +2,9 @@ package com.ruoyi.system.mapper; import java.util.List; import com.ruoyi.system.domain.Building; +import com.ruoyi.system.domain.Student; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; /** * 楼宇信息表Mapper接口 @@ -11,6 +14,19 @@ import com.ruoyi.system.domain.Building; */ public interface BuildingMapper { + /*@Select("SELECT * FROM student LIMIT #{offset}, #{limit}")*/ + List findDormitoryAdminsByPage(@Param("offset") int offset, @Param("limit") int limit); + // 查询总记录数 + @Select("SELECT COUNT(*) FROM building") + int countDormitoryAdmins(); + + List findDormitoryAdminsByValueAndPage( + @Param("searchColumn") String searchColumn, // 注意:这里不直接传递用户输入的列名,而是传递一个经过验证的列名 + @Param("searchValue") String searchValue, + @Param("offset") int offset, + @Param("size") int size + ); + int countDormitoryAdminsByValue(@Param("searchColumn") String searchType, @Param("searchValue") String searchValue); /** * 查询楼宇信息表 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DormitoryMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DormitoryMapper.java index acb5fa7..49e8d93 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DormitoryMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DormitoryMapper.java @@ -2,16 +2,29 @@ package com.ruoyi.system.mapper; import java.util.List; import com.ruoyi.system.domain.Dormitory; -import com.ruoyi.system.domain.Student; +import com.ruoyi.system.domain.DormitoryAdmin; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; /** * 宿舍表Mapper接口 * * @author ruoyi - * @date 2024-12-26 + * @date 2024-12-23 */ public interface DormitoryMapper { + /*@Select("SELECT * FROM dormitory WHERE availabe > 0")*/ + List selectAvailableDormitories(); + public void subAvailable(Long id); + public void addAvailable(Long id); + + @Select("SELECT * FROM dormitory LIMIT #{offset}, #{limit}") + List findDormitoryAdminsByPage(@Param("offset") int offset, @Param("limit") int limit); + + // 查询总记录数 + @Select("SELECT COUNT(*) FROM dormitory") + int countDormitoryAdmins(); /** * 查询宿舍表 * @@ -60,28 +73,4 @@ public interface DormitoryMapper */ public int deleteDormitoryByIds(Long[] ids); - /** - * 批量删除学生表 - * - * @param ids 需要删除的数据主键集合 - * @return 结果 - */ - public int deleteStudentByDormitoryIds(Long[] ids); - - /** - * 批量新增学生表 - * - * @param studentList 学生表列表 - * @return 结果 - */ - public int batchStudent(List studentList); - - - /** - * 通过宿舍表主键删除学生表信息 - * - * @param id 宿舍表ID - * @return 结果 - */ - public int deleteStudentByDormitoryId(Long id); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/StudentMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/StudentMapper.java index 2b6e28c..8a5effd 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/StudentMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/StudentMapper.java @@ -4,6 +4,7 @@ import java.util.List; import com.ruoyi.system.domain.DormitoryAdmin; import com.ruoyi.system.domain.Student; +import com.ruoyi.system.vo.StudentVo; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -21,6 +22,15 @@ public interface StudentMapper // 查询总记录数 @Select("SELECT COUNT(*) FROM student") int countDormitoryAdmins(); + + List findDormitoryAdminsByValueAndPage( + @Param("searchColumn") String searchColumn, // 注意:这里不直接传递用户输入的列名,而是传递一个经过验证的列名 + @Param("searchValue") String searchValue, + @Param("offset") int offset, + @Param("size") int size + ); + int countDormitoryAdminsByValue(@Param("searchColumn") String searchType, @Param("searchValue") String searchValue); + /** * 查询学生表 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IAbsentService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IAbsentService.java deleted file mode 100644 index bd3a184..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IAbsentService.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.ruoyi.system.service; - -import java.util.List; -import com.ruoyi.system.domain.Absent; -import com.ruoyi.system.domain.DormitoryAdmin; -import com.ruoyi.system.vo.PageResult; - -/** - * 缺寝信息表Service接口 - * - * @author ruoyi - * @date 2024-12-26 - */ -public interface IAbsentService -{ - /** - * 查询缺寝信息表 - * - * @param id 缺寝信息表主键 - * @return 缺寝信息表 - */ - public Absent selectAbsentById(Long id); - - /** - * 查询缺寝信息表列表 - * - * @param absent 缺寝信息表 - * @return 缺寝信息表集合 - */ - public List selectAbsentList(Absent absent); - - /** - * 新增缺寝信息表 - * - * @param absent 缺寝信息表 - * @return 结果 - */ - public int insertAbsent(Absent absent); - - /** - * 修改缺寝信息表 - * - * @param absent 缺寝信息表 - * @return 结果 - */ - public int updateAbsent(Absent absent); - - /** - * 批量删除缺寝信息表 - * - * @param ids 需要删除的缺寝信息表主键集合 - * @return 结果 - */ - public int deleteAbsentByIds(Long[] ids); - - /** - * 删除缺寝信息表信息 - * - * @param id 缺寝信息表主键 - * @return 结果 - */ - public int deleteAbsentById(Long id); -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IBuildingService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBuildingService.java index 22bb0d1..bff7e86 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IBuildingService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBuildingService.java @@ -2,6 +2,9 @@ package com.ruoyi.system.service; import java.util.List; import com.ruoyi.system.domain.Building; +import com.ruoyi.system.domain.Student; +import com.ruoyi.system.form.SearchForm; +import com.ruoyi.system.vo.PageResult; /** * 楼宇信息表Service接口 @@ -11,6 +14,9 @@ import com.ruoyi.system.domain.Building; */ public interface IBuildingService { + public PageResult findAll(int page, int size); + public PageResult search(SearchForm searchForm); + public String validateSearchColumn(String userInputSearchType); /** * 查询楼宇信息表 * @@ -58,4 +64,5 @@ public interface IBuildingService * @return 结果 */ public int deleteBuildingById(Long id); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IDormitoryAdminService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IDormitoryAdminService.java index 8ef58b7..7c15ebb 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IDormitoryAdminService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IDormitoryAdminService.java @@ -23,6 +23,7 @@ public interface IDormitoryAdminService public PageResult search(SearchForm searchForm); public String validateSearchColumn(String userInputSearchType); + /** * 查询宿舍管理员 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IDormitoryService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IDormitoryService.java index fa4c712..3a14317 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IDormitoryService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IDormitoryService.java @@ -2,15 +2,21 @@ package com.ruoyi.system.service; import java.util.List; import com.ruoyi.system.domain.Dormitory; +import com.ruoyi.system.domain.DormitoryAdmin; +import com.ruoyi.system.vo.PageResult; /** * 宿舍表Service接口 * * @author ruoyi - * @date 2024-12-26 + * @date 2024-12-23 */ public interface IDormitoryService { + + public List getAvailableDormitories(); + + public PageResult findAll(int page, int size); /** * 查询宿舍表 * @@ -58,4 +64,5 @@ public interface IDormitoryService * @return 结果 */ public int deleteDormitoryById(Long id); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IStudentService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IStudentService.java index 4447017..066a70d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IStudentService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IStudentService.java @@ -4,6 +4,8 @@ import java.util.List; import com.ruoyi.system.domain.DormitoryAdmin; import com.ruoyi.system.domain.Student; +import com.ruoyi.system.form.SearchForm; +import com.ruoyi.system.form.StudentForm; import com.ruoyi.system.vo.PageResult; import com.ruoyi.system.vo.StudentVo; @@ -16,7 +18,14 @@ import com.ruoyi.system.vo.StudentVo; public interface IStudentService { public Boolean saveStudent(Student student); + public PageResult findAll(int page, int size); + + public PageResult search(SearchForm searchForm); + public String validateSearchColumn(String userInputSearchType); + + public Boolean update(StudentForm studentForm); + public Boolean deleteById(Long id); /** * 查询学生表 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AbsentServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AbsentServiceImpl.java deleted file mode 100644 index 1f1aa46..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AbsentServiceImpl.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.ruoyi.system.service.impl; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import java.util.ArrayList; -import com.ruoyi.common.utils.StringUtils; -import org.springframework.transaction.annotation.Transactional; -import com.ruoyi.system.domain.Student; -import com.ruoyi.system.mapper.AbsentMapper; -import com.ruoyi.system.domain.Absent; -import com.ruoyi.system.service.IAbsentService; - -/** - * 缺寝信息表Service业务层处理 - * - * @author ruoyi - * @date 2024-12-26 - */ -@Service -public class AbsentServiceImpl implements IAbsentService -{ - @Autowired - private AbsentMapper absentMapper; - - /** - * 查询缺寝信息表 - * - * @param id 缺寝信息表主键 - * @return 缺寝信息表 - */ - @Override - public Absent selectAbsentById(Long id) - { - return absentMapper.selectAbsentById(id); - } - - /** - * 查询缺寝信息表列表 - * - * @param absent 缺寝信息表 - * @return 缺寝信息表 - */ - @Override - public List selectAbsentList(Absent absent) - { - return absentMapper.selectAbsentList(absent); - } - - /** - * 新增缺寝信息表 - * - * @param absent 缺寝信息表 - * @return 结果 - */ - @Transactional - @Override - public int insertAbsent(Absent absent) - { - int rows = absentMapper.insertAbsent(absent); - insertStudent(absent); - return rows; - } - - /** - * 修改缺寝信息表 - * - * @param absent 缺寝信息表 - * @return 结果 - */ - @Transactional - @Override - public int updateAbsent(Absent absent) - { - absentMapper.deleteStudentByName(absent.getId()); - insertStudent(absent); - return absentMapper.updateAbsent(absent); - } - - /** - * 批量删除缺寝信息表 - * - * @param ids 需要删除的缺寝信息表主键 - * @return 结果 - */ - @Transactional - @Override - public int deleteAbsentByIds(Long[] ids) - { - absentMapper.deleteStudentByNames(ids); - return absentMapper.deleteAbsentByIds(ids); - } - - /** - * 删除缺寝信息表信息 - * - * @param id 缺寝信息表主键 - * @return 结果 - */ - @Transactional - @Override - public int deleteAbsentById(Long id) - { - absentMapper.deleteStudentByName(id); - return absentMapper.deleteAbsentById(id); - } - - /** - * 新增学生表信息 - * - * @param absent 缺寝信息表对象 - */ - public void insertStudent(Absent absent) - { - List studentList = absent.getStudentList(); - Long id = absent.getId(); - if (StringUtils.isNotNull(studentList)) - { - List list = new ArrayList(); - for (Student student : studentList) - { - student.setName(String.valueOf(id)); - list.add(student); - } - if (list.size() > 0) - { - absentMapper.batchStudent(list); - } - } - } -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BuildingServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BuildingServiceImpl.java index 1efc33a..20fd3c5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BuildingServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BuildingServiceImpl.java @@ -1,6 +1,10 @@ package com.ruoyi.system.service.impl; import java.util.List; + +import com.ruoyi.system.domain.Student; +import com.ruoyi.system.form.SearchForm; +import com.ruoyi.system.vo.PageResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.BuildingMapper; @@ -18,7 +22,52 @@ public class BuildingServiceImpl implements IBuildingService { @Autowired private BuildingMapper buildingMapper; + @Override + public PageResult findAll(int page, int size) { + int offset = page * size; + List builds = buildingMapper.findDormitoryAdminsByPage(offset, size); + int totalElements = buildingMapper.countDormitoryAdmins(); + return new PageResult<>(builds, totalElements); + } + @Override + public String validateSearchColumn(String userInputSearchType) { + // 实现你的验证逻辑,例如检查输入是否在允许的列名列表中 + // 这里只是一个示例,你应该根据你的需求来实现这个逻辑 + String[] allowedColumns = {"introduction", "name"}; // 假设这些是你允许的列名 + for (String allowedColumn : allowedColumns) { + if (allowedColumn.equalsIgnoreCase(userInputSearchType)) { + return allowedColumn; // 返回经过验证的列名 + } + } + return null; // 如果没有找到匹配的列名,则返回null + } + @Override + public PageResult search(SearchForm searchForm) { + //模糊查询加分页 + int offset = (searchForm.getPage()-1) * searchForm.getSize(); + // 模糊查询加分页 + List builds; + int totalElements; + + if (searchForm.getValue().trim().isEmpty()) { + // 如果没有搜索值,直接分页查询 + builds = buildingMapper.findDormitoryAdminsByPage(offset, searchForm.getSize()); + totalElements = buildingMapper.countDormitoryAdmins(); + } else { + String validatedSearchColumn = validateSearchColumn(searchForm.getKey()); + if (validatedSearchColumn == null) { + // 如果无效的搜索类型,直接返回空结果 + return new PageResult<>(null, 0); + } + // 如果有搜索值,执行模糊查询 + builds = buildingMapper.findDormitoryAdminsByValueAndPage(validatedSearchColumn, searchForm.getValue(),offset, searchForm.getSize()); + // 获取模糊查询后的总记录数 + totalElements = buildingMapper.countDormitoryAdminsByValue(validatedSearchColumn,searchForm.getValue()); + } + // 封装分页结果 + return new PageResult<>(builds, totalElements); + } /** * 查询楼宇信息表 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DormitoryServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DormitoryServiceImpl.java index 39a5ac1..73f3a6b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DormitoryServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DormitoryServiceImpl.java @@ -1,12 +1,11 @@ package com.ruoyi.system.service.impl; import java.util.List; + +import com.ruoyi.system.domain.DormitoryAdmin; +import com.ruoyi.system.vo.PageResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import com.ruoyi.common.utils.StringUtils; -import org.springframework.transaction.annotation.Transactional; -import com.ruoyi.system.domain.Student; import com.ruoyi.system.mapper.DormitoryMapper; import com.ruoyi.system.domain.Dormitory; import com.ruoyi.system.service.IDormitoryService; @@ -15,7 +14,7 @@ import com.ruoyi.system.service.IDormitoryService; * 宿舍表Service业务层处理 * * @author ruoyi - * @date 2024-12-26 + * @date 2024-12-23 */ @Service public class DormitoryServiceImpl implements IDormitoryService @@ -23,6 +22,18 @@ public class DormitoryServiceImpl implements IDormitoryService @Autowired private DormitoryMapper dormitoryMapper; + public List getAvailableDormitories() { + // 使用自定义 Mapper 来查询可用的宿舍 + return dormitoryMapper.selectAvailableDormitories(); + } + @Override + public PageResult findAll(int page, int size) { + int offset = page * size; + List dormitoryAdmins = dormitoryMapper.findDormitoryAdminsByPage(offset, size); + int totalElements = dormitoryMapper.countDormitoryAdmins(); + return new PageResult<>(dormitoryAdmins, totalElements); + } + /** * 查询宿舍表 * @@ -53,13 +64,10 @@ public class DormitoryServiceImpl implements IDormitoryService * @param dormitory 宿舍表 * @return 结果 */ - @Transactional @Override public int insertDormitory(Dormitory dormitory) { - int rows = dormitoryMapper.insertDormitory(dormitory); - insertStudent(dormitory); - return rows; + return dormitoryMapper.insertDormitory(dormitory); } /** @@ -68,12 +76,9 @@ public class DormitoryServiceImpl implements IDormitoryService * @param dormitory 宿舍表 * @return 结果 */ - @Transactional @Override public int updateDormitory(Dormitory dormitory) { - dormitoryMapper.deleteStudentByDormitoryId(dormitory.getId()); - insertStudent(dormitory); return dormitoryMapper.updateDormitory(dormitory); } @@ -83,11 +88,9 @@ public class DormitoryServiceImpl implements IDormitoryService * @param ids 需要删除的宿舍表主键 * @return 结果 */ - @Transactional @Override public int deleteDormitoryByIds(Long[] ids) { - dormitoryMapper.deleteStudentByDormitoryIds(ids); return dormitoryMapper.deleteDormitoryByIds(ids); } @@ -97,35 +100,9 @@ public class DormitoryServiceImpl implements IDormitoryService * @param id 宿舍表主键 * @return 结果 */ - @Transactional @Override public int deleteDormitoryById(Long id) { - dormitoryMapper.deleteStudentByDormitoryId(id); return dormitoryMapper.deleteDormitoryById(id); } - - /** - * 新增学生表信息 - * - * @param dormitory 宿舍表对象 - */ - public void insertStudent(Dormitory dormitory) - { - List studentList = dormitory.getStudentList(); - Long id = dormitory.getId(); - if (StringUtils.isNotNull(studentList)) - { - List list = new ArrayList(); - for (Student student : studentList) - { - student.setDormitoryId(id); - list.add(student); - } - if (list.size() > 0) - { - dormitoryMapper.batchStudent(list); - } - } - } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/StudentServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/StudentServiceImpl.java index 798e9de..a5bd0f1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/StudentServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/StudentServiceImpl.java @@ -3,10 +3,13 @@ package com.ruoyi.system.service.impl; import java.util.List; import com.ruoyi.system.domain.Dormitory; -import com.ruoyi.system.domain.DormitoryAdmin; +import com.ruoyi.system.form.SearchForm; +import com.ruoyi.system.form.StudentForm; import com.ruoyi.system.mapper.DormitoryMapper; import com.ruoyi.system.util.CommonUtil; import com.ruoyi.system.vo.PageResult; +import com.ruoyi.system.vo.StudentVo; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.StudentMapper; @@ -31,13 +34,13 @@ public class StudentServiceImpl implements IStudentService public Boolean saveStudent(Student student) { //添加学生数据 student.setState("入住"); - student.setCreateDate(CommonUtil.createData()); + student.setCreate_date(CommonUtil.createData()); int insert = this.studentMapper.insertStudent(student); if(insert != 1){ return false; } //更新宿舍信息 - Dormitory dormitory = dormitoryMapper.selectDormitoryById(student.getDormitoryId()); + Dormitory dormitory = dormitoryMapper.selectDormitoryById(student.getDormitory_id()); if(dormitory.getAvailabe() == 0){ return false; } @@ -56,6 +59,85 @@ public class StudentServiceImpl implements IStudentService return new PageResult<>(students, totalElements); } + public String validateSearchColumn(String userInputSearchType) { + // 实现你的验证逻辑,例如检查输入是否在允许的列名列表中 + // 这里只是一个示例,你应该根据你的需求来实现这个逻辑 + String[] allowedColumns = {"number", "name"}; // 假设这些是你允许的列名 + for (String allowedColumn : allowedColumns) { + if (allowedColumn.equalsIgnoreCase(userInputSearchType)) { + return allowedColumn; // 返回经过验证的列名 + } + } + return null; // 如果没有找到匹配的列名,则返回null + } + + @Override + public Boolean update(StudentForm studentForm) { + //更新学生信息 + Student student = new Student(); + BeanUtils.copyProperties(studentForm,student); + int update = this.studentMapper.updateStudent(student); + if(update != 1) return false; + //更新宿舍信息 + if(!studentForm.getDormitory_id().equals(studentForm.getOldDormitoryId())){ + //old+1 + try { + this.dormitoryMapper.addAvailable(studentForm.getOldDormitoryId()); + this.dormitoryMapper.subAvailable(studentForm.getDormitory_id()); + }catch (Exception e){ + return false; + } + } + return true; + } + + @Override + public Boolean deleteById(Long id) { + //修改宿舍数据 + Student student = studentMapper.selectStudentById(id); + try{ + Dormitory dormitory = dormitoryMapper.selectDormitoryById(student.getDormitory_id()); + if(dormitory.getType() > dormitory.getAvailabe()){ + this.dormitoryMapper.addAvailable(student.getDormitory_id()); + } + }catch (Exception e){ + return false; + } + //删除学生数据 + int delete = studentMapper.deleteStudentById(id); + if(delete != 1) return false; + + return true; + } + + @Override + public PageResult search(SearchForm searchForm) { + //模糊查询加分页 + int offset = (searchForm.getPage()-1) * searchForm.getSize(); + + // 模糊查询加分页 + List students; + int totalElements; + + if (searchForm.getValue().trim().isEmpty()) { + // 如果没有搜索值,直接分页查询 + students = studentMapper.findDormitoryAdminsByPage(offset, searchForm.getSize()); + totalElements = studentMapper.countDormitoryAdmins(); + } else { + String validatedSearchColumn = validateSearchColumn(searchForm.getKey()); + if (validatedSearchColumn == null) { + // 如果无效的搜索类型,直接返回空结果 + return new PageResult<>(null, 0); + } + // 如果有搜索值,执行模糊查询 + students = studentMapper.findDormitoryAdminsByValueAndPage(validatedSearchColumn, searchForm.getValue(),offset, searchForm.getSize()); + // 获取模糊查询后的总记录数 + totalElements = studentMapper.countDormitoryAdminsByValue(validatedSearchColumn,searchForm.getValue()); + } + // 封装分页结果 + return new PageResult<>(students, totalElements); + } + /** * 查询学生表 * @@ -101,6 +183,9 @@ public class StudentServiceImpl implements IStudentService @Override public int updateStudent(Student student) { + int updateStudent = this.studentMapper.updateStudent(student); + //更新宿舍数据 + return studentMapper.updateStudent(student); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/vo/BuildingVO.java b/ruoyi-system/src/main/java/com/ruoyi/system/vo/BuildingVO.java new file mode 100644 index 0000000..075eeed --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/vo/BuildingVO.java @@ -0,0 +1,8 @@ +package com.ruoyi.system.vo; + +import lombok.Data; + +@Data +public class BuildingVO { + +} diff --git a/ruoyi-system/src/main/resources/mapper/system/AbsentMapper.xml b/ruoyi-system/src/main/resources/mapper/system/AbsentMapper.xml deleted file mode 100644 index 88c728e..0000000 --- a/ruoyi-system/src/main/resources/mapper/system/AbsentMapper.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - select id, building_id, dormitory_id, student_id, dormitory_admin_id, create_date, reason from absent - - - - - - - - - - insert into absent - - building_id, - dormitory_id, - student_id, - dormitory_admin_id, - create_date, - reason, - - - #{buildingId}, - #{dormitoryId}, - #{studentId}, - #{dormitoryAdminId}, - #{createDate}, - #{reason}, - - - - - update absent - - building_id = #{buildingId}, - dormitory_id = #{dormitoryId}, - student_id = #{studentId}, - dormitory_admin_id = #{dormitoryAdminId}, - create_date = #{createDate}, - reason = #{reason}, - - where id = #{id} - - - - delete from absent where id = #{id} - - - - delete from absent where id in - - #{id} - - - - - delete from student where name in - - #{name} - - - - - delete from student where name = #{name} - - - - insert into student( id, number, name, gender, dormitory_id, state, create_date) values - - ( #{item.id}, #{item.number}, #{item.name}, #{item.gender}, #{item.dormitoryId}, #{item.state}, #{item.createDate}) - - - \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/BuildingMapper.xml b/ruoyi-system/src/main/resources/mapper/system/BuildingMapper.xml index ac17bfa..b9fc297 100644 --- a/ruoyi-system/src/main/resources/mapper/system/BuildingMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/BuildingMapper.xml @@ -28,6 +28,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + + insert into building diff --git a/ruoyi-system/src/main/resources/mapper/system/DormitoryMapper.xml b/ruoyi-system/src/main/resources/mapper/system/DormitoryMapper.xml index d49810f..37e805a 100644 --- a/ruoyi-system/src/main/resources/mapper/system/DormitoryMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/DormitoryMapper.xml @@ -13,20 +13,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - - - - - - - - - - - - select id, building_id, name, type, availabe, telephone from dormitory @@ -42,16 +28,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + where id = #{id} - - + select id, building_id, name, type, availabe, telephone from dormitory where availabe >0 @@ -83,6 +65,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + update dormitory set availabe = availabe-1 where id = #{id} + + + + update dormitory set availabe = availabe+1 where id = #{id} + delete from dormitory where id = #{id} @@ -94,22 +83,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} - - - delete from student where dormitory_id in - - #{dormitoryId} - - - - - delete from student where dormitory_id = #{dormitoryId} - - - - insert into student( id, number, name, gender, dormitory_id, state, create_date) values - - ( #{item.id}, #{item.number}, #{item.name}, #{item.gender}, #{item.dormitoryId}, #{item.state}, #{item.createDate}) - - \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/StudentMapper.xml b/ruoyi-system/src/main/resources/mapper/system/StudentMapper.xml index 152c3e4..eb0e13c 100644 --- a/ruoyi-system/src/main/resources/mapper/system/StudentMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/StudentMapper.xml @@ -20,13 +20,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -39,6 +39,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from student limit #{offset}, #{limit} + + @@ -47,17 +58,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" number, name, gender, - dormitory_id, + dormitory_id, state, - create_date, + create_date, #{number}, #{name}, #{gender}, - #{dormitoryId}, + #{dormitory_id}, #{state}, - #{createDate}, + #{create_date}, @@ -67,9 +78,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" number = #{number}, name = #{name}, gender = #{gender}, - dormitory_id = #{dormitoryId}, + dormitory_id = #{dormitory_id}, state = #{state}, - create_date = #{createDate}, + create_date = #{create_date}, where id = #{id}