kongdeqiang
2022-09-19 a9862e81851bbe037edc6bb1c7f562c1e55c0d7f
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
package com.boying.controller;
 
import com.boying.common.BaseController;
import com.boying.entity.Park;
import com.boying.entity.ViolationType;
import com.boying.service.ParkService;
import com.boying.service.ViolationTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@RequestMapping("violationType")
public class ViolationTypeController extends BaseController {
 
    @Autowired
    private ViolationTypeService violationTypeService;
 
    @PostMapping("findPage")
    public Object findPage(int page,int pageSize) {
        Pageable pageable = PageRequest.of(page-1,pageSize, Sort.Direction.DESC,"id");
        Page<ViolationType> pages = violationTypeService.findPage(pageable);
        return success("",pages);
    }
 
    @PostMapping("save")
    public Object save(ViolationType violationType) {
        violationTypeService.save(violationType);
        return success("保存成功");
    }
 
    @PostMapping("delete")
    public Object delete(Long id) {
        violationTypeService.delete(id);
        return success("删除成功");
    }
 
    @PostMapping("findAll")
    public Object findAll() {
        return success("",violationTypeService.findAll());
    }
}