|
@@ -0,0 +1,110 @@
|
|
|
+package com.yc.ship.module.resource.controller.admin.dock;
|
|
|
+
|
|
|
+import com.yc.ship.framework.common.util.collection.CollectionUtils;
|
|
|
+import com.yc.ship.module.resource.dal.dataobject.port.ResourcePortDO;
|
|
|
+import com.yc.ship.module.resource.service.port.ResourcePortService;
|
|
|
+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.constraints.*;
|
|
|
+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.resource.controller.admin.dock.vo.*;
|
|
|
+import com.yc.ship.module.resource.dal.dataobject.dock.ResourceDockDO;
|
|
|
+import com.yc.ship.module.resource.service.dock.ResourceDockService;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 资源管理-口岸码头管理")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/resource/dock")
|
|
|
+@Validated
|
|
|
+public class ResourceDockController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ResourceDockService dockService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ResourcePortService portService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建资源管理-口岸码头管理")
|
|
|
+ @PreAuthorize("@ss.hasPermission('resource:dock:create')")
|
|
|
+ public CommonResult<Long> createDock(@Valid @RequestBody ResourceDockSaveReqVO createReqVO) {
|
|
|
+ return success(dockService.createDock(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新资源管理-口岸码头管理")
|
|
|
+ @PreAuthorize("@ss.hasPermission('resource:dock:update')")
|
|
|
+ public CommonResult<Boolean> updateDock(@Valid @RequestBody ResourceDockSaveReqVO updateReqVO) {
|
|
|
+ dockService.updateDock(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除资源管理-口岸码头管理")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('resource:dock:delete')")
|
|
|
+ public CommonResult<Boolean> deleteDock(@RequestParam("id") Long id) {
|
|
|
+ dockService.deleteDock(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得资源管理-口岸码头管理")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('resource:dock:query')")
|
|
|
+ public CommonResult<ResourceDockRespVO> getDock(@RequestParam("id") Long id) {
|
|
|
+ ResourceDockDO dock = dockService.getDock(id);
|
|
|
+ return success(BeanUtils.toBean(dock, ResourceDockRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得资源管理-口岸码头管理分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('resource:dock:query')")
|
|
|
+ public CommonResult<PageResult<ResourceDockRespVO>> getDockPage(@Valid ResourceDockPageReqVO pageReqVO) {
|
|
|
+ PageResult<ResourceDockDO> pageResult = dockService.getDockPage(pageReqVO);
|
|
|
+ PageResult<ResourceDockRespVO> page = BeanUtils.toBean(pageResult, ResourceDockRespVO.class);
|
|
|
+ List<ResourceDockRespVO> list = page.getList();
|
|
|
+ List<Long> portIds = CollectionUtils.convertList(list, ResourceDockRespVO::getPortId);
|
|
|
+ List<ResourcePortDO> portList = portService.getList(portIds);
|
|
|
+ Map<Long, ResourcePortDO> longResourcePortDOMap = CollectionUtils.convertMap(portList, ResourcePortDO::getId);
|
|
|
+ list.stream().forEach(item -> {
|
|
|
+ item.setPortName(longResourcePortDOMap.get(item.getPortId()).getName());
|
|
|
+ item.setArea(item.getProvinceName()+item.getCityName()+item.getCountyName());
|
|
|
+ });
|
|
|
+ return success(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出资源管理-口岸码头管理 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('resource:dock:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportDockExcel(@Valid ResourceDockPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<ResourceDockDO> list = dockService.getDockPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "资源管理-口岸码头管理.xls", "数据", ResourceDockRespVO.class,
|
|
|
+ BeanUtils.toBean(list, ResourceDockRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|