feat: initialize shoplix platform
This commit is contained in:
commit
de2074a43b
277 files changed
+10407
No files matched your search
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.shoplix</groupId>
|
||||
<artifactId>shoplix-parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>shoplix-service</artifactId>
|
||||
<name>shoplix-service</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.shoplix.common.code.enums;
|
||||
|
||||
/** 业务编号三位前缀。 */
|
||||
public enum BusinessCodePrefixEnum {
|
||||
SITE("SIT"), DOMAIN("DOM"), PRODUCT("PRD"), SKU("SKU"), CATEGORY("CAT"),
|
||||
PRODUCT_CATEGORY("PCT"), PRODUCT_CATEGORY_RELATION("PCR"), PRODUCT_ATTRIBUTE("PAT"),
|
||||
PRODUCT_ATTRIBUTE_OPTION("PAO"), PRODUCT_ATTRIBUTE_VALUE("PAV"), PRODUCT_SPECIFICATION("PSP"),
|
||||
PRODUCT_RELATION("PRR"), CONTENT("CNT"), CONTENT_CATEGORY("CCT"),
|
||||
CONTENT_CATEGORY_RELATION("CCR"), CONTENT_PRODUCT_RELATION("CPR"),
|
||||
CASE("CAS"), NEWS("NWS"), PAGE("PAG"), SERVICE("SRV"), HELP("HLP"),
|
||||
DECORATION("DEC"), CUSTOM_CODE("CCD"), NAVIGATION("NAV"),
|
||||
NAVIGATION_ITEM("NVI"), FORM("FRM"), FORM_FIELD("FFD"), INQUIRY("INQ"),
|
||||
INQUIRY_SETTING("IST"), INQUIRY_FIELD_VALUE("IFV"), INQUIRY_ATTACHMENT("IAT"),
|
||||
INQUIRY_LOG("ILG"), INQUIRY_RECEIVER("IRC"), MAIL_TASK("MLT"), CUSTOMER("CUS"),
|
||||
CONTACT("CON"), LEAD("LED"), FOLLOW_UP("FLW"), MEDIA("MED"), SEO("SEO"), SEO_HEADING("SEH"),
|
||||
PUBLISH("PUB"), JOB("JOB"), USER("USR"), ROLE("ROL");
|
||||
|
||||
/** 三位业务前缀。 */
|
||||
private final String prefix;
|
||||
|
||||
/** 创建业务前缀枚举。 */
|
||||
BusinessCodePrefixEnum(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
/** 获取三位业务前缀。 */
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.shoplix.common.exception;
|
||||
|
||||
/** 携带稳定错误码的业务异常。 */
|
||||
public class BusinessException extends RuntimeException {
|
||||
/** 稳定业务错误码。 */
|
||||
private final String code;
|
||||
|
||||
/** 创建业务异常。 */
|
||||
public BusinessException(String code, String message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/** 获取业务错误码。 */
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.shoplix.common.utils;
|
||||
|
||||
import com.shoplix.common.code.enums.BusinessCodePrefixEnum;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/** 生成固定十六位大写字母数字业务编号。 */
|
||||
@Component
|
||||
public class BusinessCodeUtils {
|
||||
private static final long EPOCH = 1767225600000L;
|
||||
private static final int WORKER_BITS = 8;
|
||||
private static final int SEQUENCE_BITS = 12;
|
||||
private static final long MAX_WORKER_ID = (1L << WORKER_BITS) - 1;
|
||||
private static final long MAX_SEQUENCE = (1L << SEQUENCE_BITS) - 1;
|
||||
|
||||
/** 当前服务实例节点编号。 */
|
||||
private final long workerId;
|
||||
/** 上一次生成编号的毫秒时间。 */
|
||||
private long lastTimestamp = -1L;
|
||||
/** 当前毫秒内的递增序号。 */
|
||||
private long sequence;
|
||||
|
||||
/** 使用配置的节点编号创建生成器。 */
|
||||
public BusinessCodeUtils(@Value("${shoplix.code.worker-id:1}") long workerId) {
|
||||
if (workerId < 0 || workerId > MAX_WORKER_ID) {
|
||||
throw new IllegalArgumentException("shoplix.code.worker-id must be between 0 and " + MAX_WORKER_ID);
|
||||
}
|
||||
this.workerId = workerId;
|
||||
}
|
||||
|
||||
/** 根据业务类型生成固定十六位编号。 */
|
||||
public synchronized String generate(BusinessCodePrefixEnum businessType) {
|
||||
long timestamp = Instant.now().toEpochMilli();
|
||||
if (timestamp < lastTimestamp) {
|
||||
throw new IllegalStateException("System clock moved backwards");
|
||||
}
|
||||
if (timestamp == lastTimestamp) {
|
||||
sequence = (sequence + 1) & MAX_SEQUENCE;
|
||||
if (sequence == 0) {
|
||||
timestamp = waitNextMillis(lastTimestamp);
|
||||
}
|
||||
} else {
|
||||
sequence = 0;
|
||||
}
|
||||
lastTimestamp = timestamp;
|
||||
long numericId = ((timestamp - EPOCH) << (WORKER_BITS + SEQUENCE_BITS))
|
||||
| (workerId << SEQUENCE_BITS) | sequence;
|
||||
String payload = Long.toUnsignedString(numericId, 36).toUpperCase();
|
||||
return businessType.getPrefix() + "0".repeat(13 - payload.length()) + payload;
|
||||
}
|
||||
|
||||
/** 等待进入下一毫秒。 */
|
||||
private long waitNextMillis(long previousTimestamp) {
|
||||
long timestamp = Instant.now().toEpochMilli();
|
||||
while (timestamp <= previousTimestamp) {
|
||||
Thread.onSpinWait();
|
||||
timestamp = Instant.now().toEpochMilli();
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.shoplix.common.utils;
|
||||
import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.HexFormat;
|
||||
/** 隐私数据不可逆摘要工具。 */
|
||||
public final class HashUtils {
|
||||
/** 禁止实例化工具类。 */ private HashUtils() {}
|
||||
/** 使用盐生成SHA-256十六进制摘要。 */ public static String sha256(String value,String salt){try{return HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest((salt+":"+value).getBytes(StandardCharsets.UTF_8)));}catch(NoSuchAlgorithmException e){throw new IllegalStateException("SHA-256 unavailable",e);}}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.shoplix.modules.common.enums;
|
||||
|
||||
/** 内容发布状态。 */
|
||||
public enum PublishStatusEnum {
|
||||
DRAFT, PUBLISHED, OFFLINE
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.shoplix.modules.content.enums;
|
||||
|
||||
/** 内容中心类型。 */
|
||||
public enum ContentTypeEnum {
|
||||
NEWS, CASE, HELP
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.shoplix.modules.content.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/** 内容分类持久化实体。 */
|
||||
@Data
|
||||
@TableName("content_category")
|
||||
public class ContentCategoryEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type = IdType.AUTO) private Long id;
|
||||
/** 分类业务编号。 */ private String categoryCode;
|
||||
/** 所属站点业务编号。 */ private String siteCode;
|
||||
/** 内容类型。 */ private String contentType;
|
||||
/** 父分类业务编号。 */ private String parentCategoryCode;
|
||||
/** 英文分类名称。 */ private String categoryName;
|
||||
/** 英文路径标识。 */ private String slug;
|
||||
/** 英文分类描述。 */ private String description;
|
||||
/** 封面媒体业务编号。 */ private String coverMediaCode;
|
||||
/** 排序值。 */ private Integer sortNo;
|
||||
/** 发布状态。 */ private String status;
|
||||
/** 逻辑删除状态。 */ private Integer deleted;
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.shoplix.modules.content.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** 新闻、案例和帮助统一内容持久化实体。 */
|
||||
@Data
|
||||
@TableName("content")
|
||||
public class ContentEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type = IdType.AUTO) private Long id;
|
||||
/** 内容业务编号。 */ private String contentCode;
|
||||
/** 所属站点业务编号。 */ private String siteCode;
|
||||
/** 内容类型。 */ private String contentType;
|
||||
/** 主分类业务编号。 */ private String primaryCategoryCode;
|
||||
/** 英文标题。 */ private String title;
|
||||
/** 英文路径标识。 */ private String slug;
|
||||
/** 英文摘要。 */ private String summary;
|
||||
/** 英文富文本正文。 */ private String contentBody;
|
||||
/** 封面媒体业务编号。 */ private String coverMediaCode;
|
||||
/** 作者名称。 */ private String authorName;
|
||||
/** 内容来源。 */ private String sourceName;
|
||||
/** 推荐标识。 */ private Integer featuredFlag;
|
||||
/** 排序值。 */ private Integer sortNo;
|
||||
/** 发布状态。 */ private String status;
|
||||
/** 发布时间。 */ private LocalDateTime publishTime;
|
||||
/** 下线时间。 */ private LocalDateTime offlineTime;
|
||||
/** 浏览次数。 */ private Long viewCount;
|
||||
/** 逻辑删除状态。 */ private Integer deleted;
|
||||
/** 创建时间。 */ private LocalDateTime createTime;
|
||||
/** 更新时间。 */ private LocalDateTime updateTime;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.modules.content.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.content.repository.entity.ContentCategoryEntity;
|
||||
|
||||
/** 内容分类基础 Mapper。 */
|
||||
public interface ContentCategoryMapper extends BaseMapper<ContentCategoryEntity> {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.modules.content.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.content.repository.entity.ContentEntity;
|
||||
|
||||
/** 内容基础 Mapper。 */
|
||||
public interface ContentMapper extends BaseMapper<ContentEntity> {
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.shoplix.modules.content.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.content.repository.entity.ContentCategoryEntity;
|
||||
import com.shoplix.modules.content.repository.mapper.ContentCategoryMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/** 内容分类单表数据源服务。 */
|
||||
@Service
|
||||
public class ContentCategoryRepositoryService {
|
||||
private final ContentCategoryMapper mapper;
|
||||
/** 注入内容分类 Mapper。 */ public ContentCategoryRepositoryService(ContentCategoryMapper mapper) { this.mapper = mapper; }
|
||||
/** 查询站点指定类型分类。 */
|
||||
public List<ContentCategoryEntity> list(String siteCode, String type, boolean publishedOnly) {
|
||||
var query = Wrappers.<ContentCategoryEntity>lambdaQuery().eq(ContentCategoryEntity::getSiteCode, siteCode)
|
||||
.eq(ContentCategoryEntity::getContentType, type);
|
||||
if (publishedOnly) query.eq(ContentCategoryEntity::getStatus, "PUBLISHED");
|
||||
return mapper.selectList(query.orderByAsc(ContentCategoryEntity::getSortNo));
|
||||
}
|
||||
/** 按站点和分类业务编号查询分类。 */
|
||||
public Optional<ContentCategoryEntity> findByCode(String siteCode, String categoryCode) {
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<ContentCategoryEntity>lambdaQuery()
|
||||
.eq(ContentCategoryEntity::getSiteCode, siteCode)
|
||||
.eq(ContentCategoryEntity::getCategoryCode, categoryCode)));
|
||||
}
|
||||
/** 新增内容分类。 */
|
||||
public int insert(ContentCategoryEntity entity) { return mapper.insert(entity); }
|
||||
/** 按业务编号更新内容分类。 */
|
||||
public int updateByCode(ContentCategoryEntity entity) {
|
||||
return mapper.update(entity, Wrappers.<ContentCategoryEntity>lambdaUpdate()
|
||||
.eq(ContentCategoryEntity::getSiteCode, entity.getSiteCode())
|
||||
.eq(ContentCategoryEntity::getCategoryCode, entity.getCategoryCode()));
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.shoplix.modules.content.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.content.repository.entity.ContentEntity;
|
||||
import com.shoplix.modules.content.repository.mapper.ContentMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/** 内容单表数据源服务。 */
|
||||
@Service
|
||||
public class ContentRepositoryService {
|
||||
private final ContentMapper mapper;
|
||||
/** 注入内容 Mapper。 */ public ContentRepositoryService(ContentMapper mapper) { this.mapper = mapper; }
|
||||
/** 按站点和业务编号查询。 */
|
||||
public Optional<ContentEntity> findByCode(String siteCode, String contentCode) {
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<ContentEntity>lambdaQuery()
|
||||
.eq(ContentEntity::getSiteCode, siteCode).eq(ContentEntity::getContentCode, contentCode)
|
||||
.eq(ContentEntity::getDeleted, 0).last("LIMIT 1")));
|
||||
}
|
||||
/** 按站点、类型和路径查询已发布内容。 */
|
||||
public Optional<ContentEntity> findPublishedBySlug(String siteCode, String type, String slug) {
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<ContentEntity>lambdaQuery()
|
||||
.eq(ContentEntity::getSiteCode, siteCode).eq(ContentEntity::getContentType, type)
|
||||
.eq(ContentEntity::getSlug, slug).eq(ContentEntity::getStatus, "PUBLISHED").last("LIMIT 1")));
|
||||
}
|
||||
/** 查询站点指定类型的后台内容列表。 */
|
||||
public List<ContentEntity> list(String siteCode, String type) {
|
||||
return mapper.selectList(Wrappers.<ContentEntity>lambdaQuery().eq(ContentEntity::getSiteCode, siteCode)
|
||||
.eq(ContentEntity::getDeleted, 0)
|
||||
.eq(ContentEntity::getContentType, type).orderByDesc(ContentEntity::getPublishTime)
|
||||
.orderByDesc(ContentEntity::getUpdateTime));
|
||||
}
|
||||
/** 查询站点指定类型的已发布内容列表。 */
|
||||
public List<ContentEntity> listPublished(String siteCode, String type) {
|
||||
return mapper.selectList(Wrappers.<ContentEntity>lambdaQuery().eq(ContentEntity::getSiteCode, siteCode)
|
||||
.eq(ContentEntity::getContentType, type).eq(ContentEntity::getStatus, "PUBLISHED")
|
||||
.orderByDesc(ContentEntity::getFeaturedFlag).orderByDesc(ContentEntity::getPublishTime));
|
||||
}
|
||||
/** 新增内容。 */ public int insert(ContentEntity entity) { return mapper.insert(entity); }
|
||||
/** 按内容业务编号更新。 */
|
||||
public int updateByCode(ContentEntity entity) {
|
||||
return mapper.update(entity, Wrappers.<ContentEntity>lambdaUpdate()
|
||||
.eq(ContentEntity::getSiteCode, entity.getSiteCode()).eq(ContentEntity::getContentCode, entity.getContentCode()));
|
||||
}
|
||||
/** 按业务编号逻辑删除内容。 */
|
||||
public int deleteByCode(String siteCode, String contentCode) {
|
||||
return mapper.update(null, Wrappers.<ContentEntity>lambdaUpdate().set(ContentEntity::getDeleted, 1)
|
||||
.eq(ContentEntity::getSiteCode, siteCode).eq(ContentEntity::getContentCode, contentCode)
|
||||
.eq(ContentEntity::getDeleted, 0));
|
||||
}
|
||||
/** 按业务编号更新内容发布状态。 */
|
||||
public int updateStatus(String siteCode, String contentCode, String status, java.time.LocalDateTime publishTime,
|
||||
java.time.LocalDateTime offlineTime) {
|
||||
return mapper.update(null, Wrappers.<ContentEntity>lambdaUpdate().set(ContentEntity::getStatus, status)
|
||||
.set(ContentEntity::getPublishTime, publishTime).set(ContentEntity::getOfflineTime, offlineTime)
|
||||
.eq(ContentEntity::getSiteCode, siteCode).eq(ContentEntity::getContentCode, contentCode)
|
||||
.eq(ContentEntity::getDeleted, 0));
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.shoplix.modules.customcode.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** 前台站自定义代码持久化实体。 */
|
||||
@Data
|
||||
@TableName("site_custom_code")
|
||||
public class SiteCustomCodeEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type = IdType.AUTO) private Long id;
|
||||
/** 自定义代码业务编号。 */ private String code;
|
||||
/** 所属站点业务编号。 */ private String siteCode;
|
||||
/** 代码标题。 */ private String title;
|
||||
/** 代码内容。 */ private String content;
|
||||
/** 语言站点:ALL全部,或具体语言编码。 */ private String locale;
|
||||
/** 终端类型:ALL全部,DESKTOP桌面,MOBILE移动端。 */ private String device;
|
||||
/** 注入位置:HEAD顶部,BODY_START正文顶部,BODY_END正文底部。 */ private String position;
|
||||
/** 是否启用:0停用,1启用。 */ private Integer enabled;
|
||||
/** 排序号。 */ private Integer sortNo;
|
||||
/** 创建时间。 */ private LocalDateTime createTime;
|
||||
/** 更新时间。 */ private LocalDateTime updateTime;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.shoplix.modules.customcode.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.customcode.repository.entity.SiteCustomCodeEntity;
|
||||
|
||||
/** 前台站自定义代码 Mapper。 */
|
||||
public interface SiteCustomCodeMapper extends BaseMapper<SiteCustomCodeEntity> { }
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.shoplix.modules.customcode.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.customcode.repository.entity.SiteCustomCodeEntity;
|
||||
import com.shoplix.modules.customcode.repository.mapper.SiteCustomCodeMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
/** 前台站自定义代码数据源服务。 */
|
||||
@Service
|
||||
public class SiteCustomCodeRepositoryService {
|
||||
private final SiteCustomCodeMapper mapper;
|
||||
/** 注入自定义代码 Mapper。 */ public SiteCustomCodeRepositoryService(SiteCustomCodeMapper mapper) { this.mapper = mapper; }
|
||||
/** 查询站点全部代码。 */ public List<SiteCustomCodeEntity> list(String siteCode) { return mapper.selectList(Wrappers.<SiteCustomCodeEntity>lambdaQuery().eq(SiteCustomCodeEntity::getSiteCode, siteCode).orderByAsc(SiteCustomCodeEntity::getSortNo).orderByAsc(SiteCustomCodeEntity::getId)); }
|
||||
/** 查询站点已启用代码。 */ public List<SiteCustomCodeEntity> listEnabled(String siteCode) { return mapper.selectList(Wrappers.<SiteCustomCodeEntity>lambdaQuery().eq(SiteCustomCodeEntity::getSiteCode, siteCode).eq(SiteCustomCodeEntity::getEnabled, 1).orderByAsc(SiteCustomCodeEntity::getSortNo).orderByAsc(SiteCustomCodeEntity::getId)); }
|
||||
/** 新增代码。 */ public int insert(SiteCustomCodeEntity entity) { return mapper.insert(entity); }
|
||||
/** 更新代码。 */ public int update(SiteCustomCodeEntity entity) { return mapper.updateById(entity); }
|
||||
/** 删除代码。 */ public int delete(String siteCode, String code) { return mapper.delete(Wrappers.<SiteCustomCodeEntity>lambdaQuery().eq(SiteCustomCodeEntity::getSiteCode, siteCode).eq(SiteCustomCodeEntity::getCode, code)); }
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.shoplix.modules.decoration.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** 前台站页面装修持久化实体。 */
|
||||
@Data
|
||||
@TableName("site_decoration")
|
||||
public class SiteDecorationEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type = IdType.AUTO) private Long id;
|
||||
/** 装修配置业务编号。 */ private String decorationCode;
|
||||
/** 所属站点业务编号。 */ private String siteCode;
|
||||
/** 装修页面类型。 */ private String pageType;
|
||||
/** 装修草稿 JSON。 */ private String draftSchema;
|
||||
/** 已发布装修 JSON。 */ private String publishedSchema;
|
||||
/** 已发布版本号。 */ private Integer publishedVersion;
|
||||
/** 装修状态:DRAFT草稿,PUBLISHED已发布。 */ private String status;
|
||||
/** 逻辑删除状态:0未删除,1已删除。 */ private Integer deleted;
|
||||
/** 创建时间。 */ private LocalDateTime createTime;
|
||||
/** 更新时间。 */ private LocalDateTime updateTime;
|
||||
/** 最近发布时间。 */ private LocalDateTime publishTime;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.modules.decoration.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.decoration.repository.entity.SiteDecorationEntity;
|
||||
|
||||
/** 页面装修基础 Mapper。 */
|
||||
public interface SiteDecorationMapper extends BaseMapper<SiteDecorationEntity> {
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.shoplix.modules.decoration.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.decoration.repository.entity.SiteDecorationEntity;
|
||||
import com.shoplix.modules.decoration.repository.mapper.SiteDecorationMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Optional;
|
||||
|
||||
/** 页面装修单表数据源服务。 */
|
||||
@Service
|
||||
public class SiteDecorationRepositoryService {
|
||||
private final SiteDecorationMapper mapper;
|
||||
/** 注入页面装修 Mapper。 */ public SiteDecorationRepositoryService(SiteDecorationMapper mapper) { this.mapper = mapper; }
|
||||
/** 按站点和页面类型查询装修配置。 */
|
||||
public Optional<SiteDecorationEntity> find(String siteCode, String pageType) {
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<SiteDecorationEntity>lambdaQuery()
|
||||
.eq(SiteDecorationEntity::getSiteCode, siteCode).eq(SiteDecorationEntity::getPageType, pageType).last("LIMIT 1")));
|
||||
}
|
||||
/** 新增装修配置。 */ public int insert(SiteDecorationEntity entity) { return mapper.insert(entity); }
|
||||
/** 按业务编号更新装修配置。 */
|
||||
public int updateByCode(SiteDecorationEntity entity) {
|
||||
return mapper.update(entity, Wrappers.<SiteDecorationEntity>lambdaUpdate()
|
||||
.eq(SiteDecorationEntity::getDecorationCode, entity.getDecorationCode())
|
||||
.eq(SiteDecorationEntity::getSiteCode, entity.getSiteCode()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.shoplix.modules.inquiry.enums;
|
||||
|
||||
/** 询盘表单字段类型。 */
|
||||
public enum InquiryFieldTypeEnum { TEXT, TEXTAREA, EMAIL, PHONE, NUMBER, SINGLE_SELECT, MULTI_SELECT, RADIO, CHECKBOX, FILE, COUNTRY }
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.shoplix.modules.inquiry.enums;
|
||||
|
||||
/** 询盘来源及表单场景。 */
|
||||
public enum InquirySceneEnum { GENERAL, PRODUCT, CONTENT, PAGE, CONTACT }
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.shoplix.modules.inquiry.enums;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/** 询盘处理状态及允许操作。 */
|
||||
public enum InquiryStatusEnum {
|
||||
NEW("新询盘", Set.of("ASSIGN", "CONFIRM_VALID", "MARK_SPAM", "CLOSE")),
|
||||
VALID("有效询盘", Set.of("ASSIGN", "FOLLOW", "MARK_SPAM", "CLOSE", "CONVERT_LEAD")),
|
||||
FOLLOWING("跟进中", Set.of("ASSIGN", "QUOTE", "MARK_WON", "MARK_LOST", "CLOSE", "CONVERT_LEAD")),
|
||||
QUOTED("已报价", Set.of("FOLLOW", "MARK_WON", "MARK_LOST", "CLOSE")),
|
||||
WON("已成交", Set.of("CLOSE")), LOST("已丢单", Set.of("FOLLOW", "CLOSE")),
|
||||
SPAM("垃圾询盘", Set.of("RESTORE")), CLOSED("已关闭", Set.of("RESTORE"));
|
||||
/** 中文状态文案。 */ private final String label;
|
||||
/** 当前状态允许操作。 */ private final Set<String> operations;
|
||||
/** 创建询盘状态。 */ InquiryStatusEnum(String label, Set<String> operations) { this.label = label; this.operations = operations; }
|
||||
/** 获取中文状态文案。 */ public String getLabel() { return label; }
|
||||
/** 获取允许操作。 */ public Set<String> getOperations() { return operations; }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.shoplix.modules.inquiry.repository.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*; import lombok.Data;
|
||||
/** 询盘动态字段值持久化实体。 */ @Data @TableName("inquiry_field_value")
|
||||
public class InquiryFieldValueEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type=IdType.AUTO) private Long id; /** 字段值业务编号。 */ private String valueCode;
|
||||
/** 站点业务编号。 */ private String siteCode; /** 询盘业务编号。 */ private String inquiryCode; /** 字段业务编号。 */ private String fieldCode;
|
||||
/** 字段键快照。 */ private String fieldKey; /** 字段标签快照。 */ private String fieldLabelSnapshot; /** 字段类型快照。 */ private String fieldTypeSnapshot;
|
||||
/** 提交值。 */ private String fieldValue; /** 排序值。 */ private Integer sortNo; /** 逻辑删除状态。 */ private Integer deleted;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.shoplix.modules.inquiry.repository.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*; import lombok.Data;
|
||||
/** 询盘表单持久化实体。 */ @Data @TableName("inquiry_form")
|
||||
public class InquiryFormEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type=IdType.AUTO) private Long id; /** 表单业务编号。 */ private String formCode;
|
||||
/** 站点业务编号。 */ private String siteCode; /** 后台表单名称。 */ private String formName; /** 表单场景。 */ private String formScene;
|
||||
/** 提交按钮英文文字。 */ private String submitButtonText; /** 英文成功提示。 */ private String successMessage;
|
||||
/** 隐私页面业务编号。 */ private String privacyPageCode; /** 发布状态。 */ private String status;
|
||||
/** 已发布版本号。 */ private Integer publishedVersion; /** 排序值。 */ private Integer sortNo; /** 逻辑删除状态。 */ private Integer deleted;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.shoplix.modules.inquiry.repository.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*; import lombok.Data;
|
||||
/** 询盘表单字段持久化实体。 */ @Data @TableName("inquiry_form_field")
|
||||
public class InquiryFormFieldEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type=IdType.AUTO) private Long id; /** 字段业务编号。 */ private String fieldCode;
|
||||
/** 站点业务编号。 */ private String siteCode; /** 表单业务编号。 */ private String formCode; /** 稳定字段键。 */ private String fieldKey;
|
||||
/** 英文字段标签。 */ private String fieldLabel; /** 字段类型。 */ private String fieldType; /** 英文占位提示。 */ private String placeholder;
|
||||
/** 英文帮助文字。 */ private String helpText; /** 必填标识。 */ private Integer requiredFlag; /** 系统字段标识。 */ private Integer systemFieldFlag;
|
||||
/** 校验规则JSON。 */ private String validationRule; /** 选项JSON。 */ private String optionsJson; /** 默认值。 */ private String defaultValue;
|
||||
/** 展示宽度。 */ private String widthType; /** 排序值。 */ private Integer sortNo; /** 状态。 */ private String status; /** 逻辑删除状态。 */ private Integer deleted;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*; import lombok.Data;
|
||||
/** 询盘通知接收人持久化实体。 */ @Data @TableName("inquiry_notification_receiver") public class InquiryNotificationReceiverEntity {/** 数据库内部主键。 */ @TableId(type=IdType.AUTO) private Long id; /** 接收人业务编号。 */ private String receiverCode; /** 站点业务编号。 */ private String siteCode; /** 接收人名称。 */ private String receiverName; /** 接收邮箱。 */ private String receiverEmail; /** 状态。 */ private String status; /** 逻辑删除状态。 */ private Integer deleted;}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.shoplix.modules.inquiry.repository.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import java.time.LocalDateTime;
|
||||
/** 询盘操作日志持久化实体。 */ @Data @TableName("inquiry_operation_log")
|
||||
public class InquiryOperationLogEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type=IdType.AUTO) private Long id; /** 日志业务编号。 */ private String logCode;
|
||||
/** 站点业务编号。 */ private String siteCode; /** 询盘业务编号。 */ private String inquiryCode; /** 操作用户编号。 */ private String operatorUserCode;
|
||||
/** 操作类型。 */ private String operationType; /** 操作前状态。 */ private String beforeStatus; /** 操作后状态。 */ private String afterStatus;
|
||||
/** 操作说明。 */ private String operationContent; /** 创建时间。 */ private LocalDateTime createTime;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.shoplix.modules.inquiry.repository.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import java.time.LocalDateTime;
|
||||
/** 客户原始询盘持久化实体。 */ @Data @TableName("inquiry_record")
|
||||
public class InquiryRecordEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type=IdType.AUTO) private Long id; /** 询盘业务编号。 */ private String inquiryCode;
|
||||
/** 站点业务编号。 */ private String siteCode; /** 表单业务编号。 */ private String formCode; /** 表单版本号。 */ private Integer formVersion;
|
||||
/** 来源类型。 */ private String sourceType; /** 来源业务编号。 */ private String sourceCode; /** 来源页面地址。 */ private String sourceUrl;
|
||||
/** 产品业务编号。 */ private String productCode; /** 产品名称快照。 */ private String productNameSnapshot;
|
||||
/** 客户姓名。 */ private String customerName; /** 客户邮箱。 */ private String customerEmail; /** 邮箱摘要。 */ private String emailHash;
|
||||
/** 客户电话。 */ private String customerPhone; /** 公司名称。 */ private String companyName; /** 国家代码。 */ private String countryCode;
|
||||
/** 询盘正文。 */ private String message; /** 处理状态。 */ private String status; /** 优先级。 */ private String priority;
|
||||
/** 负责人用户编号。 */ private String ownerUserCode; /** CRM线索编号。 */ private String crmLeadCode;
|
||||
/** UTM来源。 */ private String utmSource; /** UTM媒介。 */ private String utmMedium; /** UTM活动。 */ private String utmCampaign;
|
||||
/** UTM内容。 */ private String utmContent; /** UTM关键词。 */ private String utmTerm; /** 来源地址。 */ private String referrerUrl;
|
||||
/** 落地地址。 */ private String landingUrl; /** IP摘要。 */ private String ipHash; /** 浏览器标识。 */ private String userAgent;
|
||||
/** 设备类型。 */ private String deviceType; /** 隐私授权标识。 */ private Integer privacyConsentFlag; /** 隐私授权时间。 */ private LocalDateTime privacyConsentTime;
|
||||
/** 重复标识。 */ private Integer duplicateFlag; /** 垃圾标识。 */ private Integer spamFlag; /** 垃圾原因。 */ private String spamReason;
|
||||
/** 首次跟进时间。 */ private LocalDateTime firstFollowTime; /** 最近跟进时间。 */ private LocalDateTime lastFollowTime;
|
||||
/** 下次跟进时间。 */ private LocalDateTime nextFollowTime; /** 关闭时间。 */ private LocalDateTime closeTime;
|
||||
/** 逻辑删除状态。 */ private Integer deleted; /** 创建时间。 */ private LocalDateTime createTime;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.shoplix.modules.inquiry.repository.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*; import lombok.Data;
|
||||
/** 站点询盘设置持久化实体。 */ @Data @TableName("inquiry_setting")
|
||||
public class InquirySettingEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type=IdType.AUTO) private Long id;
|
||||
/** 设置业务编号。 */ private String settingCode; /** 站点业务编号。 */ private String siteCode;
|
||||
/** 询盘启用标识。 */ private Integer inquiryEnabled; /** 验证码启用标识。 */ private Integer captchaEnabled;
|
||||
/** 隐私授权必填标识。 */ private Integer privacyConsentRequired; /** 重复识别分钟数。 */ private Integer duplicateWindowMinutes;
|
||||
/** IP每小时限制。 */ private Integer ipHourLimit; /** 邮箱每天限制。 */ private Integer emailDayLimit;
|
||||
/** 附件启用标识。 */ private Integer attachmentEnabled; /** 最大附件数量。 */ private Integer maxAttachmentCount;
|
||||
/** 单附件最大字节。 */ private Long maxAttachmentSize; /** 允许附件类型。 */ private String allowedAttachmentTypes;
|
||||
/** 成功动作。 */ private String successAction; /** 成功页面编号。 */ private String successPageCode;
|
||||
/** 成功跳转地址。 */ private String successRedirectUrl; /** 通知启用标识。 */ private Integer notificationEnabled;
|
||||
/** 自动回复启用标识。 */ private Integer autoReplyEnabled; /** 自动回复主题。 */ private String autoReplySubject;
|
||||
/** 自动回复内容。 */ private String autoReplyContent; /** 数据保留天数。 */ private Integer dataRetentionDays;
|
||||
/** 配置状态。 */ private String status; /** 逻辑删除状态。 */ private Integer deleted;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import java.time.LocalDateTime;
|
||||
/** 邮件任务持久化实体。 */ @Data @TableName("mail_task") public class MailTaskEntity {/** 数据库内部主键。 */ @TableId(type=IdType.AUTO) private Long id; /** 任务业务编号。 */ private String taskCode; /** 站点业务编号。 */ private String siteCode; /** 业务类型。 */ private String businessType; /** 业务编号。 */ private String businessCode; /** 邮件类型。 */ private String mailType; /** 收件邮箱。 */ private String recipient; /** 邮件主题。 */ private String subject; /** 邮件正文。 */ private String content; /** 任务状态。 */ private String status; /** 重试次数。 */ private Integer retryCount; /** 下次重试时间。 */ private LocalDateTime nextRetryTime; /** 最近错误。 */ private String lastError; /** 发送时间。 */ private LocalDateTime sendTime; /** 逻辑删除状态。 */ private Integer deleted;}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.shoplix.modules.inquiry.repository.entity.InquiryFieldValueEntity; import org.apache.ibatis.annotations.Mapper;
|
||||
/** 询盘字段值Mapper。 */ @Mapper public interface InquiryFieldValueMapper extends BaseMapper<InquiryFieldValueEntity> {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.shoplix.modules.inquiry.repository.entity.InquiryFormFieldEntity; import org.apache.ibatis.annotations.Mapper;
|
||||
/** 询盘表单字段Mapper。 */ @Mapper public interface InquiryFormFieldMapper extends BaseMapper<InquiryFormFieldEntity> {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.shoplix.modules.inquiry.repository.entity.InquiryFormEntity; import org.apache.ibatis.annotations.Mapper;
|
||||
/** 询盘表单Mapper。 */ @Mapper public interface InquiryFormMapper extends BaseMapper<InquiryFormEntity> {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.shoplix.modules.inquiry.repository.entity.InquiryNotificationReceiverEntity; import org.apache.ibatis.annotations.Mapper;
|
||||
/** 询盘通知接收人Mapper。 */ @Mapper public interface InquiryNotificationReceiverMapper extends BaseMapper<InquiryNotificationReceiverEntity> {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.shoplix.modules.inquiry.repository.entity.InquiryOperationLogEntity; import org.apache.ibatis.annotations.Mapper;
|
||||
/** 询盘操作日志Mapper。 */ @Mapper public interface InquiryOperationLogMapper extends BaseMapper<InquiryOperationLogEntity> {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.shoplix.modules.inquiry.repository.entity.InquiryRecordEntity; import org.apache.ibatis.annotations.Mapper;
|
||||
/** 询盘记录Mapper。 */ @Mapper public interface InquiryRecordMapper extends BaseMapper<InquiryRecordEntity> {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.shoplix.modules.inquiry.repository.entity.InquirySettingEntity; import org.apache.ibatis.annotations.Mapper;
|
||||
/** 询盘设置Mapper。 */ @Mapper public interface InquirySettingMapper extends BaseMapper<InquirySettingEntity> {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.shoplix.modules.inquiry.repository.entity.MailTaskEntity; import org.apache.ibatis.annotations.Mapper;
|
||||
/** 邮件任务Mapper。 */ @Mapper public interface MailTaskMapper extends BaseMapper<MailTaskEntity> {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.service;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.shoplix.modules.inquiry.repository.entity.InquiryFieldValueEntity; import com.shoplix.modules.inquiry.repository.mapper.InquiryFieldValueMapper; import org.springframework.stereotype.Service; import java.util.*;
|
||||
/** 询盘字段值单表数据源服务。 */ @Service public class InquiryFieldValueRepositoryService {private final InquiryFieldValueMapper mapper; /** 注入Mapper。 */ public InquiryFieldValueRepositoryService(InquiryFieldValueMapper mapper){this.mapper=mapper;} /** 新增字段值。 */ public int insert(InquiryFieldValueEntity e){return mapper.insert(e);} /** 查询询盘字段值。 */ public List<InquiryFieldValueEntity> list(String site,String code){return mapper.selectList(Wrappers.<InquiryFieldValueEntity>lambdaQuery().eq(InquiryFieldValueEntity::getSiteCode,site).eq(InquiryFieldValueEntity::getInquiryCode,code).orderByAsc(InquiryFieldValueEntity::getSortNo));}}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.shoplix.modules.inquiry.repository.service;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.shoplix.modules.inquiry.repository.entity.InquiryFormFieldEntity; import com.shoplix.modules.inquiry.repository.mapper.InquiryFormFieldMapper; import org.springframework.stereotype.Service; import java.util.*;
|
||||
/** 询盘表单字段单表数据源服务。 */ @Service
|
||||
public class InquiryFormFieldRepositoryService {
|
||||
private final InquiryFormFieldMapper mapper; /** 注入Mapper。 */ public InquiryFormFieldRepositoryService(InquiryFormFieldMapper mapper){this.mapper=mapper;}
|
||||
/** 查询表单字段。 */ public List<InquiryFormFieldEntity> list(String site,String form,boolean enabled){var q=Wrappers.<InquiryFormFieldEntity>lambdaQuery().eq(InquiryFormFieldEntity::getSiteCode,site).eq(InquiryFormFieldEntity::getFormCode,form);if(enabled)q.eq(InquiryFormFieldEntity::getStatus,"ENABLED");return mapper.selectList(q.orderByAsc(InquiryFormFieldEntity::getSortNo));}
|
||||
/** 删除表单现有字段。 */ public int deleteByForm(String site,String form){return mapper.delete(Wrappers.<InquiryFormFieldEntity>lambdaQuery().eq(InquiryFormFieldEntity::getSiteCode,site).eq(InquiryFormFieldEntity::getFormCode,form));}
|
||||
/** 新增字段。 */ public int insert(InquiryFormFieldEntity e){return mapper.insert(e);}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.shoplix.modules.inquiry.repository.service;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.shoplix.modules.inquiry.repository.entity.InquiryFormEntity; import com.shoplix.modules.inquiry.repository.mapper.InquiryFormMapper; import org.springframework.stereotype.Service; import java.util.*;
|
||||
/** 询盘表单单表数据源服务。 */ @Service
|
||||
public class InquiryFormRepositoryService {
|
||||
private final InquiryFormMapper mapper; /** 注入Mapper。 */ public InquiryFormRepositoryService(InquiryFormMapper mapper){this.mapper=mapper;}
|
||||
/** 查询站点全部表单。 */ public List<InquiryFormEntity> list(String siteCode){return mapper.selectList(Wrappers.<InquiryFormEntity>lambdaQuery().eq(InquiryFormEntity::getSiteCode,siteCode).orderByAsc(InquiryFormEntity::getSortNo));}
|
||||
/** 查询发布场景表单。 */ public Optional<InquiryFormEntity> findPublished(String siteCode,String scene){return Optional.ofNullable(mapper.selectOne(Wrappers.<InquiryFormEntity>lambdaQuery().eq(InquiryFormEntity::getSiteCode,siteCode).eq(InquiryFormEntity::getFormScene,scene).eq(InquiryFormEntity::getStatus,"PUBLISHED").orderByAsc(InquiryFormEntity::getSortNo).last("LIMIT 1")));}
|
||||
/** 按编号查询表单。 */ public Optional<InquiryFormEntity> find(String siteCode,String code){return Optional.ofNullable(mapper.selectOne(Wrappers.<InquiryFormEntity>lambdaQuery().eq(InquiryFormEntity::getSiteCode,siteCode).eq(InquiryFormEntity::getFormCode,code)));}
|
||||
/** 新增表单。 */ public int insert(InquiryFormEntity e){return mapper.insert(e);} /** 更新表单。 */ public int update(InquiryFormEntity e){return mapper.update(e,Wrappers.<InquiryFormEntity>lambdaUpdate().eq(InquiryFormEntity::getSiteCode,e.getSiteCode()).eq(InquiryFormEntity::getFormCode,e.getFormCode()));}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.service;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.shoplix.modules.inquiry.repository.entity.InquiryNotificationReceiverEntity; import com.shoplix.modules.inquiry.repository.mapper.InquiryNotificationReceiverMapper; import org.springframework.stereotype.Service; import java.util.List;
|
||||
/** 询盘通知接收人单表数据源服务。 */ @Service public class InquiryNotificationReceiverRepositoryService {private final InquiryNotificationReceiverMapper mapper; /** 注入Mapper。 */ public InquiryNotificationReceiverRepositoryService(InquiryNotificationReceiverMapper mapper){this.mapper=mapper;} /** 查询启用接收人。 */ public List<InquiryNotificationReceiverEntity> listEnabled(String site){return mapper.selectList(Wrappers.<InquiryNotificationReceiverEntity>lambdaQuery().eq(InquiryNotificationReceiverEntity::getSiteCode,site).eq(InquiryNotificationReceiverEntity::getStatus,"ENABLED"));}}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.service;
|
||||
import com.shoplix.modules.inquiry.repository.entity.InquiryOperationLogEntity; import com.shoplix.modules.inquiry.repository.mapper.InquiryOperationLogMapper; import org.springframework.stereotype.Service;
|
||||
/** 询盘操作日志单表数据源服务。 */ @Service public class InquiryOperationLogRepositoryService {private final InquiryOperationLogMapper mapper; /** 注入Mapper。 */ public InquiryOperationLogRepositoryService(InquiryOperationLogMapper mapper){this.mapper=mapper;} /** 新增操作日志。 */ public int insert(InquiryOperationLogEntity e){return mapper.insert(e);}}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.shoplix.modules.inquiry.repository.service;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.shoplix.modules.inquiry.repository.entity.InquiryRecordEntity; import com.shoplix.modules.inquiry.repository.mapper.InquiryRecordMapper; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.*;
|
||||
/** 询盘记录单表数据源服务。 */ @Service
|
||||
public class InquiryRecordRepositoryService {
|
||||
private final InquiryRecordMapper mapper; /** 注入Mapper。 */ public InquiryRecordRepositoryService(InquiryRecordMapper mapper){this.mapper=mapper;}
|
||||
/** 新增询盘。 */ public int insert(InquiryRecordEntity e){return mapper.insert(e);}
|
||||
/** 查询后台询盘列表。 */ public List<InquiryRecordEntity> list(String site,String status){var q=Wrappers.<InquiryRecordEntity>lambdaQuery().eq(InquiryRecordEntity::getSiteCode,site);if(status!=null&&!status.isBlank())q.eq(InquiryRecordEntity::getStatus,status);return mapper.selectList(q.orderByDesc(InquiryRecordEntity::getCreateTime).last("LIMIT 500"));}
|
||||
/** 按编号查询询盘。 */ public Optional<InquiryRecordEntity> find(String site,String code){return Optional.ofNullable(mapper.selectOne(Wrappers.<InquiryRecordEntity>lambdaQuery().eq(InquiryRecordEntity::getSiteCode,site).eq(InquiryRecordEntity::getInquiryCode,code)));}
|
||||
/** 更新可变处理字段。 */ public int update(InquiryRecordEntity e){return mapper.update(e,Wrappers.<InquiryRecordEntity>lambdaUpdate().eq(InquiryRecordEntity::getSiteCode,e.getSiteCode()).eq(InquiryRecordEntity::getInquiryCode,e.getInquiryCode()));}
|
||||
/** 统计IP时间窗口提交数。 */ public long countIp(String site,String hash,LocalDateTime start){return mapper.selectCount(Wrappers.<InquiryRecordEntity>lambdaQuery().eq(InquiryRecordEntity::getSiteCode,site).eq(InquiryRecordEntity::getIpHash,hash).ge(InquiryRecordEntity::getCreateTime,start));}
|
||||
/** 统计邮箱时间窗口提交数。 */ public long countEmail(String site,String hash,LocalDateTime start){return mapper.selectCount(Wrappers.<InquiryRecordEntity>lambdaQuery().eq(InquiryRecordEntity::getSiteCode,site).eq(InquiryRecordEntity::getEmailHash,hash).ge(InquiryRecordEntity::getCreateTime,start));}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.shoplix.modules.inquiry.repository.service;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.shoplix.modules.inquiry.repository.entity.InquirySettingEntity; import com.shoplix.modules.inquiry.repository.mapper.InquirySettingMapper; import org.springframework.stereotype.Service; import java.util.Optional;
|
||||
/** 询盘设置单表数据源服务。 */ @Service
|
||||
public class InquirySettingRepositoryService {
|
||||
private final InquirySettingMapper mapper; /** 注入Mapper。 */ public InquirySettingRepositoryService(InquirySettingMapper mapper){this.mapper=mapper;}
|
||||
/** 查询站点设置。 */ public Optional<InquirySettingEntity> find(String siteCode){return Optional.ofNullable(mapper.selectOne(Wrappers.<InquirySettingEntity>lambdaQuery().eq(InquirySettingEntity::getSiteCode,siteCode)));}
|
||||
/** 新增设置。 */ public int insert(InquirySettingEntity entity){return mapper.insert(entity);}
|
||||
/** 按站点更新设置。 */ public int update(InquirySettingEntity entity){return mapper.update(entity,Wrappers.<InquirySettingEntity>lambdaUpdate().eq(InquirySettingEntity::getSiteCode,entity.getSiteCode()));}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.repository.service;
|
||||
import com.shoplix.modules.inquiry.repository.entity.MailTaskEntity; import com.shoplix.modules.inquiry.repository.mapper.MailTaskMapper; import org.springframework.stereotype.Service;
|
||||
/** 邮件任务单表数据源服务。 */ @Service public class MailTaskRepositoryService {private final MailTaskMapper mapper; /** 注入Mapper。 */ public MailTaskRepositoryService(MailTaskMapper mapper){this.mapper=mapper;} /** 新增邮件任务。 */ public int insert(MailTaskEntity e){return mapper.insert(e);}}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.media.repository.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import java.time.LocalDateTime;
|
||||
/** 站点媒体资源持久化实体。 */ @Data @TableName("media_asset") public class MediaAssetEntity {/** 数据库内部主键。 */ @TableId(type=IdType.AUTO) private Long id; /** 媒体业务编号。 */ private String mediaCode; /** 站点业务编号。 */ private String siteCode; /** 媒体类型。 */ private String mediaType; /** 原始文件名。 */ private String originalFileName; /** 存储文件名。 */ private String storageFileName; /** 相对访问地址。 */ private String relativeUrl; /** MIME类型。 */ private String mimeType; /** 文件扩展名。 */ private String fileExtension; /** 文件字节数。 */ private Long fileSize; /** 图片英文替代文本。 */ private String altText; /** 状态。 */ private String status; /** 逻辑删除状态。 */ private Integer deleted; /** 创建时间。 */ private LocalDateTime createTime;}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
package com.shoplix.modules.media.repository.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.shoplix.modules.media.repository.entity.MediaAssetEntity; import org.apache.ibatis.annotations.Mapper;
|
||||
/** 媒体资源Mapper。 */ @Mapper public interface MediaAssetMapper extends BaseMapper<MediaAssetEntity> {}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
package com.shoplix.modules.media.repository.service; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.shoplix.modules.media.repository.entity.MediaAssetEntity; import com.shoplix.modules.media.repository.mapper.MediaAssetMapper; import org.springframework.stereotype.Service; import java.util.*;
|
||||
/** 媒体资源单表数据源服务。 */ @Service public class MediaAssetRepositoryService {private final MediaAssetMapper mapper; /** 注入Mapper。 */ public MediaAssetRepositoryService(MediaAssetMapper mapper){this.mapper=mapper;} /** 新增媒体。 */ public int insert(MediaAssetEntity e){return mapper.insert(e);} /** 查询媒体。 */ public Optional<MediaAssetEntity> find(String site,String code){return Optional.ofNullable(mapper.selectOne(Wrappers.<MediaAssetEntity>lambdaQuery().eq(MediaAssetEntity::getSiteCode,site).eq(MediaAssetEntity::getMediaCode,code)));}}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.shoplix.modules.page.enums;
|
||||
|
||||
/** 固定系统页面类型。 */
|
||||
public enum SystemPageTypeEnum {
|
||||
ABOUT_US,
|
||||
CONTACT_US,
|
||||
TERMS_OF_SERVICE,
|
||||
PRIVACY_POLICY,
|
||||
COOKIE_POLICY,
|
||||
INQUIRY_SUCCESS
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.shoplix.modules.page.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** 固定页面和自定义页面持久化实体。 */
|
||||
@Data
|
||||
@TableName("page")
|
||||
public class PageEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type = IdType.AUTO) private Long id;
|
||||
/** 页面业务编号。 */ private String pageCode;
|
||||
/** 所属站点业务编号。 */ private String siteCode;
|
||||
/** 页面类型。 */ private String pageType;
|
||||
/** 固定系统页面类型。 */ private String systemPageType;
|
||||
/** 运营后台页面名称。 */ private String pageName;
|
||||
/** 英文路径标识。 */ private String slug;
|
||||
/** 英文富文本内容。 */ private String pageContent;
|
||||
/** 英文摘要。 */ private String summary;
|
||||
/** 封面媒体业务编号。 */ private String coverMediaCode;
|
||||
/** 排序值。 */ private Integer sortNo;
|
||||
/** 发布状态。 */ private String status;
|
||||
/** 发布时间。 */ private LocalDateTime publishTime;
|
||||
/** 下线时间。 */ private LocalDateTime offlineTime;
|
||||
/** 已发布版本号。 */ private Integer publishedVersion;
|
||||
/** 逻辑删除状态。 */ private Integer deleted;
|
||||
/** 创建时间。 */ private LocalDateTime createTime;
|
||||
/** 更新时间。 */ private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.modules.page.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.page.repository.entity.PageEntity;
|
||||
|
||||
/** 页面基础 Mapper。 */
|
||||
public interface PageMapper extends BaseMapper<PageEntity> {
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.shoplix.modules.page.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.page.repository.entity.PageEntity;
|
||||
import com.shoplix.modules.page.repository.mapper.PageMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/** 页面单表数据源服务。 */
|
||||
@Service
|
||||
public class PageRepositoryService {
|
||||
private final PageMapper mapper;
|
||||
|
||||
/** 注入页面 Mapper。 */
|
||||
public PageRepositoryService(PageMapper mapper) { this.mapper = mapper; }
|
||||
|
||||
/** 按站点和页面编号查询。 */
|
||||
public Optional<PageEntity> findByCode(String siteCode, String pageCode) {
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<PageEntity>lambdaQuery()
|
||||
.eq(PageEntity::getSiteCode, siteCode).eq(PageEntity::getPageCode, pageCode).last("LIMIT 1")));
|
||||
}
|
||||
|
||||
/** 按站点和英文路径查询已发布页面。 */
|
||||
public Optional<PageEntity> findPublishedBySlug(String siteCode, String slug) {
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<PageEntity>lambdaQuery()
|
||||
.eq(PageEntity::getSiteCode, siteCode).eq(PageEntity::getSlug, slug)
|
||||
.eq(PageEntity::getStatus, "PUBLISHED").last("LIMIT 1")));
|
||||
}
|
||||
|
||||
/** 查询站点页面列表。 */
|
||||
public List<PageEntity> list(String siteCode) {
|
||||
return mapper.selectList(Wrappers.<PageEntity>lambdaQuery().eq(PageEntity::getSiteCode, siteCode)
|
||||
.orderByAsc(PageEntity::getSortNo).orderByDesc(PageEntity::getUpdateTime));
|
||||
}
|
||||
|
||||
/** 新增页面。 */ public int insert(PageEntity entity) { return mapper.insert(entity); }
|
||||
/** 按页面业务编号更新页面。 */
|
||||
public int updateByCode(PageEntity entity) {
|
||||
return mapper.update(entity, Wrappers.<PageEntity>lambdaUpdate()
|
||||
.eq(PageEntity::getSiteCode, entity.getSiteCode()).eq(PageEntity::getPageCode, entity.getPageCode()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.shoplix.modules.product.enums;
|
||||
|
||||
/** 产品属性输入类型。 */
|
||||
public enum AttributeInputTypeEnum {
|
||||
TEXT, NUMBER, SINGLE_SELECT, MULTI_SELECT, BOOLEAN
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
package com.shoplix.modules.product.repository.entity; import com.baomidou.mybatisplus.annotation.*; import lombok.Data;
|
||||
/** 产品属性定义持久化实体。 */ @Data @TableName("product_attribute") public class ProductAttributeEntity {/** 数据库内部主键。 */ @TableId(type=IdType.AUTO) private Long id; /** 属性业务编号。 */ private String attributeCode; /** 站点业务编号。 */ private String siteCode; /** 英文属性名称。 */ private String attributeName; /** 输入类型。 */ private String inputType; /** 单位。 */ private String unit; /** 筛选标识。 */ private Integer filterableFlag; /** 必填标识。 */ private Integer requiredFlag; /** 排序值。 */ private Integer sortNo; /** 状态。 */ private String status; /** 逻辑删除状态。 */ private Integer deleted;}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
package com.shoplix.modules.product.repository.entity; import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import java.math.BigDecimal;
|
||||
/** 产品属性值持久化实体。 */ @Data @TableName("product_attribute_value") public class ProductAttributeValueEntity {/** 数据库内部主键。 */ @TableId(type=IdType.AUTO) private Long id; /** 属性值业务编号。 */ private String valueCode; /** 站点业务编号。 */ private String siteCode; /** 产品业务编号。 */ private String productCode; /** 属性业务编号。 */ private String attributeCode; /** 选项业务编号。 */ private String optionCode; /** 文本值。 */ private String textValue; /** 数字值。 */ private BigDecimal numberValue; /** 布尔值。 */ private Integer booleanValue; /** 排序值。 */ private Integer sortNo; /** 逻辑删除状态。 */ private Integer deleted;}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.shoplix.modules.product.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/** 产品分类持久化实体。 */
|
||||
@Data
|
||||
@TableName("product_category")
|
||||
public class ProductCategoryEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type = IdType.AUTO) private Long id;
|
||||
/** 分类业务编号。 */ private String categoryCode;
|
||||
/** 所属站点业务编号。 */ private String siteCode;
|
||||
/** 父分类业务编号。 */ private String parentCategoryCode;
|
||||
/** 英文分类名称。 */ private String categoryName;
|
||||
/** 英文路径标识。 */ private String slug;
|
||||
/** 英文分类描述。 */ private String description;
|
||||
/** 封面媒体业务编号。 */ private String coverMediaCode;
|
||||
/** 排序值。 */ private Integer sortNo;
|
||||
/** 发布状态。 */ private String status;
|
||||
/** 逻辑删除状态。 */ private Integer deleted;
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.shoplix.modules.product.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** B2B 产品持久化实体。 */
|
||||
@Data
|
||||
@TableName("product")
|
||||
public class ProductEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type = IdType.AUTO) private Long id;
|
||||
/** 产品业务编号。 */ private String productCode;
|
||||
/** 所属站点业务编号。 */ private String siteCode;
|
||||
/** 主分类业务编号。 */ private String primaryCategoryCode;
|
||||
/** 英文产品名称。 */ private String productName;
|
||||
/** 英文路径标识。 */ private String slug;
|
||||
/** 产品型号。 */ private String model;
|
||||
/** 英文摘要。 */ private String summary;
|
||||
/** 英文详情。 */ private String productContent;
|
||||
/** 封面媒体业务编号。 */ private String coverMediaCode;
|
||||
/** 推荐标识。 */ private Integer featuredFlag;
|
||||
/** 询盘启用标识。 */ private Integer inquiryEnabled;
|
||||
/** 排序值。 */ private Integer sortNo;
|
||||
/** 发布状态。 */ private String status;
|
||||
/** 发布时间。 */ private LocalDateTime publishTime;
|
||||
/** 下线时间。 */ private LocalDateTime offlineTime;
|
||||
/** 逻辑删除状态。 */ private Integer deleted;
|
||||
/** 创建时间。 */ private LocalDateTime createTime;
|
||||
/** 更新时间。 */ private LocalDateTime updateTime;
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.shoplix.modules.product.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/** 产品弱规格展示参数持久化实体。 */
|
||||
@Data
|
||||
@TableName("product_specification")
|
||||
public class ProductSpecificationEntity {
|
||||
/** 数据库内部主键。 */ @TableId(type = IdType.AUTO) private Long id;
|
||||
/** 规格业务编号。 */ private String specificationCode;
|
||||
/** 所属站点业务编号。 */ private String siteCode;
|
||||
/** 产品业务编号。 */ private String productCode;
|
||||
/** 英文规格分组。 */ private String groupName;
|
||||
/** 英文规格名称。 */ private String specificationName;
|
||||
/** 英文规格值。 */ private String specificationValue;
|
||||
/** 单位。 */ private String unit;
|
||||
/** 排序值。 */ private Integer sortNo;
|
||||
/** 逻辑删除状态。 */ private Integer deleted;
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
package com.shoplix.modules.product.repository.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.shoplix.modules.product.repository.entity.ProductAttributeEntity; import org.apache.ibatis.annotations.Mapper;
|
||||
/** 产品属性定义Mapper。 */ @Mapper public interface ProductAttributeMapper extends BaseMapper<ProductAttributeEntity> {}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
package com.shoplix.modules.product.repository.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.shoplix.modules.product.repository.entity.ProductAttributeValueEntity; import org.apache.ibatis.annotations.Mapper;
|
||||
/** 产品属性值Mapper。 */ @Mapper public interface ProductAttributeValueMapper extends BaseMapper<ProductAttributeValueEntity> {}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.modules.product.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.product.repository.entity.ProductCategoryEntity;
|
||||
|
||||
/** 产品分类基础 Mapper。 */
|
||||
public interface ProductCategoryMapper extends BaseMapper<ProductCategoryEntity> {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.modules.product.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.product.repository.entity.ProductEntity;
|
||||
|
||||
/** 产品基础 Mapper。 */
|
||||
public interface ProductMapper extends BaseMapper<ProductEntity> {
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.modules.product.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.product.repository.entity.ProductSpecificationEntity;
|
||||
|
||||
/** 产品弱规格基础 Mapper。 */
|
||||
public interface ProductSpecificationMapper extends BaseMapper<ProductSpecificationEntity> {
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
package com.shoplix.modules.product.repository.service; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.shoplix.modules.product.repository.entity.ProductAttributeEntity; import com.shoplix.modules.product.repository.mapper.ProductAttributeMapper; import org.springframework.stereotype.Service; import java.util.*;
|
||||
/** 产品属性定义单表数据源服务。 */ @Service public class ProductAttributeRepositoryService {private final ProductAttributeMapper mapper; /** 注入Mapper。 */ public ProductAttributeRepositoryService(ProductAttributeMapper mapper){this.mapper=mapper;} /** 查询站点属性。 */ public List<ProductAttributeEntity> list(String site){return mapper.selectList(Wrappers.<ProductAttributeEntity>lambdaQuery().eq(ProductAttributeEntity::getSiteCode,site).eq(ProductAttributeEntity::getStatus,"ENABLED").orderByAsc(ProductAttributeEntity::getSortNo));} /** 查询属性。 */ public Optional<ProductAttributeEntity> find(String site,String code){return Optional.ofNullable(mapper.selectOne(Wrappers.<ProductAttributeEntity>lambdaQuery().eq(ProductAttributeEntity::getSiteCode,site).eq(ProductAttributeEntity::getAttributeCode,code)));} /** 新增属性。 */ public int insert(ProductAttributeEntity e){return mapper.insert(e);}}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
package com.shoplix.modules.product.repository.service; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.shoplix.modules.product.repository.entity.ProductAttributeValueEntity; import com.shoplix.modules.product.repository.mapper.ProductAttributeValueMapper; import org.springframework.stereotype.Service; import java.util.*;
|
||||
/** 产品属性值单表数据源服务。 */ @Service public class ProductAttributeValueRepositoryService {private final ProductAttributeValueMapper mapper; /** 注入Mapper。 */ public ProductAttributeValueRepositoryService(ProductAttributeValueMapper mapper){this.mapper=mapper;} /** 查询产品属性值。 */ public List<ProductAttributeValueEntity> list(String site,String product){return mapper.selectList(Wrappers.<ProductAttributeValueEntity>lambdaQuery().eq(ProductAttributeValueEntity::getSiteCode,site).eq(ProductAttributeValueEntity::getProductCode,product).orderByAsc(ProductAttributeValueEntity::getSortNo));} /** 删除产品属性值。 */ public int delete(String site,String product){return mapper.delete(Wrappers.<ProductAttributeValueEntity>lambdaQuery().eq(ProductAttributeValueEntity::getSiteCode,site).eq(ProductAttributeValueEntity::getProductCode,product));} /** 新增属性值。 */ public int insert(ProductAttributeValueEntity e){return mapper.insert(e);}}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.shoplix.modules.product.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.product.repository.entity.ProductCategoryEntity;
|
||||
import com.shoplix.modules.product.repository.mapper.ProductCategoryMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/** 产品分类单表数据源服务。 */
|
||||
@Service
|
||||
public class ProductCategoryRepositoryService {
|
||||
private final ProductCategoryMapper mapper;
|
||||
/** 注入产品分类 Mapper。 */ public ProductCategoryRepositoryService(ProductCategoryMapper mapper) { this.mapper = mapper; }
|
||||
/** 查询站点产品分类。 */
|
||||
public List<ProductCategoryEntity> list(String siteCode, boolean publishedOnly) {
|
||||
var query = Wrappers.<ProductCategoryEntity>lambdaQuery().eq(ProductCategoryEntity::getSiteCode, siteCode);
|
||||
if (publishedOnly) query.eq(ProductCategoryEntity::getStatus, "PUBLISHED");
|
||||
return mapper.selectList(query.orderByAsc(ProductCategoryEntity::getSortNo));
|
||||
}
|
||||
/** 按站点和分类业务编号查询分类。 */
|
||||
public Optional<ProductCategoryEntity> findByCode(String siteCode, String categoryCode) {
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<ProductCategoryEntity>lambdaQuery()
|
||||
.eq(ProductCategoryEntity::getSiteCode, siteCode)
|
||||
.eq(ProductCategoryEntity::getCategoryCode, categoryCode)));
|
||||
}
|
||||
/** 新增产品分类。 */
|
||||
public int insert(ProductCategoryEntity entity) { return mapper.insert(entity); }
|
||||
/** 按业务编号更新产品分类。 */
|
||||
public int updateByCode(ProductCategoryEntity entity) {
|
||||
return mapper.update(entity, Wrappers.<ProductCategoryEntity>lambdaUpdate()
|
||||
.eq(ProductCategoryEntity::getSiteCode, entity.getSiteCode())
|
||||
.eq(ProductCategoryEntity::getCategoryCode, entity.getCategoryCode()));
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.shoplix.modules.product.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.product.repository.entity.ProductEntity;
|
||||
import com.shoplix.modules.product.repository.mapper.ProductMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/** 产品单表数据源服务。 */
|
||||
@Service
|
||||
public class ProductRepositoryService {
|
||||
private final ProductMapper mapper;
|
||||
/** 注入产品 Mapper。 */ public ProductRepositoryService(ProductMapper mapper) { this.mapper = mapper; }
|
||||
/** 按站点和产品编号查询。 */
|
||||
public Optional<ProductEntity> findByCode(String siteCode, String productCode) {
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<ProductEntity>lambdaQuery()
|
||||
.eq(ProductEntity::getSiteCode, siteCode).eq(ProductEntity::getProductCode, productCode)
|
||||
.eq(ProductEntity::getDeleted, 0).last("LIMIT 1")));
|
||||
}
|
||||
/** 按站点和路径查询已发布产品。 */
|
||||
public Optional<ProductEntity> findPublishedBySlug(String siteCode, String slug) {
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<ProductEntity>lambdaQuery()
|
||||
.eq(ProductEntity::getSiteCode, siteCode).eq(ProductEntity::getSlug, slug)
|
||||
.eq(ProductEntity::getStatus, "PUBLISHED").last("LIMIT 1")));
|
||||
}
|
||||
/** 查询后台产品列表。 */
|
||||
public List<ProductEntity> list(String siteCode) {
|
||||
return mapper.selectList(Wrappers.<ProductEntity>lambdaQuery().eq(ProductEntity::getSiteCode, siteCode)
|
||||
.eq(ProductEntity::getDeleted, 0)
|
||||
.orderByAsc(ProductEntity::getSortNo).orderByDesc(ProductEntity::getUpdateTime));
|
||||
}
|
||||
/** 查询前台已发布产品列表。 */
|
||||
public List<ProductEntity> listPublished(String siteCode, String categoryCode) {
|
||||
var query = Wrappers.<ProductEntity>lambdaQuery().eq(ProductEntity::getSiteCode, siteCode)
|
||||
.eq(ProductEntity::getStatus, "PUBLISHED");
|
||||
if (categoryCode != null && !categoryCode.isBlank()) query.eq(ProductEntity::getPrimaryCategoryCode, categoryCode);
|
||||
return mapper.selectList(query.orderByDesc(ProductEntity::getFeaturedFlag).orderByAsc(ProductEntity::getSortNo));
|
||||
}
|
||||
/** 新增产品。 */ public int insert(ProductEntity entity) { return mapper.insert(entity); }
|
||||
/** 按产品业务编号更新。 */
|
||||
public int updateByCode(ProductEntity entity) {
|
||||
return mapper.update(entity, Wrappers.<ProductEntity>lambdaUpdate()
|
||||
.eq(ProductEntity::getSiteCode, entity.getSiteCode()).eq(ProductEntity::getProductCode, entity.getProductCode()));
|
||||
}
|
||||
/** 按业务编号逻辑删除产品。 */
|
||||
public int deleteByCode(String siteCode, String productCode) {
|
||||
return mapper.update(null, Wrappers.<ProductEntity>lambdaUpdate().set(ProductEntity::getDeleted, 1)
|
||||
.eq(ProductEntity::getSiteCode, siteCode).eq(ProductEntity::getProductCode, productCode)
|
||||
.eq(ProductEntity::getDeleted, 0));
|
||||
}
|
||||
/** 按业务编号更新产品发布状态。 */
|
||||
public int updateStatus(String siteCode, String productCode, String status, java.time.LocalDateTime publishTime,
|
||||
java.time.LocalDateTime offlineTime) {
|
||||
return mapper.update(null, Wrappers.<ProductEntity>lambdaUpdate().set(ProductEntity::getStatus, status)
|
||||
.set(ProductEntity::getPublishTime, publishTime).set(ProductEntity::getOfflineTime, offlineTime)
|
||||
.eq(ProductEntity::getSiteCode, siteCode).eq(ProductEntity::getProductCode, productCode)
|
||||
.eq(ProductEntity::getDeleted, 0));
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.shoplix.modules.product.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.product.repository.entity.ProductSpecificationEntity;
|
||||
import com.shoplix.modules.product.repository.mapper.ProductSpecificationMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** 产品弱规格单表数据源服务。 */
|
||||
@Service
|
||||
public class ProductSpecificationRepositoryService {
|
||||
private final ProductSpecificationMapper mapper;
|
||||
/** 注入产品规格 Mapper。 */ public ProductSpecificationRepositoryService(ProductSpecificationMapper mapper) { this.mapper = mapper; }
|
||||
/** 查询产品有序规格。 */
|
||||
public List<ProductSpecificationEntity> list(String siteCode, String productCode) {
|
||||
return mapper.selectList(Wrappers.<ProductSpecificationEntity>lambdaQuery()
|
||||
.eq(ProductSpecificationEntity::getSiteCode, siteCode)
|
||||
.eq(ProductSpecificationEntity::getProductCode, productCode)
|
||||
.orderByAsc(ProductSpecificationEntity::getSortNo));
|
||||
}
|
||||
/** 删除产品全部规格。 */
|
||||
public int delete(String siteCode, String productCode) {
|
||||
return mapper.delete(Wrappers.<ProductSpecificationEntity>lambdaQuery()
|
||||
.eq(ProductSpecificationEntity::getSiteCode, siteCode)
|
||||
.eq(ProductSpecificationEntity::getProductCode, productCode));
|
||||
}
|
||||
/** 新增规格。 */ public int insert(ProductSpecificationEntity entity) { return mapper.insert(entity); }
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.shoplix.modules.seo.dto;
|
||||
|
||||
/** SEO 标题层级内部模型。 */
|
||||
public record SeoHeadingDto(int level, String text, int sortNo) {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.shoplix.modules.seo.enums;
|
||||
|
||||
/** SEO 支持的页面类型。 */
|
||||
public enum SeoPageTypeEnum {
|
||||
HOME,
|
||||
PRODUCT_LIST, PRODUCT_CATEGORY_LIST, PRODUCT_CATEGORY_DETAIL, PRODUCT_DETAIL,
|
||||
CASE_LIST, CASE_CATEGORY_LIST, CASE_CATEGORY_DETAIL, CASE_DETAIL,
|
||||
NEWS_LIST, NEWS_CATEGORY_LIST, NEWS_CATEGORY_DETAIL, NEWS_DETAIL,
|
||||
SERVICE_LIST, SERVICE_DETAIL, HELP_CATEGORY_LIST, HELP_DETAIL,
|
||||
SYSTEM_PAGE, CUSTOM_PAGE
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.shoplix.modules.seo.enums;
|
||||
|
||||
/** SEO 配置发布状态。 */
|
||||
public enum SeoPublishStatusEnum {
|
||||
DRAFT, PUBLISHED, OFFLINE
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.shoplix.modules.seo.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
/** 页面 H2/H3 标题持久化实体。 */
|
||||
@TableName("seo_heading")
|
||||
public class SeoHeadingEntity {
|
||||
/** 数据库内部主键。 */
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
/** 标题业务编号。 */
|
||||
private String headingCode;
|
||||
/** SEO 业务编号。 */
|
||||
private String seoCode;
|
||||
/** 标题层级,仅允许2或3。 */
|
||||
private Integer headingLevel;
|
||||
/** 标题文本。 */
|
||||
private String headingText;
|
||||
/** 页面出现顺序。 */
|
||||
private Integer sortNo;
|
||||
/** 逻辑删除状态:0未删除,1已删除。 */
|
||||
private Integer deleted;
|
||||
|
||||
/** 获取标题编号。 */ public String getHeadingCode() { return headingCode; }
|
||||
/** 设置标题编号。 */ public void setHeadingCode(String value) { headingCode = value; }
|
||||
/** 获取 SEO 编号。 */ public String getSeoCode() { return seoCode; }
|
||||
/** 设置 SEO 编号。 */ public void setSeoCode(String value) { seoCode = value; }
|
||||
/** 获取标题层级。 */ public Integer getHeadingLevel() { return headingLevel; }
|
||||
/** 设置标题层级。 */ public void setHeadingLevel(Integer value) { headingLevel = value; }
|
||||
/** 获取标题文本。 */ public String getHeadingText() { return headingText; }
|
||||
/** 设置标题文本。 */ public void setHeadingText(String value) { headingText = value; }
|
||||
/** 获取排序值。 */ public Integer getSortNo() { return sortNo; }
|
||||
/** 设置排序值。 */ public void setSortNo(Integer value) { sortNo = value; }
|
||||
/** 获取逻辑删除状态。 */ public Integer getDeleted() { return deleted; }
|
||||
/** 设置逻辑删除状态。 */ public void setDeleted(Integer value) { deleted = value; }
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.shoplix.modules.seo.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
/** 页面 SEO 元数据持久化实体。 */
|
||||
@TableName("seo_metadata")
|
||||
public class SeoMetadataEntity {
|
||||
/** 数据库内部主键。 */
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
/** SEO 业务编号。 */
|
||||
private String seoCode;
|
||||
/** 所属站点业务编号。 */
|
||||
private String siteCode;
|
||||
/** 页面类型。 */
|
||||
private String pageType;
|
||||
/** 页面目标业务编号,首页可为空字符串。 */
|
||||
private String targetCode;
|
||||
/** 浏览器及搜索结果标题。 */
|
||||
private String title;
|
||||
/** 搜索结果描述。 */
|
||||
private String description;
|
||||
/** SEO 关键词。 */
|
||||
private String keywords;
|
||||
/** 页面唯一一级标题。 */
|
||||
private String h1;
|
||||
/** 规范页面地址。 */
|
||||
private String canonicalUrl;
|
||||
/** Robots 指令。 */
|
||||
private String robots;
|
||||
/** Open Graph 标题。 */
|
||||
private String ogTitle;
|
||||
/** Open Graph 描述。 */
|
||||
private String ogDescription;
|
||||
/** Open Graph 图片地址。 */
|
||||
private String ogImageUrl;
|
||||
/** JSON-LD 结构化数据。 */
|
||||
private String structuredData;
|
||||
/** 发布状态。 */
|
||||
private String status;
|
||||
/** 逻辑删除状态:0未删除,1已删除。 */
|
||||
private Integer deleted;
|
||||
|
||||
/** 获取 SEO 编号。 */ public String getSeoCode() { return seoCode; }
|
||||
/** 设置 SEO 编号。 */ public void setSeoCode(String value) { seoCode = value; }
|
||||
/** 获取站点编号。 */ public String getSiteCode() { return siteCode; }
|
||||
/** 设置站点编号。 */ public void setSiteCode(String value) { siteCode = value; }
|
||||
/** 获取页面类型。 */ public String getPageType() { return pageType; }
|
||||
/** 设置页面类型。 */ public void setPageType(String value) { pageType = value; }
|
||||
/** 获取页面目标编号。 */ public String getTargetCode() { return targetCode; }
|
||||
/** 设置页面目标编号。 */ public void setTargetCode(String value) { targetCode = value; }
|
||||
/** 获取标题。 */ public String getTitle() { return title; }
|
||||
/** 设置标题。 */ public void setTitle(String value) { title = value; }
|
||||
/** 获取描述。 */ public String getDescription() { return description; }
|
||||
/** 设置描述。 */ public void setDescription(String value) { description = value; }
|
||||
/** 获取关键词。 */ public String getKeywords() { return keywords; }
|
||||
/** 设置关键词。 */ public void setKeywords(String value) { keywords = value; }
|
||||
/** 获取一级标题。 */ public String getH1() { return h1; }
|
||||
/** 设置一级标题。 */ public void setH1(String value) { h1 = value; }
|
||||
/** 获取规范地址。 */ public String getCanonicalUrl() { return canonicalUrl; }
|
||||
/** 设置规范地址。 */ public void setCanonicalUrl(String value) { canonicalUrl = value; }
|
||||
/** 获取 Robots 指令。 */ public String getRobots() { return robots; }
|
||||
/** 设置 Robots 指令。 */ public void setRobots(String value) { robots = value; }
|
||||
/** 获取 Open Graph 标题。 */ public String getOgTitle() { return ogTitle; }
|
||||
/** 设置 Open Graph 标题。 */ public void setOgTitle(String value) { ogTitle = value; }
|
||||
/** 获取 Open Graph 描述。 */ public String getOgDescription() { return ogDescription; }
|
||||
/** 设置 Open Graph 描述。 */ public void setOgDescription(String value) { ogDescription = value; }
|
||||
/** 获取 Open Graph 图片。 */ public String getOgImageUrl() { return ogImageUrl; }
|
||||
/** 设置 Open Graph 图片。 */ public void setOgImageUrl(String value) { ogImageUrl = value; }
|
||||
/** 获取结构化数据。 */ public String getStructuredData() { return structuredData; }
|
||||
/** 设置结构化数据。 */ public void setStructuredData(String value) { structuredData = value; }
|
||||
/** 获取发布状态。 */ public String getStatus() { return status; }
|
||||
/** 设置发布状态。 */ public void setStatus(String value) { status = value; }
|
||||
/** 获取逻辑删除状态。 */ public Integer getDeleted() { return deleted; }
|
||||
/** 设置逻辑删除状态。 */ public void setDeleted(Integer value) { deleted = value; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.modules.seo.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.seo.repository.entity.SeoHeadingEntity;
|
||||
|
||||
/** SEO 标题单表 Mapper。 */
|
||||
public interface SeoHeadingMapper extends BaseMapper<SeoHeadingEntity> {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.modules.seo.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.seo.repository.entity.SeoMetadataEntity;
|
||||
|
||||
/** SEO 元数据单表 Mapper。 */
|
||||
public interface SeoMetadataMapper extends BaseMapper<SeoMetadataEntity> {
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.shoplix.modules.seo.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.seo.repository.entity.SeoHeadingEntity;
|
||||
import com.shoplix.modules.seo.repository.mapper.SeoHeadingMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** 封装 SEO 标题单表读写。 */
|
||||
@Service
|
||||
public class SeoHeadingRepositoryService {
|
||||
/** SEO 标题 Mapper。 */
|
||||
private final SeoHeadingMapper mapper;
|
||||
|
||||
/** 注入 SEO 标题 Mapper。 */
|
||||
public SeoHeadingRepositoryService(SeoHeadingMapper mapper) { this.mapper = mapper; }
|
||||
|
||||
/** 按 SEO 编号查询有序标题。 */
|
||||
public List<SeoHeadingEntity> listBySeoCode(String seoCode) {
|
||||
return mapper.selectList(Wrappers.<SeoHeadingEntity>lambdaQuery()
|
||||
.eq(SeoHeadingEntity::getSeoCode, seoCode)
|
||||
.orderByAsc(SeoHeadingEntity::getSortNo));
|
||||
}
|
||||
|
||||
/** 删除指定 SEO 配置的全部标题。 */
|
||||
public int deleteBySeoCode(String seoCode) {
|
||||
return mapper.delete(Wrappers.<SeoHeadingEntity>lambdaQuery()
|
||||
.eq(SeoHeadingEntity::getSeoCode, seoCode));
|
||||
}
|
||||
|
||||
/** 新增一个 SEO 标题并返回影响行数。 */
|
||||
public int insert(SeoHeadingEntity entity) { return mapper.insert(entity); }
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.shoplix.modules.seo.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.seo.repository.entity.SeoMetadataEntity;
|
||||
import com.shoplix.modules.seo.enums.SeoPublishStatusEnum;
|
||||
import com.shoplix.modules.seo.repository.mapper.SeoMetadataMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/** 封装 SEO 元数据单表读写。 */
|
||||
@Service
|
||||
public class SeoMetadataRepositoryService {
|
||||
/** SEO 元数据 Mapper。 */
|
||||
private final SeoMetadataMapper mapper;
|
||||
|
||||
/** 注入 SEO 元数据 Mapper。 */
|
||||
public SeoMetadataRepositoryService(SeoMetadataMapper mapper) { this.mapper = mapper; }
|
||||
|
||||
/** 查询站点内指定页面的 SEO 配置。 */
|
||||
public Optional<SeoMetadataEntity> find(String siteCode, String pageType, String targetCode) {
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<SeoMetadataEntity>lambdaQuery()
|
||||
.eq(SeoMetadataEntity::getSiteCode, siteCode)
|
||||
.eq(SeoMetadataEntity::getPageType, pageType)
|
||||
.eq(SeoMetadataEntity::getTargetCode, targetCode)
|
||||
.last("LIMIT 1")));
|
||||
}
|
||||
|
||||
/** 查询前台可见的已发布 SEO 配置。 */
|
||||
public Optional<SeoMetadataEntity> findPublished(String siteCode, String pageType, String targetCode) {
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<SeoMetadataEntity>lambdaQuery()
|
||||
.eq(SeoMetadataEntity::getSiteCode, siteCode)
|
||||
.eq(SeoMetadataEntity::getPageType, pageType)
|
||||
.eq(SeoMetadataEntity::getTargetCode, targetCode)
|
||||
.eq(SeoMetadataEntity::getStatus, SeoPublishStatusEnum.PUBLISHED.name())
|
||||
.last("LIMIT 1")));
|
||||
}
|
||||
|
||||
/** 新增 SEO 配置并返回影响行数。 */
|
||||
public int insert(SeoMetadataEntity entity) { return mapper.insert(entity); }
|
||||
|
||||
/** 按业务编号更新 SEO 配置并返回影响行数。 */
|
||||
public int updateByCode(SeoMetadataEntity entity) {
|
||||
return mapper.update(entity, Wrappers.<SeoMetadataEntity>lambdaUpdate()
|
||||
.eq(SeoMetadataEntity::getSeoCode, entity.getSeoCode()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.shoplix.modules.seo.service;
|
||||
|
||||
import com.shoplix.common.exception.BusinessException;
|
||||
import com.shoplix.modules.seo.dto.SeoHeadingDto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/** 校验页面 H1-H3 的 SEO 层级规则。 */
|
||||
@Component
|
||||
public class SeoHeadingValidator {
|
||||
|
||||
/** 校验唯一 H1 及 H2/H3 顺序,禁止 H3 直接出现在 H2 之前。 */
|
||||
public void validate(String h1, List<SeoHeadingDto> headings) {
|
||||
if (h1 == null || h1.isBlank()) {
|
||||
throw new BusinessException("SEO_H1_REQUIRED", "H1 is required");
|
||||
}
|
||||
int previousLevel = 1;
|
||||
for (SeoHeadingDto heading : headings.stream()
|
||||
.sorted(Comparator.comparingInt(SeoHeadingDto::sortNo)).toList()) {
|
||||
if (heading.level() < 2 || heading.level() > 3) {
|
||||
throw new BusinessException("SEO_HEADING_LEVEL_INVALID", "Only H2 and H3 headings are allowed");
|
||||
}
|
||||
if (heading.text() == null || heading.text().isBlank()) {
|
||||
throw new BusinessException("SEO_HEADING_TEXT_REQUIRED", "Heading text is required");
|
||||
}
|
||||
if (heading.level() - previousLevel > 1) {
|
||||
throw new BusinessException("SEO_HEADING_ORDER_INVALID", "H3 cannot appear before an H2 heading");
|
||||
}
|
||||
previousLevel = heading.level();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.shoplix.modules.seo.service;
|
||||
|
||||
import com.shoplix.common.exception.BusinessException;
|
||||
import com.shoplix.modules.seo.enums.SeoPageTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
/** 校验不同 SEO 页面类型是否需要目标业务编号。 */
|
||||
@Component
|
||||
public class SeoTargetValidator {
|
||||
private static final Set<SeoPageTypeEnum> TARGET_REQUIRED_TYPES = EnumSet.of(
|
||||
SeoPageTypeEnum.PRODUCT_CATEGORY_DETAIL, SeoPageTypeEnum.PRODUCT_DETAIL,
|
||||
SeoPageTypeEnum.CASE_CATEGORY_DETAIL, SeoPageTypeEnum.CASE_DETAIL,
|
||||
SeoPageTypeEnum.NEWS_CATEGORY_DETAIL, SeoPageTypeEnum.NEWS_DETAIL,
|
||||
SeoPageTypeEnum.SERVICE_DETAIL, SeoPageTypeEnum.HELP_DETAIL,
|
||||
SeoPageTypeEnum.SYSTEM_PAGE, SeoPageTypeEnum.CUSTOM_PAGE);
|
||||
|
||||
/** 校验详情页、分类详情页和页面必须关联业务 Code。 */
|
||||
public void validate(SeoPageTypeEnum pageType, String targetCode) {
|
||||
if (TARGET_REQUIRED_TYPES.contains(pageType) && (targetCode == null || targetCode.isBlank())) {
|
||||
throw new BusinessException("SEO_TARGET_CODE_REQUIRED", "页面目标业务编号不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.shoplix.modules.site.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
/** 站点域名持久化实体。 */
|
||||
@TableName("sys_site_domain")
|
||||
public class SiteDomainEntity {
|
||||
/** 数据库内部主键。 */
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
/** 域名业务编号。 */
|
||||
private String domainCode;
|
||||
/** 站点业务编号。 */
|
||||
private String siteCode;
|
||||
/** 规范化后的域名。 */
|
||||
private String domain;
|
||||
/** 域名启用状态。 */
|
||||
private String status;
|
||||
/** 逻辑删除状态:0未删除,1已删除。 */
|
||||
private Integer deleted;
|
||||
|
||||
/** 获取域名业务编号。 */
|
||||
public String getDomainCode() { return domainCode; }
|
||||
/** 设置域名业务编号。 */
|
||||
public void setDomainCode(String domainCode) { this.domainCode = domainCode; }
|
||||
/** 获取站点业务编号。 */
|
||||
public String getSiteCode() { return siteCode; }
|
||||
/** 设置站点业务编号。 */
|
||||
public void setSiteCode(String siteCode) { this.siteCode = siteCode; }
|
||||
/** 获取域名。 */
|
||||
public String getDomain() { return domain; }
|
||||
/** 设置域名。 */
|
||||
public void setDomain(String domain) { this.domain = domain; }
|
||||
/** 获取域名状态。 */
|
||||
public String getStatus() { return status; }
|
||||
/** 设置域名状态。 */
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
/** 获取逻辑删除状态。 */
|
||||
public Integer getDeleted() { return deleted; }
|
||||
/** 设置逻辑删除状态。 */
|
||||
public void setDeleted(Integer deleted) { this.deleted = deleted; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.shoplix.modules.site.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shoplix.modules.site.repository.entity.SiteDomainEntity;
|
||||
|
||||
/** 站点域名单表 Mapper。 */
|
||||
public interface SiteDomainMapper extends BaseMapper<SiteDomainEntity> {
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.shoplix.modules.site.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.shoplix.modules.site.repository.entity.SiteDomainEntity;
|
||||
import com.shoplix.modules.site.repository.mapper.SiteDomainMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
/** 封装站点域名单表查询。 */
|
||||
@Service
|
||||
public class SiteDomainRepositoryService {
|
||||
private static final String ENABLED_STATUS = "ENABLED";
|
||||
/** 站点域名 Mapper。 */
|
||||
private final SiteDomainMapper mapper;
|
||||
|
||||
/** 注入站点域名 Mapper。 */
|
||||
public SiteDomainRepositoryService(SiteDomainMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
/** 按域名查询启用的站点绑定。 */
|
||||
public Optional<SiteDomainEntity> findEnabledByDomain(String domain) {
|
||||
String normalizedDomain = domain.toLowerCase(Locale.ROOT);
|
||||
return Optional.ofNullable(mapper.selectOne(Wrappers.<SiteDomainEntity>lambdaQuery()
|
||||
.eq(SiteDomainEntity::getDomain, normalizedDomain)
|
||||
.eq(SiteDomainEntity::getStatus, ENABLED_STATUS)
|
||||
.last("LIMIT 1")));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.shoplix.common.utils;
|
||||
|
||||
import com.shoplix.common.code.enums.BusinessCodePrefixEnum;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/** 业务编号生成工具测试。 */
|
||||
class BusinessCodeUtilsTest {
|
||||
|
||||
/** 验证编号长度、前缀、字符范围和并发序号唯一性。 */
|
||||
@Test
|
||||
void shouldGenerateFixedLengthUniqueCode() {
|
||||
BusinessCodeUtils codeUtils = new BusinessCodeUtils(1);
|
||||
Set<String> codes = new HashSet<>();
|
||||
for (int index = 0; index < 10_000; index++) {
|
||||
codes.add(codeUtils.generate(BusinessCodePrefixEnum.PRODUCT));
|
||||
}
|
||||
assertThat(codes).hasSize(10_000);
|
||||
assertThat(codes).allSatisfy(code -> {
|
||||
assertThat(code).hasSize(16).startsWith("PRD");
|
||||
assertThat(code).matches("[A-Z0-9]{16}");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.common.utils;
|
||||
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*;
|
||||
/** 隐私摘要工具测试。 */ class HashUtilsTest {/** 相同输入和盐必须得到稳定摘要,不同盐必须隔离。 */ @Test void shouldCreateStableSaltedHash(){String first=HashUtils.sha256("customer@example.com","site-a");assertEquals(64,first.length());assertEquals(first,HashUtils.sha256("customer@example.com","site-a"));assertNotEquals(first,HashUtils.sha256("customer@example.com","site-b"));}}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.shoplix.modules.inquiry.enums;
|
||||
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*;
|
||||
/** 询盘状态权限映射测试。 */ class InquiryStatusEnumTest {/** 新询盘允许确认和标记垃圾,垃圾询盘只允许恢复。 */ @Test void shouldExposeStatusOperations(){assertTrue(InquiryStatusEnum.NEW.getOperations().contains("CONFIRM_VALID"));assertTrue(InquiryStatusEnum.NEW.getOperations().contains("MARK_SPAM"));assertEquals(1,InquiryStatusEnum.SPAM.getOperations().size());assertTrue(InquiryStatusEnum.SPAM.getOperations().contains("RESTORE"));}}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.shoplix.modules.seo.service;
|
||||
|
||||
import com.shoplix.common.exception.BusinessException;
|
||||
import com.shoplix.modules.seo.dto.SeoHeadingDto;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||
|
||||
/** SEO 标题层级规则测试。 */
|
||||
class SeoHeadingValidatorTest {
|
||||
/** SEO 标题校验器。 */
|
||||
private final SeoHeadingValidator validator = new SeoHeadingValidator();
|
||||
|
||||
/** 验证正常的 H1、H2、H3 层级可以通过。 */
|
||||
@Test
|
||||
void shouldAcceptValidHeadingHierarchy() {
|
||||
assertThatNoException().isThrownBy(() -> validator.validate("Main heading", List.of(
|
||||
new SeoHeadingDto(2, "Section", 1),
|
||||
new SeoHeadingDto(3, "Subsection", 2))));
|
||||
}
|
||||
|
||||
/** 验证 H3 不能直接跟在 H1 后面。 */
|
||||
@Test
|
||||
void shouldRejectH3BeforeH2() {
|
||||
assertThatThrownBy(() -> validator.validate("Main heading", List.of(
|
||||
new SeoHeadingDto(3, "Subsection", 1))))
|
||||
.isInstanceOf(BusinessException.class)
|
||||
.extracting("code").isEqualTo("SEO_HEADING_ORDER_INVALID");
|
||||
}
|
||||
|
||||
/** 验证页面必须提供唯一 H1 内容。 */
|
||||
@Test
|
||||
void shouldRejectBlankH1() {
|
||||
assertThatThrownBy(() -> validator.validate(" ", List.of()))
|
||||
.isInstanceOf(BusinessException.class)
|
||||
.extracting("code").isEqualTo("SEO_H1_REQUIRED");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.shoplix.modules.seo.service;
|
||||
|
||||
import com.shoplix.common.exception.BusinessException;
|
||||
import com.shoplix.modules.seo.enums.SeoPageTypeEnum;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
/** SEO 页面目标编号规则测试。 */
|
||||
class SeoTargetValidatorTest {
|
||||
/** SEO 页面目标校验器。 */
|
||||
private final SeoTargetValidator validator = new SeoTargetValidator();
|
||||
|
||||
/** 验证固定页面必须关联页面业务编号。 */
|
||||
@Test
|
||||
void shouldRequireTargetCodeForSystemPage() {
|
||||
assertThatThrownBy(() -> validator.validate(SeoPageTypeEnum.SYSTEM_PAGE, ""))
|
||||
.isInstanceOf(BusinessException.class)
|
||||
.extracting("code").isEqualTo("SEO_TARGET_CODE_REQUIRED");
|
||||
}
|
||||
|
||||
/** 验证首页不需要目标业务编号。 */
|
||||
@Test
|
||||
void shouldAllowHomeWithoutTargetCode() {
|
||||
assertThatNoException().isThrownBy(() -> validator.validate(SeoPageTypeEnum.HOME, null));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user