Krishya | b0cc188 | 2025-06-09 10:54:09 +0800 | [diff] [blame] | 1 | package com.example.myproject.controller; |
| 2 | |
Jin | f50fba6 | 2025-06-09 22:47:24 +0800 | [diff] [blame] | 3 | import cn.dev33.satoken.annotation.SaCheckLogin; |
| 4 | import cn.dev33.satoken.annotation.SaCheckRole; |
| 5 | import cn.dev33.satoken.annotation.SaMode; |
Krishya | b0cc188 | 2025-06-09 10:54:09 +0800 | [diff] [blame] | 6 | import com.example.myproject.service.SeedRatingService; |
| 7 | import org.springframework.web.bind.annotation.*; |
| 8 | |
| 9 | import java.util.Map; |
| 10 | |
| 11 | @RestController |
| 12 | @RequestMapping("/echo/ratings") |
Jin | f50fba6 | 2025-06-09 22:47:24 +0800 | [diff] [blame] | 13 | @SaCheckLogin |
| 14 | @SaCheckRole(value = {"cookie", "chocolate", "ice-cream"}, mode = SaMode.OR) |
Krishya | b0cc188 | 2025-06-09 10:54:09 +0800 | [diff] [blame] | 15 | public class SeedRatingController { |
| 16 | |
| 17 | private final SeedRatingService ratingService; |
| 18 | |
| 19 | public SeedRatingController(SeedRatingService ratingService) { |
| 20 | this.ratingService = ratingService; |
| 21 | } |
| 22 | |
| 23 | @PostMapping |
| 24 | public Map<String, Object> submitRating( |
| 25 | @RequestParam("userId") Long userId, |
| 26 | @RequestParam("seedId") Long seedId, |
| 27 | @RequestParam("score") Integer score |
| 28 | ) { |
| 29 | return ratingService.rateSeed(userId, seedId, score); |
| 30 | } |
| 31 | } |