mirror of https://github.com/ZhongFuCheng3y/austin
parent
25966c9301
commit
f2973035bb
@ -0,0 +1,12 @@
|
|||||||
|
package com.java3y.austin.service.deduplication;
|
||||||
|
|
||||||
|
import com.java3y.austin.domain.DeduplicationParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huskey
|
||||||
|
* @date 2022/1/18
|
||||||
|
*/
|
||||||
|
public interface DeduplicationService {
|
||||||
|
|
||||||
|
void deduplication(DeduplicationParam param);
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.java3y.austin.service.deduplication.build;
|
||||||
|
|
||||||
|
import com.java3y.austin.domain.DeduplicationParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author luohaojie
|
||||||
|
* @date 2022/1/18
|
||||||
|
*/
|
||||||
|
public interface Builder {
|
||||||
|
|
||||||
|
DeduplicationParam build(String deduplication, String key);
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.java3y.austin.service.deduplication.build;
|
||||||
|
|
||||||
|
import com.java3y.austin.service.deduplication.DeduplicationConstants;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huskey
|
||||||
|
* @date 2022/1/18
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class BuilderFactory {
|
||||||
|
|
||||||
|
|
||||||
|
private Map<String, Builder> builderFactory = new HashMap<>(4);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Builder contentDeduplicationBuilder;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Builder frequencyDeduplicationBuilder;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
builderFactory.put(DeduplicationConstants.CONTENT_DEDUPLICATION, contentDeduplicationBuilder);
|
||||||
|
builderFactory.put(DeduplicationConstants.FREQUENCY_DEDUPLICATION, frequencyDeduplicationBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Builder select(String key) {
|
||||||
|
return builderFactory.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.java3y.austin.service.deduplication.build;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.java3y.austin.domain.DeduplicationParam;
|
||||||
|
import com.java3y.austin.enums.AnchorState;
|
||||||
|
import com.java3y.austin.service.deduplication.build.Builder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huskey
|
||||||
|
* @date 2022/1/18
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ContentDeduplicationBuilder implements Builder {
|
||||||
|
|
||||||
|
public DeduplicationParam build(String deduplication, String key) {
|
||||||
|
JSONObject object = JSONObject.parseObject(deduplication);
|
||||||
|
if (object == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DeduplicationParam deduplicationParam = JSONObject.parseObject(object.getString(key), DeduplicationParam.class);
|
||||||
|
if (deduplicationParam == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
deduplicationParam.setAnchorState(AnchorState.RULE_DEDUPLICATION);
|
||||||
|
return deduplicationParam;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.java3y.austin.service.deduplication.build;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.java3y.austin.domain.DeduplicationParam;
|
||||||
|
import com.java3y.austin.enums.AnchorState;
|
||||||
|
import com.java3y.austin.service.deduplication.build.Builder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huskey
|
||||||
|
* @date 2022/1/18
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class FrequencyDeduplicationBuilder implements Builder {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeduplicationParam build(String deduplication, String key) {
|
||||||
|
JSONObject object = JSONObject.parseObject(deduplication);
|
||||||
|
if (object == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DeduplicationParam deduplicationParam = JSONObject.parseObject(object.getString(key), DeduplicationParam.class);
|
||||||
|
if (deduplicationParam == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
deduplicationParam.setDeduplicationTime((DateUtil.endOfDay(new Date()).getTime() - DateUtil.current()) / 1000);
|
||||||
|
deduplicationParam.setAnchorState(AnchorState.RULE_DEDUPLICATION);
|
||||||
|
return deduplicationParam;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue