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.
81 lines
2.1 KiB
81 lines
2.1 KiB
package com.yanzhen.controller;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.yanzhen.entity.Grade;
|
|
import com.yanzhen.service.GradeService;
|
|
import com.yanzhen.utils.Result;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.Map;
|
|
//成绩管理grade的控制器
|
|
@RestController
|
|
@RequestMapping("/grade")
|
|
public class GradeController {
|
|
//注入实例
|
|
//注入成绩管理服务类
|
|
@Autowired
|
|
private GradeService gradeService;
|
|
//创建新的实例
|
|
@PostMapping("create")
|
|
public Result create(@RequestBody Grade grade){
|
|
//在成绩管理服务类中引用create方法
|
|
int flag = gradeService.create(grade);
|
|
//判断是否创建成功
|
|
if(flag>0){
|
|
//成功
|
|
return Result.ok();
|
|
}else{
|
|
//失败
|
|
return Result.fail();
|
|
}
|
|
}
|
|
|
|
//删除成绩记录
|
|
@GetMapping("delete")
|
|
public Result delete(String ids){
|
|
//在成绩管理服务类中引用delete方法
|
|
int flag = gradeService.delete(ids);
|
|
//判断是否删除成功
|
|
if(flag>0){
|
|
//成功
|
|
return Result.ok();
|
|
}else{
|
|
//失败
|
|
return Result.fail();
|
|
}
|
|
}
|
|
|
|
//更新成绩记录
|
|
@PostMapping("update")
|
|
public Result update(@RequestBody Grade grade){
|
|
//在成绩管理服务类中引用update方法
|
|
int flag = gradeService.update(grade);
|
|
//判断是否更新成功
|
|
if(flag>0){
|
|
//成功
|
|
return Result.ok();
|
|
}else{
|
|
//失败
|
|
return Result.fail();
|
|
}
|
|
}
|
|
|
|
//获取成绩记录详细信息
|
|
@GetMapping("detail")
|
|
public Grade detail(Integer id){
|
|
//返回结果
|
|
return gradeService.detail(id);
|
|
}
|
|
|
|
//查询成绩记录
|
|
@PostMapping("query")
|
|
public Map<String,Object> query(@RequestBody Grade grade){
|
|
//创建分页对象
|
|
PageInfo<Grade> pageInfo = gradeService.query(grade);
|
|
//返回结果
|
|
return Result.ok(pageInfo);
|
|
}
|
|
|
|
}
|