mirror of https://github.com/jeecgboot/jeecg-boot
config
parent
b0fb07a65d
commit
dd73b5edc2
|
@ -0,0 +1,32 @@
|
||||||
|
package org.jeecg.modules.business.domain.api.mabang.stockDoChangeStock;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.modules.business.domain.api.mabang.Request;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class contains some key information and necessary procedures
|
||||||
|
* to send a request to mabang "get order list" API, for example: target URL,
|
||||||
|
* correspondent HTTP method, procedure to generate authorization.
|
||||||
|
* <p>
|
||||||
|
* One can use static method {@code sendRequest} to send request with body,
|
||||||
|
* and then get respective response. Or use instance of this class, see below.
|
||||||
|
* <p>
|
||||||
|
* Because data returned by target API is paginated. One can retrieve all data
|
||||||
|
* by calling next and hasNext.
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class SkuChangeRequest extends Request {
|
||||||
|
|
||||||
|
public SkuChangeRequest(SkuChangeRequestBody body) {
|
||||||
|
super(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SkuChangeResponse send() {
|
||||||
|
ResponseEntity<String> res = rawSend();
|
||||||
|
return SkuChangeResponse.parse(JSON.parseObject(res.getBody()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
package org.jeecg.modules.business.domain.api.mabang.stockDoChangeStock;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.jeecg.modules.business.domain.api.mabang.RequestBody;
|
||||||
|
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.SkuData;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class SkuChangeRequestBody implements RequestBody {
|
||||||
|
|
||||||
|
private String stockSku;
|
||||||
|
private String nameCn;
|
||||||
|
private String nameEn;
|
||||||
|
private Integer status;
|
||||||
|
private BigDecimal salePrice;
|
||||||
|
private BigDecimal declareValue;
|
||||||
|
private String declareName;
|
||||||
|
private String declareEname;
|
||||||
|
private String warehouse;
|
||||||
|
private String remark;
|
||||||
|
private Integer hasBattery;
|
||||||
|
private Integer magnetic;
|
||||||
|
private Integer powder;
|
||||||
|
private Integer isPaste;
|
||||||
|
private Integer noLiquidCosmetic;
|
||||||
|
private Integer isFlammable;
|
||||||
|
private Integer isKnife;
|
||||||
|
private Integer isGift;
|
||||||
|
private String supplier;
|
||||||
|
private String supplierLink;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String api() {
|
||||||
|
return "stock-do-change-stock";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject parameters() {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
putNonNull(json, "stockSku", stockSku);
|
||||||
|
putNonNull(json, "nameCN", nameCn);
|
||||||
|
putNonNull(json, "nameEN", nameEn);
|
||||||
|
putNonNull(json, "status", status);
|
||||||
|
putNonNull(json, "salePrice", salePrice);
|
||||||
|
putNonNull(json, "declareValue", declareValue);
|
||||||
|
putNonNull(json, "declareName", declareName);
|
||||||
|
putNonNull(json, "declareEname", declareEname);
|
||||||
|
JSONArray warehouseData = new JSONArray();
|
||||||
|
JSONObject warehouse = new JSONObject();
|
||||||
|
warehouse.put("name", this.warehouse);
|
||||||
|
warehouseData.add(warehouse);
|
||||||
|
json.put("warehouseData", warehouseData.toJSONString());
|
||||||
|
putNonNull(json, "weight", remark);
|
||||||
|
putNonNull(json, "saleRemark", remark);
|
||||||
|
putNonNull(json, "hasBattery", hasBattery);
|
||||||
|
putNonNull(json, "magnetic", magnetic);
|
||||||
|
putNonNull(json, "powder", powder);
|
||||||
|
putNonNull(json, "ispaste", isPaste);
|
||||||
|
putNonNull(json, "noLiquidCosmetic", noLiquidCosmetic);
|
||||||
|
putNonNull(json, "is_flammable", isFlammable);
|
||||||
|
putNonNull(json, "is_knife", isKnife);
|
||||||
|
putNonNull(json, "isGift", isGift);
|
||||||
|
putNonNull(json, "autoCreateSupplier", 1);
|
||||||
|
JSONArray supplierData = new JSONArray();
|
||||||
|
JSONObject supplier = new JSONObject();
|
||||||
|
supplier.put("name", this.supplier);
|
||||||
|
supplier.put("productLinkAddress", this.supplierLink);
|
||||||
|
supplier.put("flag", 1);
|
||||||
|
supplierData.add(supplier);
|
||||||
|
json.put("suppliersData", supplierData.toJSONString());
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SkuChangeRequestBody(SkuData data) {
|
||||||
|
this.stockSku = data.getErpCode();
|
||||||
|
this.nameCn = data.getNameCN();
|
||||||
|
this.nameEn = data.getNameEN();
|
||||||
|
this.salePrice = data.getSalePrice();
|
||||||
|
this.declareValue = data.getDeclareValue();
|
||||||
|
this.declareName = data.getDeclareNameZh();
|
||||||
|
this.declareEname = data.getDeclareNameEn();
|
||||||
|
this.warehouse = data.getWarehouse();
|
||||||
|
this.remark = data.getSaleRemark();
|
||||||
|
this.hasBattery = data.getHasBattery();
|
||||||
|
this.magnetic = data.getMagnetic();
|
||||||
|
this.powder = data.getPowder();
|
||||||
|
this.isPaste = data.getIsPaste();
|
||||||
|
this.noLiquidCosmetic = data.getNoLiquidCosmetic();
|
||||||
|
this.isFlammable = data.getIsFlammable();
|
||||||
|
this.isKnife = data.getIsKnife();
|
||||||
|
this.isGift = data.getIsGift();
|
||||||
|
this.supplier = data.getSupplier();
|
||||||
|
this.supplierLink = data.getSupplierLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
private <E> void putNonNull(JSONObject json, String key, E value) {
|
||||||
|
if (value != null) {
|
||||||
|
json.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private <E, T> void putNonNull(JSONObject json, String key, E value, Function<E, T> mapper) {
|
||||||
|
if (value != null) {
|
||||||
|
json.put(key, mapper.apply(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.jeecg.modules.business.domain.api.mabang.stockDoChangeStock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents error that is returned by target stock-do-change-stock API
|
||||||
|
* Message will contain error details.
|
||||||
|
*/
|
||||||
|
public class SkuChangeRequestErrorException extends RuntimeException {
|
||||||
|
public SkuChangeRequestErrorException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
package org.jeecg.modules.business.domain.api.mabang.stockDoChangeStock;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.modules.business.domain.api.mabang.Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Immutable object
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Getter
|
||||||
|
public class SkuChangeResponse extends Response {
|
||||||
|
/**
|
||||||
|
* Current page data
|
||||||
|
*/
|
||||||
|
private final JSONObject data;
|
||||||
|
|
||||||
|
private final String stockId;
|
||||||
|
|
||||||
|
private final String stockSku;
|
||||||
|
|
||||||
|
public SkuChangeResponse(Code code, JSONObject data, String stockId, String stockSku) {
|
||||||
|
super(code);
|
||||||
|
this.data = data;
|
||||||
|
this.stockId = stockId;
|
||||||
|
this.stockSku = stockSku;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make an instance by parsing json, it only checks validity of code.
|
||||||
|
* if json is not valid, return null
|
||||||
|
*
|
||||||
|
* @param json the json to parse
|
||||||
|
* @return Instance
|
||||||
|
* @throws SkuChangeRequestErrorException if response code represents error.
|
||||||
|
*/
|
||||||
|
public static SkuChangeResponse parse(JSONObject json) throws SkuChangeRequestErrorException {
|
||||||
|
log.debug("Constructing a response by json.");
|
||||||
|
String code = json.getString("code");
|
||||||
|
if (code.equals(Code.ERROR.value))
|
||||||
|
throw new SkuChangeRequestErrorException(json.getString("message"));
|
||||||
|
|
||||||
|
JSONObject data = json.getJSONObject("data");
|
||||||
|
String stockId = data.getString("stockId");
|
||||||
|
String stockSku = data.getString("stockSku");
|
||||||
|
if(data != null) {
|
||||||
|
log.info("Constructed response: data contained {}", data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log.info("Data is null");
|
||||||
|
}
|
||||||
|
return new SkuChangeResponse(Code.SUCCESS, data, stockId, stockSku);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SkuListResponse{" +
|
||||||
|
", data=" + data +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -176,6 +176,11 @@ spring:
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
port: 6379
|
port: 6379
|
||||||
password: ''
|
password: ''
|
||||||
|
#MongoDB 配置
|
||||||
|
data:
|
||||||
|
mongodb:
|
||||||
|
authentication-database: xxx
|
||||||
|
uri: xxx
|
||||||
#mybatis plus 设置
|
#mybatis plus 设置
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml
|
mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml
|
||||||
|
@ -189,7 +194,7 @@ mybatis-plus:
|
||||||
table-underline: true
|
table-underline: true
|
||||||
configuration:
|
configuration:
|
||||||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
|
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
# 返回类型为Map,显示null对应的字段
|
# 返回类型为Map,显示null对应的字段
|
||||||
call-setters-on-nulls: true
|
call-setters-on-nulls: true
|
||||||
#jeecg专用配置
|
#jeecg专用配置
|
||||||
|
@ -237,6 +242,9 @@ jeecg:
|
||||||
shippingInvoiceDetailDir: C://dev//invoices//shippingDetail
|
shippingInvoiceDetailDir: C://dev//invoices//shippingDetail
|
||||||
shippingInvoicePdfDir: C://dev//invoices//pdf//shipping
|
shippingInvoicePdfDir: C://dev//invoices//pdf//shipping
|
||||||
shippingInvoiceDetailPdfDir: C://dev//invoices//pdf//shippingDetail
|
shippingInvoiceDetailPdfDir: C://dev//invoices//pdf//shippingDetail
|
||||||
|
invoiceDetailExportDir: xxx
|
||||||
|
# sku csv file for image search
|
||||||
|
skuCsvPath: xxx
|
||||||
#webapp文件路径
|
#webapp文件路径
|
||||||
webapp: /opt/webapp
|
webapp: /opt/webapp
|
||||||
shiro:
|
shiro:
|
||||||
|
@ -346,7 +354,10 @@ justauth:
|
||||||
timeout: 1h
|
timeout: 1h
|
||||||
mabang:
|
mabang:
|
||||||
api:
|
api:
|
||||||
appkey: "87a1a0c46df86eb2683e74776894dae9"
|
appkey: "xxx"
|
||||||
devid: "200809"
|
devid: "xxx"
|
||||||
company:
|
company:
|
||||||
orgName: "WIA"
|
orgName: "xxx"
|
||||||
|
jessy:
|
||||||
|
name: "xxx"
|
||||||
|
email: "xxx"
|
Loading…
Reference in New Issue