|
|
@ -6,10 +6,7 @@ import app.entities.db.Annonce; |
|
|
|
import app.repositories.AnnonceRepository; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
@RestController |
|
|
|
@RequestMapping("api/bot/discord") |
|
|
@ -21,9 +18,24 @@ public class DiscordNewsController { |
|
|
|
@PostMapping("/news") |
|
|
|
@CheckWebAccess(auth_method = AuthMethod.SECRET_KEY) |
|
|
|
public ResponseEntity createNews(@RequestBody Annonce annonce) { |
|
|
|
if (annonceRepository.getAnnonceByUniq(annonce.getUniq()) != null) |
|
|
|
return ResponseEntity.badRequest().build(); |
|
|
|
|
|
|
|
annonce.setId(null); |
|
|
|
annonce.setType("news"); |
|
|
|
annonceRepository.save(annonce); |
|
|
|
return ResponseEntity.ok().body(null); |
|
|
|
} |
|
|
|
|
|
|
|
@DeleteMapping("/news") |
|
|
|
@CheckWebAccess(auth_method = AuthMethod.SECRET_KEY) |
|
|
|
public ResponseEntity deleteNews(@RequestBody String uniq) { |
|
|
|
Annonce annonce = annonceRepository.getAnnonceByUniq(uniq); |
|
|
|
if (annonce == null) |
|
|
|
return ResponseEntity.notFound().build(); |
|
|
|
else { |
|
|
|
annonceRepository.delete(uniq); |
|
|
|
return ResponseEntity.ok(null); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|