indev
This commit is contained in:
		| @ -18,11 +18,13 @@ import jakarta.websocket.server.PathParam; | |||||||
| import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||||
| import ovh.herisson.Clyde.Repositories.CourseRepository; | import ovh.herisson.Clyde.Repositories.CourseRepository; | ||||||
| import ovh.herisson.Clyde.Repositories.Msg.ForumRepository; | import ovh.herisson.Clyde.Repositories.Msg.ForumRepository; | ||||||
|  | import ovh.herisson.Clyde.Repositories.Msg.TopicRepository; | ||||||
| import ovh.herisson.Clyde.Responses.UnauthorizedResponse; | import ovh.herisson.Clyde.Responses.UnauthorizedResponse; | ||||||
| import ovh.herisson.Clyde.Services.AuthenticatorService; | import ovh.herisson.Clyde.Services.AuthenticatorService; | ||||||
| import ovh.herisson.Clyde.Services.CourseService; | import ovh.herisson.Clyde.Services.CourseService; | ||||||
| import ovh.herisson.Clyde.Services.Msg.ForumService; | import ovh.herisson.Clyde.Services.Msg.ForumService; | ||||||
| import ovh.herisson.Clyde.Tables.Course; | import ovh.herisson.Clyde.Tables.Course; | ||||||
|  | import ovh.herisson.Clyde.Tables.Token; | ||||||
| import ovh.herisson.Clyde.Tables.User; | import ovh.herisson.Clyde.Tables.User; | ||||||
| import ovh.herisson.Clyde.Tables.Msg.Forum; | import ovh.herisson.Clyde.Tables.Msg.Forum; | ||||||
| import ovh.herisson.Clyde.Tables.Msg.Topic; | import ovh.herisson.Clyde.Tables.Msg.Topic; | ||||||
| @ -37,6 +39,7 @@ public class ForumController { | |||||||
| 	private AuthenticatorService authServ; | 	private AuthenticatorService authServ; | ||||||
| 	private ForumService forumServ; | 	private ForumService forumServ; | ||||||
| 	private ForumRepository forumRepo; | 	private ForumRepository forumRepo; | ||||||
|  | 	private TopicRepository topicRepo; | ||||||
|  |  | ||||||
| 	//// Endpoints to get and create new forums | 	//// Endpoints to get and create new forums | ||||||
|  |  | ||||||
| @ -81,4 +84,19 @@ public class ForumController { | |||||||
| 		forumServ.createTopic(f, data); | 		forumServ.createTopic(f, data); | ||||||
| 		return new ResponseEntity<>(HttpStatus.ACCEPTED); | 		return new ResponseEntity<>(HttpStatus.ACCEPTED); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	//// Endpoints related to topics and messages | ||||||
|  | 	 | ||||||
|  | 	@GetMapping("/forum/post/{id}") | ||||||
|  | 	public ResponseEntity<Topic> getPost(@RequestHeader("Authorization") String token, @PathVariable long id){ | ||||||
|  | 		User u = authServ.getUserFromToken(token); | ||||||
|  | 		if(u != null){ | ||||||
|  | 			return new UnauthorizedResponse<>(null); | ||||||
|  | 		} | ||||||
|  | 		Topic t = topicRepo.findById(id).orElse(null); | ||||||
|  | 		return new ResponseEntity<>(t, HttpStatus.OK); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	// TODO: <tonitch> Create a new post/topic and response to a topic | ||||||
| } | } | ||||||
|  | |||||||
| @ -0,0 +1,10 @@ | |||||||
|  | package ovh.herisson.Clyde.EndPoints.Msg; | ||||||
|  |  | ||||||
|  | import org.springframework.data.repository.CrudRepository; | ||||||
|  |  | ||||||
|  | import ovh.herisson.Clyde.Tables.Msg.Topic; | ||||||
|  |  | ||||||
|  | public interface TopicRepository extends CrudRepository<Topic, Long> { | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
		Reference in New Issue
	
	Block a user