11import {
22 Authorized ,
3- Delete ,
43 JsonController ,
5- ForbiddenError ,
64 CurrentUser ,
7- Param ,
8- Put ,
95 Post ,
106 Body
117} from "routing-controllers" ;
@@ -15,16 +11,11 @@ import { SettingsServiceToken, ISettingsService } from "../services/settings-ser
1511import { RatingServiceToken , IRatingService } from "../services/rating-service" ;
1612import {
1713 RatingDTO ,
18- CriteriaDTO ,
19- SuccessResponseDTO ,
2014 convertBetweenEntityAndDTO
2115} from "./dto" ;
2216import { User } from "../entities/user" ;
23- import { Criteria } from "../entities/criteria" ;
2417import { Rating } from "../entities/rating" ;
2518
26- // TODO separate rating and criteria controller?
27-
2819@JsonController ( "/ratings" )
2920export class RatingController {
3021 public constructor (
@@ -69,48 +60,5 @@ export class RatingController {
6960 return convertBetweenEntityAndDTO ( createdRating , RatingDTO ) ;
7061 }
7162
72- /**
73- * Create criteria.
74- */
75- @Post ( "/criteria" )
76- @Authorized ( UserRole . Root )
77- public async createCriteria (
78- @Body ( ) { data : criteriaDTO } : { data : CriteriaDTO } ,
79- ) : Promise < CriteriaDTO > {
80- const criteria = convertBetweenEntityAndDTO ( criteriaDTO , Criteria ) ;
81- const createdCriteria = await this . _ratings . createCriteria ( criteria ) ;
82- return convertBetweenEntityAndDTO ( createdCriteria , CriteriaDTO ) ;
83- }
84-
85- /**
86- * Update criteria.
87- */
88- @Put ( "/criteria/:id" )
89- @Authorized ( UserRole . Root )
90- public async updateCriteria (
91- @Param ( "id" ) criteriaId : number ,
92- @Body ( ) { data : criteriaDTO } : { data : CriteriaDTO } ,
93- ) : Promise < CriteriaDTO > {
94- // TODO There is a TeamUpdateDTO. CriteriaUpdateDTO?
95- const criteria = convertBetweenEntityAndDTO ( criteriaDTO , Criteria ) ;
96- const updateCriteria = await this . _ratings . updateCriteria ( criteria ) ;
97- return convertBetweenEntityAndDTO ( updateCriteria , CriteriaDTO ) ;
98- }
99-
100- /**
101- * Delete criteria.
102- */
103- @Delete ( "/criteria/:id" )
104- @Authorized ( UserRole . Root )
105- public async deleteCriteria (
106- @Param ( "id" ) criteriaId : number ,
107- @CurrentUser ( ) user : User ,
108- ) : Promise < SuccessResponseDTO > {
109- await this . _ratings . deleteCriteriaByID ( criteriaId , user ) ;
110- const response = new SuccessResponseDTO ( ) ;
111- response . success = true ;
112- return response ;
113- }
114-
11563 // TODO write test that all the root endpoints are not accessible by users
11664}
0 commit comments