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