I have a project to make a site as stack overflow but current for reviews for products, I write on java spring boot, in my project you can leave a question and you can answer these questions and can put + or - a question how to make so that one user can current once plus put?
public Question postMarkToQuestion(Long questionId, String mark) { Question question = questionRep.findById(questionId).get(); if(mark.equals("+")){ question.setLikes(question.getLikes() + 1); } else if(mark.equals("-")){ question.setDislikes(question.getDislikes() + 1); } questionRep.save(question); return question; }