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 io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("ffzf/violationtype") @RequiredArgsConstructor @Tag(description = "ffzf/violationtype" , name = "违章类型接口" ) public class ViolationTypeController { private final ViolationTypeService violationTypeService; @PostMapping("/findPage") @Operation(summary = "分页查询" , description = "分页查询" ) public Object findPage(Page page) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda() .orderByDesc(ViolationType::getId); return R.ok(violationTypeService.page(page,wrapper)); } @PostMapping("/save") @Operation(summary = "新增违章类型" , description = "新增违章类型" ) public Object save(ViolationType violationType) { violationTypeService.saveOrUpdate(violationType); return R.ok("保存成功"); } @GetMapping("/{id}") @Operation(summary = "根据id查询" , description = "根据id查询" ) public Object getObj(@PathVariable Integer id) { return R.ok(violationTypeService.getById(id)); } @PostMapping("/delete") @Operation(summary = "删除违章类型" , description = "删除违章类型" ) public Object delete(Long id) { violationTypeService.removeById(id); return R.ok("删除成功"); } @PostMapping("/findAll") @Operation(summary = "查询所有" , description = "查询所有" ) public Object findAll() { return R.ok(violationTypeService.list()); } }