package cn.aopmin.controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* @author 白豆五
* @version 2023/06/28
* @since JDK8
*/
@RestController
@RequestMapping(“/api/user”)
public class UserController {
// region 通过ID获取用户信息
@PostMapping("/info")
public String getInfo(Long userId) {
// 匿名内部类方式构建map存放用户信息
Map<String, Object> userInfo = new HashMap<String, Object>() {
{
put("userId", 129);
put("userName", "白豆五");
put("userAge", 18);
put("userSex", "男");
}
};
if (userId == userInfo.get(userInfo)) { //如果两个包装类型比