|
|
@@ -16,15 +16,17 @@
|
|
|
*/
|
|
|
package org.springblade.client.controller;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import javax.validation.Valid;
|
|
|
-
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -34,6 +36,8 @@ import org.springblade.client.vo.StorageTypeVO;
|
|
|
import org.springblade.client.service.IStorageTypeService;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* 仓库 控制器
|
|
|
*
|
|
|
@@ -55,7 +59,10 @@ public class StorageTypeController extends BladeController {
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiOperation(value = "详情", notes = "传入storageType")
|
|
|
public R<StorageType> detail(StorageType storageType) {
|
|
|
- StorageType detail = storageTypeService.getOne(Condition.getQueryWrapper(storageType));
|
|
|
+ if (storageType.getId() == null){
|
|
|
+ return R.fail(500,"请选择要查询的数据");
|
|
|
+ }
|
|
|
+ StorageType detail = storageTypeService.getMessage(storageType);
|
|
|
return R.data(detail);
|
|
|
}
|
|
|
|
|
|
@@ -98,6 +105,14 @@ public class StorageTypeController extends BladeController {
|
|
|
@ApiOperationSupport(order = 5)
|
|
|
@ApiOperation(value = "修改", notes = "传入storageType")
|
|
|
public R update(@Valid @RequestBody StorageType storageType) {
|
|
|
+ if (storageType.getId() == null){
|
|
|
+ return R.fail(500,"请选择要删除的数据");
|
|
|
+ }
|
|
|
+ Integer count = storageTypeService.count(new QueryWrapper<StorageType>().eq("parent_id", storageType.getId()).eq("is_deleted", 0));
|
|
|
+ if (count != null && count>0){
|
|
|
+ return R.fail(500,"存在下级仓库不能删除");
|
|
|
+ }
|
|
|
+ storageType.setIsDeleted(1);
|
|
|
return R.status(storageTypeService.updateById(storageType));
|
|
|
}
|
|
|
|
|
|
@@ -108,10 +123,13 @@ public class StorageTypeController extends BladeController {
|
|
|
@ApiOperationSupport(order = 6)
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入storageType")
|
|
|
public R submit(@Valid @RequestBody StorageType storageType) {
|
|
|
- return R.status(storageTypeService.saveOrUpdate(storageType));
|
|
|
+ if (StringUtils.isBlank(storageType.getCname())){
|
|
|
+ return R.fail(500,"仓库名称不能为空");
|
|
|
+ }
|
|
|
+ return R.data(storageTypeService.saveMessage(storageType));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 删除 仓库
|
|
|
*/
|
|
|
@@ -121,6 +139,15 @@ public class StorageTypeController extends BladeController {
|
|
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
return R.status(storageTypeService.removeByIds(Func.toLongList(ids)));
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 懒加载获取部门树形结构
|
|
|
+ */
|
|
|
+ @GetMapping("/lazy-tree")
|
|
|
+ @ApiOperationSupport(order = 9)
|
|
|
+ @ApiOperation(value = "懒加载树形结构", notes = "树形结构")
|
|
|
+ public R<List<StorageTypeVO>> lazyTree(String tenantId, Long parentId, BladeUser bladeUser) {
|
|
|
+ List<StorageTypeVO> tree = storageTypeService.lazyTree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()), parentId);
|
|
|
+ return R.data(tree);
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
}
|