package com.battery.business.web;
|
|
import java.util.List;
|
import com.battery.business.service.report.FormationReportRepository;
|
import com.battery.business.service.report.FormationReportService;
|
import com.battery.business.service.report.FormationReportRequest;
|
import com.battery.business.service.report.CompareReportEditRequest;
|
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
import jakarta.validation.Valid;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.web.bind.annotation.*;
|
|
/** 化成报表按所属动作授权,授权用户可以跨创建人协作。 */
|
@RestController
|
@RequestMapping("/system/formation-report")
|
public class FormationReportController extends BaseController
|
{
|
private final FormationReportService service;
|
private final FormationReportRepository reports;
|
public FormationReportController(FormationReportService service, FormationReportRepository reports)
|
{ this.service = service; this.reports = reports; }
|
|
/** 查询真实化成来源,不额外要求测试管理权限。 */
|
@GetMapping("/sources") @PreAuthorize("@ss.hasPermi('system:formation-report:add')")
|
public AjaxResult sources() { return success(service.sources()); }
|
|
/** 后端校验归属并读取当前循环及业务字段。 */
|
@PostMapping("/preview") @PreAuthorize("@ss.hasPermi('system:formation-report:add')")
|
public AjaxResult preview(@RequestBody List<FormationReportRequest.Selection> selections) { return success(service.preview(selections)); }
|
|
/** 查询独立报表摘要。 */
|
@GetMapping("/list") @PreAuthorize("@ss.hasPermi('system:formation-report:query')")
|
public AjaxResult list() { return success().put("rows", service.list()); }
|
|
/** 创建身份及首个完整版本。 */
|
@PostMapping @PreAuthorize("@ss.hasPermi('system:formation-report:add')")
|
public AjaxResult create(@Valid @RequestBody FormationReportRequest request) { return success(service.create(request, getUserId(), getUsername())); }
|
|
/** 重开最新保存版本,不读取来源测试。 */
|
@GetMapping("/{id}") @PreAuthorize("@ss.hasPermi('system:formation-report:query')")
|
public AjaxResult get(@PathVariable long id) { return success(service.page(id, null)); }
|
|
/** 编辑权限独立读取最新基准。 */
|
@GetMapping("/{id}/editing") @PreAuthorize("@ss.hasPermi('system:formation-report:edit')")
|
public AjaxResult editing(@PathVariable long id) { return success(service.page(id, null)); }
|
|
/** 查看历史版本的操作人、时间和说明。 */
|
@GetMapping("/{id}/versions") @PreAuthorize("@ss.hasPermi('system:formation-report:query')")
|
public AjaxResult history(@PathVariable long id) { return success(reports.history(id)); }
|
|
/** 指定历史版本只读,不提供回滚。 */
|
@GetMapping("/{id}/versions/{versionNo}") @PreAuthorize("@ss.hasPermi('system:formation-report:query')")
|
public AjaxResult version(@PathVariable long id, @PathVariable int versionNo) { return success(service.page(id, versionNo)); }
|
|
/** 查看曲线必须沿用首屏固定版本,不能在切换循环时重读最新来源。 */
|
@GetMapping("/{id}/versions/{versionNo}/cycles/{cycleNo}") @PreAuthorize("@ss.hasPermi('system:formation-report:query')")
|
public AjaxResult cycle(@PathVariable long id, @PathVariable int versionNo, @PathVariable int cycleNo)
|
{ return success(service.cycleCurves(id, versionNo, cycleNo)); }
|
|
/** 编辑动作可独立读取已打开基准的曲线,不额外要求查询权限。 */
|
@GetMapping("/{id}/editing/versions/{versionNo}/cycles/{cycleNo}") @PreAuthorize("@ss.hasPermi('system:formation-report:edit')")
|
public AjaxResult editingCycle(@PathVariable long id, @PathVariable int versionNo, @PathVariable int cycleNo)
|
{ return success(service.cycleCurves(id, versionNo, cycleNo)); }
|
|
/** 导出权限独立读取指定快照,打开打印不记录下载成功。 */
|
@GetMapping("/{id}/versions/{versionNo}/print") @PreAuthorize("@ss.hasPermi('system:formation-report:export')")
|
public AjaxResult print(@PathVariable long id, @PathVariable int versionNo) { return success(service.get(id, versionNo)); }
|
|
/** 普通编辑不接受来源或测量快照。 */
|
@PostMapping("/{id}/versions") @PreAuthorize("@ss.hasPermi('system:formation-report:edit')")
|
public AjaxResult edit(@PathVariable long id, @Valid @RequestBody FormationReportRequest.Edit request)
|
{ return success(service.edit(id, request, getUserId(), getUsername())); }
|
|
/** 明确按当前来源生成新版本。 */
|
@PostMapping("/{id}/refresh-source") @PreAuthorize("@ss.hasPermi('system:formation-report:edit')")
|
public AjaxResult refresh(@PathVariable long id, @Valid @RequestBody CompareReportEditRequest.Refresh request)
|
{ return success(service.refresh(id, request, getUserId(), getUsername())); }
|
|
/** 整体删除及最小日志同成同败。 */
|
@DeleteMapping("/{id}") @PreAuthorize("@ss.hasPermi('system:formation-report:remove')")
|
public AjaxResult delete(@PathVariable long id) { service.delete(id, getUserId(), getUsername()); return success(); }
|
}
|