final state of exercise 2

This commit is contained in:
d045778
2019-09-23 13:25:44 +02:00
parent 1e28cb217f
commit fb8f6acac7
8 changed files with 153 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
namespace sap.capire.reviews;
using { sap.capire.reviews as my } from '../db/schema';
service ReviewsService {
event reviewed : { subject:String; rating: Decimal(2,1) };
// API
entity Reviews as projection on my.Reviews excluding { likes }
action like (review:Reviews.ID);
action unlike (review:Reviews.ID);
// Input validation
annotate Reviews with {
subject @mandatory;
title @mandatory;
rating @mandatory @assert.enum;
}
// Auto-fill reviewers and review dates
annotate Reviews with {
reviewer @cds.on.insert:$user;
date @cds.on.insert:$now;
date @cds.on.update:$now;
}
}