答案点赞配置
| 12 | * |
| 13 | */ |
| 14 | @Component("answerLikeConfig") |
| 15 | public class AnswerLikeConfig { |
| 16 | |
| 17 | @Resource LikeConfig likeConfig; |
| 18 | |
| 19 | /** 分表数量 **/ |
| 20 | @Value("${bbs.sharding.answerLikeConfig_tableQuantity}") |
| 21 | @Getter |
| 22 | private Integer tableQuantity = 1; |
| 23 | |
| 24 | /** |
| 25 | * 根据答案点赞Id查询分配到表编号 |
| 26 | * 根据答案点赞Id和答案点赞分表数量求余 |
| 27 | * @param answerLikeId 答案点赞Id |
| 28 | * 注意:答案点赞Id要先判断最后4位是不是数字 |
| 29 | * likeManage.verificationTopicLikeId(?) |
| 30 | * @return |
| 31 | */ |
| 32 | public Integer answerLikeIdRemainder(String answerLikeId){ |
| 33 | int answerId = likeConfig.getItemLikeId(answerLikeId); |
| 34 | return answerId % this.getTableQuantity(); |
| 35 | } |
| 36 | /** |
| 37 | * 根据答案Id查询分配到表编号 |
| 38 | * 根据答案Id和答案点赞分表数量求余(用户Id后四位) |
| 39 | * @param answerId 答案Id |
| 40 | * @return |
| 41 | */ |
| 42 | public Integer answerIdRemainder(Long answerId){ |
| 43 | //选取得后N位答案Id |
| 44 | String afterAnswerId = String.format("%04d", answerId%10000); |
| 45 | return Integer.parseInt(afterAnswerId) % this.getTableQuantity(); |
| 46 | } |
| 47 | |
| 48 | |
| 49 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…