Commit d740f4f5 by Jony.L

Merge remote-tracking branch 'origin/compute' into develop

parents 202136eb 1f6f50e9
package com.luhu.computility.framework.common.enums;
import cn.hutool.core.util.ObjUtil;
import com.luhu.computility.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* 通用删除状态枚举
*
* @author jony
*/
@Getter
@AllArgsConstructor
public enum CommonDeleteStatusEnum implements ArrayValuable<Integer> {
NOT_DELETED(0, "未删除"),
DELETED(1, "已删除");
public static final Integer[] ARRAYS = Arrays.stream(values()).map(CommonDeleteStatusEnum::getValue).toArray(Integer[]::new);
/**
* 状态值
*/
private final Integer value;
public Integer getValue() {
return value;
}
/**
* 状态名
*/
private final String name;
@Override
public Integer[] array() {
return ARRAYS;
}
public static boolean isNotDeleted(Integer status) {
return ObjUtil.equal(NOT_DELETED.value, status);
}
public static boolean isDeleted(Integer status) {
return ObjUtil.equal(DELETED.value, status);
}
}
\ No newline at end of file
......@@ -6,5 +6,6 @@ import lombok.Data;
public class ApiEndpointDTO {
private Long apiEndpointId;
private String apiEndpointName;
private Boolean isShelf;
}
......@@ -8,6 +8,8 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Service
@Validated
......@@ -16,9 +18,17 @@ public class ApiApiServiceImpl implements ApiApi {
@Resource
private ApiMapper apiMapper;
private static final Logger logger = LoggerFactory.getLogger(ApiApiServiceImpl.class);
@Override
public List<ApiDTO> getApisByIndustryApplicationId(Long industryApplicationId) {
return apiMapper.selectApisByIndustryApplicationId(industryApplicationId);
List<ApiDTO> apis = apiMapper.selectApisByIndustryApplicationId(industryApplicationId);
try {
logger.info("ApiApiServiceImpl.getApisByIndustryApplicationId for id {} returned {} entries: {}", industryApplicationId, apis == null ? 0 : apis.size(), apis);
} catch (Exception e) {
logger.warn("Failed to log apis in ApiApiServiceImpl for id {}", industryApplicationId, e);
}
return apis;
}
}
......@@ -9,6 +9,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
* API 调用日志 Service 实现类
......@@ -30,7 +31,11 @@ public class ApiEndpointApiServiceImpl implements ApiEndpointApi {
@Override
public List<ApiEndpointDTO> getApiEndpointsByIndustryApplicationId(Long industryApplicationId) {
return apiEndpointMapper.selectApiEndpointsByIndustryApplicationId(industryApplicationId);
List<ApiEndpointDTO> apiEndpoints = apiEndpointMapper.selectApiEndpointsByIndustryApplicationId(industryApplicationId);
// 过滤掉 isShelf 不为 true 的 apiEndpoint
return apiEndpoints.stream()
.filter(endpoint -> Boolean.TRUE.equals(endpoint.getIsShelf()))
.collect(Collectors.toList());
}
}
......@@ -5,6 +5,8 @@ import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.luhu.computility.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import software.amazon.awssdk.services.s3.endpoints.internal.Value;
import java.time.LocalDateTime;
import static com.luhu.computility.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
......@@ -37,6 +39,9 @@ public class ApiEndpointPageReqVO extends PageParam {
@Schema(description = "备注", example = "你说的对")
private String remark;
@Schema(description = "是否上架")
private Boolean isShelf;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
......
......@@ -60,6 +60,10 @@ public class ApiEndpointRespVO {
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "是否上架", example = "true")
@ExcelProperty("是否上架")
private Boolean isShelf;
@Schema(description = "关联行业应用", example = "[{}]")
@ExcelProperty("关联行业应用")
......
......@@ -46,6 +46,8 @@ public class ApiEndpointSaveReqVO {
@Schema(description = "备注", example = "你说的对")
private String remark;
@Schema(description = "是否上架")
private Boolean isShelf;
@Schema(description = "关联行业应用", example = "[{}]")
@NotEmpty(message = "行业应用至少填写一个")
......
......@@ -28,6 +28,7 @@ import static com.luhu.computility.framework.apilog.core.enums.OperateTypeEnum.*
import com.luhu.computility.module.apihub.controller.admin.apiendpointrel.vo.*;
import com.luhu.computility.module.apihub.dal.dataobject.apiendpointrel.ApiEndpointRelDO;
import com.luhu.computility.module.apihub.service.apiendpointrel.ApiEndpointRelService;
import com.luhu.computility.module.biz.api.industryapplication.dto.IndustryApplicationRespDTO;
@Tag(name = "管理后台 - API 应用与接口关系")
@RestController
......@@ -100,5 +101,13 @@ public class ApiEndpointRelController {
ExcelUtils.write(response, "API 应用与接口关系.xls", "数据", ApiEndpointRelRespVO.class,
BeanUtils.toBean(list, ApiEndpointRelRespVO.class));
}
@GetMapping("/list-by-endpoint")
@Operation(summary = "根据API接口ID查询所有关联的API应用信息列表")
@Parameter(name = "apiEndpointId", description = "API接口ID", required = true, example = "1024")
public CommonResult<List<com.luhu.computility.module.apihub.controller.admin.api.vo.ApiRespVO>> getApisByEndpointId(@RequestParam("apiEndpointId") Long apiEndpointId) {
List<com.luhu.computility.module.apihub.controller.admin.api.vo.ApiRespVO> apis = apiEndpointRelService.getApisByEndpointId(apiEndpointId);
return success(apis);
}
}
\ No newline at end of file
......@@ -37,6 +37,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import static com.luhu.computility.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.luhu.computility.framework.common.pojo.CommonResult.success;
......@@ -80,7 +81,12 @@ public class AppApiController {
List<ApiEndpointRespVO> apiEndpointRespVOS = apiEndpointRelService.getApiEndpointByApiId(id);
for (ApiEndpointRespVO apiEndpointRespVO : apiEndpointRespVOS) {
// 过滤掉 isShelf 不为 true 的 apiEndpoint
List<ApiEndpointRespVO> filteredApiEndpoints = apiEndpointRespVOS.stream()
.filter(endpoint -> Boolean.TRUE.equals(endpoint.getIsShelf()))
.collect(Collectors.toList());
for (ApiEndpointRespVO apiEndpointRespVO : filteredApiEndpoints) {
List<IndustryApplicationRespDTO> industryApplicationRespDTOS = apiEndpointApplicationRelService.getApplicationByApiEndpointId(apiEndpointRespVO.getId());
apiEndpointRespVO.setIndustryApplications(industryApplicationRespDTOS);
}
......
......@@ -64,6 +64,9 @@ public class ApiEndpointDO extends BaseDO {
* 备注
*/
private String remark;
/**
* 是否上架
*/
@TableField("is_shelf")
private Boolean isShelf;
}
\ No newline at end of file
......@@ -34,10 +34,11 @@ public interface ApiMapper extends BaseMapperX<ApiDO> {
}
@Select("SELECT DISTINCT a.id AS apiId, a.name AS apiName, a.trial_url AS trialUrl " +
"FROM apihub_api a " +
"INNER JOIN apihub_api_endpoint_rel r ON r.api_id = a.id AND r.deleted = 0 " +
"INNER JOIN apihub_api_endpoint_application_rel ar ON ar.api_endpoint_id = r.api_endpoint_id AND ar.deleted = 0 " +
"WHERE ar.industry_application_id = #{industryApplicationId} AND a.deleted = 0")
"FROM apihub_api a " +
"INNER JOIN apihub_api_endpoint_rel r ON r.api_id = a.id AND r.deleted = 0 " +
"INNER JOIN apihub_api_endpoint_application_rel ar ON ar.api_endpoint_id = r.api_endpoint_id AND ar.deleted = 0 " +
"INNER JOIN apihub_api_endpoint e ON e.id = r.api_endpoint_id AND e.deleted = 0 " +
"WHERE ar.industry_application_id = #{industryApplicationId} AND a.deleted = 0 AND a.status = 1 AND e.is_shelf = 1")
List<ApiDTO> selectApisByIndustryApplicationId(@Param("industryApplicationId") Long industryApplicationId);
default PageResult<ApiRespVO> selectJoinPage(ApiPageReqVO reqVO) {
......
......@@ -34,11 +34,12 @@ public interface ApiEndpointMapper extends BaseMapperX<ApiEndpointDO> {
.eqIfPresent(ApiEndpointDO::getAuthType, reqVO.getAuthType())
.eqIfPresent(ApiEndpointDO::getRateLimit, reqVO.getRateLimit())
.eqIfPresent(ApiEndpointDO::getRemark, reqVO.getRemark())
.eqIfPresent(ApiEndpointDO::getIsShelf, reqVO.getIsShelf())
.betweenIfPresent(ApiEndpointDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ApiEndpointDO::getId));
}
@Select("SELECT DISTINCT e.id AS apiEndpointId, e.name AS apiEndpointName " +
@Select("SELECT DISTINCT e.id AS apiEndpointId, e.name AS apiEndpointName, e.is_shelf AS isShelf " +
"FROM apihub_api_endpoint e " +
"INNER JOIN apihub_api_endpoint_application_rel ar ON ar.api_endpoint_id = e.id AND ar.deleted = 0 " +
"INNER JOIN apihub_api_endpoint_rel r ON r.api_endpoint_id = e.id AND r.deleted = 0 " +
......
......@@ -46,4 +46,14 @@ public interface ApiEndpointRelMapper extends BaseMapperX<ApiEndpointRelDO> {
);
}
/**
* 根据apiEndpointId查询所有关联的API信息
*/
@org.apache.ibatis.annotations.Select(
"SELECT a.* FROM apihub_api a " +
"INNER JOIN apihub_api_endpoint_rel r ON r.api_id = a.id AND r.deleted = 0 " +
"WHERE r.api_endpoint_id = #{apiEndpointId} AND a.deleted = 0 AND a.status = 1"
)
List<com.luhu.computility.module.apihub.dal.dataobject.api.ApiDO> selectApisByEndpointId(Long apiEndpointId);
}
\ No newline at end of file
......@@ -6,6 +6,8 @@ import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.luhu.computility.module.apihub.controller.admin.api.vo.*;
import com.luhu.computility.module.apihub.dal.dataobject.api.ApiDO;
import com.luhu.computility.framework.common.pojo.PageResult;
......@@ -29,6 +31,8 @@ public class ApiServiceImpl implements ApiService {
@Resource
private ApiMapper apiMapper;
private static final Logger logger = LoggerFactory.getLogger(ApiServiceImpl.class);
@Override
public Long createApi(ApiSaveReqVO createReqVO) {
// 插入
......@@ -81,7 +85,13 @@ public class ApiServiceImpl implements ApiService {
@Override
public List<ApiDTO> getApisByIndustryApplicationId(Long industryApplicationId) {
return apiMapper.selectApisByIndustryApplicationId(industryApplicationId);
List<ApiDTO> apis = apiMapper.selectApisByIndustryApplicationId(industryApplicationId);
try {
logger.info("ApiServiceImpl.getApisByIndustryApplicationId for id {} returned {} entries: {}", industryApplicationId, apis == null ? 0 : apis.size(), apis);
} catch (Exception e) {
logger.warn("Failed to log apis in ApiServiceImpl for id {}", industryApplicationId, e);
}
return apis;
}
}
......@@ -8,6 +8,7 @@ import com.luhu.computility.module.apihub.controller.admin.apiendpointrel.vo.*;
import com.luhu.computility.module.apihub.dal.dataobject.apiendpointrel.ApiEndpointRelDO;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.pojo.PageParam;
import com.luhu.computility.module.biz.api.industryapplication.dto.IndustryApplicationRespDTO;
/**
* API 应用与接口关系 Service 接口
......@@ -74,4 +75,19 @@ public interface ApiEndpointRelService {
* 根据apiId删除关联的ApiEndpoint
*/
Integer deleteByApiId(Long apiId);
/**
* 根据API接口ID查询所有关联的API应用列表
*
* @param apiEndpointId API接口ID
* @return API应用列表
*/
List<IndustryApplicationRespDTO> getApplicationsByApiEndpointId(Long apiEndpointId);
/**
* 根据API接口ID查询所有关联的API信息
* @param apiEndpointId API接口ID
* @return API信息列表
*/
List<com.luhu.computility.module.apihub.controller.admin.api.vo.ApiRespVO> getApisByEndpointId(Long apiEndpointId);
}
\ No newline at end of file
......@@ -12,6 +12,8 @@ import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import com.luhu.computility.module.apihub.dal.mysql.apiendpointrel.ApiEndpointRelMapper;
import com.luhu.computility.module.apihub.service.apiendpointapplicationrel.ApiEndpointApplicationRelService;
import com.luhu.computility.module.biz.api.industryapplication.dto.IndustryApplicationRespDTO;
import static com.luhu.computility.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.luhu.computility.framework.common.util.collection.CollectionUtils.convertList;
......@@ -28,6 +30,9 @@ public class ApiEndpointRelServiceImpl implements ApiEndpointRelService {
@Resource
private ApiEndpointRelMapper apiEndpointRelMapper;
@Resource
private ApiEndpointApplicationRelService apiEndpointApplicationRelService;
@Override
public Long createApiEndpointRel(ApiEndpointRelSaveReqVO createReqVO) {
......@@ -89,7 +94,13 @@ public class ApiEndpointRelServiceImpl implements ApiEndpointRelService {
return apiEndpointRelMapper.deleteByApiId(apiId);
}
@Override
public List<IndustryApplicationRespDTO> getApplicationsByApiEndpointId(Long apiEndpointId) {
return apiEndpointApplicationRelService.getApplicationByApiEndpointId(apiEndpointId);
}
@Override
public List<com.luhu.computility.module.apihub.controller.admin.api.vo.ApiRespVO> getApisByEndpointId(Long apiEndpointId) {
List<com.luhu.computility.module.apihub.dal.dataobject.api.ApiDO> apiList = apiEndpointRelMapper.selectApisByEndpointId(apiEndpointId);
return com.luhu.computility.framework.common.util.object.BeanUtils.toBean(apiList, com.luhu.computility.module.apihub.controller.admin.api.vo.ApiRespVO.class);
}
}
\ No newline at end of file
......@@ -19,6 +19,8 @@ import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.Arrays;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.luhu.computility.framework.common.pojo.CommonResult.success;
......@@ -27,6 +29,8 @@ import static com.luhu.computility.framework.common.pojo.CommonResult.success;
@RequestMapping("/biz/industry-application")
public class AppIndustryApplicationController {
private static final Logger logger = LoggerFactory.getLogger(AppIndustryApplicationController.class);
@Resource
private IndustryApplicationService industryApplicationService;
@Resource
......@@ -65,6 +69,13 @@ public class AppIndustryApplicationController {
respVO.setApis(apiApi.getApisByIndustryApplicationId(id));
respVO.setApiEndpoints(apiEndpointApi.getApiEndpointsByIndustryApplicationId(id));
// Debug: log the apis returned to verify filtering
try {
logger.info("AppIndustryApplication apis for id {}: {}", id, respVO.getApis());
} catch (Exception e) {
logger.warn("Failed to log apis for industry application {}", id, e);
}
return success(respVO);
}
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.luhu</groupId>
<artifactId>computility-module-compute</artifactId>
<version>${revision}</version>
</parent>
<artifactId>computility-module-compute-api</artifactId>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-common</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.luhu.computility.module.compute.enums;
import com.luhu.computility.framework.common.exception.ErrorCode;
/**
* Compute 错误码枚举类
* <p>
* Compute 系统,使用 1-020-000-000 段
*/
public interface ErrorCodeConstants {
ErrorCode RESOURCE_CATEGORY_NOT_EXISTS = new ErrorCode(1_030_001_000, "算力资源分类表(仅用于算力服务器分类)不存在");
ErrorCode RESOURCE_SKU_NOT_EXISTS = new ErrorCode(1_030_002_000, "算力资源SKU表(价格和租赁信息)不存在");
ErrorCode RESOURCE_SPU_NOT_EXISTS = new ErrorCode(1_030_003_000, "算力资源SPU表(基础配置信息)不存在");
ErrorCode RESOURCE_ORDER_NOT_EXISTS = new ErrorCode(1_030_004_000, "算力资源订单不存在");
ErrorCode RESOURCE_ORDER_SKU_NOT_EXISTS = new ErrorCode(1_030_004_001, "算力资源SKU不存在");
ErrorCode RESOURCE_ORDER_SPU_NOT_EXISTS = new ErrorCode(1_030_004_002, "算力资源SPU不存在");
ErrorCode RESOURCE_CONFIG_NOT_EXISTS = new ErrorCode(1_030_005_000, "算力资源配置不存在");
ErrorCode RESOURCE_ORDER_STATUS_NOT_UNPAID = new ErrorCode(1_030_006_000, "算力资源订单状态不是待支付");
ErrorCode RESOURCE_ORDER_PAY_ORDER_ID_MISMATCH = new ErrorCode(1_030_007_000, "支付订单ID不匹配");
ErrorCode RESOURCE_ORDER_NOT_BELONGS_TO_USER = new ErrorCode(1_030_008_000, "算力资源订单不属于当前用户");
}
\ No newline at end of file
package com.luhu.computility.module.compute.enums;
import lombok.Getter;
/**
* @Author: jony
* @Date : 2025/9/30 14:56
* @VERSION v1.0
*/
@Getter
public enum ResourceEnableStatus {
ENABLE(0,"启用"),
DISABLE(1,"禁用");
private Integer value;
private String label;
private ResourceEnableStatus(Integer value, String label) {
this.value = value;
this.label = label;
}
public static ResourceEnableStatus getByValue(int value) {
for (ResourceEnableStatus o : ResourceEnableStatus.values()) {
if (o.getValue() == value) {
return o;
}
}
return null;
}
public static String getLabelByValue(Integer value) {
for (ResourceEnableStatus status : values()) {
if (status.getValue() == value) {
return status.getLabel();
}
}
return null;
}
}
package com.luhu.computility.module.compute.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 算力资源订单发票状态枚举
*
* @Author: jony
* @Date : 2025/10/11
* @VERSION v1.0
*/
@AllArgsConstructor
@Getter
public enum ResourceOrderInvoiceStatus {
UNINVOICE(0, "未开票"),
INVOICING(1, "开票中"),
INVOICED(2, "已开票");
private final Integer value;
private final String label;
public static ResourceOrderInvoiceStatus getByValue(int value) {
for (ResourceOrderInvoiceStatus status : ResourceOrderInvoiceStatus.values()) {
if (status.getValue() == value) {
return status;
}
}
return null;
}
public static String getLabelByValue(Integer value) {
for (ResourceOrderInvoiceStatus status : values()) {
if (status.getValue() == value) {
return status.getLabel();
}
}
return null;
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 算力资源订单退款状态枚举
*
* @Author: jony
* @Date : 2025/10/11
* @VERSION v1.0
*/
@AllArgsConstructor
@Getter
public enum ResourceOrderRefundStatus {
NOT_REFUND(0, "未退款"),
REFUNDING(1, "退款中"),
REFUNDED(2, "已退款");
private final Integer value;
private final String label;
public static ResourceOrderRefundStatus getByValue(int value) {
for (ResourceOrderRefundStatus status : ResourceOrderRefundStatus.values()) {
if (status.getValue() == value) {
return status;
}
}
return null;
}
public static String getLabelByValue(Integer value) {
for (ResourceOrderRefundStatus status : values()) {
if (status.getValue() == value) {
return status.getLabel();
}
}
return null;
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.enums;
import lombok.Getter;
/**
* 算力资源订单状态枚举
*
* @Author: jony
* @Date : 2025/10/10
* @VERSION v1.0
*/
@Getter
public enum ResourceOrderStatus {
UNPAID(0, "待支付"),
PAID(1, "已支付"),
CANCELED(2, "已取消");
private final Integer value;
private final String label;
private ResourceOrderStatus(Integer value, String label) {
this.value = value;
this.label = label;
}
public static ResourceOrderStatus getByValue(int value) {
for (ResourceOrderStatus status : ResourceOrderStatus.values()) {
if (status.getValue() == value) {
return status;
}
}
return null;
}
public static String getLabelByValue(Integer value) {
for (ResourceOrderStatus status : values()) {
if (status.getValue() == value) {
return status.getLabel();
}
}
return null;
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.enums;
import lombok.Getter;
/**
* 算力资源SKU状态枚举
*
* @Author: jony
* @Date : 2025/10/11
* @VERSION v1.0
*/
@Getter
public enum ResourceSkuStatus {
ONLINE(0, "上架"),
OFFLINE(1, "下架");
private final Integer value;
private final String label;
private ResourceSkuStatus(Integer value, String label) {
this.value = value;
this.label = label;
}
public static ResourceSkuStatus getByValue(int value) {
for (ResourceSkuStatus status : ResourceSkuStatus.values()) {
if (status.getValue() == value) {
return status;
}
}
return null;
}
public static String getLabelByValue(Integer value) {
for (ResourceSkuStatus status : values()) {
if (status.getValue() == value) {
return status.getLabel();
}
}
return null;
}
}
\ No newline at end of file
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;
}
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.luhu</groupId>
<artifactId>computility-module-compute</artifactId>
<version>${revision}</version>
</parent>
<artifactId>computility-module-compute-biz</artifactId>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 依赖自身模块的 api 模块 -->
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-module-compute-api</artifactId>
<version>${revision}</version>
</dependency>
<!-- 依赖系统模块 -->
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-module-system</artifactId>
<version>${revision}</version>
</dependency>
<!-- 依赖通用模块 -->
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-common</artifactId>
<version>${revision}</version>
</dependency>
<!-- 依赖支付模块 -->
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-module-pay</artifactId>
<version>${revision}</version>
</dependency>
<!-- 业务组件 -->
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-spring-boot-starter-biz-tenant</artifactId>
</dependency>
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-spring-boot-starter-biz-ip</artifactId>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-spring-boot-starter-security</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-spring-boot-starter-mybatis</artifactId>
</dependency>
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-spring-boot-starter-redis</artifactId>
</dependency>
<!-- Test 测试相关 -->
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-spring-boot-starter-test</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-spring-boot-starter-excel</artifactId>
</dependency>
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-module-member</artifactId>
<version>2.6.0-jdk8-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.luhu.computility.module.compute.config;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* 算力资源订单配置
*
* @author jony
* @since 2025-10-13
*/
@Configuration
@EnableConfigurationProperties(ResourceOrderProperties.class)
public class ResourceOrderConfig {
}
\ No newline at end of file
package com.luhu.computility.module.compute.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.time.Duration;
/**
* 算力资源订单的配置项
*
* @author jony
*/
@ConfigurationProperties(prefix = "computility.compute.order")
@Data
@Validated
public class ResourceOrderProperties {
private static final String PAY_APP_KEY_DEFAULT = "computemall";
/**
* 支付应用标识
*
* 在 pay 模块的 [支付管理 -> 应用信息]
*/
@NotEmpty(message = "Pay 应用标识不能为空")
private String payAppKey = PAY_APP_KEY_DEFAULT;
/**
* 支付超时时间
*/
@NotNull(message = "支付超时时间不能为空")
private Duration payExpireTime;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourcecategory;
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.luhu.computility.framework.common.pojo.PageParam;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.pojo.CommonResult;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import static com.luhu.computility.framework.common.pojo.CommonResult.success;
import com.luhu.computility.framework.excel.core.util.ExcelUtils;
import com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog;
import static com.luhu.computility.framework.apilog.core.enums.OperateTypeEnum.*;
import com.luhu.computility.module.compute.controller.admin.resourcecategory.vo.*;
import com.luhu.computility.module.compute.dal.dataobject.resourcecategory.ResourceCategoryDO;
import com.luhu.computility.module.compute.service.resourcecategory.ResourceCategoryService;
@Tag(name = "管理后台 - 算力资源分类表(仅用于算力服务器分类)")
@RestController
@RequestMapping("/compute/resource-category")
@Validated
public class ResourceCategoryController {
@Resource
private ResourceCategoryService resourceCategoryService;
@GetMapping("/list-simple")
@Operation(summary = "获取精简算力资源分类列表")
public CommonResult<List<ResourceCategorySimpleRespVO>> getSimpleCategory(){
return success(BeanUtils.toBean(resourceCategoryService.getAllCategory(), ResourceCategorySimpleRespVO.class));
}
@PostMapping("/create")
@Operation(summary = "创建算力资源分类表(仅用于算力服务器分类)")
@PreAuthorize("@ss.hasPermission('compute:resource-category:create')")
public CommonResult<Long> createResourceCategory(@Valid @RequestBody ResourceCategorySaveReqVO createReqVO) {
return success(resourceCategoryService.createResourceCategory(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新算力资源分类表(仅用于算力服务器分类)")
@PreAuthorize("@ss.hasPermission('compute:resource-category:update')")
public CommonResult<Boolean> updateResourceCategory(@Valid @RequestBody ResourceCategorySaveReqVO updateReqVO) {
resourceCategoryService.updateResourceCategory(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除算力资源分类表(仅用于算力服务器分类)")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('compute:resource-category:delete')")
public CommonResult<Boolean> deleteResourceCategory(@RequestParam("id") Long id) {
resourceCategoryService.deleteResourceCategory(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除算力资源分类表(仅用于算力服务器分类)")
@PreAuthorize("@ss.hasPermission('compute:resource-category:delete')")
public CommonResult<Boolean> deleteResourceCategoryList(@RequestParam("ids") List<Long> ids) {
resourceCategoryService.deleteResourceCategoryListByIds(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得算力资源分类表(仅用于算力服务器分类)")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('compute:resource-category:query')")
public CommonResult<ResourceCategoryRespVO> getResourceCategory(@RequestParam("id") Long id) {
ResourceCategoryDO resourceCategory = resourceCategoryService.getResourceCategory(id);
return success(BeanUtils.toBean(resourceCategory, ResourceCategoryRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得算力资源分类表(仅用于算力服务器分类)分页")
@PreAuthorize("@ss.hasPermission('compute:resource-category:query')")
public CommonResult<PageResult<ResourceCategoryRespVO>> getResourceCategoryPage(@Valid ResourceCategoryPageReqVO pageReqVO) {
PageResult<ResourceCategoryDO> pageResult = resourceCategoryService.getResourceCategoryPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ResourceCategoryRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出算力资源分类表(仅用于算力服务器分类) Excel")
@PreAuthorize("@ss.hasPermission('compute:resource-category:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportResourceCategoryExcel(@Valid ResourceCategoryPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ResourceCategoryDO> list = resourceCategoryService.getResourceCategoryPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "算力资源分类表(仅用于算力服务器分类).xls", "数据", ResourceCategoryRespVO.class,
BeanUtils.toBean(list, ResourceCategoryRespVO.class));
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourcecategory.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.luhu.computility.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.luhu.computility.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 算力资源分类表(仅用于算力服务器分类)分页 Request VO")
@Data
public class ResourceCategoryPageReqVO extends PageParam {
@Schema(description = "分类名称(如:高性能计算服务资源)", example = "王五")
private String name;
@Schema(description = "分类图标地址", example = "https://www.iocoder.cn")
private String picUrl;
@Schema(description = "分类排序(数字越小越靠前)")
private Integer sort;
@Schema(description = "状态(0=启用,1=禁用)", example = "1")
private Integer status;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourcecategory.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 算力资源分类表(仅用于算力服务器分类) Response VO")
@Data
@ExcelIgnoreUnannotated
public class ResourceCategoryRespVO {
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13591")
@ExcelProperty("分类编号")
private Long id;
@Schema(description = "分类名称(如:高性能计算服务资源)", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("分类名称(如:高性能计算服务资源)")
private String name;
@Schema(description = "分类图标地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
@ExcelProperty("分类图标地址")
private String picUrl;
@Schema(description = "分类排序(数字越小越靠前)")
@ExcelProperty("分类排序(数字越小越靠前)")
private Integer sort;
@Schema(description = "状态(0=启用,1=禁用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("状态(0=启用,1=禁用)")
private Integer status;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourcecategory.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 算力资源分类表(仅用于算力服务器分类)新增/修改 Request VO")
@Data
public class ResourceCategorySaveReqVO {
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13591")
private Long id;
@Schema(description = "分类名称(如:高性能计算服务资源)", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "分类名称(如:高性能计算服务资源)不能为空")
private String name;
@Schema(description = "分类图标地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
@NotEmpty(message = "分类图标地址不能为空")
private String picUrl;
@Schema(description = "分类排序(数字越小越靠前)")
private Integer sort;
@Schema(description = "状态(0=启用,1=禁用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "状态(0=启用,1=禁用)不能为空")
private Integer status;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourcecategory.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @Author: jony
* @Date : 2025/9/30 16:46
* @VERSION v1.0
*/
@Data
public class ResourceCategorySimpleRespVO {
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13591")
@ExcelProperty("分类编号")
private Long id;
@Schema(description = "分类名称(如:高性能计算服务资源)", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("分类名称(如:高性能计算服务资源)")
private String name;
}
package com.luhu.computility.module.compute.controller.admin.resourceconfig;
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.luhu.computility.framework.common.pojo.PageParam;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.pojo.CommonResult;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import static com.luhu.computility.framework.common.pojo.CommonResult.success;
import com.luhu.computility.framework.excel.core.util.ExcelUtils;
import com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog;
import static com.luhu.computility.framework.apilog.core.enums.OperateTypeEnum.*;
import com.luhu.computility.module.compute.controller.admin.resourceconfig.vo.*;
import com.luhu.computility.module.compute.dal.dataobject.resourceconfig.ResourceConfigDO;
import com.luhu.computility.module.compute.service.resourceconfig.ResourceConfigService;
@Tag(name = "管理后台 - 算力资源配置")
@RestController
@RequestMapping("/compute/resource-config")
@Validated
public class ResourceConfigController {
@Resource
private ResourceConfigService resourceConfigService;
@GetMapping("/list-simple-config-by-category")
@Operation(summary = "精简资源配置列表")
public CommonResult<List<ResourceConfigSimpleRespVO>> listSimpleConfigByCategory(String category){
List<ResourceConfigDO> configDOList = resourceConfigService.listSimpleConfigByCategory(category);
return success(BeanUtils.toBean(configDOList, ResourceConfigSimpleRespVO.class));
}
@PostMapping("/create")
@Operation(summary = "创建算力资源配置")
@PreAuthorize("@ss.hasPermission('compute:resource-config:create')")
public CommonResult<Long> createResourceConfig(@Valid @RequestBody ResourceConfigSaveReqVO createReqVO) {
return success(resourceConfigService.createResourceConfig(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新算力资源配置")
@PreAuthorize("@ss.hasPermission('compute:resource-config:update')")
public CommonResult<Boolean> updateResourceConfig(@Valid @RequestBody ResourceConfigSaveReqVO updateReqVO) {
resourceConfigService.updateResourceConfig(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除算力资源配置")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('compute:resource-config:delete')")
public CommonResult<Boolean> deleteResourceConfig(@RequestParam("id") Long id) {
resourceConfigService.deleteResourceConfig(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除算力资源配置")
@PreAuthorize("@ss.hasPermission('compute:resource-config:delete')")
public CommonResult<Boolean> deleteResourceConfigList(@RequestParam("ids") List<Long> ids) {
resourceConfigService.deleteResourceConfigListByIds(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得算力资源配置")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('compute:resource-config:query')")
public CommonResult<ResourceConfigRespVO> getResourceConfig(@RequestParam("id") Long id) {
ResourceConfigDO resourceConfig = resourceConfigService.getResourceConfig(id);
return success(BeanUtils.toBean(resourceConfig, ResourceConfigRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得算力资源配置分页")
@PreAuthorize("@ss.hasPermission('compute:resource-config:query')")
public CommonResult<PageResult<ResourceConfigRespVO>> getResourceConfigPage(@Valid ResourceConfigPageReqVO pageReqVO) {
PageResult<ResourceConfigDO> pageResult = resourceConfigService.getResourceConfigPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ResourceConfigRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出算力资源配置 Excel")
@PreAuthorize("@ss.hasPermission('compute:resource-config:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportResourceConfigExcel(@Valid ResourceConfigPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ResourceConfigDO> list = resourceConfigService.getResourceConfigPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "算力资源配置.xls", "数据", ResourceConfigRespVO.class,
BeanUtils.toBean(list, ResourceConfigRespVO.class));
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourceconfig.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.luhu.computility.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.luhu.computility.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 算力资源配置分页 Request VO")
@Data
public class ResourceConfigPageReqVO extends PageParam {
@Schema(description = "配置类别")
private String configCategory;
@Schema(description = "配置选项")
private String configOption;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "状态:0=启用,1=禁用", example = "2")
private Integer status;
@Schema(description = "详情备注(如:i7-13700K 16核24线程)", example = "你猜")
private String detailRemark;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourceconfig.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 算力资源配置 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ResourceConfigRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11532")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "配置类别", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("配置类别")
private String configCategory;
@Schema(description = "配置选项", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("配置选项")
private String configOption;
@Schema(description = "排序")
@ExcelProperty("排序")
private Integer sort;
@Schema(description = "状态:0=启用,1=禁用", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("状态:0=启用,1=禁用")
private Integer status;
@Schema(description = "详情备注(如:i7-13700K 16核24线程)", example = "你猜")
@ExcelProperty("详情备注(如:i7-13700K 16核24线程)")
private String detailRemark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourceconfig.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 算力资源配置新增/修改 Request VO")
@Data
public class ResourceConfigSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11532")
private Long id;
@Schema(description = "配置类别", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "配置类别不能为空")
private String configCategory;
@Schema(description = "配置选项", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "配置选项不能为空")
private String configOption;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "状态:0=启用,1=禁用", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "状态:0=启用,1=禁用不能为空")
private Integer status;
@Schema(description = "详情备注(如:i7-13700K 16核24线程)", example = "你猜")
private String detailRemark;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourceconfig.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @Author: jony
* @Date : 2025/9/30 14:50
* @VERSION v1.0
*/
@Schema(description = "管理后台 - 精简算力资源配置 Response VO")
@Data
public class ResourceConfigSimpleRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11532")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "配置类别", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("配置类别")
private String configCategory;
@Schema(description = "配置选项", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("配置选项")
private String configOption;
}
package com.luhu.computility.module.compute.controller.admin.resourceorder;
import cn.hutool.core.util.ObjectUtil;
import com.luhu.computility.framework.common.exception.ServiceException;
import com.luhu.computility.framework.common.pojo.CommonResult;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.module.compute.controller.admin.resourceorder.vo.*;
import com.luhu.computility.module.compute.enums.ResourceOrderInvoiceStatus;
import com.luhu.computility.module.compute.enums.ResourceOrderStatus;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import com.luhu.computility.framework.excel.core.util.ExcelUtils;
import com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog;
import static com.luhu.computility.framework.apilog.core.enums.OperateTypeEnum.*;
import com.luhu.computility.framework.common.pojo.PageParam;
import com.luhu.computility.module.compute.service.resourceorder.ResourceOrderService;
import com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO;
import com.luhu.computility.module.pay.api.notify.dto.PayOrderNotifyReqDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;
import org.springframework.validation.annotation.Validated;
import static com.luhu.computility.framework.common.pojo.CommonResult.success;
import com.luhu.computility.framework.common.util.object.BeanUtils;
@Tag(name = "管理后台 - 算力资源订单")
@RestController
@RequestMapping("/compute/resource-order")
@Validated
@Slf4j
public class ResourceOrderController {
@Resource
private ResourceOrderService resourceOrderService;
/**
* 内部支付任务回调
*/
@PostMapping("/pay/update-paid")
@PermitAll
@Operation(summary = "支付订单回调,更新订单为已支付")
public CommonResult<Boolean> updateOrderPaid(@Valid @RequestBody PayOrderNotifyReqDTO notifyReqDTO) {
log.info("[updateOrderPaid][req({})]", notifyReqDTO);
resourceOrderService.updateOrderPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), notifyReqDTO.getPayOrderId());
return success(true);
}
@PostMapping("/create")
@Operation(summary = "创建算力资源订单")
@PreAuthorize("@ss.hasPermission('compute:resource-order:create')")
public CommonResult<Long> createResourceOrder(@Valid @RequestBody ResourceOrderSaveReqVO createReqVO) {
return success(resourceOrderService.createResourceOrder(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新算力资源订单")
@PreAuthorize("@ss.hasPermission('compute:resource-order:update')")
public CommonResult<Boolean> updateResourceOrder(@Valid @RequestBody ResourceOrderSaveReqVO updateReqVO) {
resourceOrderService.updateResourceOrder(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除算力资源订单")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('compute:resource-order:delete')")
public CommonResult<Boolean> deleteResourceOrder(@RequestParam("id") Long id) {
resourceOrderService.deleteResourceOrder(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除算力资源订单")
@PreAuthorize("@ss.hasPermission('compute:resource-order:delete')")
public CommonResult<Boolean> deleteResourceOrderList(@RequestParam("ids") List<Long> ids) {
resourceOrderService.deleteResourceOrderListByIds(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得算力资源订单")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('compute:resource-order:query')")
public CommonResult<ResourceOrderRespVO> getResourceOrder(@RequestParam("id") Long id) {
ResourceOrderDO resourceOrder = resourceOrderService.getResourceOrder(id);
return success(BeanUtils.toBean(resourceOrder, ResourceOrderRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得算力资源订单分页")
@PreAuthorize("@ss.hasPermission('compute:resource-order:query')")
public CommonResult<PageResult<ResourceOrderRespVO>> getResourceOrderPage(@Valid ResourceOrderPageReqVO pageReqVO) {
return success(resourceOrderService.getResourceOrderPage(pageReqVO));
}
@GetMapping("/export-excel")
@Operation(summary = "导出算力资源订单 Excel")
@PreAuthorize("@ss.hasPermission('compute:resource-order:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportResourceOrderExcel(@Valid ResourceOrderPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
// 导出 Excel
ExcelUtils.write(response, "算力资源订单.xls", "数据", ResourceOrderRespVO.class,
resourceOrderService.getResourceOrderPage(pageReqVO).getList());
}
@PutMapping("/issue-invoice")
@Operation(summary = "开具发票")
public CommonResult<Boolean> issueInvoice(@RequestBody ResourceOrderSaveReqVO saveVO){
if(ObjectUtil.isEmpty(saveVO.getInvoiceUrl())){
throw new ServiceException("没有接收到发票文件地址!");
}
if(saveVO.getInvoiceStatus().equals(ResourceOrderInvoiceStatus.INVOICED.getValue())){
throw new ServiceException("该订单已经开具发票");
}
// 校验订单支付状态
ResourceOrderDO order = resourceOrderService.getResourceOrder(saveVO.getId());
if(order == null){
throw new ServiceException("订单不存在!");
}
if(!order.getStatus().equals(ResourceOrderStatus.PAID.getValue())){
throw new ServiceException("只有已支付的订单可以开票!");
}
return success(resourceOrderService.updateInvoice(saveVO));
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourceorder.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.luhu.computility.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.luhu.computility.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 算力资源订单分页 Request VO")
@Data
public class ResourceOrderPageReqVO extends PageParam {
@Schema(description = "下单用户ID", example = "14416")
private Long userId;
@Schema(description = "算力资源SKU ID", example = "31061")
private Long skuId;
@Schema(description = "算力资源名称(下单时快照)", example = "王五")
private String spuName;
@Schema(description = "订单编号")
private String orderNo;
@Schema(description = "订单状态:0=待支付,1=已支付,2=已取消", example = "1")
private Integer status;
@Schema(description = "市场价格(分)", example = "17709")
private Long marketPrice;
@Schema(description = "实付金额(分)", example = "30624")
private Long paymentPrice;
@Schema(description = "支付订单编号", example = "15798")
private Long payOrderId;
@Schema(description = "支付时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] payTime;
@Schema(description = "支付渠道")
private String payChannelCode;
@Schema(description = "租赁开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] rentStartTime;
@Schema(description = "租赁结束时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] rentEndTime;
@Schema(description = "取消时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] cancelTime;
@Schema(description = "备注", example = "你说的对")
private String remark;
@Schema(description = "算力资源状态:[0]未启用,[1]使用中,[2]已释放", example = "1")
private Integer resourceStatus;
@Schema(description = "退款状态", example = "1")
private Integer refundStatus;
@Schema(description = "退款金额", example = "7376")
private String refundPrice;
@Schema(description = "开票状态:[0]未开 [1]开票中 [2]已开票", example = "1")
private Integer invoiceStatus;
@Schema(description = "发票链接", example = "https://www.iocoder.cn")
private String invoiceUrl;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourceorder.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 算力资源订单 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ResourceOrderRespVO {
@Schema(description = "订单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1595")
@ExcelProperty("订单ID")
private Long id;
@Schema(description = "下单用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "14416")
@ExcelProperty("下单用户ID")
private Long userId;
@Schema(description = "用户昵称", example = "张三")
@ExcelProperty("用户昵称")
private String nickname;
@Schema(description = "算力资源SKU ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "31061")
@ExcelProperty("算力资源SKU ID")
private Long skuId;
@Schema(description = "算力资源名称(下单时快照)", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("算力资源名称(下单时快照)")
private String spuName;
@Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("订单编号")
private String orderNo;
@Schema(description = "订单状态:0=待支付,1=已支付,2=已取消", example = "1")
@ExcelProperty("订单状态:0=待支付,1=已支付,2=已取消")
private Integer status;
@Schema(description = "市场价格(分)", example = "17709")
@ExcelProperty("市场价格(分)")
private Long marketPrice;
@Schema(description = "实付金额(分)", requiredMode = Schema.RequiredMode.REQUIRED, example = "30624")
@ExcelProperty("实付金额(分)")
private Long paymentPrice;
@Schema(description = "支付订单编号", example = "15798")
@ExcelProperty("支付订单编号")
private Long payOrderId;
@Schema(description = "支付时间")
@ExcelProperty("支付时间")
private LocalDateTime payTime;
@Schema(description = "支付渠道")
@ExcelProperty("支付渠道")
private String payChannelCode;
@Schema(description = "租赁开始时间")
@ExcelProperty("租赁开始时间")
private LocalDateTime rentStartTime;
@Schema(description = "租赁结束时间")
@ExcelProperty("租赁结束时间")
private LocalDateTime rentEndTime;
@Schema(description = "取消时间")
@ExcelProperty("取消时间")
private LocalDateTime cancelTime;
@Schema(description = "备注", example = "你说的对")
@ExcelProperty("备注")
private String remark;
@Schema(description = "算力资源状态:[0]未启用,[1]使用中,[2]已释放", example = "1")
@ExcelProperty("算力资源状态:[0]未启用,[1]使用中,[2]已释放")
private Integer resourceStatus;
@Schema(description = "退款状态", example = "1")
@ExcelProperty("退款状态")
private Integer refundStatus;
@Schema(description = "退款金额", example = "7376")
@ExcelProperty("退款金额")
private String refundPrice;
@Schema(description = "开票状态:[0]未开 [1]开票中 [2]已开票", example = "1")
@ExcelProperty("开票状态:[0]未开 [1]开票中 [2]已开票")
private Integer invoiceStatus;
@Schema(description = "发票链接", example = "https://www.iocoder.cn")
@ExcelProperty("发票链接")
private String invoiceUrl;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourceorder.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 算力资源订单新增/修改 Request VO")
@Data
public class ResourceOrderSaveReqVO {
@Schema(description = "订单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1595")
private Long id;
@Schema(description = "下单用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "14416")
@NotNull(message = "下单用户ID不能为空")
private Long userId;
@Schema(description = "算力资源SKU ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "31061")
@NotNull(message = "算力资源SKU ID不能为空")
private Long skuId;
@Schema(description = "算力资源名称(下单时快照)", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "算力资源名称(下单时快照)不能为空")
private String spuName;
@Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "订单编号不能为空")
private String orderNo;
@Schema(description = "订单状态:0=待支付,1=已支付,2=已取消", example = "1")
private Integer status;
@Schema(description = "市场价格(分)", example = "17709")
private Long marketPrice;
@Schema(description = "实付金额(分)", requiredMode = Schema.RequiredMode.REQUIRED, example = "30624")
@NotNull(message = "实付金额(分)不能为空")
private Long paymentPrice;
@Schema(description = "支付订单编号", example = "15798")
private Long payOrderId;
@Schema(description = "支付时间")
private LocalDateTime payTime;
@Schema(description = "支付渠道")
private String payChannelCode;
@Schema(description = "租赁开始时间")
private LocalDateTime rentStartTime;
@Schema(description = "租赁结束时间")
private LocalDateTime rentEndTime;
@Schema(description = "取消时间")
private LocalDateTime cancelTime;
@Schema(description = "备注", example = "你说的对")
private String remark;
@Schema(description = "算力资源状态:[0]未启用,[1]使用中,[2]已释放", example = "1")
private Integer resourceStatus;
@Schema(description = "退款状态", example = "1")
private Integer refundStatus;
@Schema(description = "退款金额", example = "7376")
private String refundPrice;
@Schema(description = "开票状态:[0]未开 [1]开票中 [2]已开票", example = "1")
private Integer invoiceStatus;
@Schema(description = "发票链接", example = "https://www.iocoder.cn")
private String invoiceUrl;
}
\ No newline at end of file
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;
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 java.util.stream.Collectors;
import com.luhu.computility.framework.common.pojo.PageParam;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.pojo.CommonResult;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import static com.luhu.computility.framework.common.pojo.CommonResult.success;
import com.luhu.computility.framework.excel.core.util.ExcelUtils;
import com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog;
import static com.luhu.computility.framework.apilog.core.enums.OperateTypeEnum.*;
import com.luhu.computility.module.compute.controller.admin.resourcesku.vo.*;
import com.luhu.computility.module.compute.dal.dataobject.resourcesku.ResourceSkuDO;
import com.luhu.computility.module.compute.service.resourcesku.ResourceSkuService;
@Tag(name = "管理后台 - 算力资源SKU表(价格和租赁信息)")
@RestController
@RequestMapping("/compute/resource-sku")
@Validated
public class ResourceSkuController {
@Resource
private ResourceSkuService resourceSkuService;
@Autowired
private ResourceSpuService resourceSpuService;
@PostMapping("/create")
@Operation(summary = "创建算力资源SKU表(价格和租赁信息)")
@PreAuthorize("@ss.hasPermission('compute:resource-sku:create')")
public CommonResult<Long> createResourceSku(@Valid @RequestBody ResourceSkuSaveReqVO createReqVO) {
return success(resourceSkuService.createResourceSku(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新算力资源SKU表(价格和租赁信息)")
@PreAuthorize("@ss.hasPermission('compute:resource-sku:update')")
public CommonResult<Boolean> updateResourceSku(@Valid @RequestBody ResourceSkuSaveReqVO updateReqVO) {
resourceSkuService.updateResourceSku(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除算力资源SKU表(价格和租赁信息)")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('compute:resource-sku:delete')")
public CommonResult<Boolean> deleteResourceSku(@RequestParam("id") Long id) {
resourceSkuService.deleteResourceSku(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除算力资源SKU表(价格和租赁信息)")
@PreAuthorize("@ss.hasPermission('compute:resource-sku:delete')")
public CommonResult<Boolean> deleteResourceSkuList(@RequestParam("ids") List<Long> ids) {
resourceSkuService.deleteResourceSkuListByIds(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得算力资源SKU表(价格和租赁信息)")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('compute:resource-sku:query')")
public CommonResult<ResourceSkuRespVO> getResourceSku(@RequestParam("id") Long id) {
ResourceSkuDO resourceSku = resourceSkuService.getResourceSku(id);
return success(BeanUtils.toBean(resourceSku, ResourceSkuRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得算力资源SKU表(价格和租赁信息)分页")
@PreAuthorize("@ss.hasPermission('compute:resource-sku:query')")
public CommonResult<PageResult<ResourceSkuRespVO>> getResourceSkuPage(@Valid ResourceSkuPageReqVO pageReqVO) {
PageResult<ResourceSkuDO> pageResult = resourceSkuService.getResourceSkuPage(pageReqVO);
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")
@Operation(summary = "导出算力资源SKU表(价格和租赁信息) Excel")
@PreAuthorize("@ss.hasPermission('compute:resource-sku:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportResourceSkuExcel(@Valid ResourceSkuPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ResourceSkuDO> list = resourceSkuService.getResourceSkuPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "算力资源SKU表(价格和租赁信息).xls", "数据", ResourceSkuRespVO.class,
BeanUtils.toBean(list, ResourceSkuRespVO.class));
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourcesku.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.luhu.computility.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.luhu.computility.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 算力资源SKU表(价格和租赁信息)分页 Request VO")
@Data
public class ResourceSkuPageReqVO extends PageParam {
@Schema(description = "关联的SPU ID", example = "11013")
private Long spuId;
@Schema(description = "租赁天数(30/90/365等)")
private Integer durationDays;
@Schema(description = "支付价格(单位:分)", example = "22794")
private Integer paymentPrice;
@Schema(description = "市场价格(单位:分)", example = "5360")
private Integer marketPrice;
@Schema(description = "状态(0-下架,1-上架)", example = "2")
private Integer status;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourcesku.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 算力资源SKU表(价格和租赁信息) Response VO")
@Data
@ExcelIgnoreUnannotated
public class ResourceSkuRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29086")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "关联的SPU ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11013")
@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;
@Schema(description = "支付价格(单位:分)", requiredMode = Schema.RequiredMode.REQUIRED, example = "22794")
@ExcelProperty("支付价格(单位:分)")
private Integer paymentPrice;
@Schema(description = "市场价格(单位:分)", example = "5360")
@ExcelProperty("市场价格(单位:分)")
private Integer marketPrice;
@Schema(description = "状态(0-下架,1-上架)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("状态(0-下架,1-上架)")
private Integer status;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourcesku.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 算力资源SKU表(价格和租赁信息)新增/修改 Request VO")
@Data
public class ResourceSkuSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29086")
private Long id;
@Schema(description = "关联的SPU ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11013")
@NotNull(message = "关联的SPU ID不能为空")
private Long spuId;
@Schema(description = "租赁天数(30/90/365等)", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "租赁天数(30/90/365等)不能为空")
private Integer durationDays;
@Schema(description = "支付价格(单位:分)", requiredMode = Schema.RequiredMode.REQUIRED, example = "22794")
@NotNull(message = "支付价格(单位:分)不能为空")
private Integer paymentPrice;
@Schema(description = "市场价格(单位:分)", example = "5360")
private Integer marketPrice;
@Schema(description = "状态(0-下架,1-上架)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "状态(0-下架,1-上架)不能为空")
private Integer status;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourcespu;
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.luhu.computility.framework.common.pojo.PageParam;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.pojo.CommonResult;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import static com.luhu.computility.framework.common.pojo.CommonResult.success;
import com.luhu.computility.framework.excel.core.util.ExcelUtils;
import com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog;
import static com.luhu.computility.framework.apilog.core.enums.OperateTypeEnum.*;
import com.luhu.computility.module.compute.controller.admin.resourcespu.vo.*;
import com.luhu.computility.module.compute.dal.dataobject.resourcespu.ResourceSpuDO;
import com.luhu.computility.module.compute.service.resourcespu.ResourceSpuService;
@Tag(name = "管理后台 - 算力资源SPU表(基础配置信息)")
@RestController
@RequestMapping("/compute/resource-spu")
@Validated
public class ResourceSpuController {
@Resource
private ResourceSpuService resourceSpuService;
@PostMapping("/create")
@Operation(summary = "创建算力资源SPU表(基础配置信息)")
@PreAuthorize("@ss.hasPermission('compute:resource-spu:create')")
public CommonResult<Long> createResourceSpu(@Valid @RequestBody ResourceSpuSaveReqVO createReqVO) {
return success(resourceSpuService.createResourceSpu(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新算力资源SPU表(基础配置信息)")
@PreAuthorize("@ss.hasPermission('compute:resource-spu:update')")
public CommonResult<Boolean> updateResourceSpu(@Valid @RequestBody ResourceSpuSaveReqVO updateReqVO) {
resourceSpuService.updateResourceSpu(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除算力资源SPU表(基础配置信息)")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('compute:resource-spu:delete')")
public CommonResult<Boolean> deleteResourceSpu(@RequestParam("id") Long id) {
resourceSpuService.deleteResourceSpu(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除算力资源SPU表(基础配置信息)")
@PreAuthorize("@ss.hasPermission('compute:resource-spu:delete')")
public CommonResult<Boolean> deleteResourceSpuList(@RequestParam("ids") List<Long> ids) {
resourceSpuService.deleteResourceSpuListByIds(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得算力资源SPU表(基础配置信息)")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('compute:resource-spu:query')")
public CommonResult<ResourceSpuRespVO> getResourceSpu(@RequestParam("id") Long id) {
ResourceSpuDO resourceSpu = resourceSpuService.getResourceSpu(id);
return success(BeanUtils.toBean(resourceSpu, ResourceSpuRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得算力资源SPU表(基础配置信息)分页")
@PreAuthorize("@ss.hasPermission('compute:resource-spu:query')")
public CommonResult<PageResult<ResourceSpuRespVO>> getResourceSpuPage(@Valid ResourceSpuPageReqVO pageReqVO) {
return success(resourceSpuService.getResourceSpuPage(pageReqVO));
}
@GetMapping("/export-excel")
@Operation(summary = "导出算力资源SPU表(基础配置信息) Excel")
@PreAuthorize("@ss.hasPermission('compute:resource-spu:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportResourceSpuExcel(@Valid ResourceSpuPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ResourceSpuRespVO> list = resourceSpuService.getResourceSpuPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "算力资源SPU表(基础配置信息).xls", "数据", ResourceSpuRespVO.class,
BeanUtils.toBean(list, ResourceSpuRespVO.class));
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourcespu.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.luhu.computility.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.luhu.computility.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 算力资源SPU表(基础配置信息)分页 Request VO")
@Data
public class ResourceSpuPageReqVO extends PageParam {
@Schema(description = "算力资源名称", example = "李四")
private String name;
@Schema(description = "CPU配置")
private String cpu;
@Schema(description = "GPU配置")
private String gpu;
@Schema(description = "内存配置")
private String ram;
@Schema(description = "存储配置")
private String storage;
@Schema(description = "服务器ip")
private String ip;
@Schema(description = "初始用户名", example = "芋艿")
private String initUsername;
@Schema(description = "初始密码")
private String initPassword;
@Schema(description = "商品简介")
private String intro;
@Schema(description = "算力资源分类编号", example = "21747")
private Long categoryId;
@Schema(description = "商品封面图", example = "https://www.iocoder.cn")
private String picUrl;
@Schema(description = "商品轮播图地址,以逗号分隔,最多15张")
private String sliderPicUrls;
@Schema(description = "总库存数量")
private Integer stock;
@Schema(description = "商品销量")
private Integer sales;
@Schema(description = "服务器所在地")
private String location;
@Schema(description = "状态(0 下架,1 上架,2 回收)", example = "1")
private Integer status;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourcespu.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 算力资源SPU表(基础配置信息) Response VO")
@Data
@ExcelIgnoreUnannotated
public class ResourceSpuRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "22333")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "算力资源名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@ExcelProperty("算力资源名称")
private String name;
@Schema(description = "CPU配置", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("CPU配置")
private String cpu;
@Schema(description = "GPU配置")
@ExcelProperty("GPU配置")
private String gpu;
@Schema(description = "内存配置", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("内存配置")
private String ram;
@Schema(description = "存储配置", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("存储配置")
private String storage;
@Schema(description = "服务器ip", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("服务器ip")
private String ip;
@Schema(description = "初始用户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@ExcelProperty("初始用户名")
private String initUsername;
@Schema(description = "初始密码", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("初始密码")
private String initPassword;
@Schema(description = "商品简介")
@ExcelProperty("商品简介")
private String intro;
@Schema(description = "算力资源分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21747")
@ExcelProperty("算力资源分类编号")
private Long categoryId;
@Schema(description = "算力资源分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "高性能计算服务资源")
@ExcelProperty("算力资源分类名称")
private String categoryName;
@Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
@ExcelProperty("商品封面图")
private String picUrl;
@Schema(description = "商品轮播图地址,以逗号分隔,最多15张")
@ExcelProperty("商品轮播图地址,以逗号分隔,最多15张")
private String sliderPicUrls;
@Schema(description = "总库存数量", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("总库存数量")
private Integer stock;
@Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED)
@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;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.admin.resourcespu.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 算力资源SPU表(基础配置信息)新增/修改 Request VO")
@Data
public class ResourceSpuSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "22333")
private Long id;
@Schema(description = "算力资源名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@NotEmpty(message = "算力资源名称不能为空")
private String name;
@Schema(description = "CPU配置", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "CPU配置不能为空")
private String cpu;
@Schema(description = "GPU配置")
private String gpu;
@Schema(description = "内存配置", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "内存配置不能为空")
private String ram;
@Schema(description = "存储配置", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "存储配置不能为空")
private String storage;
@Schema(description = "服务器ip", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "服务器ip不能为空")
private String ip;
@Schema(description = "初始用户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@NotEmpty(message = "初始用户名不能为空")
private String initUsername;
@Schema(description = "初始密码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "初始密码不能为空")
private String initPassword;
@Schema(description = "商品简介")
private String intro;
@Schema(description = "算力资源分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21747")
@NotNull(message = "算力资源分类编号不能为空")
private Long categoryId;
@Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
@NotEmpty(message = "商品封面图不能为空")
private String picUrl;
@Schema(description = "商品轮播图地址,以逗号分隔,最多15张")
private String sliderPicUrls;
@Schema(description = "总库存数量", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "总库存数量不能为空")
private Integer stock;
@Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED)
@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;
}
\ No newline at end of file
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;
}
package com.luhu.computility.module.compute.controller.app.resourcecategory;
import com.luhu.computility.framework.common.pojo.CommonResult;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import com.luhu.computility.module.compute.controller.app.resourcecategory.vo.AppResourceCategoryRespVO;
import com.luhu.computility.module.compute.service.resourcecategory.ResourceCategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import static com.luhu.computility.framework.common.pojo.CommonResult.success;
@Tag(name = "用户 APP - 算力资源分类")
@RestController
@RequestMapping("/compute/resource-category")
@Validated
@Slf4j
public class AppResourceCategoryController {
@Resource
private ResourceCategoryService resourceCategoryService;
@GetMapping("/list")
@Operation(summary = "获得算力资源分类列表")
public CommonResult<List<AppResourceCategoryRespVO>> getResourceCategoryList() {
return success(BeanUtils.toBean(resourceCategoryService.getAllCategory(), AppResourceCategoryRespVO.class));
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.app.resourcecategory.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "用户 APP - 算力资源分类 Response VO")
@Data
public class AppResourceCategoryRespVO {
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
@Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "GPU服务器")
private String name;
@Schema(description = "分类描述", example = "高性能GPU算力服务器")
private String remark;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.app.resourceorder;
import com.luhu.computility.framework.common.pojo.CommonResult;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderCreateReqVO;
import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderCreateRespVO;
import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderPageReqVO;
import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderRespVO;
import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderInvoiceReqVO;
import com.luhu.computility.module.compute.service.resourceorder.ResourceOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import org.springframework.validation.annotation.Validated;
import static com.luhu.computility.framework.common.pojo.CommonResult.success;
import static com.luhu.computility.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "用户 APP - 算力资源订单")
@RestController
@RequestMapping("/compute/order")
@Validated
@Slf4j
public class AppResourceOrderController {
@Resource
private ResourceOrderService resourceOrderService;
@PostMapping("/create")
@Operation(summary = "创建算力资源订单")
public CommonResult<AppResourceOrderCreateRespVO> createResourceOrder(@Valid @RequestBody AppResourceOrderCreateReqVO createReqVO) {
Long userId = getLoginUserId();
AppResourceOrderCreateRespVO respVO = resourceOrderService.createUserResourceOrder(userId, createReqVO);
return success(respVO);
}
@PutMapping("/cancel")
@Operation(summary = "取消算力资源订单")
public CommonResult<Boolean> cancelResourceOrder(@RequestParam("orderId") Long orderId) {
Long userId = getLoginUserId();
resourceOrderService.cancelOrder(userId, orderId);
return success(true);
}
@GetMapping("/page")
@Operation(summary = "获得用户算力资源订单分页")
public CommonResult<PageResult<AppResourceOrderRespVO>> getUserResourceOrderPage(@Valid AppResourceOrderPageReqVO pageReqVO) {
Long userId = getLoginUserId();
pageReqVO.setUserId(userId);
PageResult<AppResourceOrderRespVO> pageResult = resourceOrderService.getUserResourceOrderPage(pageReqVO);
return success(pageResult);
}
@GetMapping("/get")
@Operation(summary = "获得算力资源订单详情")
@Parameter(name = "id", description = "编号", required = true)
public CommonResult<AppResourceOrderRespVO> getUserResourceOrder(@RequestParam("id") Long id) {
Long userId = getLoginUserId();
AppResourceOrderRespVO orderDetail = resourceOrderService.getUserResourceOrder(userId, id);
return success(orderDetail);
}
@PostMapping("/invoice-request")
@Operation(summary = "申请开票")
public CommonResult<Boolean> invoiceRequest(@RequestBody AppResourceOrderInvoiceReqVO reqVO) {
resourceOrderService.updateRequestInvoice(reqVO);
return success(true);
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.app.resourceorder.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Schema(description = "用户 APP - 算力资源订单创建 Request VO")
@Data
public class AppResourceOrderCreateReqVO {
@Schema(description = "算力资源SKU ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "31061")
@NotNull(message = "算力资源SKU ID不能为空")
private Long skuId;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.app.resourceorder.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "用户 APP - 算力资源订单创建 Response VO")
@Data
public class AppResourceOrderCreateRespVO {
@Schema(description = "订单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1595")
private Long id;
@Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED)
private String orderNo;
@Schema(description = "支付订单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15798")
private Long payOrderId;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.app.resourceorder.vo;
import lombok.Data;
/**
* 用户 App - 算力资源订单申请开票 Request VO
*
* @author jony
*/
@Data
public class AppResourceOrderInvoiceReqVO {
private Long id;
//发票图片链接
private String invoiceUrl;
//开票状态
private Integer invoiceStatus;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.app.resourceorder.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.luhu.computility.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "用户 APP - 算力资源订单分页 Request VO")
@Data
public class AppResourceOrderPageReqVO {
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long userId;
@Schema(description = "订单编号", example = "1024")
private Long id;
@Schema(description = "订单号", example = "X202410110001")
private String no;
@Schema(description = "分类编号", example = "1")
private Long categoryId;
@Schema(description = "订单状态", example = "0")
private Integer status;
@Schema(description = "支付订单编号", example = "1024")
private Long payOrderId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "页码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer pageNo = 1;
@Schema(description = "每页大小", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
private Integer pageSize = 10;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.app.resourceorder.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "用户 APP - 算力资源订单 Response VO")
@Data
public class AppResourceOrderRespVO {
@Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
@Schema(description = "订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "X202410110001")
private String orderNo;
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long userId;
@Schema(description = "商品SPU编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long spuId;
@Schema(description = "商品SPU名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "GPU服务器A型")
private String spuName;
@Schema(description = "商品SKU编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long skuId;
@Schema(description = "商品SKU名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "GPU服务器A型-7天")
private String skuName;
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long categoryId;
@Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "GPU服务器")
private String categoryName;
@Schema(description = "支付价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "888800")
private Integer payPrice;
@Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long payOrderId;
@Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
private Integer status;
@Schema(description = "开票状态", example = "0")
private Integer invoiceStatus;
@Schema(description = "发票文件URL", example = "https://example.com/invoice.pdf")
private String invoiceUrl;
@Schema(description = "CPU配置", example = "Intel Xeon E5-2680 v4")
private String cpu;
@Schema(description = "GPU配置", example = "NVIDIA RTX 4090")
private String gpu;
@Schema(description = "内存配置", example = "64GB DDR4")
private String ram;
@Schema(description = "存储配置", example = "2TB NVMe SSD")
private String storage;
@Schema(description = "服务器IP", example = "192.168.1.100")
private String ip;
@Schema(description = "服务器所在地", example = "深圳")
private String location;
@Schema(description = "备注", example = "高性能GPU服务器,适合AI训练")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime updateTime;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.app.resourcesku;
import com.luhu.computility.framework.common.pojo.CommonResult;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import com.luhu.computility.module.compute.controller.app.resourcesku.vo.AppResourceSkuPageReqVO;
import com.luhu.computility.module.compute.controller.app.resourcesku.vo.AppResourceSkuRespVO;
import com.luhu.computility.module.compute.dal.dataobject.resourcesku.ResourceSkuDO;
import com.luhu.computility.module.compute.dal.dataobject.resourcespu.ResourceSpuDO;
import com.luhu.computility.module.compute.service.resourcesku.ResourceSkuService;
import com.luhu.computility.module.compute.service.resourcespu.ResourceSpuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.validation.annotation.Validated;
import static com.luhu.computility.framework.common.pojo.CommonResult.success;
@Tag(name = "用户 APP - 算力资源SKU")
@RestController
@RequestMapping("/compute/resource-sku")
@Validated
@Slf4j
public class AppResourceSkuController {
@Resource
private ResourceSkuService resourceSkuService;
@Resource
private ResourceSpuService resourceSpuService;
@GetMapping("/page")
@Operation(summary = "获得算力资源SKU分页")
public CommonResult<PageResult<AppResourceSkuRespVO>> getResourceSkuPage(@Valid AppResourceSkuPageReqVO pageReqVO) {
// 根据分类ID查询该分类下的所有SPU
List<ResourceSpuDO> spus;
if (pageReqVO.getCategoryId() != null) {
// 根据分类ID查询SPU
spus = resourceSpuService.getResourceSpuListByCategoryId(pageReqVO.getCategoryId());
} else {
// 查询所有上架的SPU
spus = resourceSpuService.getOnlineResourceSpuList();
}
if (spus.isEmpty()) {
PageResult<AppResourceSkuRespVO> emptyResult = new PageResult<>();
emptyResult.setTotal(0L);
emptyResult.setList(Collections.emptyList());
return success(emptyResult);
}
// 获取这些SPU对应的所有可用SKU
List<Long> spuIds = spus.stream().map(ResourceSpuDO::getId).collect(Collectors.toList());
List<ResourceSkuDO> skus = resourceSkuService.getResourceSkuListBySpuIds(spuIds, pageReqVO.getStatus());
// 分页处理
int total = skus.size();
int start = (pageReqVO.getPageNo() - 1) * pageReqVO.getPageSize();
int end = Math.min(start + pageReqVO.getPageSize(), total);
List<ResourceSkuDO> pageSkus = skus.subList(start, end);
// 组装返回数据
Map<Long, ResourceSpuDO> spuMap = spus.stream()
.collect(Collectors.toMap(ResourceSpuDO::getId, spu -> spu));
List<AppResourceSkuRespVO> respList = pageSkus.stream().map(sku -> {
ResourceSpuDO spu = spuMap.get(sku.getSpuId());
if (spu == null) {
return null;
}
AppResourceSkuRespVO respVO = new AppResourceSkuRespVO();
respVO.setId(sku.getId());
respVO.setName(spu.getName());
respVO.setRemark(spu.getIntro());
respVO.setPrice(sku.getPaymentPrice());
respVO.setFeeInfo(sku.getDurationDays() + "天");
respVO.setCpu(spu.getCpu());
respVO.setGpu(spu.getGpu());
respVO.setRam(spu.getRam());
respVO.setStorage(spu.getStorage());
respVO.setIp(spu.getIp());
respVO.setLocation(spu.getLocation());
return respVO;
}).filter(obj -> obj != null).collect(Collectors.toList());
PageResult<AppResourceSkuRespVO> result = new PageResult<>();
result.setTotal((long) total);
result.setList(respList);
return success(result);
}
@GetMapping("/get-detail")
@Operation(summary = "获得算力资源SKU详情")
@Parameter(name = "id", description = "编号", required = true)
public CommonResult<AppResourceSkuRespVO> getResourceSkuDetail(@RequestParam("id") Long id) {
ResourceSkuDO resourceSku = resourceSkuService.getResourceSku(id);
ResourceSpuDO resourceSpu = resourceSpuService.getResourceSpu(resourceSku.getSpuId());
if (resourceSpu == null) {
return success(null);
}
AppResourceSkuRespVO respVO = BeanUtils.toBean(resourceSpu, AppResourceSkuRespVO.class);
respVO.setId(resourceSku.getId());
respVO.setPrice(resourceSku.getPaymentPrice());
respVO.setFeeInfo(resourceSku.getDurationDays() + "天");
return success(respVO);
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.app.resourcesku.vo;
import com.luhu.computility.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "用户 APP - 算力资源SKU分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AppResourceSkuPageReqVO extends PageParam {
@Schema(description = "分类ID", example = "1")
private Long categoryId;
@Schema(description = "状态", example = "1")
private Integer status;
}
\ No newline at end of file
package com.luhu.computility.module.compute.controller.app.resourcesku.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "用户 APP - 算力资源SKU Response VO")
@Data
public class AppResourceSkuRespVO {
@Schema(description = "SKU编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "GPU服务器A型")
private String name;
@Schema(description = "描述", example = "高性能GPU服务器,适合AI训练")
private String remark;
@Schema(description = "商品价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "888800")
private Integer price;
@Schema(description = "费用信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "7天")
private String feeInfo;
@Schema(description = "CPU配置", example = "Intel Xeon E5-2680 v4")
private String cpu;
@Schema(description = "GPU配置", example = "NVIDIA RTX 4090")
private String gpu;
@Schema(description = "内存配置", example = "64GB DDR4")
private String ram;
@Schema(description = "存储配置", example = "2TB NVMe SSD")
private String storage;
@Schema(description = "服务器IP", example = "192.168.1.100")
private String ip;
@Schema(description = "服务器所在地", example = "深圳")
private String location;
}
\ No newline at end of file
package com.luhu.computility.module.compute.dal.dataobject.resourcecategory;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.luhu.computility.framework.mybatis.core.dataobject.BaseDO;
/**
* 算力资源分类表(仅用于算力服务器分类) DO
*
* @author jony
*/
@TableName("compute_resource_category")
@KeySequence("compute_resource_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResourceCategoryDO extends BaseDO {
/**
* 分类编号
*/
@TableId
private Long id;
/**
* 分类名称(如:高性能计算服务资源)
*/
private String name;
/**
* 分类图标地址
*/
private String picUrl;
/**
* 分类排序(数字越小越靠前)
*/
private Integer sort;
/**
* 状态(0=启用,1=禁用)
*/
private Integer status;
}
\ No newline at end of file
package com.luhu.computility.module.compute.dal.dataobject.resourceconfig;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.luhu.computility.framework.mybatis.core.dataobject.BaseDO;
/**
* 算力资源配置 DO
*
* @author jony
*/
@TableName("compute_resource_config")
@KeySequence("compute_resource_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResourceConfigDO extends BaseDO {
/**
* 主键ID
*/
@TableId
private Long id;
/**
* 配置类别
*/
private String configCategory;
/**
* 配置选项
*/
private String configOption;
/**
* 排序
*/
private Integer sort;
/**
* 状态:0=启用,1=禁用
*/
private Integer status;
/**
* 详情备注(如:i7-13700K 16核24线程)
*/
private String detailRemark;
}
\ No newline at end of file
package com.luhu.computility.module.compute.dal.dataobject.resourceorder;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.luhu.computility.framework.mybatis.core.dataobject.BaseDO;
/**
* 算力资源订单 DO
*
* @author jony
*/
@TableName("compute_resource_order")
@KeySequence("compute_resource_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResourceOrderDO extends BaseDO {
/**
* 订单ID
*/
@TableId
private Long id;
/**
* 下单用户ID
*/
private Long userId;
/**
* 用户IP
*/
private String userIp;
/**
* 算力资源SKU ID
*/
private Long skuId;
/**
* 算力资源名称(下单时快照)
*/
private String spuName;
/**
* 订单编号
*/
private String orderNo;
/**
* 订单状态:0=待支付,1=已支付,2=已取消
*/
private Integer status;
/**
* 市场价格(分)
*/
private Long marketPrice;
/**
* 实付金额(分)
*/
private Long paymentPrice;
/**
* 支付订单编号
*/
private Long payOrderId;
/**
* 支付时间
*/
private LocalDateTime payTime;
/**
* 支付渠道
*/
private String payChannelCode;
/**
* 租赁开始时间
*/
private LocalDateTime rentStartTime;
/**
* 租赁结束时间
*/
private LocalDateTime rentEndTime;
/**
* 取消时间
*/
private LocalDateTime cancelTime;
/**
* 备注
*/
private String remark;
/**
* 算力资源状态:[0]未启用,[1]使用中,[2]已释放
*/
private Integer resourceStatus;
/**
* 退款状态
*/
private Integer refundStatus;
/**
* 退款金额
*/
private String refundPrice;
/**
* 开票状态:[0]未开 [1]开票中 [2]已开票
*/
private Integer invoiceStatus;
/**
* 发票链接
*/
private String invoiceUrl;
}
\ No newline at end of file
package com.luhu.computility.module.compute.dal.dataobject.resourcesku;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.luhu.computility.framework.mybatis.core.dataobject.BaseDO;
/**
* 算力资源SKU表(价格和租赁信息) DO
*
* @author jony
*/
@TableName("compute_resource_sku")
@KeySequence("compute_resource_sku_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResourceSkuDO extends BaseDO {
/**
* 主键ID
*/
@TableId
private Long id;
/**
* 关联的SPU ID
*/
private Long spuId;
/**
* 租赁天数(30/90/365等)
*/
private Integer durationDays;
/**
* 支付价格(单位:分)
*/
private Integer paymentPrice;
/**
* 市场价格(单位:分)
*/
private Integer marketPrice;
/**
* 状态(0-下架,1-上架)
*/
private Integer status;
}
\ No newline at end of file
package com.luhu.computility.module.compute.dal.dataobject.resourcespu;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.luhu.computility.framework.mybatis.core.dataobject.BaseDO;
/**
* 算力资源SPU表(基础配置信息) DO
*
* @author jony
*/
@TableName("compute_resource_spu")
@KeySequence("compute_resource_spu_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResourceSpuDO extends BaseDO {
/**
* 主键ID
*/
@TableId
private Long id;
/**
* 算力资源名称
*/
private String name;
/**
* CPU配置
*/
private String cpu;
/**
* GPU配置
*/
private String gpu;
/**
* 内存配置
*/
private String ram;
/**
* 存储配置
*/
private String storage;
/**
* 服务器ip
*/
private String ip;
/**
* 初始用户名
*/
private String initUsername;
/**
* 初始密码
*/
private String initPassword;
/**
* 商品简介
*/
private String intro;
/**
* 算力资源分类编号
*/
private Long categoryId;
/**
* 商品封面图
*/
private String picUrl;
/**
* 商品轮播图地址,以逗号分隔,最多15张
*/
private String sliderPicUrls;
/**
* 总库存数量
*/
private Integer stock;
/**
* 商品销量
*/
private Integer sales;
/**
* 服务器所在地
*/
private String location;
/**
* 状态(0 下架,1 上架,2 回收)
*/
private Integer status;
}
\ No newline at end of file
package com.luhu.computility.module.compute.dal.mysql.resourcecategory;
import java.util.*;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.luhu.computility.framework.mybatis.core.mapper.BaseMapperX;
import com.luhu.computility.module.compute.dal.dataobject.resourcecategory.ResourceCategoryDO;
import org.apache.ibatis.annotations.Mapper;
import com.luhu.computility.module.compute.controller.admin.resourcecategory.vo.*;
/**
* 算力资源分类表(仅用于算力服务器分类) Mapper
*
* @author jony
*/
@Mapper
public interface ResourceCategoryMapper extends BaseMapperX<ResourceCategoryDO> {
default PageResult<ResourceCategoryDO> selectPage(ResourceCategoryPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ResourceCategoryDO>()
.likeIfPresent(ResourceCategoryDO::getName, reqVO.getName())
.eqIfPresent(ResourceCategoryDO::getPicUrl, reqVO.getPicUrl())
.eqIfPresent(ResourceCategoryDO::getSort, reqVO.getSort())
.eqIfPresent(ResourceCategoryDO::getStatus, reqVO.getStatus())
.betweenIfPresent(ResourceCategoryDO::getCreateTime, reqVO.getCreateTime())
.orderByAsc(ResourceCategoryDO::getSort));
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.dal.mysql.resourceconfig;
import java.util.*;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.luhu.computility.framework.mybatis.core.mapper.BaseMapperX;
import com.luhu.computility.module.compute.dal.dataobject.resourceconfig.ResourceConfigDO;
import org.apache.ibatis.annotations.Mapper;
import com.luhu.computility.module.compute.controller.admin.resourceconfig.vo.*;
/**
* 算力资源配置 Mapper
*
* @author jony
*/
@Mapper
public interface ResourceConfigMapper extends BaseMapperX<ResourceConfigDO> {
default PageResult<ResourceConfigDO> selectPage(ResourceConfigPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ResourceConfigDO>()
.eqIfPresent(ResourceConfigDO::getConfigCategory, reqVO.getConfigCategory())
.eqIfPresent(ResourceConfigDO::getConfigOption, reqVO.getConfigOption())
.eqIfPresent(ResourceConfigDO::getSort, reqVO.getSort())
.eqIfPresent(ResourceConfigDO::getStatus, reqVO.getStatus())
.eqIfPresent(ResourceConfigDO::getDetailRemark, reqVO.getDetailRemark())
.betweenIfPresent(ResourceConfigDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ResourceConfigDO::getId));
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.dal.mysql.resourceorder;
import java.util.*;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.luhu.computility.framework.mybatis.core.mapper.BaseMapperX;
import com.luhu.computility.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO;
import com.luhu.computility.module.member.dal.dataobject.user.MemberUserDO;
import org.apache.ibatis.annotations.Mapper;
import com.luhu.computility.module.compute.controller.admin.resourceorder.vo.*;
/**
* 算力资源订单 Mapper
*
* @author jony
*/
@Mapper
public interface ResourceOrderMapper extends BaseMapperX<ResourceOrderDO> {
default PageResult<ResourceOrderRespVO> selectPage(ResourceOrderPageReqVO reqVO) {
return selectJoinPage(reqVO, ResourceOrderRespVO.class, new MPJLambdaWrapperX<ResourceOrderDO>()
.selectAll(ResourceOrderDO.class)
.selectAs(MemberUserDO::getNickname, ResourceOrderRespVO::getNickname)
.leftJoin(MemberUserDO.class, MemberUserDO::getId, ResourceOrderDO::getUserId)
.eqIfPresent(ResourceOrderDO::getUserId, reqVO.getUserId())
.eqIfPresent(ResourceOrderDO::getSkuId, reqVO.getSkuId())
.likeIfPresent(ResourceOrderDO::getSpuName, reqVO.getSpuName())
.eqIfPresent(ResourceOrderDO::getOrderNo, reqVO.getOrderNo())
.eqIfPresent(ResourceOrderDO::getStatus, reqVO.getStatus())
.eqIfPresent(ResourceOrderDO::getMarketPrice, reqVO.getMarketPrice())
.eqIfPresent(ResourceOrderDO::getPaymentPrice, reqVO.getPaymentPrice())
.eqIfPresent(ResourceOrderDO::getPayOrderId, reqVO.getPayOrderId())
.betweenIfPresent(ResourceOrderDO::getPayTime, reqVO.getPayTime())
.eqIfPresent(ResourceOrderDO::getPayChannelCode, reqVO.getPayChannelCode())
.betweenIfPresent(ResourceOrderDO::getRentStartTime, reqVO.getRentStartTime())
.betweenIfPresent(ResourceOrderDO::getRentEndTime, reqVO.getRentEndTime())
.betweenIfPresent(ResourceOrderDO::getCancelTime, reqVO.getCancelTime())
.eqIfPresent(ResourceOrderDO::getRemark, reqVO.getRemark())
.eqIfPresent(ResourceOrderDO::getResourceStatus, reqVO.getResourceStatus())
.eqIfPresent(ResourceOrderDO::getRefundStatus, reqVO.getRefundStatus())
.eqIfPresent(ResourceOrderDO::getRefundPrice, reqVO.getRefundPrice())
.eqIfPresent(ResourceOrderDO::getInvoiceStatus, reqVO.getInvoiceStatus())
.eqIfPresent(ResourceOrderDO::getInvoiceUrl, reqVO.getInvoiceUrl())
.betweenIfPresent(ResourceOrderDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ResourceOrderDO::getId));
}
default PageResult<ResourceOrderDO> selectPageDO(ResourceOrderPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ResourceOrderDO>()
.eqIfPresent(ResourceOrderDO::getUserId, reqVO.getUserId())
.eqIfPresent(ResourceOrderDO::getSkuId, reqVO.getSkuId())
.likeIfPresent(ResourceOrderDO::getSpuName, reqVO.getSpuName())
.eqIfPresent(ResourceOrderDO::getOrderNo, reqVO.getOrderNo())
.eqIfPresent(ResourceOrderDO::getStatus, reqVO.getStatus())
.eqIfPresent(ResourceOrderDO::getMarketPrice, reqVO.getMarketPrice())
.eqIfPresent(ResourceOrderDO::getPaymentPrice, reqVO.getPaymentPrice())
.eqIfPresent(ResourceOrderDO::getPayOrderId, reqVO.getPayOrderId())
.betweenIfPresent(ResourceOrderDO::getPayTime, reqVO.getPayTime())
.eqIfPresent(ResourceOrderDO::getPayChannelCode, reqVO.getPayChannelCode())
.betweenIfPresent(ResourceOrderDO::getRentStartTime, reqVO.getRentStartTime())
.betweenIfPresent(ResourceOrderDO::getRentEndTime, reqVO.getRentEndTime())
.betweenIfPresent(ResourceOrderDO::getCancelTime, reqVO.getCancelTime())
.eqIfPresent(ResourceOrderDO::getRemark, reqVO.getRemark())
.eqIfPresent(ResourceOrderDO::getResourceStatus, reqVO.getResourceStatus())
.eqIfPresent(ResourceOrderDO::getRefundStatus, reqVO.getRefundStatus())
.eqIfPresent(ResourceOrderDO::getRefundPrice, reqVO.getRefundPrice())
.eqIfPresent(ResourceOrderDO::getInvoiceStatus, reqVO.getInvoiceStatus())
.eqIfPresent(ResourceOrderDO::getInvoiceUrl, reqVO.getInvoiceUrl())
.betweenIfPresent(ResourceOrderDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ResourceOrderDO::getId));
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.dal.mysql.resourcesku;
import java.util.*;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.luhu.computility.framework.mybatis.core.mapper.BaseMapperX;
import com.luhu.computility.module.compute.dal.dataobject.resourcesku.ResourceSkuDO;
import org.apache.ibatis.annotations.Mapper;
import com.luhu.computility.module.compute.controller.admin.resourcesku.vo.*;
/**
* 算力资源SKU表(价格和租赁信息) Mapper
*
* @author jony
*/
@Mapper
public interface ResourceSkuMapper extends BaseMapperX<ResourceSkuDO> {
default PageResult<ResourceSkuDO> selectPage(ResourceSkuPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ResourceSkuDO>()
.eqIfPresent(ResourceSkuDO::getSpuId, reqVO.getSpuId())
.eqIfPresent(ResourceSkuDO::getDurationDays, reqVO.getDurationDays())
.eqIfPresent(ResourceSkuDO::getPaymentPrice, reqVO.getPaymentPrice())
.eqIfPresent(ResourceSkuDO::getMarketPrice, reqVO.getMarketPrice())
.eqIfPresent(ResourceSkuDO::getStatus, reqVO.getStatus())
.betweenIfPresent(ResourceSkuDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ResourceSkuDO::getId));
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.dal.mysql.resourcespu;
import java.util.*;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.luhu.computility.framework.mybatis.core.mapper.BaseMapperX;
import com.luhu.computility.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.luhu.computility.module.compute.dal.dataobject.resourcecategory.ResourceCategoryDO;
import com.luhu.computility.module.compute.dal.dataobject.resourcespu.ResourceSpuDO;
import com.luhu.computility.module.compute.dal.mysql.resourcecategory.ResourceCategoryMapper;
import org.apache.ibatis.annotations.Mapper;
import com.luhu.computility.module.compute.controller.admin.resourcespu.vo.*;
/**
* 算力资源SPU表(基础配置信息) Mapper
*
* @author jony
*/
@Mapper
public interface ResourceSpuMapper extends BaseMapperX<ResourceSpuDO> {
default PageResult<ResourceSpuRespVO> selectPage(ResourceSpuPageReqVO reqVO) {
return selectJoinPage(reqVO, ResourceSpuRespVO.class,new MPJLambdaWrapperX<ResourceSpuDO>()
.selectAll(ResourceSpuDO.class)
.selectAs(ResourceCategoryDO::getName,ResourceSpuRespVO::getCategoryName)
.leftJoin(ResourceCategoryDO.class,ResourceCategoryDO::getId,ResourceSpuDO::getCategoryId)
.likeIfPresent(ResourceSpuDO::getName, reqVO.getName())
.eqIfPresent(ResourceSpuDO::getCpu, reqVO.getCpu())
.eqIfPresent(ResourceSpuDO::getGpu, reqVO.getGpu())
.eqIfPresent(ResourceSpuDO::getRam, reqVO.getRam())
.eqIfPresent(ResourceSpuDO::getStorage, reqVO.getStorage())
.eqIfPresent(ResourceSpuDO::getIp, reqVO.getIp())
.likeIfPresent(ResourceSpuDO::getInitUsername, reqVO.getInitUsername())
.eqIfPresent(ResourceSpuDO::getInitPassword, reqVO.getInitPassword())
.likeIfPresent(ResourceSpuDO::getIntro, reqVO.getIntro())
.eqIfPresent(ResourceSpuDO::getCategoryId, reqVO.getCategoryId())
.eqIfPresent(ResourceSpuDO::getPicUrl, reqVO.getPicUrl())
.eqIfPresent(ResourceSpuDO::getSliderPicUrls, reqVO.getSliderPicUrls())
.eqIfPresent(ResourceSpuDO::getStock, reqVO.getStock())
.eqIfPresent(ResourceSpuDO::getSales, reqVO.getSales())
.eqIfPresent(ResourceSpuDO::getStatus, reqVO.getStatus())
.betweenIfPresent(ResourceSpuDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ResourceSpuDO::getId));
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.dal.redis;
/**
* 算力资源 Redis Key 枚举类
*
* @author jony
*/
public interface RedisKeyConstants {
/**
* 算力资源订单序号的缓存
*
* KEY 格式:compute_trade_no:{prefix}
* VALUE 数据格式:编号自增
*/
String COMPUTE_TRADE_NO = "compute_trade_no:";
}
\ No newline at end of file
package com.luhu.computility.module.compute.dal.redis.no;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.luhu.computility.module.compute.dal.redis.RedisKeyConstants;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.time.Duration;
/**
* 算力资源订单序号的 Redis DAO
*
* @author jony
*/
@Repository
public class ResourceOrderNoRedisDAO {
public static final String RESOURCE_ORDER_NO_PREFIX = "a";
@Resource
private StringRedisTemplate stringRedisTemplate;
/**
* 生成序号
*
* @param prefix 前缀
* @return 序号
*/
public String generate(String prefix) {
// 递增序号
String noPrefix = prefix + DateUtil.format(java.time.LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN);
String key = RedisKeyConstants.COMPUTE_TRADE_NO + noPrefix;
Long no = stringRedisTemplate.opsForValue().increment(key);
// 设置过期时间
stringRedisTemplate.expire(key, Duration.ofMinutes(1L));
return noPrefix + no;
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.service.resourcecategory;
import java.util.*;
import javax.validation.*;
import com.luhu.computility.module.compute.controller.admin.resourcecategory.vo.*;
import com.luhu.computility.module.compute.dal.dataobject.resourcecategory.ResourceCategoryDO;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.pojo.PageParam;
/**
* 算力资源分类表(仅用于算力服务器分类) Service 接口
*
* @author jony
*/
public interface ResourceCategoryService {
/**
*
*
* @return
*/
List<ResourceCategoryDO> getAllCategory();
/**
* 创建算力资源分类表(仅用于算力服务器分类)
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createResourceCategory(@Valid ResourceCategorySaveReqVO createReqVO);
/**
* 更新算力资源分类表(仅用于算力服务器分类)
*
* @param updateReqVO 更新信息
*/
void updateResourceCategory(@Valid ResourceCategorySaveReqVO updateReqVO);
/**
* 删除算力资源分类表(仅用于算力服务器分类)
*
* @param id 编号
*/
void deleteResourceCategory(Long id);
/**
* 批量删除算力资源分类表(仅用于算力服务器分类)
*
* @param ids 编号
*/
void deleteResourceCategoryListByIds(List<Long> ids);
/**
* 获得算力资源分类表(仅用于算力服务器分类)
*
* @param id 编号
* @return 算力资源分类表(仅用于算力服务器分类)
*/
ResourceCategoryDO getResourceCategory(Long id);
/**
* 获得算力资源分类表(仅用于算力服务器分类)分页
*
* @param pageReqVO 分页查询
* @return 算力资源分类表(仅用于算力服务器分类)分页
*/
PageResult<ResourceCategoryDO> getResourceCategoryPage(ResourceCategoryPageReqVO pageReqVO);
}
\ No newline at end of file
package com.luhu.computility.module.compute.service.resourcecategory;
import com.luhu.computility.framework.common.pojo.PageParam;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import com.luhu.computility.module.compute.controller.admin.resourcecategory.vo.ResourceCategoryPageReqVO;
import com.luhu.computility.module.compute.controller.admin.resourcecategory.vo.ResourceCategorySaveReqVO;
import com.luhu.computility.module.compute.dal.dataobject.resourcecategory.ResourceCategoryDO;
import com.luhu.computility.module.compute.dal.mysql.resourcecategory.ResourceCategoryMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import static com.luhu.computility.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.luhu.computility.module.compute.enums.ErrorCodeConstants.RESOURCE_CATEGORY_NOT_EXISTS;
import static com.luhu.computility.module.compute.enums.ResourceEnableStatus.ENABLE;
/**
* 算力资源分类表(仅用于算力服务器分类) Service 实现类
*
* @author jony
*/
@Service
@Validated
public class ResourceCategoryServiceImpl implements ResourceCategoryService {
@Resource
private ResourceCategoryMapper resourceCategoryMapper;
@Override
public List<ResourceCategoryDO> getAllCategory() {
ResourceCategoryPageReqVO reqVO = new ResourceCategoryPageReqVO();
reqVO.setStatus(ENABLE.getValue()).setPageSize(PageParam.PAGE_SIZE_NONE);
List<ResourceCategoryDO> list = resourceCategoryMapper.selectPage(reqVO).getList();
return list;
}
@Override
public Long createResourceCategory(ResourceCategorySaveReqVO createReqVO) {
// 插入
ResourceCategoryDO resourceCategory = BeanUtils.toBean(createReqVO, ResourceCategoryDO.class);
resourceCategoryMapper.insert(resourceCategory);
// 返回
return resourceCategory.getId();
}
@Override
public void updateResourceCategory(ResourceCategorySaveReqVO updateReqVO) {
// 校验存在
validateResourceCategoryExists(updateReqVO.getId());
// 更新
ResourceCategoryDO updateObj = BeanUtils.toBean(updateReqVO, ResourceCategoryDO.class);
resourceCategoryMapper.updateById(updateObj);
}
@Override
public void deleteResourceCategory(Long id) {
// 校验存在
validateResourceCategoryExists(id);
// 删除
resourceCategoryMapper.deleteById(id);
}
@Override
public void deleteResourceCategoryListByIds(List<Long> ids) {
// 删除
resourceCategoryMapper.deleteByIds(ids);
}
private void validateResourceCategoryExists(Long id) {
if (resourceCategoryMapper.selectById(id) == null) {
throw exception(RESOURCE_CATEGORY_NOT_EXISTS);
}
}
@Override
public ResourceCategoryDO getResourceCategory(Long id) {
return resourceCategoryMapper.selectById(id);
}
@Override
public PageResult<ResourceCategoryDO> getResourceCategoryPage(ResourceCategoryPageReqVO pageReqVO) {
return resourceCategoryMapper.selectPage(pageReqVO);
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.service.resourceconfig;
import java.util.*;
import javax.validation.*;
import com.luhu.computility.module.compute.controller.admin.resourceconfig.vo.*;
import com.luhu.computility.module.compute.dal.dataobject.resourceconfig.ResourceConfigDO;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.pojo.PageParam;
/**
* 算力资源配置 Service 接口
*
* @author jony
*/
public interface ResourceConfigService {
/**
* 通过配置类别获取配置
*
* @param category
* @return
*/
List<ResourceConfigDO> listSimpleConfigByCategory(String category);
/**
* 创建算力资源配置
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createResourceConfig(@Valid ResourceConfigSaveReqVO createReqVO);
/**
* 更新算力资源配置
*
* @param updateReqVO 更新信息
*/
void updateResourceConfig(@Valid ResourceConfigSaveReqVO updateReqVO);
/**
* 删除算力资源配置
*
* @param id 编号
*/
void deleteResourceConfig(Long id);
/**
* 批量删除算力资源配置
*
* @param ids 编号
*/
void deleteResourceConfigListByIds(List<Long> ids);
/**
* 获得算力资源配置
*
* @param id 编号
* @return 算力资源配置
*/
ResourceConfigDO getResourceConfig(Long id);
/**
* 获得算力资源配置分页
*
* @param pageReqVO 分页查询
* @return 算力资源配置分页
*/
PageResult<ResourceConfigDO> getResourceConfigPage(ResourceConfigPageReqVO pageReqVO);
}
\ No newline at end of file
package com.luhu.computility.module.compute.service.resourceconfig;
import cn.hutool.core.util.ObjectUtil;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import com.luhu.computility.module.compute.controller.admin.resourceconfig.vo.ResourceConfigPageReqVO;
import com.luhu.computility.module.compute.controller.admin.resourceconfig.vo.ResourceConfigSaveReqVO;
import com.luhu.computility.module.compute.dal.dataobject.resourceconfig.ResourceConfigDO;
import com.luhu.computility.module.compute.dal.mysql.resourceconfig.ResourceConfigMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import static com.luhu.computility.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.luhu.computility.module.compute.enums.ErrorCodeConstants.RESOURCE_CONFIG_NOT_EXISTS;
import static com.luhu.computility.module.compute.enums.ResourceEnableStatus.ENABLE;
/**
* 算力资源配置 Service 实现类
*
* @author jony
*/
@Service
@Validated
public class ResourceConfigServiceImpl implements ResourceConfigService {
@Resource
private ResourceConfigMapper resourceConfigMapper;
@Override
public List<ResourceConfigDO> listSimpleConfigByCategory(String category) {
ResourceConfigPageReqVO queryVo = new ResourceConfigPageReqVO();
if (ObjectUtil.isEmpty(category)) {
queryVo.setConfigCategory(null);
} else {
queryVo.setConfigCategory(category);
}
queryVo.setStatus(ENABLE.getValue());
List<ResourceConfigDO> list = resourceConfigMapper.selectPage(queryVo).getList();
return list;
}
@Override
public Long createResourceConfig(ResourceConfigSaveReqVO createReqVO) {
// 插入
ResourceConfigDO resourceConfig = BeanUtils.toBean(createReqVO, ResourceConfigDO.class);
resourceConfigMapper.insert(resourceConfig);
// 返回
return resourceConfig.getId();
}
@Override
public void updateResourceConfig(ResourceConfigSaveReqVO updateReqVO) {
// 校验存在
validateResourceConfigExists(updateReqVO.getId());
// 更新
ResourceConfigDO updateObj = BeanUtils.toBean(updateReqVO, ResourceConfigDO.class);
resourceConfigMapper.updateById(updateObj);
}
@Override
public void deleteResourceConfig(Long id) {
// 校验存在
validateResourceConfigExists(id);
// 删除
resourceConfigMapper.deleteById(id);
}
@Override
public void deleteResourceConfigListByIds(List<Long> ids) {
// 删除
resourceConfigMapper.deleteByIds(ids);
}
private void validateResourceConfigExists(Long id) {
if (resourceConfigMapper.selectById(id) == null) {
throw exception(RESOURCE_CONFIG_NOT_EXISTS);
}
}
@Override
public ResourceConfigDO getResourceConfig(Long id) {
return resourceConfigMapper.selectById(id);
}
@Override
public PageResult<ResourceConfigDO> getResourceConfigPage(ResourceConfigPageReqVO pageReqVO) {
return resourceConfigMapper.selectPage(pageReqVO);
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.service.resourceorder;
import java.util.*;
import javax.validation.*;
import com.luhu.computility.module.compute.controller.admin.resourceorder.vo.*;
import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderCreateReqVO;
import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderCreateRespVO;
import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderPageReqVO;
import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderRespVO;
import com.luhu.computility.module.compute.controller.app.resourceorder.vo.AppResourceOrderInvoiceReqVO;
import com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.pojo.PageParam;
/**
* 算力资源订单 Service 接口
*
* @author jony
*/
public interface ResourceOrderService {
/**
* 创建算力资源订单
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createResourceOrder(@Valid ResourceOrderSaveReqVO createReqVO);
/**
* 更新算力资源订单
*
* @param updateReqVO 更新信息
*/
void updateResourceOrder(@Valid ResourceOrderSaveReqVO updateReqVO);
/**
* 删除算力资源订单
*
* @param id 编号
*/
void deleteResourceOrder(Long id);
/**
* 批量删除算力资源订单
*
* @param ids 编号
*/
void deleteResourceOrderListByIds(List<Long> ids);
/**
* 获得算力资源订单
*
* @param id 编号
* @return 算力资源订单
*/
ResourceOrderDO getResourceOrder(Long id);
/**
* 获得算力资源订单分页
*
* @param pageReqVO 分页查询
* @return 算力资源订单分页
*/
PageResult<ResourceOrderRespVO> getResourceOrderPage(ResourceOrderPageReqVO pageReqVO);
/**
* 用户创建算力资源订单
*
* @param userId 用户ID
* @param createReqVO 创建信息
* @return 创建响应
*/
AppResourceOrderCreateRespVO createUserResourceOrder(Long userId, @Valid AppResourceOrderCreateReqVO createReqVO);
/**
* 更新订单为已支付(支付回调使用)
*
* @param orderId 订单ID
* @param payOrderId 支付订单ID
*/
void updateOrderPaid(Long orderId, Long payOrderId);
/**
* 取消订单
*
* @param userId 用户ID
* @param orderId 订单ID
*/
void cancelOrder(Long userId, Long orderId);
/**
* 获得用户算力资源订单分页
*
* @param pageReqVO 分页查询
* @return 算力资源订单分页
*/
PageResult<AppResourceOrderRespVO> getUserResourceOrderPage(AppResourceOrderPageReqVO pageReqVO);
/**
* 获得用户算力资源订单详情
*
* @param userId 用户ID
* @param id 订单ID
* @return 算力资源订单详情
*/
AppResourceOrderRespVO getUserResourceOrder(Long userId, Long id);
/**
* 更新开票状态
*
* @param saveVO 保存信息
* @return 是否成功
*/
boolean updateInvoice(ResourceOrderSaveReqVO saveVO);
/**
* 用户申请开票
*
* @param reqVO 申请信息
* @return 是否成功
*/
boolean updateRequestInvoice(AppResourceOrderInvoiceReqVO reqVO);
}
\ No newline at end of file
package com.luhu.computility.module.compute.service.resourcesku;
import java.util.*;
import javax.validation.*;
import com.luhu.computility.module.compute.controller.admin.resourcesku.vo.*;
import com.luhu.computility.module.compute.dal.dataobject.resourcesku.ResourceSkuDO;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.pojo.PageParam;
/**
* 算力资源SKU表(价格和租赁信息) Service 接口
*
* @author jony
*/
public interface ResourceSkuService {
/**
* 创建算力资源SKU表(价格和租赁信息)
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createResourceSku(@Valid ResourceSkuSaveReqVO createReqVO);
/**
* 更新算力资源SKU表(价格和租赁信息)
*
* @param updateReqVO 更新信息
*/
void updateResourceSku(@Valid ResourceSkuSaveReqVO updateReqVO);
/**
* 删除算力资源SKU表(价格和租赁信息)
*
* @param id 编号
*/
void deleteResourceSku(Long id);
/**
* 批量删除算力资源SKU表(价格和租赁信息)
*
* @param ids 编号
*/
void deleteResourceSkuListByIds(List<Long> ids);
/**
* 获得算力资源SKU表(价格和租赁信息)
*
* @param id 编号
* @return 算力资源SKU表(价格和租赁信息)
*/
ResourceSkuDO getResourceSku(Long id);
/**
* 获得算力资源SKU表(价格和租赁信息)分页
*
* @param pageReqVO 分页查询
* @return 算力资源SKU表(价格和租赁信息)分页
*/
PageResult<ResourceSkuDO> getResourceSkuPage(ResourceSkuPageReqVO pageReqVO);
/**
* 根据SPU ID列表获得SKU列表
*
* @param spuIds SPU ID列表
* @param status 状态筛选(可选)
* @return SKU列表
*/
List<ResourceSkuDO> getResourceSkuListBySpuIds(List<Long> spuIds, Integer status);
}
\ No newline at end of file
package com.luhu.computility.module.compute.service.resourcesku;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.luhu.computility.module.compute.controller.admin.resourcesku.vo.*;
import com.luhu.computility.module.compute.dal.dataobject.resourcesku.ResourceSkuDO;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.pojo.PageParam;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import com.luhu.computility.module.compute.dal.mysql.resourcesku.ResourceSkuMapper;
import static com.luhu.computility.framework.common.exception.util.ServiceExceptionUtil.exception;
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.ResourceSkuStatus.ONLINE;
import static com.luhu.computility.framework.common.enums.CommonDeleteStatusEnum.NOT_DELETED;
/**
* 算力资源SKU表(价格和租赁信息) Service 实现类
*
* @author jony
*/
@Service
@Validated
public class ResourceSkuServiceImpl implements ResourceSkuService {
@Resource
private ResourceSkuMapper resourceSkuMapper;
@Override
public Long createResourceSku(ResourceSkuSaveReqVO createReqVO) {
// 插入
ResourceSkuDO resourceSku = BeanUtils.toBean(createReqVO, ResourceSkuDO.class);
resourceSkuMapper.insert(resourceSku);
// 返回
return resourceSku.getId();
}
@Override
public void updateResourceSku(ResourceSkuSaveReqVO updateReqVO) {
// 校验存在
validateResourceSkuExists(updateReqVO.getId());
// 更新
ResourceSkuDO updateObj = BeanUtils.toBean(updateReqVO, ResourceSkuDO.class);
resourceSkuMapper.updateById(updateObj);
}
@Override
public void deleteResourceSku(Long id) {
// 校验存在
validateResourceSkuExists(id);
// 删除
resourceSkuMapper.deleteById(id);
}
@Override
public void deleteResourceSkuListByIds(List<Long> ids) {
// 删除
resourceSkuMapper.deleteByIds(ids);
}
private void validateResourceSkuExists(Long id) {
if (resourceSkuMapper.selectById(id) == null) {
throw exception(RESOURCE_SKU_NOT_EXISTS);
}
}
@Override
public ResourceSkuDO getResourceSku(Long id) {
return resourceSkuMapper.selectById(id);
}
@Override
public PageResult<ResourceSkuDO> getResourceSkuPage(ResourceSkuPageReqVO pageReqVO) {
return resourceSkuMapper.selectPage(pageReqVO);
}
@Override
public List<ResourceSkuDO> getResourceSkuListBySpuIds(List<Long> spuIds, Integer status) {
if (spuIds == null || spuIds.isEmpty()) {
return Collections.emptyList();
}
LambdaQueryWrapper<ResourceSkuDO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(ResourceSkuDO::getSpuId, spuIds)
.eq(ResourceSkuDO::getDeleted, NOT_DELETED.getValue());
if (status != null) {
// 根据状态筛选
wrapper.eq(ResourceSkuDO::getStatus, status);
} else {
// 不筛选状态,只要未删除的,默认只查上架状态的
wrapper.eq(ResourceSkuDO::getStatus, ONLINE.getValue());
}
return resourceSkuMapper.selectList(wrapper);
}
}
\ No newline at end of file
package com.luhu.computility.module.compute.service.resourcespu;
import java.util.*;
import javax.validation.*;
import com.luhu.computility.module.compute.controller.admin.resourcespu.vo.*;
import com.luhu.computility.module.compute.dal.dataobject.resourcespu.ResourceSpuDO;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.pojo.PageParam;
/**
* 算力资源SPU表(基础配置信息) Service 接口
*
* @author jony
*/
public interface ResourceSpuService {
/**
* 创建算力资源SPU表(基础配置信息)
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createResourceSpu(@Valid ResourceSpuSaveReqVO createReqVO);
/**
* 更新算力资源SPU表(基础配置信息)
*
* @param updateReqVO 更新信息
*/
void updateResourceSpu(@Valid ResourceSpuSaveReqVO updateReqVO);
/**
* 删除算力资源SPU表(基础配置信息)
*
* @param id 编号
*/
void deleteResourceSpu(Long id);
/**
* 批量删除算力资源SPU表(基础配置信息)
*
* @param ids 编号
*/
void deleteResourceSpuListByIds(List<Long> ids);
/**
* 获得算力资源SPU表(基础配置信息)
*
* @param id 编号
* @return 算力资源SPU表(基础配置信息)
*/
ResourceSpuDO getResourceSpu(Long id);
/**
* 获得算力资源SPU表(基础配置信息)分页
*
* @param pageReqVO 分页查询
* @return 算力资源SPU表(基础配置信息)分页
*/
PageResult<ResourceSpuRespVO> getResourceSpuPage(ResourceSpuPageReqVO pageReqVO);
List<ResourceSpuSimpleRespVO> getResourceSimpleSpuList();
/**
* 根据ID列表获得算力资源SPU列表
*
* @param ids ID列表
* @return 算力资源SPU列表
*/
List<ResourceSpuDO> getResourceSpuListByIds(List<Long> ids);
/**
* 根据分类ID获得算力资源SPU列表
*
* @param categoryId 分类ID
* @return 算力资源SPU列表
*/
List<ResourceSpuDO> getResourceSpuListByCategoryId(Long categoryId);
/**
* 获取所有上架的算力资源SPU列表
*
* @return 上架的算力资源SPU列表
*/
List<ResourceSpuDO> getOnlineResourceSpuList();
}
\ No newline at end of file
package com.luhu.computility.module.compute.service.resourcespu;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.luhu.computility.module.compute.controller.admin.resourcespu.vo.*;
import com.luhu.computility.module.compute.dal.dataobject.resourcespu.ResourceSpuDO;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.pojo.PageParam;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import com.luhu.computility.module.compute.dal.mysql.resourcespu.ResourceSpuMapper;
import static com.luhu.computility.framework.common.exception.util.ServiceExceptionUtil.exception;
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;
import static com.luhu.computility.framework.common.enums.CommonDeleteStatusEnum.NOT_DELETED;
/**
* 算力资源SPU表(基础配置信息) Service 实现类
*
* @author jony
*/
@Service
@Validated
public class ResourceSpuServiceImpl implements ResourceSpuService {
@Resource
private ResourceSpuMapper resourceSpuMapper;
@Override
public Long createResourceSpu(ResourceSpuSaveReqVO createReqVO) {
// 插入
ResourceSpuDO resourceSpu = BeanUtils.toBean(createReqVO, ResourceSpuDO.class);
resourceSpuMapper.insert(resourceSpu);
// 返回
return resourceSpu.getId();
}
@Override
public void updateResourceSpu(ResourceSpuSaveReqVO updateReqVO) {
// 校验存在
validateResourceSpuExists(updateReqVO.getId());
// 更新
ResourceSpuDO updateObj = BeanUtils.toBean(updateReqVO, ResourceSpuDO.class);
resourceSpuMapper.updateById(updateObj);
}
@Override
public void deleteResourceSpu(Long id) {
// 校验存在
validateResourceSpuExists(id);
// 删除
resourceSpuMapper.deleteById(id);
}
@Override
public void deleteResourceSpuListByIds(List<Long> ids) {
// 删除
resourceSpuMapper.deleteByIds(ids);
}
private void validateResourceSpuExists(Long id) {
if (resourceSpuMapper.selectById(id) == null) {
throw exception(RESOURCE_SPU_NOT_EXISTS);
}
}
@Override
public ResourceSpuDO getResourceSpu(Long id) {
return resourceSpuMapper.selectById(id);
}
@Override
public PageResult<ResourceSpuRespVO> getResourceSpuPage(ResourceSpuPageReqVO pageReqVO) {
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);
}
@Override
public List<ResourceSpuDO> getResourceSpuListByIds(List<Long> ids) {
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
return resourceSpuMapper.selectBatchIds(ids);
}
@Override
public List<ResourceSpuDO> getResourceSpuListByCategoryId(Long categoryId) {
if (categoryId == null) {
return Collections.emptyList();
}
LambdaQueryWrapper<ResourceSpuDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ResourceSpuDO::getCategoryId, categoryId)
.eq(ResourceSpuDO::getStatus, ONLINE.getValue())
.eq(ResourceSpuDO::getDeleted, NOT_DELETED.getValue());
return resourceSpuMapper.selectList(wrapper);
}
@Override
public List<ResourceSpuDO> getOnlineResourceSpuList() {
LambdaQueryWrapper<ResourceSpuDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ResourceSpuDO::getStatus, ONLINE.getValue())
.eq(ResourceSpuDO::getDeleted, NOT_DELETED.getValue());
return resourceSpuMapper.selectList(wrapper);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.luhu.computility.module.compute.dal.mysql.resourcecategory.ResourceCategoryMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.luhu.computility.module.compute.dal.mysql.resourceconfig.ResourceConfigMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.luhu.computility.module.compute.dal.mysql.resourceorder.ResourceOrderMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.luhu.computility.module.compute.dal.mysql.resourcesku.ResourceSkuMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.luhu.computility.module.compute.dal.mysql.resourcespu.ResourceSpuMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>computility</artifactId>
<groupId>com.luhu</groupId>
<version>${revision}</version>
</parent>
<modules>
<module>computility-module-compute-api</module>
<module>computility-module-compute-biz</module>
</modules>
<modelVersion>4.0.0</modelVersion>
<artifactId>computility-module-compute</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>
算力资源
</description>
</project>
\ No newline at end of file
package com.luhu.computility.module.trade.controller.app.order;
import cn.hutool.core.collection.CollectionUtil;
import com.google.common.collect.Maps;
import com.luhu.computility.framework.common.exception.ServiceException;
import com.luhu.computility.framework.common.pojo.CommonResult;
import com.luhu.computility.framework.common.pojo.PageResult;
......@@ -12,26 +13,21 @@ import com.luhu.computility.module.trade.controller.app.order.vo.*;
import com.luhu.computility.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO;
import com.luhu.computility.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO;
import com.luhu.computility.module.trade.convert.order.TradeOrderConvert;
import com.luhu.computility.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import com.luhu.computility.module.trade.dal.dataobject.order.TradeOrderDO;
import com.luhu.computility.module.trade.dal.dataobject.order.TradeOrderItemDO;
import com.luhu.computility.module.trade.enums.order.TradeOrderInvoiceStatusEnum;
import com.luhu.computility.module.trade.enums.order.TradeOrderStatusEnum;
import com.luhu.computility.module.trade.enums.order.TradeOrderTypeEnum;
import com.luhu.computility.module.trade.framework.order.config.TradeOrderProperties;
import com.luhu.computility.module.trade.service.aftersale.AfterSaleService;
import com.luhu.computility.module.trade.service.delivery.DeliveryExpressService;
import com.luhu.computility.module.trade.service.order.TradeOrderQueryService;
import com.luhu.computility.module.trade.service.order.TradeOrderToResourceService;
import com.luhu.computility.module.trade.service.order.TradeOrderUpdateService;
import com.luhu.computility.module.trade.service.price.TradePriceService;
import com.google.common.collect.Maps;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.C;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......
......@@ -802,6 +802,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
@Override
public boolean updateRequestInvoice(AppTradeOrderInvoiceReqVO reqVO) {
TradeOrderDO tradeOrderDO = tradeOrderMapper.selectById(reqVO.getId());
if (tradeOrderDO == null) {
throw new ServiceException("订单不存在,请检查订单ID是否正确");
}
Integer status = tradeOrderDO.getStatus();//订单状态
if(status.equals(UNPAID.getStatus())){
throw new ServiceException("未支付的订单不能申请开票");
......
......@@ -99,6 +99,11 @@
</dependency>
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-module-compute-biz</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.luhu</groupId>
<artifactId>computility-module-external</artifactId>
<version>${revision}</version>
</dependency>
......
......@@ -42,9 +42,13 @@ spring:
primary: master
datasource:
master:
url: jdbc:mysql://43.139.100.220:13306/new_computility?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
# 重点加了 catalog=new_computility,强制绑定数据库目录
url: jdbc:mysql://8.136.9.68:3306/new_computility?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&catalog=new_computility
username: root
password: D7kaJdNdLsjzXGhD
password: Luchuan@123
#url: jdbc:mysql://43.139.100.220:13306/new_computility?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
#username: root
#password: D7kaJdNdLsjzXGhD
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
redis:
......@@ -161,9 +165,9 @@ computility:
captcha:
enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试;
pay:
order-notify-url: https://phsl.lijinqi.com/admin-api/pay/notify/order # 支付渠道的【支付】回调地址
refund-notify-url: https://phsl.lijinqi.com/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址
transfer-notify-url: https://phsl.lijinqi.com/admin-api/pay/notify/transfer # 支付渠道的【转账】回调地址
order-notify-url: https://phslgld.hnluchuan.com/admin-api/pay/notify/order # 支付渠道的【支付】回调地址
refund-notify-url: https://phslgld.hnluchuan.com/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址
transfer-notify-url: https://phslgld.hnluchuan.com/admin-api/pay/notify/transfer # 支付渠道的【转账】回调地址
access-log: # 访问日志的配置项
enable: true
demo: false # 开启演示模式
......
......@@ -55,12 +55,17 @@ spring:
primary: master
datasource:
master:
url: jdbc:mysql://43.139.100.220:13306/new_computility?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
#url: jdbc:mysql://localhost/new_computility?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
#username: root
#password: 159357 # D7kaJdNdLsjzXGhD
#url: jdbc:mysql://43.139.100.220:13306/new_computility?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
#username: root
#password: D7kaJdNdLsjzXGhD
url: jdbc:mysql://8.136.9.68:3306/new_computility?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
username: root
password: D7kaJdNdLsjzXGhD
password: Luchuan@123
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
redis:
host: 127.0.0.1 # 地址
......
......@@ -362,6 +362,9 @@ computility:
receive-expire-time: 14d # 收货的过期时间
comment-expire-time: 7d # 评论的过期时间
status-sync-to-wxa-enable: true # 是否同步订单状态到微信小程序
compute:
order:
pay-expire-time: 30m # 支付的过期时间,30分钟
express:
client: kd_100
......
......@@ -23,6 +23,7 @@
<module>computility-module-mall</module>
<module>computility-module-biz</module>
<module>computility-module-apihub</module>
<module>computility-module-compute</module>
<module>computility-module-external</module>
<!-- <module>computility-module-crm</module>-->
<!-- <module>computility-module-erp</module>-->
......@@ -60,6 +61,11 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version> <!-- 可根据实际情况调整版本号 -->
</dependency>
</dependencies>
</dependencyManagement>
......@@ -72,6 +78,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<!-- maven-compiler-plugin 插件,解决 spring-boot-configuration-processor + Lombok + MapStruct 组合 -->
<!-- https://stackoverflow.com/questions/33483697/re-run-spring-boot-configuration-annotation-processor-to-update-generated-metada -->
......
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