燕山石化溯源三维电子沙盘-【后端】-服务
13693261870
2023-04-25 ecd0ef5c6a78ac091b3fc2d42035cd0582c93a3f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.yssh.controller;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
 
import java.util.List;
 
import org.springframework.beans.factory.annotation.Autowired;
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.ILocationService;
import com.yssh.utils.Result;
 
/**
 * @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 {
    
    @Autowired
    private ILocationService 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("删除成功");
    }
}