package com.newfiber.modules.inspection.controller; import com.github.pagehelper.PageHelper; import com.newfiber.common.utils.Constant; import com.newfiber.common.utils.R; import com.newfiber.modules.inspection.entity.InspectionTrack; import com.newfiber.modules.inspection.request.InspectionTrackSaveReq; import com.newfiber.modules.inspection.request.InspectionTrackUpdateReq; import com.newfiber.modules.inspection.service.InspectionTrackService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperationSupport; import java.util.Arrays; import java.util.Map; import javax.annotation.Resource; import javax.validation.Valid; import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * 巡检轨迹Controller * * @author : xiongk * @since : 2020-11-23 10:10 */ @RestController @Api(value = "巡检轨迹管理", tags = "巡检轨迹管理") @RequestMapping("/inspection_track") public class InspectionTrackController { @Resource private InspectionTrackService inspectionTrackService; @ApiOperation(value = "新增巡检轨迹") @ApiOperationSupport(order = 10) @PostMapping(value = "/save") public R save(@RequestBody @Valid InspectionTrackSaveReq request) { InspectionTrack inspectionTrack = new InspectionTrack(); BeanUtils.copyProperties(request, inspectionTrack); inspectionTrackService.save(inspectionTrack); return R.ok(); } @ApiOperation(value = "删除巡检轨迹", hidden = true) @ApiOperationSupport(order = 20) @PostMapping("/delete") public R delete(@RequestBody Integer[] ids) { inspectionTrackService.removeByIds(Arrays.asList(ids)); return R.ok(); } @ApiOperation(value = "修改巡检轨迹", hidden = true) @ApiOperationSupport(order = 30) @PostMapping(value = "/update") public R update(@RequestBody @Valid InspectionTrackUpdateReq request) { InspectionTrack inspectionTrack = new InspectionTrack(); BeanUtils.copyProperties(request, inspectionTrack); inspectionTrackService.updateById(inspectionTrack); return R.ok(); } @ApiOperation(value = "详细查询巡检轨迹") @ApiOperationSupport(order = 40) @PostMapping("/detail/{id}") public R detail(@PathVariable("id") @Valid Integer id) { return R.ok().put("data", inspectionTrackService.getById(id)); } @ApiOperation(value = "分页条件查询巡检轨迹") @ApiOperationSupport(order = 50) @PostMapping(value = "/page") public R page(@RequestBody Map<String, Object> params) { int page = Integer.parseInt(params.get(Constant.PAGE).toString()); int limit = Integer.parseInt(params.get(Constant.LIMIT).toString()); PageHelper.startPage(page, limit); params.remove(Constant.PAGE); params.remove(Constant.LIMIT); return R.ok().put("page", inspectionTrackService.listByMap(params)); } @ApiOperation(value = "列表条件查询巡检轨迹") @ApiOperationSupport(order = 60) @PostMapping(value = "/list") public R list(@RequestBody Map<String, Object> params) { return R.ok().put("list", inspectionTrackService.listByMap(params)); } }