Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
dfb120f5
提交
dfb120f5
authored
4月 26, 2021
作者:
吴德鹏
浏览文件
操作
浏览文件
下载
差异文件
合并分支 'feature_1.0' 到 'master'
商品导入 查看合并请求
!1
上级
658820a6
67591291
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
992 行增加
和
479 行删除
+992
-479
PaypalConfig.java
...ain/java/com/example/afrishop_v3/config/PaypalConfig.java
+57
-57
PaypalContoller.java
.../com/example/afrishop_v3/controllers/PaypalContoller.java
+408
-408
CategoryEnum.java
...main/java/com/example/afrishop_v3/enums/CategoryEnum.java
+25
-0
TbCfDescripiton.java
.../java/com/example/afrishop_v3/models/TbCfDescripiton.java
+2
-0
TbCfExpressTemplate.java
...a/com/example/afrishop_v3/models/TbCfExpressTemplate.java
+10
-0
TbCfGoodstwotype.java
...java/com/example/afrishop_v3/models/TbCfGoodstwotype.java
+2
-0
TbCfGoodstype.java
...in/java/com/example/afrishop_v3/models/TbCfGoodstype.java
+6
-0
TbCfStationItem.java
.../java/com/example/afrishop_v3/models/TbCfStationItem.java
+11
-13
ItemTask.java
src/main/java/com/example/afrishop_v3/quartz/ItemTask.java
+321
-0
TbCfDescripitonRepository.java
...ple/afrishop_v3/repository/TbCfDescripitonRepository.java
+7
-0
TbCfGoodstwotypeRepository.java
...le/afrishop_v3/repository/TbCfGoodstwotypeRepository.java
+9
-0
TbCfGoodstypeRepository.java
...ample/afrishop_v3/repository/TbCfGoodstypeRepository.java
+8
-0
TbCfStationItemRepository.java
...ple/afrishop_v3/repository/TbCfStationItemRepository.java
+3
-0
PayPalUtil.java
src/main/java/com/example/afrishop_v3/util/PayPalUtil.java
+1
-0
application-test.yml
src/main/resources/application-test.yml
+1
-1
MainTest.java
src/test/java/com/example/afrishop_v3/MainTest.java
+121
-0
没有找到文件。
src/main/java/com/example/afrishop_v3/config/PaypalConfig.java
浏览文件 @
dfb120f5
package
com
.
example
.
afrishop_v3
.
config
;
import
com.example.afrishop_v3.models.Token
;
import
com.example.afrishop_v3.repository.TokenRepository
;
import
com.example.afrishop_v3.util.PayPalUtil
;
import
com.paypal.base.codec.binary.Base64
;
import
com.paypal.base.rest.APIContext
;
import
com.paypal.base.rest.OAuthTokenCredential
;
import
com.paypal.base.rest.PayPalRESTException
;
import
net.sf.json.JSONObject
;
import
org.apache.commons.lang3.builder.ToStringExclude
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.*
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.util.*
;
import
java.util.concurrent.*
;
@Configuration
public
class
PaypalConfig
{
@Value
(
"${paypal.client_app}"
)
private
String
clientId
;
@Value
(
"${paypal.client_secret}"
)
private
String
clientSecret
;
@Value
(
"${paypal.mode}"
)
private
String
mode
;
@Bean
public
Map
<
String
,
String
>
paypalSdkConfig
()
{
Map
<
String
,
String
>
sdkConfig
=
new
HashMap
<>();
sdkConfig
.
put
(
"mode"
,
mode
);
return
sdkConfig
;
}
@Bean
public
OAuthTokenCredential
authTokenCredential
()
{
return
new
OAuthTokenCredential
(
clientId
,
clientSecret
,
paypalSdkConfig
());
}
@Bean
public
APIContext
apiContext
()
throws
PayPalRESTException
{
APIContext
apiContext
=
new
APIContext
(
authTokenCredential
().
getAccessToken
());
apiContext
.
setConfigurationMap
(
paypalSdkConfig
());
return
apiContext
;
}
}
//
package com.example.afrishop_v3.config;
//
//
import com.example.afrishop_v3.models.Token;
//
import com.example.afrishop_v3.repository.TokenRepository;
//
import com.example.afrishop_v3.util.PayPalUtil;
//
import com.paypal.base.codec.binary.Base64;
//
import com.paypal.base.rest.APIContext;
//
import com.paypal.base.rest.OAuthTokenCredential;
//
import com.paypal.base.rest.PayPalRESTException;
//
//
import net.sf.json.JSONObject;
//
import org.apache.commons.lang3.builder.ToStringExclude;
//
import org.springframework.beans.factory.annotation.Value;
//
import org.springframework.context.annotation.*;
//
//
//
import java.io.IOException;
//
import java.io.UnsupportedEncodingException;
//
import java.util.*;
//
import java.util.concurrent.*;
//
//
//
@Configuration
//
public class PaypalConfig {
//
//
@Value("${paypal.client_app}")
//
private String clientId;
//
//
@Value("${paypal.client_secret}")
//
private String clientSecret;
//
//
@Value("${paypal.mode}")
//
private String mode;
//
//
//
@Bean
//
public Map<String, String> paypalSdkConfig() {
//
Map<String, String> sdkConfig = new HashMap<>();
//
sdkConfig.put("mode", mode);
//
return sdkConfig;
//
}
//
//
//
@Bean
//
public OAuthTokenCredential authTokenCredential() {
//
return new OAuthTokenCredential(clientId, clientSecret, paypalSdkConfig());
//
}
//
//
@Bean
//
public APIContext apiContext() throws PayPalRESTException {
//
APIContext apiContext = new APIContext(authTokenCredential().getAccessToken());
//
apiContext.setConfigurationMap(paypalSdkConfig());
//
return apiContext;
//
}
//
//
//
}
src/main/java/com/example/afrishop_v3/controllers/PaypalContoller.java
浏览文件 @
dfb120f5
差异被折叠。
点击展开。
src/main/java/com/example/afrishop_v3/enums/CategoryEnum.java
0 → 100644
浏览文件 @
dfb120f5
package
com
.
example
.
afrishop_v3
.
enums
;
public
enum
CategoryEnum
{
WOMEN
(
1
,
"Women"
),
CURVE
(
3
,
"Curve+Plus"
),
MEN
(
5
,
"Men"
),
KIDS
(
4
,
"Kids"
);
private
Integer
categoryId
;
private
String
categoryName
;
CategoryEnum
(
Integer
categoryId
,
String
categoryName
){
this
.
categoryId
=
categoryId
;
this
.
categoryName
=
categoryName
;
}
public
Integer
getCategoryId
()
{
return
categoryId
;
}
public
String
getCategoryName
()
{
return
categoryName
;
}
}
src/main/java/com/example/afrishop_v3/models/TbCfDescripiton.java
浏览文件 @
dfb120f5
...
...
@@ -63,6 +63,8 @@ public class TbCfDescripiton{
*/
private
String
twoType
;
private
String
tempId
;
private
Integer
sort
;
public
Integer
getSort
()
{
...
...
src/main/java/com/example/afrishop_v3/models/TbCfExpressTemplate.java
浏览文件 @
dfb120f5
...
...
@@ -19,6 +19,9 @@ import java.util.Date;
@Data
public
class
TbCfExpressTemplate
{
/**
* 模板id
*/
...
...
@@ -89,6 +92,13 @@ public class TbCfExpressTemplate{
*/
private
Date
updateTime
;
public
TbCfExpressTemplate
()
{
}
public
TbCfExpressTemplate
(
String
templateId
)
{
this
.
templateId
=
templateId
;
}
/**
* 设置:模板id
*/
...
...
src/main/java/com/example/afrishop_v3/models/TbCfGoodstwotype.java
浏览文件 @
dfb120f5
...
...
@@ -41,6 +41,8 @@ public class TbCfGoodstwotype{
*/
private
String
goodstwotypeUrl
;
private
String
tempId
;
@Transient
private
boolean
autoLoad
=
false
;
...
...
src/main/java/com/example/afrishop_v3/models/TbCfGoodstype.java
浏览文件 @
dfb120f5
...
...
@@ -2,6 +2,7 @@ package com.example.afrishop_v3.models;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.springframework.data.relational.core.sql.In
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
...
...
@@ -41,6 +42,11 @@ public class TbCfGoodstype{
*/
private
String
goodstypeImage
;
/**
* 临时ID
*/
private
Integer
tempId
;
/**
* 设置:商品分类Id
*/
...
...
src/main/java/com/example/afrishop_v3/models/TbCfStationItem.java
浏览文件 @
dfb120f5
...
...
@@ -93,7 +93,7 @@ public class TbCfStationItem {
/**
* 是否置顶 Y:是 N:否
*/
private
String
itemTop
;
private
Integer
itemTop
;
/**
* 供应商
*/
...
...
@@ -127,6 +127,16 @@ public class TbCfStationItem {
private
String
handled
;
private
String
tempId
;
public
String
getTempId
()
{
return
tempId
;
}
public
void
setTempId
(
String
tempId
)
{
this
.
tempId
=
tempId
;
}
@JsonIgnore
@ManyToOne
@JoinColumn
(
columnDefinition
=
"template"
,
name
=
"template"
)
...
...
@@ -394,19 +404,7 @@ public class TbCfStationItem {
return
itemSku
;
}
/**
* 设置:是否置顶 Y:是 N:否
*/
public
void
setItemTop
(
String
itemTop
)
{
this
.
itemTop
=
itemTop
;
}
/**
* 获取:是否置顶 Y:是 N:否
*/
public
String
getItemTop
()
{
return
itemTop
;
}
/**
* 设置:供应商
...
...
src/main/java/com/example/afrishop_v3/quartz/ItemTask.java
0 → 100644
浏览文件 @
dfb120f5
差异被折叠。
点击展开。
src/main/java/com/example/afrishop_v3/repository/TbCfDescripitonRepository.java
浏览文件 @
dfb120f5
package
com
.
example
.
afrishop_v3
.
repository
;
import
com.example.afrishop_v3.models.TbCfDescripiton
;
import
com.example.afrishop_v3.models.TbCfGoodstwotype
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
java.util.List
;
...
...
@@ -10,4 +12,9 @@ public interface TbCfDescripitonRepository extends PagingAndSortingRepository<Tb
List
<
TbCfDescripiton
>
findAllByGoodstwotypeIdOrderBySort
(
String
categoryTwo
);
int
countByGoodstwotypeId
(
String
id
);
boolean
existsByDescripitionNameAndTempId
(
String
name
,
String
tempId
);
TbCfDescripiton
findFirstByDescripitionNameAndTempId
(
String
name
,
String
tempId
);
}
src/main/java/com/example/afrishop_v3/repository/TbCfGoodstwotypeRepository.java
浏览文件 @
dfb120f5
package
com
.
example
.
afrishop_v3
.
repository
;
import
com.example.afrishop_v3.models.TbCfGoodstwotype
;
import
com.example.afrishop_v3.models.TbCfGoodstype
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
java.util.List
;
...
...
@@ -10,4 +12,11 @@ public interface TbCfGoodstwotypeRepository extends PagingAndSortingRepository<T
int
countByGoodstypeId
(
String
id
);
@Query
(
value
=
"select max(sort) from TbCfGoodstwotype where goodstypeId=:goodstypeId"
)
int
findMaxSort
(
String
goodstypeId
);
boolean
existsByGoodstwotypeTitleAndTempId
(
String
name
,
String
tempId
);
TbCfGoodstwotype
findFirstByGoodstwotypeTitleAndTempId
(
String
name
,
String
tempId
);
}
src/main/java/com/example/afrishop_v3/repository/TbCfGoodstypeRepository.java
浏览文件 @
dfb120f5
package
com
.
example
.
afrishop_v3
.
repository
;
import
com.example.afrishop_v3.models.TbCfGoodstype
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
public
interface
TbCfGoodstypeRepository
extends
PagingAndSortingRepository
<
TbCfGoodstype
,
String
>
{
@Query
(
value
=
"select max(goodstypeSort) from TbCfGoodstype"
)
int
findMaxSort
();
boolean
existsByGoodstypeTitle
(
String
name
);
TbCfGoodstype
findByGoodstypeTitle
(
String
name
);
}
src/main/java/com/example/afrishop_v3/repository/TbCfStationItemRepository.java
浏览文件 @
dfb120f5
...
...
@@ -62,4 +62,7 @@ public interface TbCfStationItemRepository extends PagingAndSortingRepository<Tb
@Transactional
int
updateItmeImg
(
@Param
(
"itemImg"
)
String
itemImg
,
@Param
(
"itemId"
)
String
itemId
);
// @Query("select i from #{#entityName} i where tempId is not null")
List
<
TbCfStationItem
>
findAllByTempIdIsNotNull
();
}
src/main/java/com/example/afrishop_v3/util/PayPalUtil.java
浏览文件 @
dfb120f5
...
...
@@ -34,6 +34,7 @@ public class PayPalUtil {
Response
response
=
client
.
newCall
(
request
).
execute
();
String
string
=
response
.
body
().
string
();
System
.
out
.
println
(
"================"
+
string
);
net
.
sf
.
json
.
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
string
);
String
token_type
=
jsonObject
.
getString
(
"token_type"
);
String
access_token
=
jsonObject
.
getString
(
"access_token"
);
...
...
src/main/resources/application-test.yml
浏览文件 @
dfb120f5
server
:
servlet
:
context-path
:
/afrishop
port
:
80
99
port
:
80
12
spring
:
datasource
:
...
...
src/test/java/com/example/afrishop_v3/MainTest.java
0 → 100644
浏览文件 @
dfb120f5
//package com.example.afrishop_v3;
//
//import com.example.afrishop_v3.enums.CategoryEnum;
//import com.example.afrishop_v3.models.Country;
//import com.example.afrishop_v3.util.HttpClientUtil;
//import net.sf.json.JSONArray;
//import net.sf.json.JSONObject;
//import org.junit.Test;
//
//import java.io.IOException;
//import java.util.*;
//import java.util.stream.Collectors;
//
//public class MainTest {
//// usd_shop_price(现价) usd_market_price(原价)
// //https://apiv2.lovelywholesale.com/lw-api/product/item/296341?Origin=https:%2F%2Fm.lovelywholesale.com%2F&v=1619262060361
// private final String ITEM_URL="https://goapi.lovelywholesale.com/search/category/products";
// private volatile Integer page=1;
// private final Integer limit=48;
// private int total_page=0;
//// @Test
// public void importItems(Integer category_id) throws IOException {
// JSONArray items=null;
// do {
// page++ ;
// Map<String,Object> params=new LinkedHashMap<>();
// params.put("offset",page);
// params.put("limit",limit);
// params.put("category_id",category_id);
// params.put("original_category_id",category_id);
// params.put("is_virtual",1);
// String response = HttpClientUtil.sendPostWithBodyParameter(ITEM_URL, params);
// JSONObject jsonObject = JSONObject.fromObject(response);
// JSONObject data = jsonObject.getJSONObject("data");
// total_page = data.getInt("total_page");
// items = data.getJSONArray("search_list");
// for (int i = 0; i < items.size(); i++) {
// JSONObject item = items.getJSONObject(i);
// String itemId = item.getString("goods_id");
// String itemName = item.getString("goods_name");
// String categoryName = item.getString("category_name");
// }
//
// }while (page<total_page);
//
//
// }
//
// private final String CATEGORY_URL="https://apiv2.lovelywholesale.com/lw-api/head/switch-top-category";
//
// @Test
// public void importCategory() throws IOException {
// String topCategory = null;
// List<Integer> ids= Arrays.asList(1,3,5,4);
// for (int i = 0; i < ids.size(); i++) {
// Integer catId = ids.get(i);
// if (CategoryEnum.WOMEN.getCategoryId()==catId){
// topCategory=CategoryEnum.WOMEN.getCategoryName();
// }else if (CategoryEnum.CURVE.getCategoryId()==catId){
// topCategory=CategoryEnum.CURVE.getCategoryName();
// }else if (CategoryEnum.MEN.getCategoryId()==catId){
// topCategory=CategoryEnum.MEN.getCategoryName();
// }else if (CategoryEnum.KIDS.getCategoryId()==catId){
// topCategory=CategoryEnum.KIDS.getCategoryName();
// }
// Map<String,Object> params=new LinkedHashMap<>();
// params.put("top_cat_id",catId);
// String response=HttpClientUtil.sendPostWithBodyParameter(CATEGORY_URL,params);
// JSONObject jsonObject = JSONObject.fromObject(response);
// JSONObject data = jsonObject.getJSONObject("data");
// JSONArray categorys = data.getJSONArray("categorys");
// for (int j = 0; j < categorys.size(); j++) {
// JSONObject category = categorys.getJSONObject(j);
// String categoryId = category.getString("nav_id");
// String navName = category.getString("nav_name");
// Map<String, String> children = getCategoryChildren(categoryId);
// System.err.println("一级分类:"+topCategory+"---"+"二级分类-:"+categoryId+"---"+navName);
// //二级分类入库
//// children.entrySet().stream().forEach(System.err::println);
// //三级分类入库
// //通过三级分类查询商品、入库
// children.forEach((k, v) ->{
// try {
// importItems(Integer.parseInt(k));
// } catch (IOException e) {
// e.printStackTrace();
// }
// });
// }
//
//
// }
//
// }
//
// private final String url="https://apiv2.lovelywholesale.com/lw-api/list/get_child_cat";
//
//// @Test
// public Map<String,String> getCategoryChildren(String categoryId) throws IOException {
// Map<String,String> results=new LinkedHashMap<>();
// Map<String,Object> params=new LinkedHashMap<>();
// params.put("nav_id",categoryId);
// String response=HttpClientUtil.sendPostWithBodyParameter(url,params);
// JSONObject jsonObject = JSONObject.fromObject(response);
// JSONObject data = jsonObject.getJSONObject("data");
// JSONArray categorys = data.getJSONArray("category");
// for (int j = 0; j < categorys.size(); j++) {
// JSONObject category = categorys.getJSONObject(j);
// JSONArray childs = category.getJSONArray("child");
// for (int i = 0; i < childs.size(); i++) {
// JSONObject child = childs.getJSONObject(i);
// String name = child.getString("nav_name");
// String cat_id = child.getJSONObject("cat_info").getString("cat_id");
// System.err.println(cat_id+"---"+name);
// results.put(cat_id,name);
// }
// }
// return results;
// }
//
//}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论