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());
|
}
|
}
|