MCPcopy Create free account
hub / github.com/diyhi/bbs / AnswerLikeConfig

Class AnswerLikeConfig

src/main/java/cms/component/like/AnswerLikeConfig.java:14–49  ·  view source on GitHub ↗

答案点赞配置

Source from the content-addressed store, hash-verified

12 *
13 */
14@Component("answerLikeConfig")
15public 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…