基本信息
源码名称:DDD框架COLA应用示例
源码大小:0.16M
文件格式:.zip
开发语言:Java
更新时间:2021-07-20
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
基于DDD框架COLA应用示例
基于DDD框架COLA应用示例
public class ATAMetricItem extends MetricItem { private static Logger logger = LoggerFactory.getLogger(ATAMetricItem.class); private String authorId;//作者 private String title;//文章标题 private String url;//文章链接 private long thumbsUpCount;//点赞数 private long hitCount;//点击数 private long commentCount;//评论数 private long favoriteCount;//收藏数 private static int HIT_STEP_SIZE = 100; private static int THUMB_UPS_STEP_SIZE = 20; private static int FAVORITE_STEP_SIZE = 15; private static int COMMENT_STEP_SIZE = 3; private static double STEP_SCORE = 0.25; private static double BASIC_SCORE = 0.5; public ATAMetricItem(){ } public ATAMetricItem(String title, long thumbsUpCount, long hitCount, long favoriteCount, long commentCount) { this.title = title; this.thumbsUpCount = thumbsUpCount; this.hitCount = hitCount; this.favoriteCount = favoriteCount; this.commentCount = commentCount; } public static ATAMetricItem valueOf(String json){ return JSON.parseObject(json, ATAMetricItem.class); } @Override public double calculateScore() { logger.debug("calculate score for : " this); double score = BASIC_SCORE; score = addScoreByHitCount(score); score = addScoreByThumbsupCount(score); score = addScoreByFavoriteCount(score); score = addScoreByCommentCount(score); logger.debug("calculated score is : " score); return score; } private double addScoreByHitCount(double score) { for(int counter = HIT_STEP_SIZE; counter <= hitCount; counter = counter HIT_STEP_SIZE){ score = score STEP_SCORE; } return score; } private double addScoreByThumbsupCount(double score){ for(int counter = THUMB_UPS_STEP_SIZE; counter <= thumbsUpCount; counter = counter THUMB_UPS_STEP_SIZE){ score = score STEP_SCORE; } return score; } private double addScoreByFavoriteCount(double score){ for(int counter = FAVORITE_STEP_SIZE; counter <= favoriteCount; counter = counter FAVORITE_STEP_SIZE){ score = score STEP_SCORE; } return score; } private double addScoreByCommentCount(double score){ for(int counter = COMMENT_STEP_SIZE; counter <= commentCount; counter = counter COMMENT_STEP_SIZE){ score = score STEP_SCORE; } return score; } }