功能迭代

This commit is contained in:
张锐 committed 2026-12-01 17:45:37 +08:00
1 parent 9df10ca806
commit 5fc7d4564c
11 files changed
+227 -11

No files matched your search

@@ -5,6 +5,8 @@ import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.util.List;
/** 后台保存产品公共内容模板请求。 */
public record SaveProductTemplateAdminReq(
/** 模板业务编号,新增时为空。 */ @Size(max = 16) String templateCode,
@@ -12,6 +14,7 @@ public record SaveProductTemplateAdminReq(
/** 模板名称。 */ @NotBlank @Size(max = 100) String templateName,
/** 模板用途说明。 */ @Size(max = 500) String description,
/** 模板英文富文本内容。 */ @NotBlank String templateContent,
/** 关联推荐产品业务编号,最多选择 12 个。 */ @Size(max = 12) List<@Size(max = 16) String> relatedProductCodes,
/** 发布状态。 */ @NotNull PublishStatusEnum status,
/** 模板排序值。 */ @NotNull Integer sortNo) {
}
@@ -1,11 +1,14 @@
package com.shoplix.admin.modules.product.res;
import java.util.List;
/** 后台产品公共内容模板响应。 */
public record ProductTemplateAdminRes(
/** 模板业务编号。 */ String templateCode,
/** 模板名称。 */ String templateName,
/** 模板用途说明。 */ String description,
/** 模板英文富文本内容。 */ String templateContent,
/** 关联推荐产品业务编号。 */ List<String> relatedProductCodes,
/** 发布状态。 */ String status,
/** 模板排序值。 */ Integer sortNo,
/** 更新时间毫秒时间戳。 */ Long updateTime) {
@@ -245,6 +245,14 @@ public class AdminProductService {
entity.setTemplateName(request.templateName().trim());
entity.setDescription(request.description());
entity.setTemplateContent(request.templateContent());
List<String> relatedProductCodes = request.relatedProductCodes() == null ? List.of()
: request.relatedProductCodes().stream().filter(code -> code != null && !code.isBlank()).distinct().toList();
for (String productCode : relatedProductCodes) {
if (repository.findByCode(request.siteCode(), productCode).isEmpty()) {
throw templateException("PRODUCT_TEMPLATE_RELATED_PRODUCT_NOT_FOUND", ProductTemplateMessageKeys.UNAVAILABLE);
}
}
entity.setRelatedProductCodes(String.join(",", relatedProductCodes));
entity.setStatus(request.status().name());
entity.setSortNo(request.sortNo());
entity.setUpdateTime(System.currentTimeMillis());
@@ -283,7 +291,14 @@ public class AdminProductService {
/** 转换产品公共内容模板响应。 */
private ProductTemplateAdminRes toTemplateResponse(ProductContentTemplateEntity entity) {
return new ProductTemplateAdminRes(entity.getTemplateCode(), entity.getTemplateName(), entity.getDescription(),
entity.getTemplateContent(), entity.getStatus(), entity.getSortNo(), entity.getUpdateTime());
entity.getTemplateContent(), splitProductCodes(entity.getRelatedProductCodes()), entity.getStatus(),
entity.getSortNo(), entity.getUpdateTime());
}
/** 拆分模板关联产品业务编号。 */
private List<String> splitProductCodes(String value) {
return value == null || value.isBlank() ? List.of()
: java.util.Arrays.stream(value.split(",")).map(String::trim).filter(code -> !code.isBlank()).toList();
}
/** 创建已完成多语言解析的产品模板业务异常。 */
@@ -0,0 +1,2 @@
ALTER TABLE product_content_template
ADD COLUMN related_product_codes VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '关联推荐产品业务编号列表,多个编号使用英文逗号分隔' AFTER template_content;