mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-02 02:06:38 +08:00
modify post type param->raw
This commit is contained in:
parent
fa74fb3f99
commit
5569c3e88e
@ -18,7 +18,8 @@ public class CouponConfigService {
|
||||
public String couponConfigGet(CouponConfigGetEntity couponConfigGetEntity) throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponConfigGetEntity);
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
return SmartHttpUtil.sendPostForm(url+"get",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"get",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
|
||||
public String couponConfigFindAll(CouponConfigFindAllEntity couponConfigFindAllEntity) throws Exception{
|
||||
@ -28,6 +29,8 @@ public class CouponConfigService {
|
||||
paramMap.put("rows",StringUtil.toString(couponConfigFindAllEntity.getRows()).equals("0")?null:StringUtil.toString(couponConfigFindAllEntity.getRows()));
|
||||
paramMap.put("page",StringUtil.toString(couponConfigFindAllEntity.getPage()).equals("0")?null:StringUtil.toString(couponConfigFindAllEntity.getPage()));
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
return SmartHttpUtil.sendPostForm(url+"findAll",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"findAll",jsonObject.toString(),null,"utf-8");
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,19 +16,22 @@ public class CouponService {
|
||||
|
||||
public String couponCancel(CouponCancelEntity couponCancelEntity) throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponCancelEntity);
|
||||
return SmartHttpUtil.sendPostForm(url+"cancel",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"cancel",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
|
||||
public String couponCosume(CouponCosumeEntity couponCosumeEntity) throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponCosumeEntity);
|
||||
paramMap.put("petCategoryId",StringUtil.toString(couponCosumeEntity.getPetCategoryId()).equals("0")?null:StringUtil.toString(couponCosumeEntity.getPetCategoryId()));
|
||||
paramMap.put("petBodySizeId",StringUtil.toString(couponCosumeEntity.getPetBodySizeId()).equals("0")?null:StringUtil.toString(couponCosumeEntity.getPetBodySizeId()));
|
||||
return SmartHttpUtil.sendPostForm(url+"consume",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"consume",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
|
||||
public String couponFetch(CouponFetchEntity couponFetchEntity) throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponFetchEntity);
|
||||
return SmartHttpUtil.sendPostForm(url+"fetch",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"fetch",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
|
||||
public String couponGetAll(CouponGetAllEntity couponGetAllEntity) throws Exception{
|
||||
@ -37,12 +40,14 @@ public class CouponService {
|
||||
paramMap.put("status",StringUtil.toString(couponGetAllEntity.getStatus()).equals("0")?null:StringUtil.toString(couponGetAllEntity.getStatus()));
|
||||
paramMap.put("page",StringUtil.toString(couponGetAllEntity.getPage()).equals("0")?null:StringUtil.toString(couponGetAllEntity.getPage()));
|
||||
paramMap.put("rows",StringUtil.toString(couponGetAllEntity.getRows()).equals("0")?null:StringUtil.toString(couponGetAllEntity.getRows()));
|
||||
return SmartHttpUtil.sendPostForm(url+"getAll",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"getAll",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
|
||||
public String couponGet(CouponGetEntity couponGetEntity) throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponGetEntity);
|
||||
return SmartHttpUtil.sendPostForm(url+"get",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"get",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
|
||||
|
||||
@ -53,6 +58,7 @@ public class CouponService {
|
||||
paramMap.put("status",StringUtil.toString(couponV2GetAllEntity.getStatus()).equals("0")?null:StringUtil.toString(couponV2GetAllEntity.getStatus()));
|
||||
paramMap.put("rows",StringUtil.toString(couponV2GetAllEntity.getRows()).equals("0")?null:StringUtil.toString(couponV2GetAllEntity.getRows()));
|
||||
paramMap.put("page",StringUtil.toString(couponV2GetAllEntity.getPage()).equals("0")?null:StringUtil.toString(couponV2GetAllEntity.getPage()));
|
||||
return SmartHttpUtil.sendPostForm(url+"v2/getAll",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"v2/getAll",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ public class MemberAccountService {
|
||||
public String memberAccountChange(MemberAccountChangeEntity memberAccountChangeEntity) throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(memberAccountChangeEntity);
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
return SmartHttpUtil.sendPostForm(url+"change",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"change",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
|
||||
public String memberAccountHistory(MemberAccountHistoryEntity memberAccountHistoryEntity) throws Exception{
|
||||
|
@ -27,14 +27,16 @@ public class MemberAddressService {
|
||||
public String memberAddressAdd(MemberAddressAddEntity memberAddressAddEntity) throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(memberAddressAddEntity);
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
return SmartHttpUtil.sendPostForm(url+"add",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"add",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
|
||||
public String memberAddressUpdate(MemberAddressUpdateEntity memberAddressUpdateEntity) throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(memberAddressUpdateEntity);
|
||||
paramMap.put("id",StringUtil.toString(memberAddressUpdateEntity.equals("0")?null:StringUtil.toString(memberAddressUpdateEntity.getId())));
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
return SmartHttpUtil.sendPostForm(url+"add",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"update",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -9,7 +9,6 @@ import net.lab1024.smartadmin.common.constant.JudgeEnum;
|
||||
import net.lab1024.smartadmin.common.heartbeat.StringUtil;
|
||||
import net.lab1024.smartadmin.module.business.log.LogService;
|
||||
import net.lab1024.smartadmin.module.business.log.userloginlog.domain.UserLoginLogEntity;
|
||||
import net.lab1024.smartadmin.module.system.login.LoginTokenService;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.member.*;
|
||||
import net.lab1024.smartadmin.util.MapRemoveNullUtil;
|
||||
import net.lab1024.smartadmin.util.SmartHttpUtil;
|
||||
@ -22,7 +21,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -80,16 +78,20 @@ public class MemberService {
|
||||
public String memberAdd(MemberAddEntity memberAddEntity)throws Exception {
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(memberAddEntity);
|
||||
paramMap.put("cityId",StringUtil.toString(memberAddEntity.getCityId()).equals("0")?null:StringUtil.toString(memberAddEntity.getCityId()));
|
||||
paramMap.put("districtId",memberAddEntity.getDistrictId().equals("0")?null:memberAddEntity.getDistrictId());
|
||||
paramMap.put("gender",StringUtil.toString(memberAddEntity.getGender()).equals("0")?null:StringUtil.toString(memberAddEntity.getGender()));
|
||||
paramMap.put("districtId",StringUtil.toString(memberAddEntity.getDistrictId()).equals("0")?null:StringUtil.toString(memberAddEntity.getDistrictId()));
|
||||
paramMap.put("provinceId",StringUtil.toString(memberAddEntity.getProvinceId()).equals("0")?null:StringUtil.toString(memberAddEntity.getProvinceId()));
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
return SmartHttpUtil.sendPostForm(url+"add",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"add",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
|
||||
public String memberUpdateMemberLevel(MemberUpdateMemberLevelEntity memberUpdateMemberLevelEntity)throws Exception {
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(memberUpdateMemberLevelEntity);
|
||||
paramMap.put("id",StringUtil.toString(memberUpdateMemberLevelEntity.getId()).equals("0")?null:StringUtil.toString(memberUpdateMemberLevelEntity.getId()));
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
return SmartHttpUtil.sendPostForm(url+"check",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"check",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
|
||||
public String memberUpdate(MemberUpdateEntity memberUpdateEntity)throws Exception{
|
||||
@ -98,7 +100,8 @@ public class MemberService {
|
||||
paramMap.put("cityId",StringUtil.toString(memberUpdateEntity.getCityId()).equals("0")?null:StringUtil.toString(memberUpdateEntity.getCityId()));
|
||||
paramMap.put("districtId",StringUtil.toString(memberUpdateEntity.getDistrictId()).equals("0")?null:StringUtil.toString(memberUpdateEntity.getDistrictId()));
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
return SmartHttpUtil.sendPostForm(url+"update",paramMap,null);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"update",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,7 +2,9 @@ package net.lab1024.smartadmin.module.system.royalcanin.member;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
@ -11,6 +13,8 @@ import lombok.Data;
|
||||
* @Date 2021-12-06
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MemberAddEntity {
|
||||
|
||||
/**
|
||||
@ -82,7 +86,7 @@ public class MemberAddEntity {
|
||||
* 区
|
||||
*/
|
||||
@ApiModelProperty(example = "2426")
|
||||
private String districtId;
|
||||
private int districtId;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
|
@ -2,10 +2,12 @@ package net.lab1024.smartadmin.util;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
@ -14,6 +16,7 @@ import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -148,4 +151,50 @@ public class SmartHttpUtil {
|
||||
return body;
|
||||
}
|
||||
|
||||
public static String httpPostRaw(String url, String stringJson, Map<String,String> headers, String encode){
|
||||
String str="";
|
||||
if(encode == null){
|
||||
encode = "utf-8";
|
||||
}
|
||||
//HttpClients.createDefault()等价于 HttpClientBuilder.create().build();
|
||||
CloseableHttpClient closeableHttpClient = HttpClients.createDefault();
|
||||
HttpPost httpost = new HttpPost(url);
|
||||
|
||||
//设置header
|
||||
httpost.setHeader("Content-type", "application/json");
|
||||
if (headers != null && headers.size() > 0) {
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
httpost.setHeader(entry.getKey(),entry.getValue());
|
||||
}
|
||||
}
|
||||
//组织请求参数
|
||||
StringEntity stringEntity = new StringEntity(stringJson, encode);
|
||||
httpost.setEntity(stringEntity);
|
||||
String content = null;
|
||||
CloseableHttpResponse httpResponse = null;
|
||||
try {
|
||||
//响应信息
|
||||
httpResponse = closeableHttpClient.execute(httpost);
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
content = EntityUtils.toString(entity, encode);
|
||||
System.out.println(content);
|
||||
str=content;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
try {
|
||||
httpResponse.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try { //关闭连接、释放资源
|
||||
closeableHttpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user