package com.battery.business.web; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.battery.business.domain.TCollector; import com.battery.business.service.ITCollectorService; /** * 采集器管理 Controller。 * * @author ruoyi */ @RestController @RequestMapping("/system/collector") public class TCollectorController extends BaseController { @Autowired private ITCollectorService collectorService; /** 分页查询采集器列表。 */ @PreAuthorize("@ss.hasPermi('system:collector:list')") @GetMapping("/list") public TableDataInfo list(TCollector collector) { startPage(); List list = collectorService.selectCollectorList(collector); return getDataTable(list); } /** 查询采集器详情。 */ @PreAuthorize("@ss.hasPermi('system:collector:query')") @GetMapping(value = "/{collectorId}") public AjaxResult getInfo(@PathVariable Long collectorId) { return success(collectorService.selectCollectorById(collectorId)); } /** 新增采集器。 */ @PreAuthorize("@ss.hasPermi('system:collector:add')") @Log(title = "采集器管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody TCollector collector) { collector.setCreateBy(getUsername()); return toAjax(collectorService.insertCollector(collector)); } /** 编辑采集器基础资料。 */ @PreAuthorize("@ss.hasPermi('system:collector:edit')") @Log(title = "采集器管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody TCollector collector) { collector.setUpdateBy(getUsername()); return toAjax(collectorService.updateCollector(collector)); } /** 启用或禁用采集器。 */ @PreAuthorize("@ss.hasPermi('system:collector:edit')") @Log(title = "采集器管理", businessType = BusinessType.UPDATE) @PutMapping("/changeStatus") public AjaxResult changeStatus(@RequestBody TCollector collector) { collector.setUpdateBy(getUsername()); return toAjax(collectorService.updateCollectorStatus(collector)); } /** 批量逻辑删除采集器。 */ @PreAuthorize("@ss.hasPermi('system:collector:remove')") @Log(title = "采集器管理", businessType = BusinessType.DELETE) @DeleteMapping("/{collectorIds}") public AjaxResult remove(@PathVariable Long[] collectorIds) { return toAjax(collectorService.deleteCollectorByIds(collectorIds, getUsername())); } }