VisitsController.java 1.5 KB
Newer Older
1
package me.zhengjie.modules.monitor.rest;
郑杰 已提交
2

3 4
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
5 6
import me.zhengjie.modules.monitor.service.VisitsService;
import me.zhengjie.utils.RequestHolder;
郑杰 已提交
7 8 9 10 11 12 13 14 15
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
16
 * @author Zheng Jie
郑杰 已提交
17 18 19
 * @date 2018-12-13
 */
@RestController
20 21
@RequestMapping("/api/visits")
@Api(tags = "系统:访问记录管理")
郑杰 已提交
22 23
public class VisitsController {

24
    private final VisitsService visitsService;
郑杰 已提交
25

26 27 28 29 30 31
    public VisitsController(VisitsService visitsService) {
        this.visitsService = visitsService;
    }

    @PostMapping
    @ApiOperation("创建访问记录")
郑杰 已提交
32
    public ResponseEntity create(){
33
        visitsService.count(RequestHolder.getHttpServletRequest());
郑杰 已提交
34 35 36
        return new ResponseEntity(HttpStatus.CREATED);
    }

37 38
    @GetMapping
    @ApiOperation("查询")
郑杰 已提交
39
    public ResponseEntity get(){
40
        return new ResponseEntity<>(visitsService.get(),HttpStatus.OK);
郑杰 已提交
41 42
    }

43 44
    @GetMapping(value = "/chartData")
    @ApiOperation("查询图表数据")
郑杰 已提交
45
    public ResponseEntity getChartData(){
46
        return new ResponseEntity<>(visitsService.getChartData(),HttpStatus.OK);
郑杰 已提交
47 48
    }
}