记得上下班打卡 | git大法好,push需谨慎

Commit 8e49dd3c authored by 胡佳晨's avatar 胡佳晨

暂时提交

parent 9e9e84ba
package com.liquidnet.commons.lang.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.liquidnet.commons.lang.util.spring.RestTemplateConfig;
import org.springframework.http.*;
......@@ -65,7 +66,7 @@ public class HttpUtil {
return request(url, params, headers, HttpMethod.POST);
}
public static String postJson(String url,String jsonStr) {
public static String postJson(String url, String jsonStr) {
MultiValueMap<String, String> headers = new LinkedMultiValueMap();
headers.add("Content-Type", "application/json;charset=UTF-8");
headers.add("Accept", "application/json;charset=UTF-8");
......@@ -82,11 +83,12 @@ public class HttpUtil {
HttpEntity<Object> httpEntity = new HttpEntity(jsonStr, httpHeaders);
// 提交方式:表单、json
Object respObj = restTemplate.postForEntity(url,httpEntity,Object.class).getBody();;
Object respObj = restTemplate.postForEntity(url, httpEntity, Object.class).getBody();
;
return JsonUtils.toJson(respObj);
}
public static String postJson(String url,String jsonStr,MultiValueMap<String, String> headers) {
public static String postJson(String url, String jsonStr, MultiValueMap<String, String> headers) {
MultiValueMap<String, String> commonHeader = new LinkedMultiValueMap();
commonHeader.add("Content-Type", "application/json;charset=UTF-8");
commonHeader.add("Accept", "application/json;charset=UTF-8");
......@@ -107,12 +109,13 @@ public class HttpUtil {
// 提交方式:表单、json
// ResponseEntity<String> response = restTemplate.exchange(url, method, httpEntity, String.class);
Object respObj = restTemplate.postForEntity(url,httpEntity,Object.class).getBody();;
Object respObj = restTemplate.postForEntity(url, httpEntity, Object.class).getBody();
return JsonUtils.toJson(respObj);
}
/**
* josn post提交
*
* @param url
* @param jsonParam
* @return
......@@ -144,12 +147,25 @@ public class HttpUtil {
} catch (Exception e) {
System.out.println("posturl:" + url + ", err=" + e.getMessage());
}
if(result!=null){
if (result != null) {
rsResultObj = JSONObject.parseObject(result);
}
return rsResultObj;
}
/**
* post请求
*
* @param url
* @param jsonString 请求参数
* @param headers 请求头
* @return
*/
public static String getRaw(String url, String jsonString, MultiValueMap<String, String> headers) {
return requestRaw(url, jsonString, headers, HttpMethod.GET);
}
/**
* post请求
*
......@@ -276,15 +292,20 @@ public class HttpUtil {
// header
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add("Accept", MediaType.APPLICATION_JSON.toString());
httpHeaders.set("Content-Type","application/json;charset=UTF-8");
httpHeaders.set("Content-Type", "application/json;charset=UTF-8");
if (headers != null) {
httpHeaders.addAll(headers);
}
HttpEntity<Object> httpEntity = new HttpEntity(params, httpHeaders);
// RestTemplate restTemplate = new RestTemplate();
// 提交方式:表单、json
ResponseEntity<String> response = restTemplate.postForEntity(url, httpEntity, String.class);
ResponseEntity<String> response = null;
if (HttpMethod.POST == method) {
HttpEntity<String> httpEntity = new HttpEntity(params, httpHeaders);
response = restTemplate.postForEntity(url, httpEntity, String.class);
} else if (HttpMethod.GET == method) {
HttpEntity<String> httpEntity = new HttpEntity(params, httpHeaders);
Map<String,Object> map = JSON.parseObject(params.toString());
response = restTemplate.exchange(url,method,httpEntity,String.class,map);
}
return response.getBody();
}
......
......@@ -83,7 +83,7 @@ liquidnet:
chime:
url: http://devchime.zhengzai.tv
other:
ticketSystemUrl: https://report.capapiao.com
ticketSystemUrl: http://dev-report.capapiao.com
appId: 11920532
secret: 0854C2FFE6BED88E1E21E7F5BAF988CDF9D81D38
executor-main:
......
......@@ -85,7 +85,7 @@ liquidnet:
chime:
url: http://testchime.zhengzai.tv
other:
ticketSystemUrl: https://report.capapiao.com
ticketSystemUrl: http://dev-report.capapiao.com/
appId: 11920532
secret: 0854C2FFE6BED88E1E21E7F5BAF988CDF9D81D38
executor-main:
......
......@@ -9,10 +9,7 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List;
......@@ -25,7 +22,7 @@ public class TicketSystemController {
@Autowired
ITicketSystemService ticketSystemService;
@PostMapping("type/list")
@GetMapping("type/list")
@ApiOperation("查询标准演出类型")
public ResponseDto<List<STPTListVo>> getPerformanceTypeList() {
String accessToken = ticketSystemService.getAccessToken();
......@@ -33,7 +30,7 @@ public class TicketSystemController {
return ResponseDto.success(vo);
}
@PostMapping("field/list")
@GetMapping("field/list")
@ApiOperation("查询标准演出场所")
public ResponseDto<List<STFieldListVo>> getFieldList(STFieldListParam fieldListParam) {
String accessToken = ticketSystemService.getAccessToken();
......
......@@ -10,12 +10,13 @@ import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.platform.param.ticketSystem.*;
import com.liquidnet.service.platform.service.ticketSystem.ITicketSystemService;
import com.liquidnet.service.platform.vo.ticketSystem.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
/**
......@@ -27,6 +28,7 @@ import java.util.List;
* @since 2021-05-11
*/
@Service
@Slf4j
public class ITicketSystemServiceImpl implements ITicketSystemService {
@Value("${liquidnet.service.other.ticketSystemUrl}")
private String ticketSystemUrl;
......@@ -46,9 +48,9 @@ public class ITicketSystemServiceImpl implements ITicketSystemService {
} else {
MultiValueMap<String, String> headers = CollectionUtil.linkedMultiValueMapStringString();
headers.add("Accept", "application/json;charset=UTF-8");
MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString();
params.add("appId", appId);
params.add("secret", secret);
HashMap<String, String> params = CollectionUtil.mapStringString();
params.put("appId", appId);
params.put("secret", secret);
ResponseDataVo<STAccessTokenVo> response =
JsonUtils.fromJson(HttpUtil.postRaw(ticketSystemUrl + "/getAccessToken", JSON.toJSONString(params), headers),
new TypeReference<ResponseDataVo<STAccessTokenVo>>() {
......@@ -63,11 +65,17 @@ public class ITicketSystemServiceImpl implements ITicketSystemService {
public List<STPTListVo> getPerformanceTypeList(String accessToken) {
MultiValueMap<String, String> headers = CollectionUtil.linkedMultiValueMapStringString();
headers.add("Accept", "application/json;charset=UTF-8");
ResponseListVo<List<STPTListVo>> response =
JsonUtils.fromJson(HttpUtil.get(ticketSystemUrl + "/standard/performance/type/list?accessToken=" + accessToken, null, headers),
new TypeReference<ResponseListVo<List<STPTListVo>>>() {
HashMap<String, String> params = CollectionUtil.mapStringString();
params.put("accessToken", accessToken);
String json = HttpUtil.getRaw(ticketSystemUrl + "/standard/performance/type/list?accessToken={accessToken}" , JSON.toJSONString(params), headers);
log.info("json = "+json);
ResponseDataVo<List<STPTListVo>> response =
JsonUtils.fromJson(HttpUtil.getRaw(ticketSystemUrl + "/standard/performance/type/list?accessToken={accessToken}" , JSON.toJSONString(params), headers),
new TypeReference<ResponseDataVo<List<STPTListVo>>>() {
});
return response.getData().getDataList();
log.info("url="+ticketSystemUrl + "/standard/performance/type/list");
log.info("param="+JSON.toJSONString(params));
return response.getData();
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment