增加了absent表
This commit is contained in:
parent
b31ef51f62
commit
49564f3123
|
@ -0,0 +1,115 @@
|
|||
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));
|
||||
}
|
||||
}
|
|
@ -3,9 +3,7 @@ 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.vo.ResultVo;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -29,7 +27,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|||
* 宿舍表Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-23
|
||||
* @date 2024-12-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dormitory")
|
||||
|
@ -38,18 +36,11 @@ 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;
|
||||
}
|
||||
/**
|
||||
* 查询宿舍表列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dormitory:list')")
|
||||
// @PreAuthorize("@ss.hasPermi('system:dormitory:list')")
|
||||
@Anonymous
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(Dormitory dormitory)
|
||||
{
|
||||
|
@ -61,7 +52,8 @@ public class DormitoryController extends BaseController
|
|||
/**
|
||||
* 导出宿舍表列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dormitory:export')")
|
||||
// @PreAuthorize("@ss.hasPermi('system:dormitory:export')")
|
||||
@Anonymous
|
||||
@Log(title = "宿舍表", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Dormitory dormitory)
|
||||
|
@ -74,7 +66,8 @@ public class DormitoryController extends BaseController
|
|||
/**
|
||||
* 获取宿舍表详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dormitory:query')")
|
||||
// @PreAuthorize("@ss.hasPermi('system:dormitory:query')")
|
||||
@Anonymous
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
|
@ -84,7 +77,8 @@ public class DormitoryController extends BaseController
|
|||
/**
|
||||
* 新增宿舍表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dormitory:add')")
|
||||
// @PreAuthorize("@ss.hasPermi('system:dormitory:add')")
|
||||
@Anonymous
|
||||
@Log(title = "宿舍表", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Dormitory dormitory)
|
||||
|
@ -95,7 +89,8 @@ public class DormitoryController extends BaseController
|
|||
/**
|
||||
* 修改宿舍表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dormitory:edit')")
|
||||
// @PreAuthorize("@ss.hasPermi('system:dormitory:edit')")
|
||||
@Anonymous
|
||||
@Log(title = "宿舍表", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Dormitory dormitory)
|
||||
|
@ -106,7 +101,8 @@ public class DormitoryController extends BaseController
|
|||
/**
|
||||
* 删除宿舍表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dormitory:remove')")
|
||||
// @PreAuthorize("@ss.hasPermi('system:dormitory:remove')")
|
||||
@Anonymous
|
||||
@Log(title = "宿舍表", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
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,5 +1,6 @@
|
|||
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;
|
||||
|
@ -9,7 +10,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
|||
* 宿舍表对象 dormitory
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-23
|
||||
* @date 2024-12-26
|
||||
*/
|
||||
public class Dormitory extends BaseEntity
|
||||
{
|
||||
|
@ -38,6 +39,9 @@ public class Dormitory extends BaseEntity
|
|||
@Excel(name = "telephone")
|
||||
private String telephone;
|
||||
|
||||
/** 学生表信息 */
|
||||
private List<Student> studentList;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
|
@ -93,6 +97,16 @@ 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)
|
||||
|
@ -102,6 +116,7 @@ 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-23
|
||||
* @date 2024-12-26
|
||||
*/
|
||||
public class Student extends BaseEntity
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ public class Student extends BaseEntity
|
|||
|
||||
/** dormitory_id */
|
||||
@Excel(name = "dormitory_id")
|
||||
private Long dormitory_id;
|
||||
private Long dormitoryId;
|
||||
|
||||
/** state */
|
||||
@Excel(name = "state")
|
||||
|
@ -40,7 +40,7 @@ public class Student extends BaseEntity
|
|||
|
||||
/** create_date */
|
||||
@Excel(name = "create_date")
|
||||
private String create_date;
|
||||
private String createDate;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
|
@ -80,12 +80,12 @@ public class Student extends BaseEntity
|
|||
}
|
||||
public void setDormitoryId(Long dormitoryId)
|
||||
{
|
||||
this.dormitory_id = dormitoryId;
|
||||
this.dormitoryId = dormitoryId;
|
||||
}
|
||||
|
||||
public Long getDormitoryId()
|
||||
{
|
||||
return dormitory_id;
|
||||
return dormitoryId;
|
||||
}
|
||||
public void setState(String state)
|
||||
{
|
||||
|
@ -98,12 +98,12 @@ public class Student extends BaseEntity
|
|||
}
|
||||
public void setCreateDate(String createDate)
|
||||
{
|
||||
this.create_date = createDate;
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public String getCreateDate()
|
||||
{
|
||||
return create_date;
|
||||
return createDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
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,18 +2,16 @@ package com.ruoyi.system.mapper;
|
|||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.Dormitory;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import com.ruoyi.system.domain.Student;
|
||||
|
||||
/**
|
||||
* 宿舍表Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-23
|
||||
* @date 2024-12-26
|
||||
*/
|
||||
public interface DormitoryMapper
|
||||
{
|
||||
@Select("SELECT * FROM dormitory WHERE availabe > 0")
|
||||
List<Dormitory> selectAvailableDormitories();
|
||||
/**
|
||||
* 查询宿舍表
|
||||
*
|
||||
|
@ -61,4 +59,29 @@ public interface DormitoryMapper
|
|||
* @return 结果
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
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);
|
||||
}
|
|
@ -7,12 +7,10 @@ import com.ruoyi.system.domain.Dormitory;
|
|||
* 宿舍表Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-23
|
||||
* @date 2024-12-26
|
||||
*/
|
||||
public interface IDormitoryService
|
||||
{
|
||||
|
||||
public List<Dormitory> getAvailableDormitories();
|
||||
/**
|
||||
* 查询宿舍表
|
||||
*
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,10 @@ 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.DormitoryMapper;
|
||||
import com.ruoyi.system.domain.Dormitory;
|
||||
import com.ruoyi.system.service.IDormitoryService;
|
||||
|
@ -11,7 +15,7 @@ import com.ruoyi.system.service.IDormitoryService;
|
|||
* 宿舍表Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-23
|
||||
* @date 2024-12-26
|
||||
*/
|
||||
@Service
|
||||
public class DormitoryServiceImpl implements IDormitoryService
|
||||
|
@ -19,10 +23,6 @@ public class DormitoryServiceImpl implements IDormitoryService
|
|||
@Autowired
|
||||
private DormitoryMapper dormitoryMapper;
|
||||
|
||||
public List<Dormitory> getAvailableDormitories() {
|
||||
// 使用自定义 Mapper 来查询可用的宿舍
|
||||
return dormitoryMapper.selectAvailableDormitories();
|
||||
}
|
||||
/**
|
||||
* 查询宿舍表
|
||||
*
|
||||
|
@ -53,10 +53,13 @@ public class DormitoryServiceImpl implements IDormitoryService
|
|||
* @param dormitory 宿舍表
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int insertDormitory(Dormitory dormitory)
|
||||
{
|
||||
return dormitoryMapper.insertDormitory(dormitory);
|
||||
int rows = dormitoryMapper.insertDormitory(dormitory);
|
||||
insertStudent(dormitory);
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,9 +68,12 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -77,9 +83,11 @@ public class DormitoryServiceImpl implements IDormitoryService
|
|||
* @param ids 需要删除的宿舍表主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int deleteDormitoryByIds(Long[] ids)
|
||||
{
|
||||
dormitoryMapper.deleteStudentByDormitoryIds(ids);
|
||||
return dormitoryMapper.deleteDormitoryByIds(ids);
|
||||
}
|
||||
|
||||
|
@ -89,9 +97,35 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
<?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>
|
|
@ -13,6 +13,20 @@ 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>
|
||||
|
@ -28,11 +42,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectDormitoryById" parameterType="Long" resultMap="DormitoryResult">
|
||||
<include refid="selectDormitoryVo"/>
|
||||
<select id="selectDormitoryById" parameterType="Long" resultMap="DormitoryStudentResult">
|
||||
select id, building_id, name, type, availabe, telephone
|
||||
from dormitory
|
||||
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>
|
||||
|
||||
<insert id="insertDormitory" parameterType="Dormitory" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into dormitory
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
@ -73,4 +94,22 @@ 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>
|
Loading…
Reference in New Issue