Likit-client is a Likit client library for Java.
<dependency>
<groupId>io.github.lxihaaa</groupId>
<artifactId>likit-client</artifactId>
<version>1.0.0-RELEASE</version>
</dependency>implementation group: 'io.github.lxihaaa', name: 'likit-client', version: '1.0.0-RELEASE'add configuration to application.yml
likit:
server:
host: localhost
port: 4778
tls: falseif you deploy likit in zeabur. you should set tls to true.
likit:
server:
host: likit-grpc.zeabur.app
port: 443
tls: trueA Comment Like Example
@RestController
@RequestMapping("/comment")
public class VoteController {
@Autowired
private LikitService likitService;
private final String businessId = "COMMENT_LIKE";
@GetMapping("/vote")
public String Vote(){
// get userId from JWT, Cookie or any other way
String userId = ....
// messageId is the id of the thing that be voted
String messageId = ...
long count = likitService.vote(businessId, messageId, userId);
return count;
}
@GetMapping("/unvote")
public String UnVote(){
// get userId from JWT, Cookie or any other way
String userId = ....
// messageId is the id of the thing that be voted
String messageId = ...
long count = likitService.unvote(businessId, messageId, userId);
return count;
}
@GetMapping("/listComment")
public String count(){
// get userId from JWT, Cookie or any other way
String userId = ....
Comment[] comments = commentService.getComment(...);
for (Comment comment : comments) {
comment.setIsVote(likitService.getIsVote(businessId, comment.getId(), userId));
comment.setVoteCount(likitService.getVoteCount(businessId, comment.getId()));
}
return comments;
}
}