skyouc
2025-03-19 b07a6193d605fdf3154bf81faed0244030679b60
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocController.java
@@ -1,5 +1,6 @@
package com.vincent.rsf.server.manager.controller;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vincent.rsf.framework.common.Cools;
@@ -18,6 +19,7 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -65,11 +67,28 @@
    @OperationLog("Create 库位信息表")
    @PostMapping("/loc/save")
    public R save(@RequestBody Loc loc) {
        if (Objects.isNull(loc.getWarehouseId())) {
            throw new CoolException("仓库ID不能为空!!");
        }
        if (Objects.isNull(loc.getAreaId())) {
            throw new CoolException("仓库ID不能为空!!");
        }
        if (Objects.isNull(loc.getTypeIds())) {
            throw new CoolException("库位类型不能为空!!");
        }
        List<Long> lists = JSONArray.parseArray(loc.getTypeIds(), Long.class);
        String join = StringUtils.join(lists, ",");
        loc.setType(join);
        loc.setCreateBy(getLoginUserId());
        loc.setUpdateBy(getLoginUserId());
        if (!locService.save(loc)) {
            return R.error("Save Fail");
        }
        if (!locService.saveType(loc)) {
            throw new CoolException("库位类型保存失败!!");
        }
        return R.ok("Save Success").add(loc);
    }