kongdeqiang
2024-04-09 fb050c0dafa5363a73540dd9e52b78487e25ba0a
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("ffzf/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());
    }
}