package com.ruoyi.web.controller.system; 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.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.enums.BusinessType; import com.ruoyi.system.domain.TBatteryGroupTemplate; import com.ruoyi.system.service.ITBatteryGroupTemplateService; /** * 电池组模板管理 Controller。 * * @author ruoyi */ @RestController @RequestMapping("/system/batteryGroupTemplate") public class TBatteryGroupTemplateController extends BaseController { @Autowired private ITBatteryGroupTemplateService batteryGroupTemplateService; /** 查询模板下拉选项。 */ @PreAuthorize("@ss.hasPermi('system:batteryGroupTemplate:list')") @GetMapping("/options") public AjaxResult options() { List options = batteryGroupTemplateService.selectBatteryGroupTemplateOptions(); return success(options); } /** 查询模板详情及字段关系。 */ @PreAuthorize("@ss.hasPermi('system:batteryGroupTemplate:query')") @GetMapping("/{templateId}") public AjaxResult getInfo(@PathVariable Long templateId) { return success(batteryGroupTemplateService.selectBatteryGroupTemplateById(templateId)); } /** 新增电池组模板。 */ @PreAuthorize("@ss.hasPermi('system:batteryGroupTemplate:add')") @Log(title = "电池组模板管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody TBatteryGroupTemplate template) { template.setCreateBy(getUsername()); return toAjax(batteryGroupTemplateService.insertBatteryGroupTemplate(template)); } /** 编辑电池组模板并替换字段关系。 */ @PreAuthorize("@ss.hasPermi('system:batteryGroupTemplate:edit')") @Log(title = "电池组模板管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody TBatteryGroupTemplate template) { template.setUpdateBy(getUsername()); return toAjax(batteryGroupTemplateService.updateBatteryGroupTemplate(template)); } }