gunshi-project-ss/src/main/java/com/gunshi/project/ss/controller/FundBudgetController.java

95 lines
3.1 KiB
Java
Raw Normal View History

2026-01-16 10:38:26 +08:00
package com.gunshi.project.ss.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.core.result.R;
import com.gunshi.project.ss.entity.so.FundBudgetPageSo;
import com.gunshi.project.ss.model.FileAssociations;
import com.gunshi.project.ss.model.FundBudget;
import com.gunshi.project.ss.service.FileAssociationsService;
import com.gunshi.project.ss.service.FundBudgetService;
import io.swagger.v3.oas.annotations.Operation;
2026-02-08 13:56:19 +08:00
import io.swagger.v3.oas.annotations.Parameter;
2026-01-16 10:38:26 +08:00
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Tag(name = "经费预算")
@RestController
@RequestMapping(value="/fundBudget")
public class FundBudgetController extends AbstractCommonFileController {
@Autowired
private FundBudgetService fundBudgetService;
@Autowired
private FileAssociationsService fileService;
@Operation(description = "根据年份查询")
@GetMapping("/get/{year}")
public R<FundBudget> get(@PathVariable("year") Integer year){
FundBudget res = fundBudgetService.getByYear(year);
if(res!=null){
List<FileAssociations> files = fileService.getFiles(getGroupId(), res.getId().toString());
}
return R.ok(res);
}
2026-01-16 10:38:26 +08:00
@Operation(description = "分页")
@PostMapping("/page")
public R<Page<FundBudget>> pageInfo(@RequestBody FundBudgetPageSo pageSo){
Page<FundBudget> page = fundBudgetService.pageInfo(pageSo);
for (FundBudget record : page.getRecords()) {
List<FileAssociations> files = fileService.getFiles(getGroupId(), record.getId().toString());
record.setFiles(files);
}
return R.ok(page);
}
2026-02-08 13:56:19 +08:00
@Operation(description = "统计")
@GetMapping("stat")
public R<FundBudget> stat(@RequestParam(value = "year",required = false) @Parameter(description = "年份") Integer year){
FundBudget res = fundBudgetService.stat(year);
return R.ok(res);
}
2026-01-16 10:38:26 +08:00
@Operation(description = "新增")
@PostMapping("/insert")
public R<FundBudget> insert(@RequestBody FundBudget fundBudget){
boolean flag = fundBudgetService.saveData(fundBudget);
if(flag){
fileService.saveFile(fundBudget.getFiles(),getGroupId(),fundBudget.getId().toString());
}
return R.ok(fundBudget);
}
@Operation(description = "更新")
@PostMapping("/update")
public R<FundBudget> update(@RequestBody FundBudget fundBudget){
boolean flag = fundBudgetService.updateData(fundBudget);
if(flag){
fileService.saveFile(fundBudget.getFiles(),getGroupId(),fundBudget.getId().toString());
}
return R.ok(fundBudget);
}
@Operation(description = "删除")
@GetMapping("/del/{id}")
public R<Boolean> del(@PathVariable("id") Long id){
boolean flag = fundBudgetService.removeById(id);
if(flag){
fileService.deleteFile(getGroupId(),id.toString());
}
return R.ok(flag);
}
@Override
public String getGroupId() {
return "fundBudget";
}
}