package com.gunshi.project.hsz.controller; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.gunshi.core.result.R; import com.gunshi.project.hsz.entity.dto.InspectItemDto; import com.gunshi.project.hsz.entity.so.AttCctvBasePage; import com.gunshi.project.hsz.model.InspectItem; import com.gunshi.project.hsz.service.InspectItemService; import com.gunshi.project.hsz.validate.markers.Insert; import com.gunshi.project.hsz.validate.markers.Update; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; /** * 描述: 巡检项 * author: xusan * date: 2024-08-29 09:58:10 */ @Tag(name = "巡检项") @RestController @RequestMapping(value="/inspectItem") public class InspectItemController { @Autowired private InspectItemService service; @Operation(summary = "新增") @PostMapping("/insert") public R insert(@Validated(Insert.class) @RequestBody InspectItem dto) { dto.setId(IdWorker.getId()); dto.setStatus(0); boolean result = service.save(dto); return R.ok(result ? dto : null); } @Operation(summary = "修改") @PostMapping("/update") public R update(@Validated(Update.class) @RequestBody InspectItem dto) { boolean result = service.updateById(dto); return R.ok(result ? dto : null); } @Operation(summary = "删除") @GetMapping("/del/{id}") public R del(@Schema(name = "id") @PathVariable("id") Long id) { return R.ok(service.delData(id)); } @Operation(summary = "启停") @PostMapping("/startStop") public R startStop(@RequestBody InspectItemDto dto) { return R.ok(service.startStop(dto)); } @Operation(summary = "分页") @PostMapping("/page") public R> page(@RequestBody @Validated AttCctvBasePage page) { return R.ok(service.pageQuery(page)); } }