You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
spring/wll/SelectionDormitoryControlle...

82 lines
2.5 KiB

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
@RequestMapping("/selectionDormitory")
public class SelectionDormitoryController {
//注入实例
//注入选择宿舍服务类
@Autowired
private SelectionDormitoryService selectionDormitoryService;
//创建新的实例
@PostMapping("create")
public Result create(@RequestBody Map<String,String> map){
//获取clazzId,dormitoryIds
String clazzId = map.get("clazzId");
String dormitoryIds = map.get("dormitoryIds");
//在选择宿舍管理服务类中引用create方法
int flag = selectionDormitoryService.create(clazzId,dormitoryIds);
//判断是否创建成功
if(flag>0){
//成功
return Result.ok();
}else{
//失败
return Result.fail();
}
}
//删除选择宿舍信息
@GetMapping("delete")
public Result delete(String ids){
//在选择宿舍管理服务类中引用delete方法
int flag = selectionDormitoryService.delete(ids);
//判断是否删除成功
if(flag>0){
//成功
return Result.ok();
}else{
//失败
return Result.fail();
}
}
//更新选择宿舍信息
@PostMapping("update")
public Result update(@RequestBody SelectionDormitory selectionDormitory){
//在选择宿舍管理服务类中引用update方法
int flag = selectionDormitoryService.update(selectionDormitory);
//判断是否更新成功
if(flag>0){
//成功
return Result.ok();
}else{
//失败
return Result.fail();
}
}
//获取选择宿舍的详细信息
@GetMapping("detail")
public SelectionDormitory detail(Integer id){
//返回结果
return selectionDormitoryService.detail(id);
}
//查询选择宿舍的信息
@PostMapping("query")
public Map<String,Object> query(@RequestBody SelectionDormitory selectionDormitory){
//创建分页对象
PageInfo<SelectionDormitory> pageInfo = selectionDormitoryService.query(selectionDormitory);
//返回结果
return Result.ok(pageInfo);
}
}