Vue+SpringBoot的篮球社区平台
1.开发工具eclipse或IDEA2.主要功能看演示地址3.技术架构springBoot+Vue+mysql4.部分代码展示package com.pjq.grapeoject.web;import com.auth0.jwt.interfaces.DecodedJWT;import com.pjq.grapeoject.Service.userService;import com.pjq.gr
1.开发工具
eclipse或IDEA
2.主要功能看演示地址
3.技术架构
springBoot+Vue+mysql
4.部分代码展示
package com.pjq.grapeoject.web;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.pjq.grapeoject.Service.userService;
import com.pjq.grapeoject.domain.User;
import com.pjq.grapeoject.utils.JWTUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(“user”)
public class userController {
@Autowired
private userService userservice;
@PostMapping("register")
public ResponseEntity<Void> register (User user) {
userservice.register(user);
return ResponseEntity.status(HttpStatus.CREATED).build();
}
/**
*
* @param userName
* @param passWord
* @return token
*/
@GetMapping("login")
public String loginSearch(@RequestParam("userName") String userName,
@RequestParam("passWord") String passWord){
List<User> l= userservice.login(userName,passWord);
Integer id=l.get(0).getId();
Integer flag=l.get(0).getStatusFlag();
String username=l.get(0).getUsername();
String uid=id.toString();
String uflag=flag.toString();
Map<String,String> payload = new HashMap<>();
payload.put("id",uid);
payload.put("flag",uflag);
payload.put("username",username);
String token = JWTUtils.getToken(payload);
return token;
}
@PostMapping("token")
public String test(HttpServletRequest request){
//处理自己业务逻辑
String token = request.getHeader("token");
DecodedJWT verify = JWTUtils.verify(token);
String uflag= verify.getClaim("flag").asString();
return uflag;
}
@GetMapping("check")
public ResponseEntity<Boolean> checkData(@RequestParam("userName") String userName){
if (userName==null||userName=="") {
return ResponseEntity.ok(false);
}
return ResponseEntity.ok(userservice.checkData(userName));
}
}
演示地址:
链接:https://pan.baidu.com/s/1KACrU1ktScX5abFkGUQunQ
提取码:tjt9
更多推荐
所有评论(0)