刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 1 | package com.pt5.pthouduan.controller; |
| 2 | |
| 3 | import com.pt5.pthouduan.entity.User; |
| 4 | import com.pt5.pthouduan.service.UserService; |
| 5 | import org.springframework.beans.factory.annotation.Autowired; |
| 6 | import org.springframework.web.bind.annotation.*; |
| 7 | import org.springframework.stereotype.Controller; |
| 8 | |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame^] | 9 | import java.util.Map; |
| 10 | |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 11 | /** |
| 12 | * <p> |
| 13 | * 前端控制器 |
| 14 | * </p> |
| 15 | * |
| 16 | * @author ljx |
| 17 | * @since 2025-04-14 |
| 18 | */ |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame^] | 19 | @RestController |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 20 | @RequestMapping("/user") |
| 21 | public class UserController { |
| 22 | @Autowired |
| 23 | private UserService userService; |
| 24 | |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame^] | 25 | @PostMapping("/register") |
| 26 | public Map<String, Object> register(@RequestBody User user,@RequestParam String code) { |
| 27 | return userService.register(user,code); |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 28 | } |
| 29 | |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame^] | 30 | @PostMapping("/login") |
| 31 | public Map<String, Object> login(@RequestParam String username, |
| 32 | @RequestParam String password) { |
| 33 | return userService.login(username, password); |
| 34 | } |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 35 | |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame^] | 36 | @PostMapping("/calgrade") |
| 37 | public Map<String, Object> calgrade(@RequestParam String username) { |
| 38 | return userService.CalGrade(username); |
| 39 | } |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 40 | |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame^] | 41 | @PostMapping("/changesex") |
| 42 | public Map<String, Object> changsex(@RequestParam String username, |
| 43 | @RequestParam String sex) { |
| 44 | return userService.changesex(username,sex); |
| 45 | } |
| 46 | |
| 47 | @PostMapping("/changeimage") |
| 48 | public Map<String, Object> changeimage(@RequestParam String username, |
| 49 | @RequestParam String image) { |
| 50 | return userService.changeImage(username,image); |
| 51 | } |
| 52 | |
| 53 | @PostMapping("/changePassword") |
| 54 | public Map<String, Object> changePassword(@RequestParam String username, |
| 55 | @RequestParam String oldpassword, |
| 56 | @RequestParam String newpassword) { |
| 57 | return userService.changePassword(username,oldpassword,newpassword); |
| 58 | } |
| 59 | |
| 60 | @GetMapping("/info") |
| 61 | public Map<String, Object> getUserInfo(@RequestParam(required = false) String username) { |
| 62 | return userService.login(username, ""); |
| 63 | } |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 64 | } |