UserRecallRequest.java
3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.yoho.search.models.recall;
import com.alibaba.fastjson.JSON;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.search.base.utils.MD5Util;
import com.yoho.search.cache.CacheTimeConstants;
import com.yoho.search.cache.model.ICacheRequest;
import org.apache.commons.lang.StringUtils;
import java.util.List;
public class UserRecallRequest implements ICacheRequest {
private final ParamQueryFilter paramQueryFilter;
private final int pageSize;
private final List<Integer> firstProductSkns;
private final int uid;
private final String udid;
private int pageId;
private RedisKeyBuilder redisKeyBuilder;
private boolean defaultOrder;
private boolean aUser;
public UserRecallRequest(ParamQueryFilter paramQueryFilter, int pageSize, List<Integer> firstProductSkns, int uid, String udid, int pageId, boolean defaultOrder,boolean aUser) {
this.paramQueryFilter = paramQueryFilter;
this.firstProductSkns = firstProductSkns;
this.pageSize = pageSize;
this.uid = uid;
this.udid = udid;
this.pageId = pageId;
this.defaultOrder = defaultOrder;
this.redisKeyBuilder = genRedisKeyBuilder();
this.aUser = aUser;
}
public boolean hasUidOrUdid() {
return uid > 0 || StringUtils.isNotBlank(udid);
}
public boolean openDetailLog() {
if (this.uid == 9963947) {
return true;
}
if ("f6ec847d5ac7ce275992db526666e997eb39425a".equalsIgnoreCase(this.udid)) {
return true;
}
return false;
}
@Override
public RedisKeyBuilder redisKeyBuilder() {
return this.redisKeyBuilder;
}
private RedisKeyBuilder genRedisKeyBuilder() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(paramQueryFilter == null ? "" : paramQueryFilter.getParamMd5Key());
stringBuilder.append(pageSize);
stringBuilder.append(firstProductSkns == null ? "" : JSON.toJSON(firstProductSkns));
stringBuilder.append(uid);
stringBuilder.append(udid == null ? "" : udid);
stringBuilder.append(pageId);
stringBuilder.append(defaultOrder);
stringBuilder.append(aUser);
String value = MD5Util.string2MD5(stringBuilder.toString());
return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("USER_RECALL_SKN_LIST:").appendVar(cacheTimeInMinute()).appendFixed(":").appendVar(value);
}
@Override
public int cacheTimeInMinute() {
return CacheTimeConstants.USER_RECALL_SKN_LIST;
}
public ParamQueryFilter getParamQueryFilter() {
return paramQueryFilter;
}
public int getPageSize() {
return pageSize;
}
public int getUid() {
return uid;
}
public String getUdid() {
return udid;
}
public List<Integer> getFirstProductSkns() {
return firstProductSkns;
}
public int getPageId() {
return pageId;
}
public boolean isDefaultOrder() {
return defaultOrder;
}
public boolean isAUser() {
return aUser;
}
}