package com.ruoyi.web.controller.api;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.basic.PageInfo;
|
import com.ruoyi.common.core.domain.BasePage;
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.system.model.YcFinancialManagement;
|
import com.ruoyi.system.model.YcRevenueExpenditureType;
|
import com.ruoyi.system.service.YcFinancialManagementService;
|
import com.ruoyi.system.service.YcRevenueExpenditureTypeService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.util.StringUtils;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
|
/**
|
* <p>
|
* 收支类型表 前端控制器
|
* </p>
|
*
|
* @author xiaochen
|
* @since 2025-07-15
|
*/
|
@Api(tags = "收支类型表")
|
@RestController
|
@RequestMapping("/yc-revenue-expenditure-type")
|
public class YcRevenueExpenditureTypeController {
|
|
private final YcRevenueExpenditureTypeService ycRevenueExpenditureTypeService;
|
private final YcFinancialManagementService ycFinancialManagementService;
|
|
@Autowired
|
public YcRevenueExpenditureTypeController(YcRevenueExpenditureTypeService ycRevenueExpenditureTypeService, YcFinancialManagementService ycFinancialManagementService) {
|
this.ycRevenueExpenditureTypeService = ycRevenueExpenditureTypeService;
|
this.ycFinancialManagementService = ycFinancialManagementService;
|
}
|
|
/**
|
* 查询收支类型列表
|
*/
|
@ApiOperation( value = "查询收支类型分页列表")
|
@PostMapping(value = "/pageList")
|
public R<PageInfo<YcRevenueExpenditureType>> pageList(@RequestBody BasePage query) {
|
return R.ok(ycRevenueExpenditureTypeService.pageList(query));
|
}
|
|
/**
|
* 查询收支类型列表
|
*/
|
@ApiOperation( value = "查询收支类型列表,类型查询必传")
|
@GetMapping(value = "/typeList")
|
public R<List<YcRevenueExpenditureType>> list(@RequestParam(value = "typeName",required = false) String typeName,
|
@RequestParam(value = "revenueType") Integer revenueType) {
|
LambdaQueryWrapper<YcRevenueExpenditureType> wrapper = new LambdaQueryWrapper<>();
|
if(StringUtils.hasLength(typeName)){
|
wrapper.like(YcRevenueExpenditureType::getTypeName, typeName);
|
}
|
wrapper.eq(YcRevenueExpenditureType::getRevenueType, revenueType);
|
List<YcRevenueExpenditureType> list = ycRevenueExpenditureTypeService.list(wrapper);
|
return R.ok(list);
|
}
|
|
/**
|
* 查询收支类型列表
|
*/
|
@ApiOperation( value = "查询收支类型列表,不传类型")
|
@GetMapping(value = "/list")
|
public R<List<YcRevenueExpenditureType>> pageList(@RequestParam(value = "typeName",required = false) String typeName) {
|
LambdaQueryWrapper<YcRevenueExpenditureType> wrapper = new LambdaQueryWrapper<>();
|
if(StringUtils.hasLength(typeName)){
|
wrapper.like(YcRevenueExpenditureType::getTypeName, typeName);
|
}
|
List<YcRevenueExpenditureType> list = ycRevenueExpenditureTypeService.list(wrapper);
|
return R.ok(list);
|
}
|
|
/**
|
* 添加收支类型管理
|
*/
|
@ApiOperation( value = "添加收支类型")
|
@Log(title = "收支类型-添加", businessType = BusinessType.INSERT)
|
@PostMapping(value = "/add")
|
public R<Boolean> add(@RequestBody YcRevenueExpenditureType dto) {
|
return R.ok(ycRevenueExpenditureTypeService.save(dto));
|
}
|
|
/**
|
* 修改收支类型
|
*/
|
@ApiOperation( value = "修改收支类型")
|
@Log(title = "收支类型-修改", businessType = BusinessType.UPDATE)
|
@PostMapping(value = "/update")
|
public R<Boolean> update(@RequestBody YcRevenueExpenditureType dto) {
|
return R.ok(ycRevenueExpenditureTypeService.updateById(dto));
|
}
|
|
/**
|
* 查看收支类型详情
|
*/
|
@ApiOperation( value = "查看收支类型详情")
|
@GetMapping(value = "/getDetailById")
|
public R<YcRevenueExpenditureType> getDetailById(@RequestParam("id") Long id) {
|
return R.ok(ycRevenueExpenditureTypeService.getById(id));
|
}
|
|
/**
|
* 删除收支类型
|
*/
|
@ApiOperation( value = "删除收支类型")
|
@Log(title = "收支类型-删除", businessType = BusinessType.DELETE)
|
@DeleteMapping(value = "/deleteById")
|
public R<Boolean> deleteById(@RequestParam("id") Long id) {
|
// 查询分类是否在财务管理里面存在
|
long count = ycFinancialManagementService.count(Wrappers.lambdaQuery(YcFinancialManagement.class)
|
.eq(YcFinancialManagement::getTypeId, id));
|
if(count>0){
|
return R.fail("该分类在财务管理中正在使用,无法删除");
|
}
|
return R.ok(ycRevenueExpenditureTypeService.removeById(id));
|
}
|
|
}
|