| | |
| | | import com.battery.business.report.CompareReportRepository; |
| | | import com.battery.business.report.CompareReportService; |
| | | import com.battery.business.report.CompareReportRequest; |
| | | import com.battery.business.report.CompareReportEditRequest; |
| | | import com.battery.business.report.CompareFieldTemplateRepository; |
| | | import com.battery.business.report.CompareFieldTemplateRequest; |
| | | import com.battery.business.report.CompareFieldTemplateService; |
| | | import jakarta.validation.Valid; |
| | | import java.util.List; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | |
| | | { |
| | | private final CompareReportRepository reports; |
| | | private final CompareReportService service; |
| | | public CompareReportController(CompareReportRepository reports, CompareReportService service) |
| | | { this.reports = reports; this.service = service; } |
| | | private final CompareFieldTemplateRepository templates; |
| | | private final CompareFieldTemplateService templateService; |
| | | public CompareReportController(CompareReportRepository reports, CompareReportService service, CompareFieldTemplateRepository templates, CompareFieldTemplateService templateService) |
| | | { this.reports = reports; this.service = service; this.templates = templates; this.templateService = templateService; } |
| | | |
| | | /** 查看或编写报表均可读取模板,不额外要求测试或共享字段管理权限。 */ |
| | | @PreAuthorize("@ss.hasAnyPermi('system:compare-report:query,system:compare-report:add,system:compare-report:edit')") |
| | | @GetMapping("/templates") |
| | | public AjaxResult templates() { return success(templates.list()); } |
| | | |
| | | /** 模板新增复用报表新增权限;只接收经过验证的字段结构。 */ |
| | | @PreAuthorize("@ss.hasPermi('system:compare-report:add')") |
| | | @PostMapping("/templates") |
| | | public AjaxResult createTemplate(@Valid @RequestBody CompareFieldTemplateRequest request) |
| | | { |
| | | return success().put("id", templateService.create(request, getUserId(), getUsername())); |
| | | } |
| | | |
| | | /** 模板更新复用报表编辑权限,允许跨创建人协作。 */ |
| | | @PreAuthorize("@ss.hasPermi('system:compare-report:edit')") |
| | | @PutMapping("/templates/{id}") |
| | | public AjaxResult updateTemplate(@PathVariable long id, @Valid @RequestBody CompareFieldTemplateRequest request) |
| | | { templateService.update(id, request); return success(); } |
| | | |
| | | /** 查询报表摘要;筛选与分页沿用现有列表交互。 */ |
| | | @PreAuthorize("@ss.hasPermi('system:compare-report:query')") |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:compare-report:query')") |
| | | @GetMapping("/{id}") |
| | | public AjaxResult get(@PathVariable long id) { return success(service.get(id)); } |
| | | |
| | | /** 删除权限独立于创建人;业务事务同步记录删除,不使用异步操作日志切面。 */ |
| | | @PreAuthorize("@ss.hasPermi('system:compare-report:remove')") |
| | | @DeleteMapping("/{id}") |
| | | public AjaxResult delete(@PathVariable long id) |
| | | { |
| | | service.delete(id, getUserId(), getUsername()); |
| | | return success(); |
| | | } |
| | | |
| | | /** 授权查看全部历史版本摘要,不限制创建人。 */ |
| | | @PreAuthorize("@ss.hasPermi('system:compare-report:query')") |
| | | @GetMapping("/{id}/versions") |
| | | public AjaxResult history(@PathVariable long id) { return success(reports.history(id)); } |
| | | |
| | | /** 指定历史版本只读,不依赖来源仍存在。 */ |
| | | @PreAuthorize("@ss.hasPermi('system:compare-report:query')") |
| | | @GetMapping("/{id}/versions/{versionNo}") |
| | | public AjaxResult version(@PathVariable long id, @PathVariable int versionNo) { return success(service.get(id, versionNo)); } |
| | | |
| | | /** 导出仅返回指定已保存版本;不读取来源,也不记录浏览器无法确认的 PDF 保存结果。 */ |
| | | @PreAuthorize("@ss.hasPermi('system:compare-report:export')") |
| | | @GetMapping("/{id}/versions/{versionNo}/print") |
| | | public AjaxResult print(@PathVariable long id, @PathVariable int versionNo) { return success(service.get(id, versionNo)); } |
| | | |
| | | /** 修订 CSV 使用正式版本摘要,导出权限独立于历史查看权限。 */ |
| | | @PreAuthorize("@ss.hasPermi('system:compare-report:export')") |
| | | @GetMapping("/{id}/versions/export") |
| | | public AjaxResult exportHistory(@PathVariable long id) { return success(reports.history(id)); } |
| | | |
| | | /** 编辑权限可读取最新快照作为基准,无需来源测试权限。 */ |
| | | @PreAuthorize("@ss.hasPermi('system:compare-report:edit')") |
| | | @GetMapping("/{id}/editing") |
| | | public AjaxResult editing(@PathVariable long id) { return success(service.get(id)); } |
| | | |
| | | /** 普通编辑只追加新版本,拒绝调用方提供测量事实。 */ |
| | | @PreAuthorize("@ss.hasPermi('system:compare-report:edit')") |
| | | @PostMapping("/{id}/versions") |
| | | public AjaxResult edit(@PathVariable long id, @Valid @RequestBody CompareReportEditRequest request) |
| | | { return success(service.edit(id, request, getUserId(), getUsername())); } |
| | | |
| | | /** 独立动作重读当前来源并追加快照,失败由业务事务完整回滚。 */ |
| | | @PreAuthorize("@ss.hasPermi('system:compare-report:edit')") |
| | | @PostMapping("/{id}/refresh-source") |
| | | public AjaxResult refresh(@PathVariable long id, @Valid @RequestBody CompareReportEditRequest.Refresh request) |
| | | { return success(service.refresh(id, request, getUserId(), getUsername())); } |
| | | } |