119 lines
3.2 KiB
Java
119 lines
3.2 KiB
Java
package net.carbon.controller;
|
|
|
|
import net.carbon.bean.PageResponse;
|
|
import net.carbon.model.request.EconomicsUpdateRequest;
|
|
import net.carbon.model.vo.EconomicsVO;
|
|
import net.carbon.result.Result;
|
|
import net.carbon.service.EconomicsService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
/**
|
|
* (Economics)表控制层
|
|
*
|
|
* @author makejava
|
|
* @since 2025-02-21 13:44:09
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/api/economics/v1/")
|
|
public class EconomicsController {
|
|
|
|
/**
|
|
* 分页查询所有数据
|
|
*
|
|
* @param page 分页对象
|
|
* @param economics 查询实体
|
|
* @return 所有数据
|
|
*/
|
|
// @GetMapping
|
|
// public Result selectAll(Page<Economics> page, Economics economics) {
|
|
// return success(this.economicsService.page(page, new QueryWrapper<>(economics)));
|
|
// }
|
|
|
|
/**
|
|
* 通过主键查询单条数据
|
|
*
|
|
* @param id 主键
|
|
* @return 单条数据
|
|
*/
|
|
// @GetMapping("{id}")
|
|
// public R selectOne(@PathVariable Serializable id) {
|
|
// return success(this.economicsService.getById(id));
|
|
// }
|
|
|
|
/**
|
|
* 新增数据
|
|
*
|
|
* @param economics 实体对象
|
|
* @return 新增结果
|
|
*/
|
|
// @PostMapping
|
|
// public R insert(@RequestBody Economics economics) {
|
|
// return success(this.economicsService.save(economics));
|
|
// }
|
|
|
|
/**
|
|
* 修改数据
|
|
*
|
|
* @param economics 实体对象
|
|
* @return 修改结果
|
|
*/
|
|
// @PutMapping
|
|
// public R update(@RequestBody Economics economics) {
|
|
// return success(this.economicsService.updateById(economics));
|
|
// }
|
|
|
|
/**
|
|
* 删除数据
|
|
*
|
|
* @param idList 主键结合
|
|
* @return 删除结果
|
|
*/
|
|
// @DeleteMapping
|
|
// public R delete(@RequestParam("idList") List<Long> idList) {
|
|
// return success(this.economicsService.removeByIds(idList));
|
|
// }
|
|
|
|
|
|
@Autowired
|
|
private EconomicsService economicsService;
|
|
|
|
// 获取所有指标
|
|
@GetMapping("/list")
|
|
public Result<PageResponse<EconomicsVO>> getAllIndicators(@RequestParam("pageSize") Long pageSize, @RequestParam("current") Long current) {
|
|
return Result.success(economicsService.getPage(pageSize, current));
|
|
}
|
|
|
|
// 新增指标
|
|
// @PostMapping("/create")
|
|
// public Result createIndicator(@RequestBody EconomicsRequest economicsRequest) {
|
|
//
|
|
// boolean save = economicsService.save(economicsRequest);
|
|
// if (save) {
|
|
// return Result.success();
|
|
// }
|
|
// return Result.error("创建失败");
|
|
// }
|
|
|
|
// 生成编辑接口
|
|
@PostMapping("/update")
|
|
public Result updateIndicator(@RequestBody EconomicsUpdateRequest economicsUpdateReq) {
|
|
int row = economicsService.updateById(economicsUpdateReq);
|
|
if (row > 0) {
|
|
return Result.success();
|
|
}
|
|
return Result.error("编辑失败");
|
|
}
|
|
|
|
// 剔除指标
|
|
@DeleteMapping("/delete/{id}")
|
|
public Result delete(@PathVariable("id") Long id) {
|
|
int row = economicsService.delete(id);
|
|
if (row > 0) {
|
|
return Result.success();
|
|
}
|
|
return Result.error("删除失败");
|
|
}
|
|
}
|
|
|