优化了后端接口
This commit is contained in:
parent
1826f60f9c
commit
b07df697d5
|
@ -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<Absent> 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<Absent> list = absentService.selectAbsentList(absent);
|
||||
ExcelUtil<Absent> util = new ExcelUtil<Absent>(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));
|
||||
}
|
||||
}
|
|
@ -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<PageResult<Building>> listBuilding(
|
||||
@PathVariable("page") int page, // 使用 @PathVariable 而不是 @RequestParam
|
||||
@PathVariable("size") int size) { // 同样使用 @PathVariable
|
||||
|
||||
// 注意:通常页码从 1 开始更合理,但这里保留您的默认值 0
|
||||
// 如果业务逻辑需要页码从 1 开始,您可能需要在服务层添加额外的处理
|
||||
|
||||
PageResult<Building> pageResult = buildingService.findAll(page-1, size);
|
||||
return ResponseEntity.ok(pageResult);
|
||||
}
|
||||
|
||||
@Anonymous
|
||||
@GetMapping("/search")
|
||||
public PageResult<Building> 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));
|
||||
|
|
|
@ -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<Dormitory> list = dormitoryService.getAvailableDormitories();
|
||||
ResultVo resultVo = new ResultVo();
|
||||
resultVo.setData(list);
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
|
||||
@Anonymous
|
||||
@GetMapping("/list/{page}/{size}")
|
||||
public ResponseEntity<PageResult<Dormitory>> getAllDormitoryAdmins(
|
||||
@PathVariable("page") int page, // 使用 @PathVariable 而不是 @RequestParam
|
||||
@PathVariable("size") int size) { // 同样使用 @PathVariable
|
||||
|
||||
// 注意:通常页码从 1 开始更合理,但这里保留您的默认值 0
|
||||
// 如果业务逻辑需要页码从 1 开始,您可能需要在服务层添加额外的处理
|
||||
|
||||
PageResult<Dormitory> 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)
|
||||
|
|
|
@ -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<Student> pageResult = studentService.findAll(page-1, size);
|
||||
return ResponseEntity.ok(pageResult);
|
||||
}
|
||||
@Anonymous
|
||||
@GetMapping("/search")
|
||||
public PageResult<Student> search(SearchForm searchForm){
|
||||
return studentService.search(searchForm);
|
||||
}
|
||||
/**
|
||||
* 查询学生表列表
|
||||
*/
|
||||
|
@ -71,12 +81,54 @@ public class StudentController extends BaseController
|
|||
List<Student> 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)
|
||||
|
|
|
@ -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<Student> 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<Student> getStudentList()
|
||||
{
|
||||
return studentList;
|
||||
}
|
||||
|
||||
public void setStudentList(List<Student> 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();
|
||||
}
|
||||
}
|
|
@ -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<Student> studentList;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
|
@ -97,16 +93,6 @@ public class Dormitory extends BaseEntity
|
|||
return telephone;
|
||||
}
|
||||
|
||||
public List<Student> getStudentList()
|
||||
{
|
||||
return studentList;
|
||||
}
|
||||
|
||||
public void setStudentList(List<Student> 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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<Absent> 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<Student> studentList);
|
||||
|
||||
|
||||
/**
|
||||
* 通过缺寝信息表主键删除学生表信息
|
||||
*
|
||||
* @param id 缺寝信息表ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteStudentByName(Long id);
|
||||
}
|
|
@ -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<Building> findDormitoryAdminsByPage(@Param("offset") int offset, @Param("limit") int limit);
|
||||
// 查询总记录数
|
||||
@Select("SELECT COUNT(*) FROM building")
|
||||
int countDormitoryAdmins();
|
||||
|
||||
List<Building> 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);
|
||||
/**
|
||||
* 查询楼宇信息表
|
||||
*
|
||||
|
|
|
@ -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<Dormitory> selectAvailableDormitories();
|
||||
public void subAvailable(Long id);
|
||||
public void addAvailable(Long id);
|
||||
|
||||
@Select("SELECT * FROM dormitory LIMIT #{offset}, #{limit}")
|
||||
List<Dormitory> 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<Student> studentList);
|
||||
|
||||
|
||||
/**
|
||||
* 通过宿舍表主键删除学生表信息
|
||||
*
|
||||
* @param id 宿舍表ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteStudentByDormitoryId(Long id);
|
||||
}
|
||||
|
|
|
@ -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<Student> 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);
|
||||
|
||||
/**
|
||||
* 查询学生表
|
||||
*
|
||||
|
|
|
@ -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<Absent> 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);
|
||||
}
|
|
@ -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<Building> 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);
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ public interface IDormitoryAdminService
|
|||
public PageResult search(SearchForm searchForm);
|
||||
public String validateSearchColumn(String userInputSearchType);
|
||||
|
||||
|
||||
/**
|
||||
* 查询宿舍管理员
|
||||
*
|
||||
|
|
|
@ -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<Dormitory> getAvailableDormitories();
|
||||
|
||||
public PageResult<Dormitory> findAll(int page, int size);
|
||||
/**
|
||||
* 查询宿舍表
|
||||
*
|
||||
|
@ -58,4 +64,5 @@ public interface IDormitoryService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteDormitoryById(Long id);
|
||||
|
||||
}
|
||||
|
|
|
@ -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<Student> 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);
|
||||
/**
|
||||
* 查询学生表
|
||||
*
|
||||
|
|
|
@ -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<Absent> 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<Student> studentList = absent.getStudentList();
|
||||
Long id = absent.getId();
|
||||
if (StringUtils.isNotNull(studentList))
|
||||
{
|
||||
List<Student> list = new ArrayList<Student>();
|
||||
for (Student student : studentList)
|
||||
{
|
||||
student.setName(String.valueOf(id));
|
||||
list.add(student);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
absentMapper.batchStudent(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<Building> findAll(int page, int size) {
|
||||
int offset = page * size;
|
||||
List<Building> 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<Building> 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);
|
||||
}
|
||||
/**
|
||||
* 查询楼宇信息表
|
||||
*
|
||||
|
|
|
@ -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<Dormitory> getAvailableDormitories() {
|
||||
// 使用自定义 Mapper 来查询可用的宿舍
|
||||
return dormitoryMapper.selectAvailableDormitories();
|
||||
}
|
||||
@Override
|
||||
public PageResult<Dormitory> findAll(int page, int size) {
|
||||
int offset = page * size;
|
||||
List<Dormitory> 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<Student> studentList = dormitory.getStudentList();
|
||||
Long id = dormitory.getId();
|
||||
if (StringUtils.isNotNull(studentList))
|
||||
{
|
||||
List<Student> list = new ArrayList<Student>();
|
||||
for (Student student : studentList)
|
||||
{
|
||||
student.setDormitoryId(id);
|
||||
list.add(student);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
dormitoryMapper.batchStudent(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Student> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package com.ruoyi.system.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BuildingVO {
|
||||
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.system.mapper.AbsentMapper">
|
||||
|
||||
<resultMap type="Absent" id="AbsentResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="buildingId" column="building_id" />
|
||||
<result property="dormitoryId" column="dormitory_id" />
|
||||
<result property="studentId" column="student_id" />
|
||||
<result property="dormitoryAdminId" column="dormitory_admin_id" />
|
||||
<result property="createDate" column="create_date" />
|
||||
<result property="reason" column="reason" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="AbsentStudentResult" type="Absent" extends="AbsentResult">
|
||||
<collection property="studentList" ofType="Student" column="id" select="selectStudentList" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="Student" id="StudentResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="number" column="number" />
|
||||
<result property="name" column="name" />
|
||||
<result property="gender" column="gender" />
|
||||
<result property="dormitoryId" column="dormitory_id" />
|
||||
<result property="state" column="state" />
|
||||
<result property="createDate" column="create_date" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAbsentVo">
|
||||
select id, building_id, dormitory_id, student_id, dormitory_admin_id, create_date, reason from absent
|
||||
</sql>
|
||||
|
||||
<select id="selectAbsentList" parameterType="Absent" resultMap="AbsentResult">
|
||||
<include refid="selectAbsentVo"/>
|
||||
<where>
|
||||
<if test="buildingId != null "> and building_id = #{buildingId}</if>
|
||||
<if test="dormitoryId != null "> and dormitory_id = #{dormitoryId}</if>
|
||||
<if test="studentId != null "> and student_id = #{studentId}</if>
|
||||
<if test="dormitoryAdminId != null "> and dormitory_admin_id = #{dormitoryAdminId}</if>
|
||||
<if test="createDate != null and createDate != ''"> and create_date = #{createDate}</if>
|
||||
<if test="reason != null and reason != ''"> and reason = #{reason}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectAbsentById" parameterType="Long" resultMap="AbsentStudentResult">
|
||||
select id, building_id, dormitory_id, student_id, dormitory_admin_id, create_date, reason
|
||||
from absent
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectStudentList" resultMap="StudentResult">
|
||||
select id, number, name, gender, dormitory_id, state, create_date
|
||||
from student
|
||||
where name = #{name}
|
||||
</select>
|
||||
|
||||
<insert id="insertAbsent" parameterType="Absent" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into absent
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="buildingId != null">building_id,</if>
|
||||
<if test="dormitoryId != null">dormitory_id,</if>
|
||||
<if test="studentId != null">student_id,</if>
|
||||
<if test="dormitoryAdminId != null">dormitory_admin_id,</if>
|
||||
<if test="createDate != null">create_date,</if>
|
||||
<if test="reason != null">reason,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="buildingId != null">#{buildingId},</if>
|
||||
<if test="dormitoryId != null">#{dormitoryId},</if>
|
||||
<if test="studentId != null">#{studentId},</if>
|
||||
<if test="dormitoryAdminId != null">#{dormitoryAdminId},</if>
|
||||
<if test="createDate != null">#{createDate},</if>
|
||||
<if test="reason != null">#{reason},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateAbsent" parameterType="Absent">
|
||||
update absent
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="buildingId != null">building_id = #{buildingId},</if>
|
||||
<if test="dormitoryId != null">dormitory_id = #{dormitoryId},</if>
|
||||
<if test="studentId != null">student_id = #{studentId},</if>
|
||||
<if test="dormitoryAdminId != null">dormitory_admin_id = #{dormitoryAdminId},</if>
|
||||
<if test="createDate != null">create_date = #{createDate},</if>
|
||||
<if test="reason != null">reason = #{reason},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAbsentById" parameterType="Long">
|
||||
delete from absent where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAbsentByIds" parameterType="String">
|
||||
delete from absent where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteStudentByNames" parameterType="String">
|
||||
delete from student where name in
|
||||
<foreach item="name" collection="array" open="(" separator="," close=")">
|
||||
#{name}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteStudentByName" parameterType="Long">
|
||||
delete from student where name = #{name}
|
||||
</delete>
|
||||
|
||||
<insert id="batchStudent">
|
||||
insert into student( id, number, name, gender, dormitory_id, state, create_date) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
( #{item.id}, #{item.number}, #{item.name}, #{item.gender}, #{item.dormitoryId}, #{item.state}, #{item.createDate})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
|
@ -28,6 +28,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectBuildingVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="findDormitoryAdminsByPage" resultType="com.ruoyi.system.domain.Building">
|
||||
select id, name, introduction, admin_id
|
||||
from building
|
||||
limit #{offset}, #{limit}
|
||||
</select>
|
||||
<select id="findDormitoryAdminsByValueAndPage" resultType="com.ruoyi.system.domain.Building">
|
||||
SELECT id, name, introduction, admin_id
|
||||
FROM building
|
||||
WHERE ${searchColumn} LIKE CONCAT('%', #{searchValue}, '%')
|
||||
LIMIT #{offset}, #{size}
|
||||
</select>
|
||||
<select id="countDormitoryAdminsByValue" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM building
|
||||
WHERE ${searchColumn} LIKE CONCAT('%', #{searchValue}, '%')
|
||||
</select>
|
||||
|
||||
<insert id="insertBuilding" parameterType="Building" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into building
|
||||
|
|
|
@ -13,20 +13,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="telephone" column="telephone" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="DormitoryStudentResult" type="Dormitory" extends="DormitoryResult">
|
||||
<collection property="studentList" ofType="Student" column="id" select="selectStudentList" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="Student" id="StudentResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="number" column="number" />
|
||||
<result property="name" column="name" />
|
||||
<result property="gender" column="gender" />
|
||||
<result property="dormitoryId" column="dormitory_id" />
|
||||
<result property="state" column="state" />
|
||||
<result property="createDate" column="create_date" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDormitoryVo">
|
||||
select id, building_id, name, type, availabe, telephone from dormitory
|
||||
</sql>
|
||||
|
@ -42,16 +28,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectDormitoryById" parameterType="Long" resultMap="DormitoryStudentResult">
|
||||
select id, building_id, name, type, availabe, telephone
|
||||
from dormitory
|
||||
<select id="selectDormitoryById" parameterType="Long" resultMap="DormitoryResult">
|
||||
<include refid="selectDormitoryVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectStudentList" resultMap="StudentResult">
|
||||
select id, number, name, gender, dormitory_id, state, create_date
|
||||
from student
|
||||
where dormitory_id = #{dormitory_id}
|
||||
<select id="selectAvailableDormitories" resultType="com.ruoyi.system.domain.Dormitory">
|
||||
select id, building_id, name, type, availabe, telephone from dormitory where availabe >0
|
||||
</select>
|
||||
|
||||
<insert id="insertDormitory" parameterType="Dormitory" useGeneratedKeys="true" keyProperty="id">
|
||||
|
@ -83,6 +65,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="subAvailable">
|
||||
update dormitory set availabe = availabe-1 where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="addAvailable">
|
||||
update dormitory set availabe = availabe+1 where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteDormitoryById" parameterType="Long">
|
||||
delete from dormitory where id = #{id}
|
||||
|
@ -94,22 +83,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteStudentByDormitoryIds" parameterType="String">
|
||||
delete from student where dormitory_id in
|
||||
<foreach item="dormitoryId" collection="array" open="(" separator="," close=")">
|
||||
#{dormitoryId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteStudentByDormitoryId" parameterType="Long">
|
||||
delete from student where dormitory_id = #{dormitoryId}
|
||||
</delete>
|
||||
|
||||
<insert id="batchStudent">
|
||||
insert into student( id, number, name, gender, dormitory_id, state, create_date) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
( #{item.id}, #{item.number}, #{item.name}, #{item.gender}, #{item.dormitoryId}, #{item.state}, #{item.createDate})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
|
@ -20,13 +20,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="selectStudentList" parameterType="Student" resultMap="StudentResult">
|
||||
<include refid="selectStudentVo"/>
|
||||
<where>
|
||||
<where>
|
||||
<if test="number != null and number != ''"> and number = #{number}</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="gender != null and gender != ''"> and gender = #{gender}</if>
|
||||
<if test="dormitoryId != null "> and dormitory_id = #{dormitoryId}</if>
|
||||
<if test="dormitory_id != null "> and dormitory_id = #{dormitory_id}</if>
|
||||
<if test="state != null and state != ''"> and state = #{state}</if>
|
||||
<if test="createDate != null and createDate != ''"> and create_date = #{createDate}</if>
|
||||
<if test="create_date != null and create_date != ''"> and create_date = #{create_date}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
@ -39,6 +39,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from student
|
||||
limit #{offset}, #{limit}
|
||||
</select>
|
||||
<select id="findDormitoryAdminsByValueAndPage" resultType="com.ruoyi.system.domain.Student">
|
||||
SELECT id, number, name, gender, dormitory_id, state, create_date
|
||||
FROM student
|
||||
WHERE ${searchColumn} LIKE CONCAT('%', #{searchValue}, '%')
|
||||
LIMIT #{offset}, #{size}
|
||||
</select>
|
||||
<select id="countDormitoryAdminsByValue" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM student
|
||||
WHERE ${searchColumn} LIKE CONCAT('%', #{searchValue}, '%')
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertStudent" parameterType="Student" useGeneratedKeys="true" keyProperty="id">
|
||||
|
@ -47,17 +58,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="number != null">number,</if>
|
||||
<if test="name != null">name,</if>
|
||||
<if test="gender != null">gender,</if>
|
||||
<if test="dormitoryId != null">dormitory_id,</if>
|
||||
<if test="dormitory_id != null">dormitory_id,</if>
|
||||
<if test="state != null">state,</if>
|
||||
<if test="createDate != null">create_date,</if>
|
||||
<if test="create_date != null">create_date,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="number != null">#{number},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="gender != null">#{gender},</if>
|
||||
<if test="dormitoryId != null">#{dormitoryId},</if>
|
||||
<if test="dormitory_id != null">#{dormitory_id},</if>
|
||||
<if test="state != null">#{state},</if>
|
||||
<if test="createDate != null">#{createDate},</if>
|
||||
<if test="create_date != null">#{create_date},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -67,9 +78,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="number != null">number = #{number},</if>
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="gender != null">gender = #{gender},</if>
|
||||
<if test="dormitoryId != null">dormitory_id = #{dormitoryId},</if>
|
||||
<if test="dormitory_id != null">dormitory_id = #{dormitory_id},</if>
|
||||
<if test="state != null">state = #{state},</if>
|
||||
<if test="createDate != null">create_date = #{createDate},</if>
|
||||
<if test="create_date != null">create_date = #{create_date},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
|
Loading…
Reference in New Issue