zepengdev
2025-06-20 218b9211344b208c425e098e1e51568c66eb1c80
oying-system/src/main/java/com/oying/modules/pc/store/domain/dto/StoreQueryCriteria.java
@@ -1,9 +1,12 @@
package com.oying.modules.pc.store.domain.dto;
import com.oying.utils.StringUtils;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.util.DigestUtils;
import java.io.Serializable;
import java.util.StringJoiner;
/**
 * @author lzp
@@ -19,13 +22,43 @@
    private Integer status;
    private Long storeId;
    private Long platformCategoryId;
    private String blurry;
    private Double longitude; // 中心点经度
    private Double latitude;  // 中心点纬度
    private Integer radius = 10000; // 搜索半径(米)
    private Integer limit = 20; // 返回数量限制
    @ApiModelProperty(value = "页码", example = "1")
    private Integer page = 1;
    @ApiModelProperty(value = "每页数据量", example = "10")
    private Integer size = 10;
    @ApiModelProperty(value = "偏移量", hidden = true)
    private long offset;
    public String buildConditionCacheKey() {
        StringJoiner baseKeyJoiner = new StringJoiner("|");
        if (platformCategoryId != null) {
            baseKeyJoiner.add("platformCategoryId=" + platformCategoryId);
        }
        if (StringUtils.isNotEmpty(blurry)) {
            baseKeyJoiner.add("blurry=" + blurry);
        }
        if (longitude != null && latitude != null) {
            baseKeyJoiner.add("longitude=" + longitude);
            baseKeyJoiner.add("latitude=" + latitude);
        }
        if (StringUtils.isNotEmpty(blurry)) {
            baseKeyJoiner.add("radius=" + radius);
        }
        // 使用MD5或SHA缩短键长度
        return "store:search:page:" + DigestUtils.md5DigestAsHex(baseKeyJoiner.toString().getBytes());
    }
}