rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WarehouseController.java
@@ -17,6 +17,7 @@
import com.vincent.rsf.server.manager.service.WarehouseService;
import com.vincent.rsf.server.system.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -73,6 +74,14 @@
        if (Objects.isNull(warehouse.getName())) {
            throw new CoolException("仓库名称不能为空!!");
        }
        List<Warehouse> warehouses = warehouseService.list(new LambdaQueryWrapper<Warehouse>().eq(Warehouse::getName, warehouse.getName()));
        if (!warehouses.isEmpty()) {
            throw new CoolException("仓库名称已存在!!");
        }
        if (!warehouseService.list(new LambdaQueryWrapper<Warehouse>().eq(Warehouse::getCode, warehouse.getCode())).isEmpty()) {
            throw new CoolException("仓库编码已存在!!");
        }
        warehouse.setCreateBy(getLoginUserId());
        warehouse.setUpdateBy(getLoginUserId());
        if (!warehouseService.save(warehouse)) {
@@ -92,6 +101,22 @@
            throw new CoolException("仓库名称不能为空!!");
        }
        warehouse.setUpdateBy(getLoginUserId());
        Warehouse warehouse1 = warehouseService.getById(warehouse.getId());
        if (!warehouse.getName().equals(warehouse1.getName())) {
            List<Warehouse> areasList = warehouseService.list(new LambdaQueryWrapper<Warehouse>().eq(Warehouse::getName, warehouse1.getName()));
            if (!areasList.isEmpty()) {
                throw new CoolException("仓库名已存在!!");
            }
        }
        if (!warehouse.getCode().equals(warehouse1.getCode())) {
            List<Warehouse> areasList = warehouseService.list(new LambdaQueryWrapper<Warehouse>().eq(Warehouse::getCode, warehouse1.getCode()));
            if (!areasList.isEmpty()) {
                throw new CoolException("仓库编码已存在!!");
            }
        }
        if (!warehouseService.updateById(warehouse)) {
            return R.error("Update Fail");
        }
@@ -142,4 +167,11 @@
        ExcelUtil.build(ExcelUtil.create(list, Warehouse.class), response);
    }
    @ApiOperation("获取仓库树状图")
    @PreAuthorize("hasAuthority('manager:warehouse:list')")
    @PostMapping("/warehouse/areas")
    public R getAreasForWarehouse(@RequestBody Map<String, Object> param) {
        return R.ok(warehouseService.getAllWarehouseAreas(param));
    }
}