个人接口/用户接口(测试)

master
Eterlaze 8 months ago
parent f6b8f1cd93
commit 8015876210

@ -0,0 +1,22 @@
package com.example.api.controller;
// 导入项目中定义的角色枚举类
import com.example.api.model.enums.Role;
// 导入Spring框架的注解支持
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
// 使用RestController注解声明这是一个REST控制器它会自动处理HTTP请求并返回数据
@RestController
// 使用RequestMapping注解指定这个控制器的基础URL路径为"/api/role"
@RequestMapping("/api/role")
public class RoleController {
// 使用GetMapping注解定义一个GET请求的处理器当访问"/api/role"路径时会被调用
@GetMapping("")
public Role[] list() {
// 返回Role枚举类中定义的所有角色数组
return Role.ROLES;
}
}

@ -0,0 +1,18 @@
package com.example.api.controller;
import com.example.api.model.entity.User;
import com.example.api.repository.UserRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("/api/user")
public class UserController {
@Resource
private UserRepository userRepository;
}
Loading…
Cancel
Save