Commit 8ea19ecb by Jony.L

算力资源重构-算力资源SKU管理修改1.0

parent 954d18d0
package com.luhu.computility.module.compute.enums;
import lombok.Getter;
/**
* @Author: jony
* @Date : 2025/10/9 10:06
* @VERSION v1.0
*/
@Getter
public enum ResourceSpuStatus {
OFFLINE(0,"下架"),
ONLINE(1,"上架"),
RECYCLE(2,"回收");
private final Integer value;
private final String label;
private ResourceSpuStatus(Integer value, String label) {
this.value = value;
this.label = label;
}
public static ResourceSpuStatus getByValue(int value) {
for (ResourceSpuStatus o : ResourceSpuStatus.values()) {
if (o.getValue() == value) {
return o;
}
}
return null;
}
public static String getLabelByValue(Integer value) {
for (ResourceSpuStatus status : values()) {
if (status.getValue() == value) {
return status.getLabel();
}
}
return null;
}
}
package com.luhu.computility.module.compute.controller.admin.resourcesku;
import com.luhu.computility.module.compute.controller.admin.resourcespu.vo.ResourceSpuSimpleRespVO;
import com.luhu.computility.module.compute.service.resourcespu.ResourceSpuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
......@@ -13,6 +16,7 @@ import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import java.util.stream.Collectors;
import com.luhu.computility.framework.common.pojo.PageParam;
import com.luhu.computility.framework.common.pojo.PageResult;
......@@ -37,6 +41,8 @@ public class ResourceSkuController {
@Resource
private ResourceSkuService resourceSkuService;
@Autowired
private ResourceSpuService resourceSpuService;
@PostMapping("/create")
@Operation(summary = "创建算力资源SKU表(价格和租赁信息)")
......@@ -85,7 +91,17 @@ public class ResourceSkuController {
@PreAuthorize("@ss.hasPermission('compute:resource-sku:query')")
public CommonResult<PageResult<ResourceSkuRespVO>> getResourceSkuPage(@Valid ResourceSkuPageReqVO pageReqVO) {
PageResult<ResourceSkuDO> pageResult = resourceSkuService.getResourceSkuPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ResourceSkuRespVO.class));
List<ResourceSpuSimpleRespVO> resourceSimpleSpuList = resourceSpuService.getResourceSimpleSpuList();
Map<Long, ResourceSpuSimpleRespVO> simpleVoMap = resourceSimpleSpuList.stream().collect(Collectors.toMap(
ResourceSpuSimpleRespVO::getId,
simpleSpu -> simpleSpu
));
PageResult<ResourceSkuRespVO> finalPageResult = BeanUtils.toBean(pageResult, ResourceSkuRespVO.class);
List<ResourceSkuRespVO> list = finalPageResult.getList();
list.forEach(item -> {
item.setSpuName(simpleVoMap.get(item.getSpuId()).getName());
});
return success(finalPageResult);
}
@GetMapping("/export-excel")
......
......@@ -20,6 +20,10 @@ public class ResourceSkuRespVO {
@ExcelProperty("关联的SPU ID")
private Long spuId;
@Schema(description = "关联的SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "名称")
@ExcelProperty("关联的SPU 名称")
private String spuName;
@Schema(description = "租赁天数(30/90/365等)", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("租赁天数(30/90/365等)")
private Integer durationDays;
......
......@@ -55,6 +55,9 @@ public class ResourceSpuPageReqVO extends PageParam {
@Schema(description = "商品销量")
private Integer sales;
@Schema(description = "服务器所在地")
private String location;
@Schema(description = "状态(0 下架,1 上架,2 回收)", example = "1")
private Integer status;
......
......@@ -76,6 +76,10 @@ public class ResourceSpuRespVO {
@ExcelProperty("商品销量")
private Integer sales;
@Schema(description = "服务器所在地")
@ExcelProperty("服务器所在地")
private String location;
@Schema(description = "状态(0 下架,1 上架,2 回收)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("状态(0 下架,1 上架,2 回收)")
private Integer status;
......
......@@ -65,6 +65,9 @@ public class ResourceSpuSaveReqVO {
@NotNull(message = "商品销量不能为空")
private Integer sales;
@Schema(description = "服务器所在地")
private String location;
@Schema(description = "状态(0 下架,1 上架,2 回收)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "状态(0 下架,1 上架,2 回收)不能为空")
private Integer status;
......
package com.luhu.computility.module.compute.controller.admin.resourcespu.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @Author: jony
* @Date : 2025/10/9 09:56
* @VERSION v1.0
*/
@Schema(description = "管理后台 - 算力资源SPU精简 Request VO")
@Data
public class ResourceSpuSimpleRespVO {
private Long id;
private String name;
}
......@@ -84,6 +84,10 @@ public class ResourceSpuDO extends BaseDO {
*/
private Integer sales;
/**
* 服务器所在地
*/
private String location;
/**
* 状态(0 下架,1 上架,2 回收)
*/
private Integer status;
......
......@@ -59,4 +59,7 @@ public interface ResourceSpuService {
*/
PageResult<ResourceSpuRespVO> getResourceSpuPage(ResourceSpuPageReqVO pageReqVO);
List<ResourceSpuSimpleRespVO> getResourceSimpleSpuList();
}
\ No newline at end of file
......@@ -19,6 +19,7 @@ import static com.luhu.computility.framework.common.exception.util.ServiceExcept
import static com.luhu.computility.framework.common.util.collection.CollectionUtils.convertList;
import static com.luhu.computility.framework.common.util.collection.CollectionUtils.diffList;
import static com.luhu.computility.module.compute.enums.ErrorCodeConstants.*;
import static com.luhu.computility.module.compute.enums.ResourceSpuStatus.ONLINE;
/**
* 算力资源SPU表(基础配置信息) Service 实现类
......@@ -82,4 +83,11 @@ public class ResourceSpuServiceImpl implements ResourceSpuService {
return resourceSpuMapper.selectPage(pageReqVO);
}
@Override
public List<ResourceSpuSimpleRespVO> getResourceSimpleSpuList() {
List<ResourceSpuDO> resourceSpuDOList = resourceSpuMapper.selectList(ResourceSpuDO::getStatus, ONLINE.getValue(),
ResourceSpuDO::getDeleted,0);
return BeanUtils.toBean(resourceSpuDOList, ResourceSpuSimpleRespVO.class);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment