80 lines
2.5 KiB
Java
80 lines
2.5 KiB
Java
|
|
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.mapper.FundBudgetMapper;
|
||
|
|
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;
|
||
|
|
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 = "分页")
|
||
|
|
@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);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
@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";
|
||
|
|
}
|
||
|
|
}
|