... |
... |
@@ -5,28 +5,6 @@ |
5 |
5 |
// Récupérer l'image en pièce jointe |
6 |
6 |
def img = doc.getAttachment(attachmentName) |
7 |
7 |
|
8 |
|
-// Accéder à l'objet et à la propriété 'count' |
9 |
|
-def obj = doc.getObject(doc.toString()) |
10 |
|
-def countProperty = obj.getProperty('count') |
11 |
|
-def countValue = countProperty.value |
12 |
|
- |
13 |
|
-// Initialiser un compteur pour la date du jour |
14 |
|
-def currentDate = new Date().format('yyyy-MM-dd') |
15 |
|
-def jsonSlurper = new groovy.json.JsonSlurper() |
16 |
|
-def json = countValue ? jsonSlurper.parseText(countValue) : [:] |
17 |
|
- |
18 |
|
-// Incrémenter le compteur pour la date actuelle |
19 |
|
-if (json.containsKey(currentDate)) { |
20 |
|
- json[currentDate] += 1 |
21 |
|
-} else { |
22 |
|
- json[currentDate] = 1 |
23 |
|
-} |
24 |
|
- |
25 |
|
-// Mettre à jour la propriété 'count' avec le nouveau JSON |
26 |
|
-def jsonOutput = new groovy.json.JsonBuilder(json).toPrettyString() |
27 |
|
-obj.set('count',jsonOutput) |
28 |
|
-doc.save() |
29 |
|
- |
30 |
30 |
if (img != null) { |
31 |
31 |
def outs = response.outputStream |
32 |
32 |
response.setContentType("image/png") |
... |
... |
@@ -40,6 +40,5 @@ |
40 |
40 |
} else { |
41 |
41 |
response.sendError(404, "L'image n'existe pas.") |
42 |
42 |
} |
43 |
|
- |
44 |
44 |
{{/groovy}} |
45 |
45 |
|