fix Trackerservice

Change-Id: Id041d972cab72183d2677f98f95d72d9d7d83793
diff --git a/src/main/java/com/example/g8backend/controller/AuthController.java b/src/main/java/com/example/g8backend/controller/AuthController.java
index 39183c1..4b3be4b 100644
--- a/src/main/java/com/example/g8backend/controller/AuthController.java
+++ b/src/main/java/com/example/g8backend/controller/AuthController.java
@@ -21,16 +21,12 @@
 
     @Autowired
     private IUserService userService;
-
     @Autowired
     private mailUtil mailUtil;
-
     @Autowired
     private PasswordEncoder passwordEncoder;
-
     @Autowired
     private JwtUtil jwtUtil;
-
     @Autowired
     RedisTemplate<String, Object> redisTemplate;
 
@@ -79,7 +75,7 @@
         if (existingUser == null || !passwordEncoder.matches(user.getPassword(), existingUser.getPassword())) {
             return ResponseEntity.badRequest().body("用户名或密码错误");
         }
-        String token = jwtUtil.generateToken(existingUser.getUserName());
+        String token = jwtUtil.generateToken(existingUser.getUserId());
         Map<String, String> response = new HashMap<>();
         response.put("token", token);
         return ResponseEntity.ok(response);
diff --git a/src/main/java/com/example/g8backend/controller/TrackerController.java b/src/main/java/com/example/g8backend/controller/TrackerController.java
new file mode 100644
index 0000000..7ee9e5a
--- /dev/null
+++ b/src/main/java/com/example/g8backend/controller/TrackerController.java
@@ -0,0 +1,15 @@
+package com.example.g8backend.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.example.g8backend.service.ITrackerService;
+
+@RestController
+@RequestMapping("/announce")
+public class TrackerController {
+
+}
diff --git a/src/main/java/com/example/g8backend/controller/UserController.java b/src/main/java/com/example/g8backend/controller/UserController.java
index 4bffa3c..2665b4c 100644
--- a/src/main/java/com/example/g8backend/controller/UserController.java
+++ b/src/main/java/com/example/g8backend/controller/UserController.java
@@ -3,52 +3,25 @@
 import com.example.g8backend.entity.User;
 import com.example.g8backend.service.IUserService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.List;
-
 @RestController
-@RequestMapping("/users")
+@RequestMapping("/user")
 public class UserController {
 
     @Autowired
     private IUserService userService;
 
-    // 获取所有用户
+    // 获取已登录的用户信息
     @GetMapping
-    public List<User> getUsers() {
-        return userService.list();
-    }
-
-    // 通过ID获取用户
-    @GetMapping("/{id}")
-    public User getUserById(@PathVariable Long id) {
-        return userService.getById(id);
-    }
-
-    // 通过用户名获取用户
-    @GetMapping("/name/{name}")
-    public User getUserByName(@PathVariable String name) {
-        return userService.getUserByName(name);
-    }
-
-    // 添加用户
-    @PostMapping
-    public void addUser(@RequestBody User user) {
-//        return userService.save(user);
-        userService.registerUser(user);
-    }
-
-    // 修改用户
-    @PutMapping
-    public boolean updateUser(@RequestBody User user) {
-        return userService.updateById(user);
-    }
-
-    // 删除用户
-    @DeleteMapping("/{id}")
-    public boolean deleteUser(@PathVariable Long id) {
-        return userService.removeById(id);
+    public ResponseEntity<?> getUserInfo(){
+        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+        long userId = (long) authentication.getPrincipal();
+        User user = userService.getById(userId);
+        user.setPassword(null);
+        return ResponseEntity.ok(user);
     }
 }
-