parent
fa4bb230ae
commit
b7375dfbf7
@ -0,0 +1,73 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Building;
|
||||
import com.yanzhen.entity.User;
|
||||
import com.yanzhen.service.BuildingService楼层设置;
|
||||
import com.yanzhen.service.UserService用户管理;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController // 标记为RESTful控制器
|
||||
@RequestMapping("/building") // 映射URL路径到该控制器
|
||||
public class BuildingController {
|
||||
|
||||
@Autowired // 自动注入BuildingService
|
||||
private BuildingService楼层设置 buildingService;
|
||||
@Autowired // 自动注入UserService
|
||||
private UserService用户管理 userService;
|
||||
|
||||
@PostMapping("create") // 映射POST请求到create方法
|
||||
public Result create(@RequestBody Building building){ // 接收JSON格式的楼宇对象
|
||||
int flag = buildingService.create(building); // 调用服务层创建楼宇
|
||||
if(flag>0){ // 如果创建成功
|
||||
return Result.ok(); // 返回成功结果
|
||||
}else{ // 如果创建失败
|
||||
return Result.fail(); // 返回失败结果
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("delete") // 映射GET请求到delete方法
|
||||
public Result delete(String ids){ // 接收楼宇ID字符串
|
||||
int flag = buildingService.delete(ids); // 调用服务层删除楼宇
|
||||
if(flag>0){ // 如果删除成功
|
||||
return Result.ok(); // 返回成功结果
|
||||
}else{ // 如果删除失败
|
||||
return Result.fail(); // 返回失败结果
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("update") // 映射POST请求到update方法
|
||||
public Result update(@RequestBody Building building){ // 接收JSON格式的楼宇对象
|
||||
int flag = buildingService.update(building); // 调用服务层更新楼宇信息
|
||||
if(flag>0){ // 如果更新成功
|
||||
return Result.ok(); // 返回成功结果
|
||||
}else{ // 如果更新失败
|
||||
return Result.fail(); // 返回失败结果
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("detail") // 映射GET请求到detail方法
|
||||
public Building detail(Integer id){ // 接收楼宇ID
|
||||
return buildingService.detail(id); // 调用服务层获取楼宇详情并返回
|
||||
}
|
||||
|
||||
@PostMapping("query") // 映射POST请求到query方法
|
||||
public Map<String,Object> query(@RequestBody Building building, HttpServletRequest request){ // 接收JSON格式的楼宇对象和HTTP请求
|
||||
User param = (User)request.getAttribute("user"); // 从请求中获取用户信息
|
||||
User loginUser = userService.detail(param.getId()); // 调用服务层获取用户详情
|
||||
if(loginUser.getType() == 1){ // 如果用户是宿管员
|
||||
building.setUserId(loginUser.getId()); // 设置楼宇的用户ID为当前登录用户的ID
|
||||
}
|
||||
PageInfo<Building> pageInfo = buildingService.query(building); // 调用服务层查询楼宇列表
|
||||
pageInfo.getList().forEach(entity->{ // 遍历查询结果中的每个楼宇
|
||||
User user = userService.detail(entity.getUserId()); // 调用服务层获取每个楼宇的用户信息
|
||||
entity.setUser(user); // 将用户信息设置到楼宇对象中
|
||||
});
|
||||
return Result.ok(pageInfo); // 返回查询结果
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.DormitorySet;
|
||||
import com.yanzhen.service.DormitorySetService宿舍设置增删查改数据库;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController // 声明这是一个控制器,并且返回的数据直接写入 HTTP 响应体中,而不是解析为跳转路径。
|
||||
@RequestMapping("/dormitorySet") // 设置请求的根路径为 /dormitorySet
|
||||
public class DormitorySetController { // 定义一个名为 DormitorySetController 的类
|
||||
|
||||
@Autowired // 自动注入 DormitorySetService 对象
|
||||
private DormitorySetService宿舍设置增删查改数据库 dormitorySetService;
|
||||
|
||||
@PostMapping("create") // 映射 HTTP POST 请求到 create 方法
|
||||
public Result create(@RequestBody DormitorySet dormitorySet){ // 从请求体中获取 DormitorySet 对象
|
||||
int flag = dormitorySetService.create(dormitorySet); // 调用服务层的 create 方法创建记录
|
||||
if(flag>0){ // 如果创建成功
|
||||
return Result.ok(); // 返回成功的 Result 对象
|
||||
}else{ // 如果创建失败
|
||||
return Result.fail(); // 返回失败的 Result 对象
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("delete") // 映射 HTTP GET 请求到 delete 方法
|
||||
public Result delete(String ids){ // 从请求参数中获取要删除的记录 ID
|
||||
int flag = dormitorySetService.delete(ids); // 调用服务层的 delete 方法删除记录
|
||||
if(flag>0){ // 如果删除成功
|
||||
return Result.ok(); // 返回成功的 Result 对象
|
||||
}else{ // 如果删除失败
|
||||
return Result.fail(); // 返回失败的 Result 对象
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("update") // 映射 HTTP POST 请求到 update 方法
|
||||
public Result update(@RequestBody DormitorySet dormitorySet){ // 从请求体中获取 DormitorySet 对象
|
||||
int flag = dormitorySetService.update(dormitorySet); // 调用服务层的 update 方法更新记录
|
||||
if(flag>0){ // 如果更新成功
|
||||
return Result.ok(); // 返回成功的 Result 对象
|
||||
}else{ // 如果更新失败
|
||||
return Result.fail(); // 返回失败的 Result 对象
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("detail") // 映射 HTTP GET 请求到 detail 方法
|
||||
public DormitorySet detail(Integer id){ // 从请求参数中获取记录 ID
|
||||
return dormitorySetService.detail(id); // 调用服务层的 detail 方法获取记录详情并返回
|
||||
}
|
||||
|
||||
@PostMapping("query") // 映射 HTTP POST 请求到 query 方法
|
||||
public Map<String,Object> query(@RequestBody DormitorySet dormitorySet){ // 从请求体中获取 DormitorySet 对象作为查询条件
|
||||
PageInfo<DormitorySet> pageInfo = dormitorySetService.query(dormitorySet); // 调用服务层的 query 方法进行分页查询
|
||||
return Result.ok(pageInfo); // 返回包含查询结果的成功的 Result 对象
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.DormitoryStudent;
|
||||
import com.yanzhen.entity.Student;
|
||||
import com.yanzhen.service.DormitoryService宿舍编号设置;
|
||||
import com.yanzhen.service.DormitoryStudentService宿舍预选设置;
|
||||
import com.yanzhen.service.StudentService学生管理;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController // 声明这是一个控制器,并且返回的数据直接写入 HTTP 响应体中,而不是解析为跳转路径。
|
||||
@RequestMapping("/dormitoryStudent") // 设置请求的根路径为 /dormitoryStudent
|
||||
public class DormitoryStudentController {
|
||||
|
||||
@Autowired // 自动注入DormitoryStudentService实例
|
||||
private DormitoryStudentService宿舍预选设置 dormitoryStudentService;
|
||||
|
||||
@Autowired // 自动注入StudentService实例
|
||||
private StudentService学生管理 studentService;
|
||||
|
||||
@Autowired // 自动注入DormitoryService实例
|
||||
private DormitoryService宿舍编号设置 dormitoryService;
|
||||
|
||||
@PostMapping("create") // 映射HTTP POST请求到 create 方法
|
||||
public Result create(@RequestBody DormitoryStudent dormitoryStudent){ // 从请求体中获取 DormitoryStudent 对象
|
||||
int flag = dormitoryStudentService.create(dormitoryStudent); // 调用服务层创建学生宿舍记录
|
||||
if(flag>0){ // 如果创建成功
|
||||
return Result.ok(); // 返回成功结果
|
||||
}else{ // 如果创建失败
|
||||
return Result.fail(); // 返回失败结果
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("delete") // 映射HTTP GET请求到 delete 方法
|
||||
public Result delete(String ids){ // 接收要删除的学生宿舍记录的ID字符串
|
||||
int flag = dormitoryStudentService.delete(ids); // 调用服务层删除指定ID的学生宿舍记录
|
||||
if(flag>0){ // 如果删除成功
|
||||
return Result.ok(); // 返回成功结果
|
||||
}else{ // 如果删除失败
|
||||
return Result.fail(); // 返回失败结果
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("update") // 映射HTTP POST请求到 update 方法
|
||||
public Result update(@RequestBody DormitoryStudent dormitoryStudent){ // 从请求体中获取 DormitoryStudent 对象
|
||||
int flag = dormitoryStudentService.update(dormitoryStudent); // 调用服务层更新学生宿舍记录
|
||||
if(flag>0){ // 如果更新成功
|
||||
return Result.ok(); // 返回成功结果
|
||||
}else{ // 如果更新失败
|
||||
return Result.fail(); // 返回失败结果
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("detail") // 映射HTTP GET请求到 detail 方法
|
||||
public DormitoryStudent detail(Integer id){ // 接收学生宿舍记录的ID
|
||||
return dormitoryStudentService.detail(id); // 调用服务层获取指定ID的学生宿舍记录详情并返回
|
||||
}
|
||||
|
||||
@PostMapping("query") // 映射HTTP POST请求到 query 方法
|
||||
public Map<String,Object> query(@RequestBody DormitoryStudent dormitoryStudent){ // 从请求体中获取 DormitoryStudent 对象用于查询条件
|
||||
PageInfo<DormitoryStudent> pageInfo = dormitoryStudentService.query(dormitoryStudent); // 调用服务层进行分页查询
|
||||
pageInfo.getList().forEach(entity->{ // 遍历查询结果列表
|
||||
Student detail = studentService.detail(entity.getStudentId()); // 获取每个学生宿舍记录对应的学生详细信息
|
||||
entity.setStudent(detail); // 将学生信息设置到学生宿舍记录中
|
||||
});
|
||||
return Result.ok(pageInfo); // 返回包含分页信息和查询结果的成功结果
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.Repair;
|
||||
import com.yanzhen.entity.Student;
|
||||
import com.yanzhen.service.BuildingService楼层设置;
|
||||
import com.yanzhen.service.DormitoryService宿舍编号设置;
|
||||
import com.yanzhen.service.RepairService报修管理;
|
||||
import com.yanzhen.service.StudentService学生管理;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController // 声明这是一个RESTful控制器
|
||||
@RequestMapping("/repair") // 设置请求路径前缀为/repair
|
||||
public class RepairController {
|
||||
|
||||
@Autowired // 自动注入RepairService实例
|
||||
private RepairService报修管理 repairService;
|
||||
@Autowired // 自动注入StudentService实例
|
||||
private StudentService学生管理 studentService;
|
||||
@Autowired // 自动注入DormitoryService实例
|
||||
private DormitoryService宿舍编号设置 dormitoryService;
|
||||
@Autowired // 自动注入BuildingService实例
|
||||
private BuildingService楼层设置 buildingService;
|
||||
|
||||
@PostMapping("create") // 映射HTTP POST请求到create方法
|
||||
public Result create(@RequestBody Repair repair){ // 接收一个Repair对象作为请求体
|
||||
int flag = repairService.create(repair); // 调用服务层创建维修记录
|
||||
if(flag>0){ // 如果创建成功
|
||||
return Result.ok(); // 返回成功结果
|
||||
}else{ // 如果创建失败
|
||||
return Result.fail(); // 返回失败结果
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("delete") // 映射HTTP GET请求到delete方法
|
||||
public Result delete(String ids){ // 接收要删除的记录ID字符串
|
||||
int flag = repairService.delete(ids); // 调用服务层删除指定ID的维修记录
|
||||
if(flag>0){ // 如果删除成功
|
||||
return Result.ok(); // 返回成功结果
|
||||
}else{ // 如果删除失败
|
||||
return Result.fail(); // 返回失败结果
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("update") // 映射HTTP POST请求到update方法
|
||||
public Result update(@RequestBody Repair repair){ // 接收一个Repair对象作为请求体
|
||||
int flag = repairService.updateSelective(repair); // 调用服务层更新维修记录,只更新非空字段
|
||||
if(flag>0){ // 如果更新成功
|
||||
return Result.ok(); // 返回成功结果
|
||||
}else{ // 如果更新失败
|
||||
return Result.fail(); // 返回失败结果
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("detail") // 映射HTTP GET请求到detail方法
|
||||
public Repair detail(Integer id){ // 接收维修记录的ID
|
||||
return repairService.detail(id); // 调用服务层获取指定ID的维修记录详情并返回
|
||||
}
|
||||
|
||||
@PostMapping("query") // 映射HTTP POST请求到query方法
|
||||
public Map<String,Object> query(@RequestBody Repair repair){ // 接收一个Repair对象作为查询条件
|
||||
PageInfo<Repair> pageInfo = new PageInfo<>(); // 创建一个分页信息对象
|
||||
if(repair.getName() != null){ // 如果查询条件中包含学生姓名
|
||||
Student detailId = studentService.detailByName(repair.getName()); // 根据姓名查找学生ID
|
||||
if(detailId != null){ // 如果找到对应的学生ID
|
||||
repair.setStudentId(detailId.getId()); // 设置查询条件的studentId属性
|
||||
}else{ // 如果没有找到对应的学生ID
|
||||
pageInfo.setList(null); // 设置分页列表为空
|
||||
pageInfo.setSize(0); // 设置分页大小为0
|
||||
return Result.ok(pageInfo); // 返回空的查询结果
|
||||
}
|
||||
}
|
||||
pageInfo = repairService.query(repair); // 调用服务层进行查询操作
|
||||
pageInfo.getList().forEach(entity->{ // 遍历查询结果列表
|
||||
entity.setBuilding(buildingService.detail(entity.getBuildingId())); // 设置每个维修记录的楼宇信息
|
||||
entity.setStudent(studentService.detail(entity.getStudentId())); // 设置每个维修记录的学生信息
|
||||
entity.setDormitory(dormitoryService.detail(entity.getDormitoryId())); // 设置每个维修记录的宿舍信息
|
||||
});
|
||||
return Result.ok(pageInfo); // 返回查询结果
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.yanzhen.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.entity.SelectionDormitory;
|
||||
import com.yanzhen.service.SelectionDormitoryService宿舍管理;
|
||||
import com.yanzhen.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController // 声明这是一个控制器,并且返回的数据直接写入 HTTP 响应体中,而不是解析为跳转路径。
|
||||
@RequestMapping("/selectionDormitory") // 设置请求的根路径为 "/selectionDormitory"
|
||||
public class SelectionDormitoryController {
|
||||
|
||||
@Autowired // 自动注入 SelectionDormitoryService 对象
|
||||
private SelectionDormitoryService宿舍管理 selectionDormitoryService;
|
||||
|
||||
@PostMapping("create") // 映射 HTTP POST 请求到 create 方法
|
||||
public Result create(@RequestBody Map<String,String> map){ // 从请求体中获取 JSON 数据并转换为 Map
|
||||
//clazzId,dormitoryIds
|
||||
String clazzId = map.get("clazzId"); // 从 Map 中获取班级ID
|
||||
String dormitoryIds = map.get("dormitoryIds"); // 从 Map 中获取宿舍ID列表
|
||||
int flag = selectionDormitoryService.create(clazzId,dormitoryIds); // 调用服务层的创建方法
|
||||
if(flag>0){ // 如果创建成功
|
||||
return Result.ok(); // 返回成功结果
|
||||
}else{ // 如果创建失败
|
||||
return Result.fail(); // 返回失败结果
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("delete") // 映射 HTTP GET 请求到 delete 方法
|
||||
public Result delete(String ids){ // 从请求参数中获取要删除的记录ID
|
||||
int flag = selectionDormitoryService.delete(ids); // 调用服务层的删除方法
|
||||
if(flag>0){ // 如果删除成功
|
||||
return Result.ok(); // 返回成功结果
|
||||
}else{ // 如果删除失败
|
||||
return Result.fail(); // 返回失败结果
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("update") // 映射 HTTP POST 请求到 update 方法
|
||||
public Result update(@RequestBody SelectionDormitory selectionDormitory){ // 从请求体中获取 JSON 数据并转换为 SelectionDormitory 对象
|
||||
int flag = selectionDormitoryService.update(selectionDormitory); // 调用服务层的更新方法
|
||||
if(flag>0){ // 如果更新成功
|
||||
return Result.ok(); // 返回成功结果
|
||||
}else{ // 如果更新失败
|
||||
return Result.fail(); // 返回失败结果
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("detail") // 映射 HTTP GET 请求到 detail 方法
|
||||
public SelectionDormitory detail(Integer id){ // 从请求参数中获取记录ID
|
||||
return selectionDormitoryService.detail(id); // 调用服务层的详情查询方法并返回结果
|
||||
}
|
||||
|
||||
@PostMapping("query") // 映射 HTTP POST 请求到 query 方法
|
||||
public Map<String,Object> query(@RequestBody SelectionDormitory selectionDormitory){ // 从请求体中获取 JSON 数据并转换为 SelectionDormitory 对象
|
||||
PageInfo<SelectionDormitory> pageInfo = selectionDormitoryService.query(selectionDormitory); // 调用服务层的查询方法并获取分页信息
|
||||
return Result.ok(pageInfo); // 返回包含分页信息的查询结果
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.yanzhen.framework.mvc; // 定义包名
|
||||
|
||||
import com.yanzhen.framework.exception.MyException; // 导入自定义异常类
|
||||
import com.yanzhen.utils.Result; // 导入结果处理工具类
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice; // 导入Spring MVC的ControllerAdvice注解
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler; // 导入Spring MVC的ExceptionHandler注解
|
||||
import org.springframework.web.bind.annotation.RequestBody; // 导入Spring MVC的RequestBody注解
|
||||
import org.springframework.web.bind.annotation.ResponseBody; // 导入Spring MVC的ResponseBody注解
|
||||
|
||||
@ControllerAdvice // 标记该类为全局异常处理类
|
||||
public class GlobalControllerAdvice {
|
||||
|
||||
@ExceptionHandler(RuntimeException.class) // 处理所有RuntimeException类型的异常
|
||||
@ResponseBody // 将返回值作为HTTP响应体
|
||||
public Result handle(RuntimeException exception){ // 定义处理方法,参数为捕获到的异常
|
||||
exception.printStackTrace(); // 打印异常堆栈信息
|
||||
return Result.fail(exception.getMessage()); // 返回失败的结果对象,包含异常信息
|
||||
}
|
||||
|
||||
@ExceptionHandler(MyException.class) // 处理所有MyException类型的异常
|
||||
@ResponseBody // 将返回值作为HTTP响应体
|
||||
public Result handle(MyException exception){ // 定义处理方法,参数为捕获到的异常
|
||||
exception.printStackTrace(); // 打印异常堆栈信息
|
||||
return Result.fail(Result.TOKEN_ERROR,exception.getMessage()); // 返回失败的结果对象,包含错误码和异常信息
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
<?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.yanzhen.mapper.AbsenceMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.Absence" id="Absence">
|
||||
<id column="id" property="id"/>
|
||||
<result column="student_id" property="studentId"/>
|
||||
<result column="dormitory_id" property="dormitoryId"/>
|
||||
<result column="start_time" property="startTime"/>
|
||||
<result column="end_time" property="endTime"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Absence">
|
||||
insert into tb_absence(
|
||||
student_id,
|
||||
dormitory_id,
|
||||
start_time,
|
||||
end_time,
|
||||
remark
|
||||
)values(
|
||||
#{studentId},
|
||||
#{dormitoryId},
|
||||
#{startTime},
|
||||
#{endTime},
|
||||
#{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Absence">
|
||||
select * from tb_absence
|
||||
<include refid="AbsenceFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_absence
|
||||
<include refid="AbsenceFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="Absence">
|
||||
select * from tb_absence where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_absence where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_absence set
|
||||
student_id=#{studentId},
|
||||
dormitory_id=#{dormitoryId},
|
||||
start_time=#{startTime},
|
||||
end_time=#{endTime},
|
||||
remark=#{remark}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_absence
|
||||
<set>
|
||||
<if test="studentId != null">student_id = #{studentId},</if>
|
||||
<if test="dormitoryId != null">dormitory_id = #{dormitoryId},</if>
|
||||
<if test="startTime != null"> start_time = #{startTime},</if>
|
||||
<if test="endTime != null"> end_time = #{endTime},</if>
|
||||
<if test="remark != null and remark != ''"> remark = #{remark},</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="AbsenceFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="studentId != null">and student_id = #{studentId}</if>
|
||||
<if test="dormitoryId != null">and dormitory_id = #{dormitoryId}</if>
|
||||
<if test="remark != null and remark != ''">and remark = #{remark}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,65 @@
|
||||
<?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.yanzhen.mapper.BedMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.Bed" id="Bed">
|
||||
<id column="id" property="id"/>
|
||||
<result column="bno" property="bno"/>
|
||||
<result column="dormitory_id" property="dormitoryId"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Bed">
|
||||
insert into tb_bed(
|
||||
bno,
|
||||
dormitory_id
|
||||
)values(
|
||||
#{bno},
|
||||
#{dormitoryId}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Bed">
|
||||
select * from tb_bed
|
||||
<include refid="BedFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_bed
|
||||
<include refid="BedFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="Bed">
|
||||
select * from tb_bed where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_bed where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByDormitoryId">
|
||||
delete from tb_bed where dormitory_id = #{dormitoryId}
|
||||
</delete>
|
||||
|
||||
<update id="update">
|
||||
update tb_bed set
|
||||
bno=#{bno},
|
||||
dormitory_id=#{dormitoryId}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_bed set
|
||||
<if test="bno != null and bno != ''"> bno = #{bno}</if>,
|
||||
<if test="dormitoryId != null">dormitory_id = #{dormitoryId}</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="BedFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="bno != null and bno != ''">and bno = #{bno}</if>
|
||||
<if test="dormitoryId != null">and dormitory_id = #{dormitoryId}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,84 @@
|
||||
<?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.yanzhen.mapper.BuildingMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.Building" id="Building">
|
||||
<id column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="storey_num" property="storeyNum"/>
|
||||
<result column="sex" property="sex"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Building">
|
||||
insert into tb_building(
|
||||
name,
|
||||
type,
|
||||
storey_num,
|
||||
sex,
|
||||
remark,
|
||||
user_id
|
||||
)values(
|
||||
#{name},
|
||||
#{type},
|
||||
#{storeyNum},
|
||||
#{sex},
|
||||
#{remark},
|
||||
#{userId}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Building">
|
||||
select * from tb_building
|
||||
<include refid="BuildingFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_building
|
||||
<include refid="BuildingFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="Building">
|
||||
select * from tb_building where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_building where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_building set
|
||||
name=#{name},
|
||||
type=#{type},
|
||||
storey_num=#{storeyNum},
|
||||
sex=#{sex},
|
||||
remark=#{remark},
|
||||
user_id=#{userId}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_building set
|
||||
<if test="name != null and name != ''"> name = #{name}</if>,
|
||||
<if test="type != null">type = #{type}</if>,
|
||||
<if test="storeyNum != null">storey_num = #{storeyNum}</if>,
|
||||
<if test="sex != null">sex = #{sex}</if>,
|
||||
<if test="remark != null and remark != ''"> remark = #{remark}</if>,
|
||||
<if test="userId != null">user_id = #{userId}</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="BuildingFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="name != null and name != ''">and name like concat('%',#{name},'%')</if>
|
||||
<if test="type != null">and type = #{type}</if>
|
||||
<if test="storeyNum != null">and storey_num = #{storeyNum}</if>
|
||||
<if test="sex != null">and sex = #{sex}</if>
|
||||
<if test="remark != null and remark != ''">and remark = #{remark}</if>
|
||||
<if test="userId != null">and user_id = #{userId}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,90 @@
|
||||
<?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.yanzhen.mapper.DormitoryMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.Dormitory" id="Dormitory">
|
||||
<id column="id" property="id"/>
|
||||
<result column="no" property="no"/>
|
||||
<result column="sex" property="sex"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="capacity" property="capacity"/>
|
||||
<result column="storey_id" property="storeyId"/>
|
||||
<result column="building_id" property="buildingId"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Dormitory">
|
||||
insert into tb_dormitory(
|
||||
no,
|
||||
sex,
|
||||
type,
|
||||
capacity,
|
||||
storey_id,
|
||||
building_id
|
||||
)values(
|
||||
#{no},
|
||||
#{sex},
|
||||
#{type},
|
||||
#{capacity},
|
||||
#{storeyId},
|
||||
#{buildingId}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Dormitory">
|
||||
select * from tb_dormitory
|
||||
<include refid="DormitoryFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_dormitory
|
||||
<include refid="DormitoryFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="Dormitory">
|
||||
select * from tb_dormitory where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_dormitory where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByBuildingIdAndStoryId">
|
||||
delete from tb_dormitory where building_id = #{buildingId} and storey_id = #{storeyId}
|
||||
</delete>
|
||||
|
||||
|
||||
<update id="update">
|
||||
update tb_dormitory set
|
||||
no=#{no},
|
||||
sex=#{sex},
|
||||
type=#{type},
|
||||
capacity=#{capacity},
|
||||
storey_id=#{storeyId},
|
||||
building_id=#{buildingId}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_dormitory set
|
||||
<if test="no != null and no != ''"> no = #{no}</if>,
|
||||
<if test="sex != null">sex = #{sex}</if>,
|
||||
<if test="type != null">type = #{type}</if>,
|
||||
<if test="capacity != null">capacity = #{capacity}</if>,
|
||||
<if test="storeyId != null">storey_id = #{storeyId}</if>,
|
||||
<if test="buildingId != null">building_id = #{buildingId}</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="DormitoryFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="no != null and no != ''">and no = #{no}</if>
|
||||
<if test="sex != null">and sex = #{sex}</if>
|
||||
<if test="type != null">and type = #{type}</if>
|
||||
<if test="capacity != null">and capacity = #{capacity}</if>
|
||||
<if test="storeyId != null">and storey_id = #{storeyId}</if>
|
||||
<if test="buildingId != null">and building_id = #{buildingId}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,84 @@
|
||||
<?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.yanzhen.mapper.DormitorySetMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.DormitorySet" id="DormitorySet">
|
||||
<id column="id" property="id"/>
|
||||
<result column="prefix" property="prefix"/>
|
||||
<result column="start" property="start"/>
|
||||
<result column="end" property="end"/>
|
||||
<result column="building_id" property="buildingId"/>
|
||||
<result column="storey_id" property="storeyId"/>
|
||||
<result column="capacity" property="capacity"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.DormitorySet">
|
||||
insert into tb_dormitory_set(
|
||||
prefix,
|
||||
start,
|
||||
end,
|
||||
building_id,
|
||||
storey_id,
|
||||
capacity
|
||||
)values(
|
||||
#{prefix},
|
||||
#{start},
|
||||
#{end},
|
||||
#{buildingId},
|
||||
#{storeyId},
|
||||
#{capacity}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="DormitorySet">
|
||||
select * from tb_dormitory_set
|
||||
<include refid="DormitorySetFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_dormitory_set
|
||||
<include refid="DormitorySetFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="DormitorySet">
|
||||
select * from tb_dormitory_set where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_dormitory_set where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_dormitory_set set
|
||||
prefix=#{prefix},
|
||||
start=#{start},
|
||||
end=#{end},
|
||||
building_id=#{buildingId},
|
||||
storey_id=#{storeyId},
|
||||
capacity=#{capacity}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_dormitory_set set
|
||||
<if test="prefix != null and prefix != ''"> prefix = #{prefix}</if>,
|
||||
<if test="start != null">start = #{start}</if>,
|
||||
<if test="end != null">end = #{end}</if>,
|
||||
<if test="buildingId != null">building_id = #{buildingId}</if>,
|
||||
<if test="storeyId != null">storey_id = #{storeyId}</if>,
|
||||
<if test="capacity != null">capacity = #{capacity}</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="DormitorySetFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="prefix != null and prefix != ''">and prefix = #{prefix}</if>
|
||||
<if test="start != null">and start = #{start}</if>
|
||||
<if test="end != null">and end = #{end}</if>
|
||||
<if test="buildingId != null">and building_id = #{buildingId}</if>
|
||||
<if test="storeyId != null">and storey_id = #{storeyId}</if>
|
||||
<if test="capacity != null">and capacity = #{capacity}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,95 @@
|
||||
<?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.yanzhen.mapper.DormitoryStudentMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.DormitoryStudent" id="DormitoryStudent">
|
||||
<id column="id" property="id"/>
|
||||
<result column="dormitory_id" property="dormitoryId"/>
|
||||
<result column="bed_id" property="bedId"/>
|
||||
<result column="student_id" property="studentId"/>
|
||||
<result column="checkin" property="checkin"/>
|
||||
<result column="status" property="status"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.DormitoryStudent">
|
||||
insert into tb_dormitory_student(
|
||||
dormitory_id,
|
||||
bed_id,
|
||||
student_id,
|
||||
checkin,
|
||||
status
|
||||
)values(
|
||||
#{dormitoryId},
|
||||
#{bedId},
|
||||
#{studentId},
|
||||
#{checkin},
|
||||
#{status}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="DormitoryStudent">
|
||||
select * from tb_dormitory_student
|
||||
<include refid="DormitoryStudentFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_dormitory_student
|
||||
<include refid="DormitoryStudentFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="DormitoryStudent">
|
||||
select * from tb_dormitory_student where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_dormitory_student where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByCond">
|
||||
delete from tb_dormitory_student where student_id = #{studentId}
|
||||
</delete>
|
||||
|
||||
|
||||
<update id="update">
|
||||
update tb_dormitory_student set
|
||||
dormitory_id=#{dormitoryId},
|
||||
bed_id=#{bedId},
|
||||
student_id=#{studentId},
|
||||
checkin=#{checkin},
|
||||
status=#{status}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_dormitory_student set
|
||||
<if test="dormitoryId != null">dormitory_id = #{dormitoryId}</if>,
|
||||
<if test="bedId != null">bed_id = #{bedId}</if>,
|
||||
<if test="studentId != null">student_id = #{studentId}</if>,
|
||||
<if test="checkin != null and checkin != ''"> checkin = #{checkin}</if>,
|
||||
<if test="status != null">status = #{status}</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="DormitoryStudentFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="dormitoryId != null">and dormitory_id = #{dormitoryId}</if>
|
||||
<if test="bedId != null">and bed_id = #{bedId}</if>
|
||||
<if test="studentId != null">and student_id = #{studentId}</if>
|
||||
<if test="status != null">and status = #{status}</if>
|
||||
</where>
|
||||
</sql>
|
||||
<!--查询楼宇入住数量-->
|
||||
<select id="countByBuildingId" resultType="int">
|
||||
select count(distinct student_id) cnt from tb_dormitory_student,tb_dormitory where tb_dormitory_student.dormitory_id = tb_dormitory.id
|
||||
and building_id = #{buildingId}
|
||||
</select>
|
||||
|
||||
<!--查询床位对应的学生-->
|
||||
<select id="queryStudentByBedId" resultType="java.util.HashMap">
|
||||
select student_id,tb_student.name from tb_dormitory_student ,tb_student where
|
||||
tb_dormitory_student.student_id = tb_student.id and bed_id = #{bedId} limit 1
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,54 @@
|
||||
<?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.yanzhen.mapper.GradeMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.Grade" id="Grade">
|
||||
<id column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Grade">
|
||||
insert into tb_grade(
|
||||
name
|
||||
)values(
|
||||
#{name}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Grade">
|
||||
select * from tb_grade
|
||||
<include refid="GradeFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_grade
|
||||
<include refid="GradeFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="Grade">
|
||||
select * from tb_grade where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_grade where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_grade set
|
||||
name=#{name}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_grade set
|
||||
<if test="name != null and name != ''"> name = #{name}</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="GradeFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="name != null and name != ''">and name = #{name}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,41 @@
|
||||
<?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.yanzhen.mapper.MenuMapper">
|
||||
|
||||
|
||||
<resultMap id="Menu" type="com.yanzhen.entity.Menu">
|
||||
<id column="id" property="id"/>
|
||||
<result column="title" property="title"/>
|
||||
<result column="icon" property="icon"/>
|
||||
<result column="href" property="href"/>
|
||||
<result column="target" property="target"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="type" property="type"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="deleteUserMenu">
|
||||
delete from tb_user_menu where user_id = #{userId}
|
||||
</insert>
|
||||
|
||||
<insert id="createUserMenu">
|
||||
insert into tb_user_menu(user_id,menu_id) values(#{userId},#{menuId})
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Menu">
|
||||
select tb_menu.* from tb_menu,tb_user_menu where tb_menu.id=tb_user_menu.menu_id
|
||||
and user_id = #{userId} and tb_menu.type = 0
|
||||
</select>
|
||||
|
||||
<select id="queryByType" resultMap="Menu">
|
||||
select tb_menu.* from tb_menu where type = 1
|
||||
</select>
|
||||
|
||||
<select id="queryCheckMenuId" resultType="int">
|
||||
select menu_id from tb_user_menu where user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="list" resultMap="Menu">
|
||||
select tb_menu.* from tb_menu where type = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,85 @@
|
||||
<?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.yanzhen.mapper.NoticeMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.Notice" id="Notice">
|
||||
<id column="id" property="id"/>
|
||||
<result column="title" property="title"/>
|
||||
<result column="content" property="content"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="filepath" property="filepath"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Notice">
|
||||
insert into tb_notice(
|
||||
title,
|
||||
content,
|
||||
create_time,
|
||||
user_id,
|
||||
filepath
|
||||
)values(
|
||||
#{title},
|
||||
#{content},
|
||||
now(),
|
||||
#{userId},
|
||||
#{filepath}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Notice">
|
||||
select * from tb_notice
|
||||
<include refid="NoticeFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_notice
|
||||
<include refid="NoticeFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="Notice">
|
||||
select * from tb_notice where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_notice where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_notice set
|
||||
title=#{title},
|
||||
content=#{content},
|
||||
create_time=#{createTime},
|
||||
user_id=#{userId},
|
||||
filepath=#{filepath}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_notice
|
||||
<set>
|
||||
<if test="title != null and title != ''"> title = #{title},</if>
|
||||
<if test="content != null and content != ''"> content = #{content},</if>
|
||||
<if test="createTime != null and createTime != ''"> create_time = #{createTime},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="filepath != null and filepath != ''"> filepath = #{filepath},</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="NoticeFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="title != null and title != ''">and title = #{title}</if>
|
||||
<if test="content != null and content != ''">and content = #{content}</if>
|
||||
<if test="userId != null">and user_id = #{userId}</if>
|
||||
<if test="filepath != null and filepath != ''">and filepath = #{filepath}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="queryByBuildingId" resultMap="Notice">
|
||||
select tb_notice.* from tb_notice,tb_notice_receive where tb_notice.id = tb_notice_receive.notice_id and building_id = #{buildingId}
|
||||
<include refid="NoticeFindCriteria"/>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,25 @@
|
||||
package com.yanzhen.mapper; // 定义包名
|
||||
|
||||
import java.util.List; // 导入List集合类
|
||||
import java.util.Map; // 导入Map集合类
|
||||
|
||||
import com.yanzhen.entity.NoticeReceive; // 导入NoticeReceive实体类
|
||||
|
||||
public interface NoticeReceiveMapper { // 定义NoticeReceiveMapper接口
|
||||
|
||||
public int create(NoticeReceive noticeReceive); // 创建NoticeReceive记录的方法
|
||||
|
||||
public int delete(Integer id); // 根据ID删除NoticeReceive记录的方法
|
||||
|
||||
public int deleteByNoticeId(Integer noticeId); // 根据通知ID删除NoticeReceive记录的方法
|
||||
|
||||
public int update(NoticeReceive noticeReceive); // 更新NoticeReceive记录的方法
|
||||
|
||||
public int updateSelective(NoticeReceive noticeReceive); // 选择性更新NoticeReceive记录的方法
|
||||
|
||||
public List<NoticeReceive> query(NoticeReceive noticeReceive); // 查询NoticeReceive记录列表的方法
|
||||
|
||||
public NoticeReceive detail(Integer id); // 根据ID获取NoticeReceive详情的方法
|
||||
|
||||
public int count(NoticeReceive noticeReceive); // 统计NoticeReceive记录数量的方法
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
<?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.yanzhen.mapper.NoticeReceiveMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.NoticeReceive" id="NoticeReceive">
|
||||
<id column="id" property="id"/>
|
||||
<result column="notice_id" property="noticeId"/>
|
||||
<result column="building_id" property="buildingId"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.NoticeReceive">
|
||||
insert into tb_notice_receive(
|
||||
notice_id,
|
||||
building_id
|
||||
)values(
|
||||
#{noticeId},
|
||||
#{buildingId}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="NoticeReceive">
|
||||
select * from tb_notice_receive
|
||||
<include refid="NoticeReceiveFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_notice_receive
|
||||
<include refid="NoticeReceiveFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="NoticeReceive">
|
||||
select * from tb_notice_receive where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_notice_receive where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByNoticeId">
|
||||
delete from tb_notice_receive where notice_id = #{noticeId}
|
||||
</delete>
|
||||
|
||||
<update id="update">
|
||||
update tb_notice_receive set
|
||||
notice_id=#{noticeId},
|
||||
building_id=#{buildingId}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_notice_receive set
|
||||
<if test="noticeId != null">notice_id = #{noticeId}</if>,
|
||||
<if test="buildingId != null">building_id = #{buildingId}</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="NoticeReceiveFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="noticeId != null">and notice_id = #{noticeId}</if>
|
||||
<if test="buildingId != null">and building_id = #{buildingId}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,82 @@
|
||||
<?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.yanzhen.mapper.OrgMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.Org" id="Org">
|
||||
<id column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="grade_id" property="gradeId"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Org">
|
||||
insert into tb_org(
|
||||
name,
|
||||
type,
|
||||
grade_id,
|
||||
parent_id,
|
||||
remark
|
||||
)values(
|
||||
#{name},
|
||||
#{type},
|
||||
#{gradeId},
|
||||
#{parentId},
|
||||
#{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Org">
|
||||
select * from tb_org
|
||||
<include refid="OrgFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_org
|
||||
<include refid="OrgFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="Org">
|
||||
select * from tb_org where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_org where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_org set
|
||||
name=#{name},
|
||||
type=#{type},
|
||||
grade_id=#{gradeId},
|
||||
parent_id=#{parentId},
|
||||
remark=#{remark}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_org set
|
||||
<if test="name != null and name != ''"> name = #{name}</if>,
|
||||
<if test="type != null">type = #{type}</if>,
|
||||
<if test="gradeId != null">grade_id = #{gradeId}</if>,
|
||||
<if test="parentId != null">parent_id = #{parentId}</if>,
|
||||
<if test="remark != null and remark != ''"> remark = #{remark}</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="OrgFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="name != null and name != ''">and name = #{name}</if>
|
||||
<if test="type != null">and type = #{type}</if>
|
||||
<if test="gradeId != null">and grade_id = #{gradeId}</if>
|
||||
<if test="parentId != null">and parent_id = #{parentId}</if>
|
||||
<if test="remark != null and remark != ''">and remark = #{remark}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="queryOrgBySelectionId" resultMap="Org">
|
||||
select tb_org.* from tb_org,tb_selection_joiner where tb_selection_joiner.clazz_id = tb_org.id and selection_id = #{selectionId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,77 @@
|
||||
<?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.yanzhen.mapper.RecordMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.Record" id="Record">
|
||||
<id column="id" property="id"/>
|
||||
<result column="student_id" property="studentId"/>
|
||||
<result column="dormitory_id" property="dormitoryId"/>
|
||||
<result column="bed_id" property="bedId"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="create_date" property="createDate"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Record">
|
||||
insert into tb_record(
|
||||
student_id,
|
||||
dormitory_id,
|
||||
bed_id,
|
||||
status,
|
||||
create_date
|
||||
)values(
|
||||
#{studentId},
|
||||
#{dormitoryId},
|
||||
#{bedId},
|
||||
#{status},
|
||||
#{createDate}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Record">
|
||||
select * from tb_record
|
||||
<include refid="RecordFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_record
|
||||
<include refid="RecordFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="Record">
|
||||
select * from tb_record where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_record where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_record set
|
||||
student_id=#{studentId},
|
||||
dormitory_id=#{dormitoryId},
|
||||
bed_id=#{bedId},
|
||||
status=#{status},
|
||||
create_date=#{createDate}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_record set
|
||||
<if test="studentId != null">student_id = #{studentId}</if>,
|
||||
<if test="dormitoryId != null">dormitory_id = #{dormitoryId}</if>,
|
||||
<if test="bedId != null">bed_id = #{bedId}</if>,
|
||||
<if test="status != null">status = #{status}</if>,
|
||||
<if test="createDate != null and createDate != ''"> create_date = #{createDate}</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="RecordFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="studentId != null">and student_id = #{studentId}</if>
|
||||
<if test="dormitoryId != null">and dormitory_id = #{dormitoryId}</if>
|
||||
<if test="bedId != null">and bed_id = #{bedId}</if>
|
||||
<if test="status != null">and status = #{status}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,85 @@
|
||||
<?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.yanzhen.mapper.RepairMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.Repair" id="Repair">
|
||||
<id column="id" property="id"/>
|
||||
<result column="student_id" property="studentId"/>
|
||||
<result column="dormitory_id" property="dormitoryId"/>
|
||||
<result column="building_id" property="buildingId"/>
|
||||
<result column="description" property="description"/>
|
||||
<result column="create_date" property="createDate"/>
|
||||
<result column="status" property="status"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Repair">
|
||||
insert into tb_repair(
|
||||
student_id,
|
||||
dormitory_id,
|
||||
building_id,
|
||||
description,
|
||||
create_date,
|
||||
status
|
||||
)values(
|
||||
#{studentId},
|
||||
#{dormitoryId},
|
||||
#{buildingId},
|
||||
#{description},
|
||||
#{createDate},
|
||||
#{status}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Repair">
|
||||
select * from tb_repair
|
||||
<include refid="RepairFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_repair
|
||||
<include refid="RepairFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="Repair">
|
||||
select * from tb_repair where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_repair where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_repair set
|
||||
student_id=#{studentId},
|
||||
dormitory_id=#{dormitoryId},
|
||||
building_id=#{buildingId},
|
||||
description=#{description},
|
||||
create_date=#{createDate},
|
||||
status=#{status}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_repair
|
||||
<set>
|
||||
<if test="studentId != null">student_id = #{studentId},</if>
|
||||
<if test="dormitoryId != null">dormitory_id = #{dormitoryId},</if>
|
||||
<if test="buildingId != null">building_id = #{buildingId},</if>
|
||||
<if test="description != null and description != ''"> description = #{description},</if>
|
||||
<if test="createDate != null and createDate != ''"> create_date = #{createDate},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="RepairFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="studentId != null">and student_id = #{studentId}</if>
|
||||
<if test="dormitoryId != null">and dormitory_id = #{dormitoryId}</if>
|
||||
<if test="buildingId != null">and building_id = #{buildingId}</if>
|
||||
<if test="description != null and description != ''">and description = #{description}</if>
|
||||
<if test="status != null">and status = #{status}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,64 @@
|
||||
<?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.yanzhen.mapper.SelectionDormitoryMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.SelectionDormitory" id="SelectionDormitory">
|
||||
<id column="id" property="id"/>
|
||||
<result column="dormitory_id" property="dormitoryId"/>
|
||||
<result column="clazz_id" property="clazzId"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.SelectionDormitory">
|
||||
insert into tb_selection_dormitory(
|
||||
dormitory_id,
|
||||
clazz_id
|
||||
)values(
|
||||
#{dormitoryId},
|
||||
#{clazzId}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="SelectionDormitory">
|
||||
select * from tb_selection_dormitory
|
||||
<include refid="SelectionDormitoryFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_selection_dormitory
|
||||
<include refid="SelectionDormitoryFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="SelectionDormitory">
|
||||
select * from tb_selection_dormitory where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_selection_dormitory where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_selection_dormitory set
|
||||
dormitory_id=#{dormitoryId},
|
||||
clazz_id=#{clazzId}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_selection_dormitory set
|
||||
<if test="dormitoryId != null">dormitory_id = #{dormitoryId}</if>,
|
||||
<if test="clazzId != null">clazz_id = #{clazzId}</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="SelectionDormitoryFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="dormitoryId != null">and dormitory_id = #{dormitoryId}</if>
|
||||
<if test="clazzId != null">and clazz_id = #{clazzId}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteByClazzId">
|
||||
delete from tb_selection_dormitory where clazz_id = #{clazzId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,65 @@
|
||||
<?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.yanzhen.mapper.SelectionJoinerMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.SelectionJoiner" id="SelectionJoiner">
|
||||
<id column="id" property="id"/>
|
||||
<result column="selection_id" property="selectionId"/>
|
||||
<result column="clazz_id" property="clazzId"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.SelectionJoiner">
|
||||
insert into tb_selection_joiner(
|
||||
selection_id,
|
||||
clazz_id
|
||||
)values(
|
||||
#{selectionId},
|
||||
#{clazzId}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="SelectionJoiner">
|
||||
select * from tb_selection_joiner
|
||||
<include refid="SelectionJoinerFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_selection_joiner
|
||||
<include refid="SelectionJoinerFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="SelectionJoiner">
|
||||
select * from tb_selection_joiner where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_selection_joiner where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_selection_joiner set
|
||||
selection_id=#{selectionId},
|
||||
clazz_id=#{clazzId}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_selection_joiner set
|
||||
<if test="selectionId != null">selection_id = #{selectionId}</if>,
|
||||
<if test="clazzId != null">clazz_id = #{clazzId}</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="SelectionJoinerFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="selectionId != null">and selection_id = #{selectionId}</if>
|
||||
<if test="clazzId != null">and clazz_id = #{clazzId}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteBySelectionId">
|
||||
delete from tb_selection_joiner where selection_id = #{selectionId}
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,75 @@
|
||||
<?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.yanzhen.mapper.SelectionMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.Selection" id="Selection">
|
||||
<id column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="start_time" property="startTime"/>
|
||||
<result column="end_time" property="endTime"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Selection">
|
||||
insert into tb_selection(
|
||||
name,
|
||||
start_time,
|
||||
end_time,
|
||||
remark
|
||||
)values(
|
||||
#{name},
|
||||
#{startTime},
|
||||
#{endTime},
|
||||
#{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Selection">
|
||||
select * from tb_selection
|
||||
<include refid="SelectionFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_selection
|
||||
<include refid="SelectionFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="Selection">
|
||||
select * from tb_selection where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_selection where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_selection set
|
||||
name=#{name},
|
||||
start_time=#{startTime},
|
||||
end_time=#{endTime},
|
||||
remark=#{remark}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_selection set
|
||||
<if test="name != null and name != ''"> name = #{name}</if>,
|
||||
<if test="startTime != null and startTime != ''"> start_time = #{startTime}</if>,
|
||||
<if test="endTime != null and endTime != ''"> end_time = #{endTime}</if>,
|
||||
<if test="remark != null and remark != ''"> remark = #{remark}</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="SelectionFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="name != null and name != ''">and name = #{name}</if>
|
||||
<if test="remark != null and remark != ''">and remark = #{remark}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="queryByClazzId" resultMap="Selection">
|
||||
select tb_selection.* from tb_selection,tb_selection_joiner where tb_selection.id = tb_selection_joiner.selection_id
|
||||
and clazz_id = #{clazzId} order by start_time desc limit 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,66 @@
|
||||
<?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.yanzhen.mapper.StoreyMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.Storey" id="Storey">
|
||||
<id column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="building_id" property="buildingId"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Storey">
|
||||
insert into tb_storey(
|
||||
name,
|
||||
building_id,
|
||||
remark
|
||||
)values(
|
||||
#{name},
|
||||
#{buildingId},
|
||||
#{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Storey">
|
||||
select * from tb_storey
|
||||
<include refid="StoreyFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_storey
|
||||
<include refid="StoreyFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="Storey">
|
||||
select * from tb_storey where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_storey where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_storey set
|
||||
name=#{name},
|
||||
building_id=#{buildingId},
|
||||
remark=#{remark}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_storey set
|
||||
<if test="name != null and name != ''"> name = #{name}</if>,
|
||||
<if test="buildingId != null">building_id = #{buildingId}</if>,
|
||||
<if test="remark != null and remark != ''"> remark = #{remark}</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="StoreyFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="name != null and name != ''">and name = #{name}</if>
|
||||
<if test="buildingId != null">and building_id = #{buildingId}</if>
|
||||
<if test="remark != null and remark != ''">and remark = #{remark}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,106 @@
|
||||
<?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.yanzhen.mapper.StudentMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.Student" id="Student">
|
||||
<id column="id" property="id"/>
|
||||
<result column="stu_no" property="stuNo"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="idcard" property="idcard"/>
|
||||
<result column="grade_id" property="gradeId"/>
|
||||
<result column="sex" property="sex"/>
|
||||
<result column="phone" property="phone"/>
|
||||
<result column="password" property="password"/>
|
||||
<result column="clazz_id" property="clazzId"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Student">
|
||||
insert into tb_student(
|
||||
stu_no,
|
||||
name,
|
||||
idcard,
|
||||
grade_id,
|
||||
sex,
|
||||
phone,
|
||||
password,
|
||||
clazz_id
|
||||
)values(
|
||||
#{stuNo},
|
||||
#{name},
|
||||
#{idcard},
|
||||
#{gradeId},
|
||||
#{sex},
|
||||
#{phone},
|
||||
'123456',
|
||||
#{clazzId}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Student">
|
||||
select * from tb_student
|
||||
<include refid="StudentFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_student
|
||||
<include refid="StudentFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="Student">
|
||||
select * from tb_student where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="detailByName" resultMap="Student">
|
||||
select * from tb_student where name = #{name}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_student where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_student set
|
||||
stu_no=#{stuNo},
|
||||
name=#{name},
|
||||
idcard=#{idcard},
|
||||
grade_id=#{gradeId},
|
||||
sex=#{sex},
|
||||
phone=#{phone},
|
||||
password=#{password},
|
||||
clazz_id=#{clazzId}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_student
|
||||
<set>
|
||||
<if test="stuNo != null and stuNo != ''"> stu_no = #{stuNo},</if>
|
||||
<if test="name != null and name != ''"> name = #{name},</if>
|
||||
<if test="idcard != null and idcard != ''"> idcard = #{idcard},</if>
|
||||
<if test="gradeId != null">grade_id = #{gradeId},</if>
|
||||
<if test="sex != null">sex = #{sex},</if>
|
||||
<if test="phone != null and phone != ''"> phone = #{phone},</if>
|
||||
<if test="password != null and password != ''"> password = #{password},</if>
|
||||
<if test="clazzId != null">clazz_id = #{clazzId},</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="StudentFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="stuNo != null and stuNo != ''">and stu_no = #{stuNo}</if>
|
||||
<if test="name != null and name != ''">and name like concat('%',#{name},'%') </if>
|
||||
<if test="idcard != null and idcard != ''">and idcard = #{idcard}</if>
|
||||
<if test="gradeId != null">and grade_id = #{gradeId}</if>
|
||||
<if test="sex != null">and sex = #{sex}</if>
|
||||
<if test="phone != null and phone != ''">and phone = #{phone}</if>
|
||||
<if test="password != null and password != ''">and password = #{password}</if>
|
||||
<if test="clazzId != null">and clazz_id = #{clazzId}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="login" resultMap="Student">
|
||||
select * from tb_student where stu_no = #{userName} and password = #{password}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,90 @@
|
||||
<?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.yanzhen.mapper.UserMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.User" id="User">
|
||||
<id column="id" property="id"/>
|
||||
<result column="user_name" property="userName"/>
|
||||
<result column="password" property="password"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="phone" property="phone"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.User">
|
||||
insert into tb_user(
|
||||
user_name,
|
||||
password,
|
||||
name,
|
||||
phone,
|
||||
type,
|
||||
remark
|
||||
)values(
|
||||
#{userName},
|
||||
#{password},
|
||||
#{name},
|
||||
#{phone},
|
||||
#{type},
|
||||
#{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="User">
|
||||
select * from tb_user
|
||||
<include refid="UserFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_user
|
||||
<include refid="UserFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="User">
|
||||
select * from tb_user where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_user where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_user set
|
||||
user_name=#{userName},
|
||||
password=#{password},
|
||||
name=#{name},
|
||||
phone=#{phone},
|
||||
type=#{type},
|
||||
remark=#{remark}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_user
|
||||
<set>
|
||||
<if test="userName != null and userName != ''"> user_name = #{userName},</if>
|
||||
<if test="password != null and password != ''"> password = #{password},</if>
|
||||
<if test="name != null and name != ''"> name = #{name},</if>
|
||||
<if test="phone != null and phone != ''"> phone = #{phone},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="remark != null and remark != ''"> remark = #{remark},</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="UserFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="userName != null and userName != ''">and user_name like concat('%',#{userName},'%') </if>
|
||||
<if test="password != null and password != ''">and password = #{password}</if>
|
||||
<if test="name != null and name != ''">and name like concat('%',#{name},'%')</if>
|
||||
<if test="phone != null and phone != ''">and phone = #{phone}</if>
|
||||
<if test="type != null">and type = #{type}</if>
|
||||
<if test="remark != null and remark != ''">and remark = #{remark}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="login" resultMap="User">
|
||||
select * from tb_user where user_name = #{userName} and password=#{password}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,96 @@
|
||||
<?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.yanzhen.mapper.VisitMapper">
|
||||
|
||||
<resultMap type="com.yanzhen.entity.Visit" id="Visit">
|
||||
<id column="id" property="id"/>
|
||||
<result column="visitor" property="visitor"/>
|
||||
<result column="phone" property="phone"/>
|
||||
<result column="sex" property="sex"/>
|
||||
<result column="idcard" property="idcard"/>
|
||||
<result column="student_id" property="studentId"/>
|
||||
<result column="visit_time" property="visitTime"/>
|
||||
<result column="leave_time" property="leaveTime"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Visit">
|
||||
insert into tb_visit(
|
||||
visitor,
|
||||
phone,
|
||||
sex,
|
||||
idcard,
|
||||
student_id,
|
||||
visit_time,
|
||||
leave_time,
|
||||
remark
|
||||
)values(
|
||||
#{visitor},
|
||||
#{phone},
|
||||
#{sex},
|
||||
#{idcard},
|
||||
#{studentId},
|
||||
#{visitTime},
|
||||
#{leaveTime},
|
||||
#{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="query" resultMap="Visit">
|
||||
select * from tb_visit
|
||||
<include refid="VisitFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
select count(1) from tb_visit
|
||||
<include refid="VisitFindCriteria"/>
|
||||
</select>
|
||||
|
||||
<select id="detail" resultMap="Visit">
|
||||
select * from tb_visit where id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
delete from tb_visit where id = #{id}
|
||||
</delete>
|
||||
<update id="update">
|
||||
update tb_visit set
|
||||
visitor=#{visitor},
|
||||
phone=#{phone},
|
||||
sex=#{sex},
|
||||
idcard=#{idcard},
|
||||
student_id=#{studentId},
|
||||
visit_time=#{visitTime},
|
||||
leave_time=#{leaveTime},
|
||||
remark=#{remark}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateSelective">
|
||||
update tb_visit
|
||||
<set>
|
||||
<if test="visitor != null and visitor != ''"> visitor = #{visitor},</if>
|
||||
<if test="phone != null and phone != ''"> phone = #{phone},</if>
|
||||
<if test="sex != null">sex = #{sex},</if>
|
||||
<if test="idcard != null and idcard != ''"> idcard = #{idcard},</if>
|
||||
<if test="studentId != null">student_id = #{studentId},</if>
|
||||
<if test="visitTime != null"> visit_time = #{visitTime},</if>
|
||||
<if test="leaveTime != null"> leave_time = #{leaveTime},</if>
|
||||
<if test="remark != null and remark != ''"> remark = #{remark},</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="VisitFindCriteria">
|
||||
<where>
|
||||
<if test="id != null">and id = #{id}</if>
|
||||
<if test="visitor != null and visitor != ''">and visitor = #{visitor}</if>
|
||||
<if test="phone != null and phone != ''">and phone = #{phone}</if>
|
||||
<if test="sex != null">and sex = #{sex}</if>
|
||||
<if test="idcard != null and idcard != ''">and idcard = #{idcard}</if>
|
||||
<if test="studentId != null">and student_id = #{studentId}</if>
|
||||
<if test="remark != null and remark != ''">and remark = #{remark}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,112 @@
|
||||
package com.yanzhen.service; // 定义包名
|
||||
|
||||
import com.yanzhen.entity.Bed; // 导入Bed实体类
|
||||
import com.yanzhen.entity.Building; // 导入Building实体类
|
||||
import com.yanzhen.entity.DormitorySet; // 导入DormitorySet实体类
|
||||
import com.yanzhen.mapper.BedMapper; // 导入BedMapper接口
|
||||
import com.yanzhen.mapper.BuildingMapper; // 导入BuildingMapper接口
|
||||
import com.yanzhen.mapper.DormitoryMapper; // 导入DormitoryMapper接口
|
||||
import com.yanzhen.entity.Dormitory; // 导入Dormitory实体类
|
||||
import com.github.pagehelper.PageHelper; // 导入PageHelper分页插件
|
||||
import com.github.pagehelper.PageInfo; // 导入PageInfo分页信息类
|
||||
import com.yanzhen.mapper.DormitorySetMapper; // 导入DormitorySetMapper接口
|
||||
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring的@Autowired注解
|
||||
import org.springframework.stereotype.Service; // 导入Spring的@Service注解
|
||||
import org.springframework.transaction.annotation.Transactional; // 导入Spring的@Transactional注解
|
||||
import org.springframework.util.StringUtils; // 导入Spring的StringUtils工具类
|
||||
|
||||
import java.util.List; // 导入Java的List集合类
|
||||
|
||||
@Service // 标注这是一个服务层的Bean
|
||||
public class DormitoryService宿舍编号设置 {// “宿舍编号设置----管理员”
|
||||
|
||||
@Autowired // 自动注入DormitoryMapper依赖
|
||||
private DormitoryMapper dormitoryMapper;
|
||||
@Autowired // 自动注入DormitorySetMapper依赖
|
||||
private DormitorySetMapper dormitorySetMapper;
|
||||
@Autowired // 自动注入BuildingMapper依赖
|
||||
private BuildingMapper buildingMapper;
|
||||
@Autowired // 自动注入BedMapper依赖
|
||||
private BedMapper bedMapper;
|
||||
|
||||
public int create(Dormitory dormitory) { // 创建宿舍记录
|
||||
return dormitoryMapper.create(dormitory); // 调用DormitoryMapper的create方法
|
||||
}
|
||||
|
||||
public int delete(String ids) { // 根据ID字符串批量删除宿舍记录
|
||||
String[] arr = ids.split(","); // 将ID字符串按逗号分割成数组
|
||||
int row = 0; // 初始化删除计数器
|
||||
for (String s : arr) { // 遍历ID数组
|
||||
if(!StringUtils.isEmpty(s)){ // 如果ID不为空
|
||||
dormitoryMapper.delete(Integer.parseInt(s)); // 调用DormitoryMapper的delete方法删除记录
|
||||
row++; // 删除计数器加1
|
||||
}
|
||||
}
|
||||
return row; // 返回删除的记录数
|
||||
}
|
||||
|
||||
public int delete(Integer id) { // 根据ID删除单个宿舍记录
|
||||
return dormitoryMapper.delete(id); // 调用DormitoryMapper的delete方法
|
||||
}
|
||||
|
||||
public int update(Dormitory dormitory) { // 更新宿舍记录
|
||||
return dormitoryMapper.update(dormitory); // 调用DormitoryMapper的update方法
|
||||
}
|
||||
|
||||
public int updateSelective(Dormitory dormitory) { // 选择性更新宿舍记录
|
||||
return dormitoryMapper.updateSelective(dormitory); // 调用DormitoryMapper的updateSelective方法
|
||||
}
|
||||
|
||||
public PageInfo<Dormitory> query(Dormitory dormitory) { // 查询宿舍记录并分页
|
||||
if(dormitory != null && dormitory.getPage() != null){ // 如果宿舍对象和分页信息不为空
|
||||
PageHelper.startPage(dormitory.getPage(),dormitory.getLimit()); // 设置分页参数
|
||||
}
|
||||
return new PageInfo<Dormitory>(dormitoryMapper.query(dormitory)); // 返回分页后的宿舍记录列表
|
||||
}
|
||||
|
||||
public Dormitory detail(Integer id) { // 根据ID查询单个宿舍详情
|
||||
return dormitoryMapper.detail(id); // 调用DormitoryMapper的detail方法
|
||||
}
|
||||
|
||||
public int count(Dormitory dormitory) { // 统计符合条件的宿舍记录数
|
||||
return dormitoryMapper.count(dormitory); // 调用DormitoryMapper的count方法
|
||||
}
|
||||
|
||||
@Transactional // 声明该方法需要事务管理
|
||||
public void init(Dormitory dormitory){ // 初始化宿舍数据
|
||||
DormitorySet param = new DormitorySet(); // 创建DormitorySet对象
|
||||
param.setBuildingId(dormitory.getBuildingId()); // 设置建筑ID
|
||||
param.setStoreyId(dormitory.getStoreyId()); // 设置楼层ID
|
||||
List<DormitorySet> dormitorySets = dormitorySetMapper.query(param); // 查询宿舍设置信息
|
||||
Building building = buildingMapper.detail(dormitory.getBuildingId()); // 查询建筑详细信息
|
||||
|
||||
//删除已有床位(先查询出来,然后批量删除)
|
||||
List<Dormitory> dormitoryList = dormitoryMapper.query(dormitory); // 查询现有的宿舍记录
|
||||
dormitoryList.forEach(item->{ // 遍历宿舍记录列表
|
||||
bedMapper.deleteByDormitoryId(item.getId()); // 删除每个宿舍对应的床位记录
|
||||
});
|
||||
//删除以有的数据(删除已有宿舍)
|
||||
dormitoryMapper.deleteByBuildingIdAndStoryId(dormitory.getBuildingId(),dormitory.getStoreyId()); // 删除指定建筑和楼层的所有宿舍记录
|
||||
|
||||
dormitorySets.forEach(dormitorySet -> { // 遍历宿舍设置信息列表
|
||||
|
||||
for(int i=dormitorySet.getStart();i<=dormitorySet.getEnd();i++){ // 根据起始和结束编号生成宿舍编号
|
||||
Dormitory entity = new Dormitory(); // 创建新的宿舍对象
|
||||
entity.setNo(dormitorySet.getPrefix()+i); // 设置宿舍编号
|
||||
entity.setBuildingId(dormitory.getBuildingId()); // 设置建筑ID
|
||||
entity.setStoreyId(dormitory.getStoreyId()); // 设置楼层ID
|
||||
entity.setCapacity(dormitorySet.getCapacity()); // 设置宿舍容量
|
||||
entity.setSex(building.getSex()); // 设置宿舍性别限制
|
||||
entity.setType(building.getType()); // 设置宿舍类型
|
||||
dormitoryMapper.create(entity); // 创建新的宿舍记录
|
||||
for(int j=1;j<=entity.getCapacity();j++){ // 根据宿舍容量生成床位记录
|
||||
Bed bed = new Bed(); // 创建新的床位对象
|
||||
bed.setBno(entity.getNo()+"-"+j); // 设置床位编号
|
||||
bed.setDormitoryId(entity.getId()); // 设置所属宿舍ID
|
||||
bedMapper.create(bed); // 创建新的床位记录
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.yanzhen.service; // 定义包名
|
||||
|
||||
import com.yanzhen.mapper.MenuMapper; // 导入MenuMapper接口
|
||||
import com.yanzhen.entity.Menu; // 导入Menu实体类
|
||||
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring的自动装配注解
|
||||
import org.springframework.stereotype.Service; // 导入Spring的服务层注解
|
||||
|
||||
import java.util.List; // 导入List集合类
|
||||
|
||||
@Service // 标记为服务层组件
|
||||
public class MenuService菜单 { // 定义MenuService类
|
||||
|
||||
@Autowired // 自动注入MenuMapper依赖
|
||||
private MenuMapper menuMapper;
|
||||
|
||||
public List<Menu> query(Integer userId){ // 根据用户ID查询对应菜单列表
|
||||
return menuMapper.query(userId); // 调用menuMapper的query方法并返回结果
|
||||
}
|
||||
public List<Menu> list(){ // 查询所有菜单的方法
|
||||
return menuMapper.list(); // 调用menuMapper的list方法并返回结果
|
||||
}
|
||||
|
||||
public List<Integer> queryCheckMenuId(Integer userId){ // 根据用户ID查询选中的菜单ID的方法
|
||||
return menuMapper.queryCheckMenuId(userId); // 调用menuMapper的queryCheckMenuId方法并返回结果
|
||||
}
|
||||
|
||||
public List<Menu> queryByType(){ // 按类型查询菜单的方法
|
||||
return menuMapper.queryByType(); // 调用menuMapper的queryByType方法并返回结果
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package com.yanzhen.service;
|
||||
|
||||
import com.yanzhen.entity.NoticeReceive;
|
||||
import com.yanzhen.mapper.NoticeMapper;
|
||||
import com.yanzhen.entity.Notice;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.yanzhen.mapper.NoticeReceiveMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service // 标记为Spring的服务组件
|
||||
public class NoticeService公告管理 { // “公告管理----管理员/宿管”
|
||||
|
||||
@Autowired // 自动注入NoticeMapper依赖
|
||||
private NoticeMapper noticeMapper;
|
||||
@Autowired // 自动注入NoticeReceiveMapper依赖
|
||||
private NoticeReceiveMapper noticeReceiveMapper;
|
||||
|
||||
// 创建通知,并关联到多个建筑
|
||||
public int create(Notice notice) {
|
||||
noticeMapper.create(notice); // 在数据库中创建通知记录
|
||||
List<Integer> buildingIds = notice.getBuildingIds(); // 获取通知关联的建筑ID列表
|
||||
for (Integer buildingId : buildingIds) { // 遍历每个建筑ID
|
||||
NoticeReceive noticeReceive = new NoticeReceive(); // 创建新的NoticeReceive对象
|
||||
noticeReceive.setBuildingId(buildingId); // 设置建筑ID
|
||||
noticeReceive.setNoticeId(notice.getId()); // 设置通知ID
|
||||
noticeReceiveMapper.create(noticeReceive); // 在数据库中创建通知接收记录
|
||||
}
|
||||
return 1; // 返回成功标志
|
||||
}
|
||||
|
||||
// 根据逗号分隔的ID字符串批量删除通知
|
||||
public int delete(String ids) {
|
||||
String[] arr = ids.split(","); // 将ID字符串分割成数组
|
||||
int row = 0; // 初始化受影响行数计数器
|
||||
for (String s : arr) { // 遍历每个ID
|
||||
if(!StringUtils.isEmpty(s)){ // 如果ID不为空
|
||||
noticeReceiveMapper.deleteByNoticeId(Integer.parseInt(s)); // 删除相关的通知接收记录
|
||||
noticeMapper.delete(Integer.parseInt(s)); // 删除通知记录
|
||||
row++; // 增加受影响行数计数器
|
||||
}
|
||||
}
|
||||
return row; // 返回受影响行数
|
||||
}
|
||||
|
||||
// 根据单个ID删除通知
|
||||
public int delete(Integer id) {
|
||||
noticeReceiveMapper.deleteByNoticeId(id); // 删除相关的通知接收记录
|
||||
return noticeMapper.delete(id); // 删除通知记录并返回结果
|
||||
}
|
||||
|
||||
// 更新通知信息
|
||||
public int update(Notice notice) {
|
||||
return noticeMapper.update(notice); // 更新通知记录并返回结果
|
||||
}
|
||||
|
||||
// 选择性更新通知信息,同时重新关联建筑
|
||||
public int updateSelective(Notice notice) {
|
||||
noticeMapper.updateSelective(notice); // 选择性更新通知记录
|
||||
noticeReceiveMapper.deleteByNoticeId(notice.getId()); // 删除旧的通知接收记录
|
||||
List<Integer> buildingIds = notice.getBuildingIds(); // 获取新的通知关联的建筑ID列表
|
||||
for (Integer buildingId : buildingIds) { // 遍历每个建筑ID
|
||||
NoticeReceive noticeReceive = new NoticeReceive(); // 创建新的NoticeReceive对象
|
||||
noticeReceive.setBuildingId(buildingId); // 设置建筑ID
|
||||
noticeReceive.setNoticeId(notice.getId()); // 设置通知ID
|
||||
noticeReceiveMapper.create(noticeReceive); // 在数据库中创建新的通知接收记录
|
||||
}
|
||||
return 1; // 返回成功标志
|
||||
}
|
||||
|
||||
// 分页查询通知
|
||||
public PageInfo<Notice> query(Notice notice) {
|
||||
if(notice != null && notice.getPage() != null){ // 如果通知对象和分页信息不为空
|
||||
PageHelper.startPage(notice.getPage(), notice.getLimit()); // 启动分页
|
||||
}
|
||||
return new PageInfo<Notice>(noticeMapper.query(notice)); // 执行查询并返回分页结果
|
||||
}
|
||||
|
||||
// 根据建筑ID分页查询通知
|
||||
public PageInfo<Notice> queryByBuildingId(Notice notice){
|
||||
if(notice != null && notice.getPage() != null){ // 如果通知对象和分页信息不为空
|
||||
PageHelper.startPage(notice.getPage(), notice.getLimit()); // 启动分页
|
||||
}
|
||||
return new PageInfo<Notice>(noticeMapper.queryByBuildingId(notice)); // 执行查询并返回分页结果
|
||||
}
|
||||
|
||||
// 根据ID获取通知详情
|
||||
public Notice detail(Integer id) {
|
||||
return noticeMapper.detail(id); // 查询并返回通知详情
|
||||
}
|
||||
|
||||
// 统计符合条件的通知数量
|
||||
public int count(Notice notice) {
|
||||
return noticeMapper.count(notice); // 查询并返回符合条件的通知数量
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue