package org.sxkj.gd.workorder.controller;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
import lombok.AllArgsConstructor;
|
import org.springblade.core.secure.utils.AuthUtil;
|
import org.springframework.web.bind.annotation.*;
|
import org.sxkj.common.model.ResponseResult;
|
import org.sxkj.gd.workorder.entity.GdOperationalRevenue;
|
import org.sxkj.gd.workorder.service.GdOperationalRevenueService;
|
import org.sxkj.gd.workorder.vo.GdOperationalRevenueVo;
|
|
import java.time.LocalDateTime;
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
/**
|
* 运营收益控制器
|
*/
|
@Api(tags = "运营收益管理")
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/revenue")
|
public class GdOperationalRevenueController {
|
|
private final GdOperationalRevenueService operationalRevenueService;
|
|
/**
|
* 分页查询运营收益
|
*/
|
@ApiOperation("分页查询运营收益")
|
@GetMapping("/page")
|
public ResponseResult page(
|
@ApiParam("页码") @RequestParam(value = "current", defaultValue = "1") long current,
|
@ApiParam("每页大小") @RequestParam(value = "size", defaultValue = "10") long size,
|
@ApiParam("营业收入") @RequestParam(value = "operatingIncome", required = false) String operatingIncome,
|
@ApiParam("综合总成本费用") @RequestParam(value = "totalCost", required = false) String totalCost,
|
@ApiParam("净利润") @RequestParam(value = "netProfit", required = false) String netProfit,
|
@ApiParam("财务内部收益率") @RequestParam(value = "financialIrr", required = false) String financialIrr,
|
@ApiParam("市场空间") @RequestParam(value = "marketSpace", required = false) String marketSpace,
|
@ApiParam("创建人") @RequestParam(value = "nickName", required = false) String nickName
|
) {
|
Page<GdOperationalRevenue> page = new Page<>(current, size);
|
IPage<GdOperationalRevenue> result = operationalRevenueService.selectPage(page, operatingIncome, totalCost, netProfit, financialIrr, marketSpace, nickName);
|
|
// 转换为Vo分页
|
IPage<GdOperationalRevenueVo> voPage = result.convert(operationalRevenueService::convertToVo);
|
return ResponseResult.success(voPage);
|
}
|
|
/**
|
* 查询所有运营收益
|
*/
|
@ApiOperation("查询所有运营收益")
|
@GetMapping("/list")
|
public ResponseResult list() {
|
List<GdOperationalRevenue> list = operationalRevenueService.list();
|
|
// 转换为Vo列表
|
List<GdOperationalRevenueVo> voList = list.stream()
|
.map(operationalRevenueService::convertToVo)
|
.collect(Collectors.toList());
|
return ResponseResult.success(voList);
|
}
|
|
|
|
/**
|
* 根据ID查询运营收益
|
*/
|
@ApiOperation("根据ID查询运营收益")
|
@GetMapping("selectById/{id}")
|
public ResponseResult getById(@ApiParam("主键ID") @PathVariable Long id) {
|
GdOperationalRevenue operationalRevenue = operationalRevenueService.getById(id);
|
|
// 转换为Vo对象
|
GdOperationalRevenueVo vo = operationalRevenueService.convertToVo(operationalRevenue);
|
return ResponseResult.success(vo);
|
}
|
|
/**
|
* 新增运营收益
|
*/
|
@ApiOperation("新增运营收益")
|
@PostMapping("/add")
|
public ResponseResult save(@RequestBody GdOperationalRevenue operationalRevenue) {
|
operationalRevenue.setCreateUser(String.valueOf(AuthUtil.getUserId()));
|
LocalDateTime now = LocalDateTime.now();
|
operationalRevenue.setCreateTime(now);
|
operationalRevenue.setUpdateTime(now);
|
operationalRevenue.setCreateDept(AuthUtil.getDeptId());
|
operationalRevenue.setUpdateUser(String.valueOf(AuthUtil.getUserId()));
|
operationalRevenue.setNickName(AuthUtil.getNickName());
|
boolean result = operationalRevenueService.save(operationalRevenue);
|
return ResponseResult.success(result);
|
}
|
|
/**
|
* 修改运营收益
|
*/
|
@ApiOperation("修改运营收益")
|
@PutMapping("update")
|
public ResponseResult updateById(@RequestBody GdOperationalRevenue operationalRevenue) {
|
LocalDateTime now = LocalDateTime.now();
|
operationalRevenue.setUpdateTime(now);
|
operationalRevenue.setUpdateUser(String.valueOf(AuthUtil.getUserId()));
|
boolean result = operationalRevenueService.updateById(operationalRevenue);
|
return ResponseResult.success(result);
|
}
|
|
/**
|
* 删除运营收益
|
*/
|
@ApiOperation("删除运营收益")
|
@DeleteMapping("delete/{id}")
|
public ResponseResult removeById(@ApiParam("主键ID") @PathVariable Long id) {
|
boolean result = operationalRevenueService.removeById(id);
|
return ResponseResult.success(result);
|
}
|
|
/**
|
* 批量删除运营收益
|
*/
|
@ApiOperation("批量删除运营收益")
|
@DeleteMapping("/batch")
|
public ResponseResult removeByIds(@RequestBody List<Long> ids) {
|
boolean result = operationalRevenueService.removeByIds(ids);
|
return ResponseResult.success(result);
|
}
|
}
|