package com.yssh.controller;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
|
import java.util.List;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import com.yssh.entity.Location;
|
import com.yssh.service.LocationService;
|
import com.yssh.utils.Result;
|
|
import javax.annotation.Resource;
|
|
/**
|
* @author wMeng
|
* @ClassName YsshLocationController
|
* @Description YsshLocationController
|
* @date 2022/10/30 13:21
|
* @Version 1.0
|
*/
|
@Api(tags="厂区热点点位")
|
@RestController
|
@RequestMapping("/location")
|
@SuppressWarnings("rawtypes")
|
public class LocationController {
|
@Resource
|
private LocationService locationService;
|
|
@ApiOperation(value = "条件查询点位数据", notes = "根据名称及其类型查询点位详细信息")
|
@GetMapping("/query")
|
public Result query(
|
@RequestParam(value = "name", required = false) String name,
|
@RequestParam(value = "type", required = true) String type) {
|
List<Location> data = locationService.query(name, type);
|
return Result.OK(data);
|
}
|
|
|
@GetMapping("/list")
|
@ApiOperation(value = "查询所有点位数据", notes = "查询所有厂区热点点位数据")
|
public Result list() {
|
List<Location> list = locationService.getAll();
|
return Result.OK(list);
|
}
|
|
|
@ApiOperation(value = "新增点位数据", notes = "新增点位详情数据")
|
@PostMapping
|
public Result insertLocation(@RequestBody Location location) {
|
int i = locationService.insertLocation(location);
|
if (i == 0) {
|
return Result.error("插入失败");
|
}
|
return Result.OK("插入成功");
|
}
|
|
@ApiOperation(value = "删除点位数据", notes = "删除点位详情数据")
|
@DeleteMapping("/{id}")
|
public Result deleteLocation(@PathVariable String id) {
|
int i = locationService.deleteLocation(id);
|
if (i == 0) {
|
return Result.error("删除失败");
|
}
|
return Result.OK("删除成功");
|
}
|
}
|