|
@@ -14,6 +14,7 @@ import com.miaxis.common.utils.SecurityUtils;
|
|
|
import com.miaxis.customer.dto.AppletCustomerInfoDto;
|
|
|
import com.miaxis.customer.service.ICustomerInfoService;
|
|
|
import com.miaxis.customer.vo.ExhibitionCustomerInfoVo;
|
|
|
+import com.miaxis.feign.dto.FilmDTO;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
@@ -21,18 +22,23 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.Data;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.http.HttpResponse;
|
|
|
+import org.apache.http.HttpStatus;
|
|
|
import org.apache.http.client.HttpClient;
|
|
|
+import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
import org.apache.http.entity.StringEntity;
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
+import org.apache.http.impl.client.HttpClientBuilder;
|
|
|
+import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.TreeMap;
|
|
|
|
|
|
/**
|
|
|
* 【小程序-客户信息】Controller
|
|
@@ -89,5 +95,63 @@ public class FilmController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 以form表单形式提交数据,发送post请求
|
|
|
+ * @explain
|
|
|
+ * 1.请求头:httppost.setHeader("Content-Type","application/x-www-form-urlencoded")
|
|
|
+ * 2.提交的数据格式:key1=value1&key2=value2...
|
|
|
+ * @return 服务器返回数据
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/fileCommonApi")
|
|
|
+ @ApiOperation("微信支付获取预订单id")
|
|
|
+ public static String httpPostWithForm(FilmDTO filmDTO){
|
|
|
+ // 用于接收返回的结果
|
|
|
+ String resultData ="";
|
|
|
+ try {
|
|
|
+ HttpPost post = new HttpPost("http://movieapi2-test.taototo.cn/"+filmDTO.getUrl());
|
|
|
+ post.setHeader("Content-Type","application/x-www-form-urlencoded");
|
|
|
+ // 创建一个http客户端
|
|
|
+ CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
|
+ // 发送post请求
|
|
|
+ HttpResponse response = httpClient.execute(post);
|
|
|
+
|
|
|
+ // 状态码为:200
|
|
|
+ if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
|
|
|
+ // 返回数据:
|
|
|
+ resultData = EntityUtils.toString(response.getEntity(),"UTF-8");
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("接口连接失败!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException("接口连接失败!");
|
|
|
+ }
|
|
|
+ return resultData;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static String getSign(Map<String, Object> params,String appSecretStr) {
|
|
|
+ Map<String, Object> sortMap = new TreeMap<String, Object>();
|
|
|
+ sortMap.putAll(params);
|
|
|
+ // 以k1=v1&k2=v2...方式拼接参数
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
+ for (Map.Entry<String, Object> s : sortMap.entrySet()) {
|
|
|
+ String k = s.getKey();
|
|
|
+ Object v = s.getValue();
|
|
|
+ builder.append(k).append("=").append(v).append("&");
|
|
|
+ }
|
|
|
+ if (!sortMap.isEmpty()) {
|
|
|
+ builder.deleteCharAt(builder.length() - 1);
|
|
|
+ }
|
|
|
+ builder.append(appSecretStr);
|
|
|
+ return builder.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|