| package com.example.myproject.controller; |
| |
| import cn.dev33.satoken.annotation.SaCheckLogin; |
| import cn.dev33.satoken.annotation.SaCheckRole; |
| import cn.dev33.satoken.annotation.SaMode; |
| import com.example.myproject.service.SeedRatingService; |
| import org.springframework.web.bind.annotation.*; |
| |
| import java.util.Map; |
| |
| @RestController |
| @RequestMapping("/echo/ratings") |
| @SaCheckLogin |
| @SaCheckRole(value = {"cookie", "chocolate", "ice-cream"}, mode = SaMode.OR) |
| public class SeedRatingController { |
| |
| private final SeedRatingService ratingService; |
| |
| public SeedRatingController(SeedRatingService ratingService) { |
| this.ratingService = ratingService; |
| } |
| |
| @PostMapping |
| public Map<String, Object> submitRating( |
| @RequestParam("userId") Long userId, |
| @RequestParam("seedId") Long seedId, |
| @RequestParam("score") Integer score |
| ) { |
| return ratingService.rateSeed(userId, seedId, score); |
| } |
| } |