|
@ -25,6 +25,7 @@ public class ImageService {
|
25
|
25
|
private File imagePath;
|
26
|
26
|
private File headPath;
|
27
|
27
|
private File orgPath;
|
|
28
|
private File resourcePath;
|
28
|
29
|
private int largeHeadPhotoWidth = 200;
|
29
|
30
|
private int largeHeadPhotoHeight = 200;
|
30
|
31
|
private int middleHeadPhotoWidth = 200;
|
|
@ -34,11 +35,13 @@ public class ImageService {
|
34
|
35
|
|
35
|
36
|
private File defaultHeadPhoto;
|
36
|
37
|
private File defaultOrgLogo;
|
|
38
|
private File defaultResourcePhoto;
|
37
|
39
|
|
38
|
40
|
private byte[] dli;
|
39
|
41
|
private byte[] dmi;
|
40
|
42
|
private byte[] dsi;
|
41
|
43
|
private byte[] dol;
|
|
44
|
private byte[] dsl;
|
42
|
45
|
|
43
|
46
|
public File getDefaultHeadPhoto() {
|
44
|
47
|
return defaultHeadPhoto;
|
|
@ -129,6 +132,14 @@ public class ImageService {
|
129
|
132
|
public void setTmpDir(File tmpPath) {
|
130
|
133
|
this.tmpPath = tmpPath;
|
131
|
134
|
}
|
|
135
|
|
|
136
|
public File getDefaultResourcePhoto() {
|
|
137
|
return defaultResourcePhoto;
|
|
138
|
}
|
|
139
|
|
|
140
|
public void setDefaultResourcePhoto(File defaultResourcePhoto) {
|
|
141
|
this.defaultResourcePhoto = defaultResourcePhoto;
|
|
142
|
}
|
132
|
143
|
|
133
|
144
|
private File getTemplateFielName(File path, String suffix) {
|
134
|
145
|
File result = null;
|
|
@ -226,11 +237,13 @@ public class ImageService {
|
226
|
237
|
this.dmi = this.zoomImage(dd, this.middleHeadPhotoWidth, this.middleHeadPhotoHeight);
|
227
|
238
|
this.dsi = this.zoomImage(dd, this.smallHeadPhotoWidth, this.smallHeadPhotoHeight);
|
228
|
239
|
this.dol = IoUtil.readStream(new FileInputStream(this.defaultOrgLogo), true);
|
|
240
|
this.dsl = IoUtil.readStream(new FileInputStream(this.defaultResourcePhoto), true);
|
229
|
241
|
} catch (IOException e) {
|
230
|
242
|
this.dli = null;
|
231
|
243
|
this.dmi = null;
|
232
|
244
|
this.dsi = null;
|
233
|
245
|
this.dol = null;
|
|
246
|
this.dsl = null;
|
234
|
247
|
throw new RuntimeException("init image error", e);
|
235
|
248
|
}
|
236
|
249
|
}
|
|
@ -247,6 +260,11 @@ public class ImageService {
|
247
|
260
|
this.initDefaultImage();
|
248
|
261
|
IoUtil.saveStream(new FileOutputStream(new File(this.orgPath, id + ".jpg")), this.dol, true);
|
249
|
262
|
}
|
|
263
|
|
|
264
|
public void saveDefaultResourcePhoto(String resourceId) throws IOException {
|
|
265
|
this.initDefaultImage();
|
|
266
|
IoUtil.saveStream(new FileOutputStream(new File(this.resourcePath, resourceId + ".jpg")), this.dsl, true);
|
|
267
|
}
|
250
|
268
|
|
251
|
269
|
@Post
|
252
|
270
|
@Path("/org")
|
|
@ -258,6 +276,17 @@ public class ImageService {
|
258
|
276
|
in.close();
|
259
|
277
|
}
|
260
|
278
|
}
|
|
279
|
|
|
280
|
@Post
|
|
281
|
@Path("/resoure")
|
|
282
|
public void saveResourcePhoto(String resourceId, String fn) throws IOException {
|
|
283
|
InputStream in = new FileInputStream(new File(this.tmpPath, fn));
|
|
284
|
try {
|
|
285
|
IoUtil.copy(in, new FileOutputStream(new File(this.resourcePath, resourceId + ".jpg")), false, true);
|
|
286
|
} finally {
|
|
287
|
in.close();
|
|
288
|
}
|
|
289
|
}
|
261
|
290
|
|
262
|
291
|
@Post
|
263
|
292
|
@Path("/head")
|