|
|
@@ -0,0 +1,93 @@
|
|
|
+package com.yc.ship.module.product.controller.admin.redddata;
|
|
|
+
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+
|
|
|
+import javax.validation.*;
|
|
|
+import javax.servlet.http.*;
|
|
|
+import java.util.*;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+import com.yc.ship.framework.common.pojo.PageParam;
|
|
|
+import com.yc.ship.framework.common.pojo.PageResult;
|
|
|
+import com.yc.ship.framework.common.pojo.CommonResult;
|
|
|
+import com.yc.ship.framework.common.util.object.BeanUtils;
|
|
|
+import static com.yc.ship.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+import com.yc.ship.framework.excel.core.util.ExcelUtils;
|
|
|
+
|
|
|
+import com.yc.ship.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import static com.yc.ship.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
+
|
|
|
+import com.yc.ship.module.product.controller.admin.redddata.vo.*;
|
|
|
+import com.yc.ship.module.product.dal.dataobject.redddata.ReddDataDO;
|
|
|
+import com.yc.ship.module.product.service.redddata.ReddDataService;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 碳排放指标管理")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/buss/redd-data")
|
|
|
+@Validated
|
|
|
+public class ReddDataController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ReddDataService reddDataService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建碳排放指标管理")
|
|
|
+ @PreAuthorize("@ss.hasPermission('buss:redd-data:create')")
|
|
|
+ public CommonResult<String> createReddData(@Valid @RequestBody ReddDataSaveReqVO createReqVO) {
|
|
|
+ return success(reddDataService.createReddData(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新碳排放指标管理")
|
|
|
+ @PreAuthorize("@ss.hasPermission('buss:redd-data:update')")
|
|
|
+ public CommonResult<Boolean> updateReddData(@Valid @RequestBody ReddDataSaveReqVO updateReqVO) {
|
|
|
+ reddDataService.updateReddData(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除碳排放指标管理")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('buss:redd-data:delete')")
|
|
|
+ public CommonResult<Boolean> deleteReddData(@RequestParam("id") String id) {
|
|
|
+ reddDataService.deleteReddData(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得碳排放指标管理")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('buss:redd-data:query')")
|
|
|
+ public CommonResult<ReddDataRespVO> getReddData(@RequestParam("id") String id) {
|
|
|
+ ReddDataDO reddData = reddDataService.getReddData(id);
|
|
|
+ return success(BeanUtils.toBean(reddData, ReddDataRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得碳排放指标管理分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('buss:redd-data:query')")
|
|
|
+ public CommonResult<PageResult<ReddDataRespVO>> getReddDataPage(@Valid ReddDataPageReqVO pageReqVO) {
|
|
|
+ PageResult<ReddDataDO> pageResult = reddDataService.getReddDataPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, ReddDataRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出碳排放指标管理 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('buss:redd-data:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportReddDataExcel(@Valid ReddDataPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<ReddDataDO> list = reddDataService.getReddDataPage(pageReqVO).getList();
|
|
|
+ ExcelUtils.write(response, "碳排放指标管理.xls", "数据", ReddDataRespVO.class,
|
|
|
+ BeanUtils.toBean(list, ReddDataRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|