|
@@ -2,8 +2,10 @@ package com.ygj.yuemum.controller.admin;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ygj.yuemum.domain.admin.Photo;
|
|
|
+import com.ygj.yuemum.domain.admin.Resume;
|
|
|
import com.ygj.yuemum.domain.maternitymatron.JlServiceUser;
|
|
|
import com.ygj.yuemum.service.admin.PhotoService;
|
|
|
+import com.ygj.yuemum.service.admin.ResumeService;
|
|
|
import com.ygj.yuemum.service.maternitymatron.JlServiceUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.core.io.ResourceLoader;
|
|
@@ -25,10 +27,13 @@ public class ImageUploadController {
|
|
|
private PhotoService photoService;
|
|
|
@Autowired
|
|
|
private JlServiceUserService jlServiceUserService;
|
|
|
+ @Autowired
|
|
|
+ private ResumeService resumeService;
|
|
|
private ResourceLoader resourceLoader;
|
|
|
public static final String ROOT = "D:/apache-tomcat-9.0.6/webapps/resume/img/";
|
|
|
public static final String ResumeFile = "D:/apache-tomcat-9.0.6/webapps/resume/";
|
|
|
public static final String httpRoot = "http://localhost:8080/resume/img/";
|
|
|
+ public static final String httphtmlRoot = "http://localhost:8080/resume/";
|
|
|
|
|
|
@RequestMapping(value = "/upload", method = RequestMethod.GET)
|
|
|
public String upload() {
|
|
@@ -93,13 +98,102 @@ public class ImageUploadController {
|
|
|
return jso;
|
|
|
}
|
|
|
@PostMapping("/createResume")
|
|
|
- public int createResume(@ModelAttribute Photo photo) {
|
|
|
+ public String createResume(@ModelAttribute Photo photo) {
|
|
|
try {
|
|
|
JlServiceUser jlServiceUser = jlServiceUserService.getResume(photo.getServant_code());
|
|
|
File file = ResourceUtils.getFile("classpath:resume/resume.html");
|
|
|
BufferedReader br = new BufferedReader(new FileReader(file));
|
|
|
+ Resume resume =new Resume();
|
|
|
+ Resume resumeold =new Resume();
|
|
|
StringBuilder stringHtml = new StringBuilder();
|
|
|
String str = "";
|
|
|
+ String photoDisplay ="";
|
|
|
+ String certificate ="";
|
|
|
+ String certificatehref ="";
|
|
|
+ String service ="";
|
|
|
+ String servicehref ="";
|
|
|
+ String comment ="";
|
|
|
+ if(photo.getComment() == null){
|
|
|
+ photo.setComment(" ");
|
|
|
+ }
|
|
|
+ List<Photo> photos = photoService.queryPhoto(photo);
|
|
|
+ if(photos.size() > 0 ) {
|
|
|
+ int stepcertificate = 0;
|
|
|
+ int stepservice = 0;
|
|
|
+ for(Photo onePhoto:photos){
|
|
|
+ if(onePhoto.getPhoto_type() == 1){
|
|
|
+ if(onePhoto.getPhoto_path() !=null){
|
|
|
+ photoDisplay = "<image class=\"resume-header-left-image\" src='"+onePhoto.getPhoto_path()+"'></image>"+"\r\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(onePhoto.getPhoto_type() == 2){
|
|
|
+ if(onePhoto.getPhoto_path() !=null){
|
|
|
+ certificate = certificate +"<li class=\"poster-item zturn-item\">"+"\r\n"
|
|
|
+ +"<image class=\"zturn-item-image-cer\" src='"+onePhoto.getPhoto_path()+"'></image>"+"\r\n"
|
|
|
+ +"</li>"+"\r\n";
|
|
|
+ if(stepcertificate == 0) {
|
|
|
+ certificatehref = certificatehref + "<a href=\"javascript:void(0);\" value='"+stepcertificate+"' class=\"indicator-list-item selected\"></a>" + "\r\n";
|
|
|
+ } else {
|
|
|
+ certificatehref = certificatehref + "<a href=\"javascript:void(0);\" value='"+stepcertificate+"' class=\"indicator-list-item \"></a>" + "\r\n";
|
|
|
+ }
|
|
|
+ stepcertificate ++ ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(onePhoto.getPhoto_type() == 4){
|
|
|
+ if(onePhoto.getPhoto_path() !=null) {
|
|
|
+ service = service+"<li class=\"poster-item zturn-item\">"+"\r\n"
|
|
|
+ + "<image class=\"zturn-item-image\" src='"+onePhoto.getPhoto_path()+"'></image>"+"\r\n"
|
|
|
+ +"</li>"+"\r\n";
|
|
|
+ if(stepservice == 0) {
|
|
|
+ servicehref = servicehref + " <a href=\"javascript:void(0);\" value='"+stepservice+"' class=\"indicator-list-item-service selected\"></a>" + "\r\n";
|
|
|
+ }else {
|
|
|
+ servicehref = servicehref + " <a href=\"javascript:void(0);\" value='"+stepservice+"' class=\"indicator-list-item-service\"></a>" + "\r\n";
|
|
|
+ }
|
|
|
+ stepservice++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(onePhoto.getPhoto_type() == 3){
|
|
|
+ comment = comment +"<a href=\"\"><img src='"+onePhoto.getPhoto_path()+"'/></a>"+"\r\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(photoDisplay == ""){
|
|
|
+ photoDisplay = "<image class=\"resume-header-left-image\" src=\"img/header.jpg\"></image>"+"\r\n";
|
|
|
+ }
|
|
|
+ if(certificate == ""){
|
|
|
+ certificate = "<li class=\"poster-item zturn-item\">"+"\r\n"
|
|
|
+ +"<image class=\"zturn-item-image-cer\" src=\"img/certificate01.jpg\"></image>"+"\r\n"
|
|
|
+ +"</li>"+"\r\n"
|
|
|
+ +"<li class=\"poster-item zturn-item\">"+"\r\n"
|
|
|
+ +"<image class=\"zturn-item-image-cer\" src=\"img/certificate02.jpg\"></image>"+"\r\n"
|
|
|
+ +"</li>"+"\r\n"
|
|
|
+ +"<li class=\"poster-item zturn-item\">"+"\r\n"
|
|
|
+ +"<image class=\"zturn-item-image-cer\" src=\"img/certificate03.jpg\"></image>"+"\r\n"
|
|
|
+ +"</li>"+"\r\n";
|
|
|
+ certificatehref = "<a href=\"javascript:void(0);\" value=\"0\" class=\"indicator-list-item selected\"></a>"+"\r\n"
|
|
|
+ +"<a href=\"javascript:void(0);\" value=\"1\" class=\"indicator-list-item\"></a>"+"\r\n"
|
|
|
+ +"<a href=\"javascript:void(0);\" value=\"2\" class=\"indicator-list-item\"></a>"+"\r\n";
|
|
|
+
|
|
|
+ }
|
|
|
+ if(service == ""){
|
|
|
+ service = "<li class=\"poster-item zturn-item\">"+"\r\n"
|
|
|
+ +"<image class=\"zturn-item-image\" src=\"img/service01.png\"></image>"+"\r\n"
|
|
|
+ +"</li>"+"\r\n"
|
|
|
+ +"<li class=\"poster-item zturn-item\">"+"\r\n"
|
|
|
+ +"<image class=\"zturn-item-image\" src=\"img/service01.png\"></image>"+"\r\n"
|
|
|
+ +"</li>"+"\r\n"
|
|
|
+ +"<li class=\"poster-item zturn-item\">"+"\r\n"
|
|
|
+ +"<image class=\"zturn-item-image\" src=\"img/service01.png\"></image>"+"\r\n"
|
|
|
+ +"</li>"+"\r\n";
|
|
|
+ servicehref = " <a href=\"javascript:void(0);\" value=\"0\" class=\"indicator-list-item-service selected\"></a>"+"\r\n"
|
|
|
+ +"<a href=\"javascript:void(0);\" value=\"1\" class=\"indicator-list-item-service\"></a>"+"\r\n"
|
|
|
+ +"<a href=\"javascript:void(0);\" value=\"2\" class=\"indicator-list-item-service\"></a>"+"\r\n";
|
|
|
+ }
|
|
|
+ if(comment == ""){
|
|
|
+ comment = "<a href=\"\"><img src=\"img/comments01.jpg\"/></a>"+"\r\n"
|
|
|
+ +"<a href=\"\"><img src=\"img/comments02.jpg\"/></a>"+"\r\n"
|
|
|
+ +"<a href=\"\"><img src=\"img/comments03.jpg\"/></a>"+"\r\n";
|
|
|
+ }
|
|
|
while((str = br.readLine())!=null){
|
|
|
str = str.replace("$name",jlServiceUser.getTruename());
|
|
|
str = str.replace("$np",jlServiceUser.getNp()+"人");
|
|
@@ -116,17 +210,31 @@ public class ImageUploadController {
|
|
|
str = str.replace("$zodiac",jlServiceUser.getZodiac());
|
|
|
str = str.replace("$height",jlServiceUser.getHeight());
|
|
|
str = str.replace("$starts",jlServiceUser.getGender());
|
|
|
+ str = str.replace("$display",photoDisplay);
|
|
|
+ str = str.replace("$credentials",certificate);
|
|
|
+ str = str.replace("$cfstyle",certificatehref);
|
|
|
+ str = str.replace("$service",service);
|
|
|
+ str = str.replace("$scstyle",servicehref);
|
|
|
+ str = str.replace("$comment",comment);
|
|
|
stringHtml.append(str+"\r\n");
|
|
|
}
|
|
|
+ resumeold = resumeService.getResume(photo.getServant_code());
|
|
|
+ if(resumeold != null) {
|
|
|
+ resumeService.deleteResume(resumeold.getId());
|
|
|
+ }
|
|
|
+ resume.setServant_code(photo.getServant_code());
|
|
|
+ resume.setResume_comment(photo.getComment());
|
|
|
+ resume.setResume_path(httphtmlRoot+photo.getServant_code() + ".html");
|
|
|
+ resumeService.addResume(resume);
|
|
|
File newResume = new File(ResumeFile + photo.getServant_code() + ".html");
|
|
|
FileWriter fileWriter = new FileWriter(newResume);
|
|
|
fileWriter.write(stringHtml.toString());
|
|
|
fileWriter.close();
|
|
|
} catch (Exception ex){
|
|
|
ex.printStackTrace();
|
|
|
- return 0;
|
|
|
+ return "error";
|
|
|
}
|
|
|
- return 1;
|
|
|
+ return httphtmlRoot+photo.getServant_code() + ".html";
|
|
|
}
|
|
|
public String getpathtype(int type){
|
|
|
switch (type) {
|