Browse Source

改变调用地址

huan.wang 6 năm trước cách đây
mục cha
commit
e6e585100e
1 tập tin đã thay đổi với 131 bổ sung131 xóa
  1. 131 131
      src/main/java/com/ygj/yuemum/service/admin/PhotoService.java

+ 131 - 131
src/main/java/com/ygj/yuemum/service/admin/PhotoService.java

@@ -1,132 +1,132 @@
-package com.ygj.yuemum.service.admin;
-
-import com.ygj.yuemum.dao.admin.PhotoDao;
-import com.ygj.yuemum.domain.admin.Photo;
-import com.ygj.yuemum.domain.admin.Resume;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.util.EntityUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-@Service
-public class PhotoService {
-
-    @Autowired
-    private PhotoDao photoDao;
-    @Autowired
-    private ResumeService resumeService;
-
-    public List<Photo> getPhotos() {
-        List<Photo> photos = photoDao.getAll();
-        return photos;
-    }
-
-    public int addPhoto(Photo photo) {
-        return photoDao.insertSelective(photo);
-    }
-
-    public String selectDisplay(Photo photo) {
-        return photoDao.selectDisplay(photo);
-    }
-
-    public int deletePhoto(Photo photo) {
-        return photoDao.deletePhoto(photo);
-    }
-
-    public List<Photo> queryPhoto(Photo photo) {
-        return photoDao.queryPhoto(photo);
-    }
-
-
-    public int updatePhoto(Photo photo) {
-        return photoDao.updateByPrimaryKeySelective(photo);
-    }
-
-    public Photo getPhoto(Integer id) {
-        return photoDao.selectByPrimaryKey(id);
-    }
-
-    public int reBuildResume(String servant_code) {
-        try {
-            if (servant_code != null) {
-                if (servant_code.equals("ALL")) {
-                    List<Resume> resumes = resumeService.getResums();
-                    for (Resume res : resumes) {
-                        if (res == null) {
-                            return 0;
-                        }
-                        Map<String, String> params = new LinkedHashMap<>();
-                        params.put("servant_code", String.valueOf(res.getServant_code()));
-                        params.put("comment", res.getResume_comment());
-                        String tt = sendPostDataByMap("http://yuesuo.yueguanjia.com:8888/createResume", params, "utf-8");
-                    }
-                } else {
-                    Resume resume = resumeService.getResume(Integer.parseInt(servant_code));
-                    if (resume == null) {
-                        return 0;
-                    }
-                    Map<String, String> params = new LinkedHashMap<>();
-                    params.put("servant_code", String.valueOf(resume.getServant_code()));
-                    params.put("comment", resume.getResume_comment());
-                    String tt = sendPostDataByMap("http://yuesuo.yueguanjia.com:8888/createResume", params, "utf-8");
-                }
-            }
-        } catch (Exception ex) {
-            ex.printStackTrace();
-            return 0;
-        }
-
-        return 1;
-    }
-
-    public static String sendPostDataByMap(String url, Map<String, String> map, String encoding) throws ClientProtocolException, IOException {
-        String result = "";
-
-        // 创建httpclient对象
-        CloseableHttpClient httpClient = HttpClients.createDefault();
-        // 创建post方式请求对象
-        HttpPost httpPost = new HttpPost(url);
-
-        // 装填参数
-        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
-        if (map != null) {
-            for (Map.Entry<String, String> entry : map.entrySet()) {
-                nameValuePairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
-            }
-        }
-
-        // 设置参数到请求对象中
-        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, encoding));
-
-        // 设置header信息
-        // 指定报文头【Content-type】、【User-Agent】
-        httpPost.setHeader("Content-type", "application/x-www-form-urlencoded");
-        httpPost.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
-
-        // 执行请求操作,并拿到结果(同步阻塞)
-        CloseableHttpResponse response = httpClient.execute(httpPost);
-        // 获取结果实体
-        // 判断网络连接状态码是否正常(0--200都数正常)
-        if (response.getStatusLine().getStatusCode() == 200) {
-            result = EntityUtils.toString(response.getEntity(), "utf-8");
-        }
-        // 释放链接
-        response.close();
-
-        return result;
-    }
-
+package com.ygj.yuemum.service.admin;
+
+import com.ygj.yuemum.dao.admin.PhotoDao;
+import com.ygj.yuemum.domain.admin.Photo;
+import com.ygj.yuemum.domain.admin.Resume;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class PhotoService {
+
+    @Autowired
+    private PhotoDao photoDao;
+    @Autowired
+    private ResumeService resumeService;
+
+    public List<Photo> getPhotos() {
+        List<Photo> photos = photoDao.getAll();
+        return photos;
+    }
+
+    public int addPhoto(Photo photo) {
+        return photoDao.insertSelective(photo);
+    }
+
+    public String selectDisplay(Photo photo) {
+        return photoDao.selectDisplay(photo);
+    }
+
+    public int deletePhoto(Photo photo) {
+        return photoDao.deletePhoto(photo);
+    }
+
+    public List<Photo> queryPhoto(Photo photo) {
+        return photoDao.queryPhoto(photo);
+    }
+
+
+    public int updatePhoto(Photo photo) {
+        return photoDao.updateByPrimaryKeySelective(photo);
+    }
+
+    public Photo getPhoto(Integer id) {
+        return photoDao.selectByPrimaryKey(id);
+    }
+
+    public int reBuildResume(String servant_code) {
+        try {
+            if (servant_code != null) {
+                if (servant_code.equals("ALL")) {
+                    List<Resume> resumes = resumeService.getResums();
+                    for (Resume res : resumes) {
+                        if (res == null) {
+                            return 0;
+                        }
+                        Map<String, String> params = new LinkedHashMap<>();
+                        params.put("servant_code", String.valueOf(res.getServant_code()));
+                        params.put("comment", res.getResume_comment());
+                        String tt = sendPostDataByMap("https://yuesuo.yueguanjia.com/yuemum-1/createResume", params, "utf-8");
+                    }
+                } else {
+                    Resume resume = resumeService.getResume(Integer.parseInt(servant_code));
+                    if (resume == null) {
+                        return 0;
+                    }
+                    Map<String, String> params = new LinkedHashMap<>();
+                    params.put("servant_code", String.valueOf(resume.getServant_code()));
+                    params.put("comment", resume.getResume_comment());
+                    String tt = sendPostDataByMap("https://yuesuo.yueguanjia.com/yuemum-1/createResume", params, "utf-8");
+                }
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            return 0;
+        }
+
+        return 1;
+    }
+
+    public static String sendPostDataByMap(String url, Map<String, String> map, String encoding) throws ClientProtocolException, IOException {
+        String result = "";
+
+        // 创建httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        // 创建post方式请求对象
+        HttpPost httpPost = new HttpPost(url);
+
+        // 装填参数
+        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
+        if (map != null) {
+            for (Map.Entry<String, String> entry : map.entrySet()) {
+                nameValuePairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
+            }
+        }
+
+        // 设置参数到请求对象中
+        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, encoding));
+
+        // 设置header信息
+        // 指定报文头【Content-type】、【User-Agent】
+        httpPost.setHeader("Content-type", "application/x-www-form-urlencoded");
+        httpPost.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
+
+        // 执行请求操作,并拿到结果(同步阻塞)
+        CloseableHttpResponse response = httpClient.execute(httpPost);
+        // 获取结果实体
+        // 判断网络连接状态码是否正常(0--200都数正常)
+        if (response.getStatusLine().getStatusCode() == 200) {
+            result = EntityUtils.toString(response.getEntity(), "utf-8");
+        }
+        // 释放链接
+        response.close();
+
+        return result;
+    }
+
 }