kongdeqiang
2023-03-02 ee83188936c8ac306144f6c8cd119b6d7574dfc6
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
package com.boying.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.boying.common.R;
import com.boying.entity.ViolationType;
import com.boying.service.ViolationTypeService;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
 
@RestController
@RequestMapping("violationType")
@RequiredArgsConstructor
public class ViolationTypeController {
 
    private final ViolationTypeService violationTypeService;
 
    @PostMapping("/findPage")
    public Object findPage(Page page) {
        QueryWrapper<ViolationType> wrapper = new QueryWrapper<>();
        wrapper.lambda()
                .orderByDesc(ViolationType::getId);
        return R.ok(violationTypeService.page(page,wrapper));
    }
 
    @PostMapping("/save")
    public Object save(ViolationType violationType) {
        violationTypeService.saveOrUpdate(violationType);
        return R.ok("保存成功");
    }
 
    @GetMapping("/{id}")
    public Object getObj(@PathVariable Integer id) {
        return R.ok(violationTypeService.getById(id));
    }
 
    @PostMapping("/delete")
    public Object delete(Long id) {
        violationTypeService.removeById(id);
        return R.ok("删除成功");
    }
 
    @PostMapping("/findAll")
    public Object findAll() {
        return R.ok(violationTypeService.list());
    }
}