数据同步基本框架
This commit is contained in:
parent
15def95223
commit
e2b073b593
@ -9,6 +9,7 @@
|
||||
package com.suisung.mall.shop.sync.controller;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.pojo.req.SyncThirdMemberReq;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import com.suisung.mall.shop.sync.service.SyncThirdDataService;
|
||||
@ -74,5 +75,11 @@ public class SyncThirdDataController {
|
||||
return syncThirdDataService.saveOrUpdateMemberBatch(appKey, sign, memberList);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "手动触发同步", notes = "手动触发同步")
|
||||
@RequestMapping(value = "/manual", method = RequestMethod.POST)
|
||||
public CommonResult syncManual(@RequestParam String storeId,
|
||||
@RequestParam Integer syncType) {
|
||||
return syncThirdDataService.syncManual(storeId, syncType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,9 +9,10 @@
|
||||
package com.suisung.mall.shop.sync.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.suisung.mall.common.modules.sync.SyncApp;
|
||||
|
||||
public interface SyncAppService {
|
||||
public interface SyncAppService extends IService<SyncApp> {
|
||||
|
||||
/**
|
||||
* 根据 appKey 获取一条记录
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
package com.suisung.mall.shop.sync.service;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.pojo.req.SyncThirdMemberReq;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
|
||||
@ -45,4 +46,12 @@ public interface SyncThirdDataService {
|
||||
* @return
|
||||
*/
|
||||
ThirdApiRes saveOrUpdateMemberBatch(String appKey, String sign, List<SyncThirdMemberReq> memberList);
|
||||
|
||||
/**
|
||||
* 手动触发同步
|
||||
* @param storeId
|
||||
* @param syncType
|
||||
* @return
|
||||
*/
|
||||
CommonResult syncManual(String storeId, Integer syncType);
|
||||
}
|
||||
|
||||
@ -18,6 +18,8 @@ import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.StateCode;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
@ -489,4 +491,75 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService {
|
||||
|
||||
return new ThirdApiRes().success("成功同步" + count + "条记录!", resp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动触发同步
|
||||
*
|
||||
* @param storeId
|
||||
* @param syncType 1-品牌,2-分类,3-商品,4-会员
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult syncManual(String storeId, Integer syncType) {
|
||||
//不存在的类型
|
||||
if (!Arrays.asList(1, 2, 3, 4).contains(syncType)) {
|
||||
return CommonResult.failed();
|
||||
}
|
||||
//获取appid、appKey
|
||||
SyncApp syncAppO = syncAppService.getOne(new LambdaQueryWrapper<SyncApp>()
|
||||
.select(SyncApp::getApp_key, SyncApp::getApp_secret)
|
||||
.eq(SyncApp::getStore_id, storeId));
|
||||
if (null == syncAppO) {
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
if (!org.springframework.util.StringUtils.hasText(syncAppO.getApp_key()) ||
|
||||
!org.springframework.util.StringUtils.hasText(syncAppO.getApp_secret())) {
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
switch (syncType) {
|
||||
case 1:
|
||||
return syncProductBrand();
|
||||
case 2:
|
||||
return syncProductClazz();
|
||||
case 3:
|
||||
return syncProduct();
|
||||
case 4:
|
||||
return syncVip();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步商品品牌
|
||||
* @return
|
||||
*/
|
||||
public CommonResult syncProductBrand() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步商品分类
|
||||
* @return
|
||||
*/
|
||||
public CommonResult syncProductClazz() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步商品
|
||||
* @return
|
||||
*/
|
||||
public CommonResult syncProduct() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步会员
|
||||
* @return
|
||||
*/
|
||||
public CommonResult syncVip() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user