Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dc-java
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huluobin
dc-java
Commits
84bc64cd
Commit
84bc64cd
authored
Jul 11, 2019
by
wutong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增同步skuMS简单分类
parent
3d2e23fb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
396 additions
and
0 deletions
+396
-0
Application.java
...ase-sync-sku/src/main/java/com/bailuntec/Application.java
+8
-0
SkuSimpleCategory.java
...ain/java/com/bailuntec/domain/pojo/SkuSimpleCategory.java
+14
-0
SkuSimpleCategoryResult.java
...va/com/bailuntec/domain/pojo/SkuSimpleCategoryResult.java
+12
-0
SkuSimpleCategoryJob.java
...src/main/java/com/bailuntec/job/SkuSimpleCategoryJob.java
+66
-0
DcBaseSkuSimpleCategoryMapper.java
...a/com/bailuntec/mapper/DcBaseSkuSimpleCategoryMapper.java
+125
-0
DcBaseSkuSimpleCategoryMapper.xml
...va/com/bailuntec/mapper/DcBaseSkuSimpleCategoryMapper.xml
+0
-0
const.properties
data-base/base-sync-sku/src/main/resources/const.properties
+3
-0
job.properties
data-base/base-sync-sku/src/main/resources/job.properties
+3
-0
SkuSimpleCategoryTest.java
...se/base-sync-sku/src/test/java/SkuSimpleCategoryTest.java
+11
-0
DcBaseSkuSimpleCategory.java
.../com/bailuntec/domain/entity/DcBaseSkuSimpleCategory.java
+154
-0
DcBaseSkuSimpleCategoryExample.java
...luntec/domain/example/DcBaseSkuSimpleCategoryExample.java
+0
-0
No files found.
data-base/base-sync-sku/src/main/java/com/bailuntec/Application.java
View file @
84bc64cd
...
...
@@ -2,6 +2,7 @@ package com.bailuntec;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.bailuntec.job.SkuMSSyncJob
;
import
com.bailuntec.job.SkuSimpleCategoryJob
;
import
com.bailuntec.listener.SkuMSSyncJobListener
;
import
com.bailuntec.utils.PropertiesUtil
;
import
com.dangdang.ddframe.job.config.JobCoreConfiguration
;
...
...
@@ -26,6 +27,7 @@ public class Application {
private
static
final
String
EVENT_RDB_STORAGE_PASSWORD
=
propertiesUtil
.
getPropertyAsString
(
"EVENT_RDB_STORAGE_PASSWORD"
);
public
static
void
main
(
String
[]
args
)
{
new
JobScheduler
(
createRegistryCenter
(),
createJobConfiguration
(),
createJobEventConfiguration
(),
new
SkuMSSyncJobListener
()).
init
();
new
JobScheduler
(
createRegistryCenter
(),
createJobConfiguration1
()).
init
();
}
private
static
CoordinatorRegistryCenter
createRegistryCenter
()
{
...
...
@@ -40,6 +42,12 @@ public class Application {
LiteJobConfiguration
simpleJobRootConfig
=
LiteJobConfiguration
.
newBuilder
(
simpleJobConfig
).
build
();
return
simpleJobRootConfig
;
}
private
static
LiteJobConfiguration
createJobConfiguration1
()
{
JobCoreConfiguration
simpleCoreConfig
=
JobCoreConfiguration
.
newBuilder
(
propertiesUtil
.
getPropertyAsString
(
"JOB_SIMPLE_CATEGORY_NAME"
),
propertiesUtil
.
getPropertyAsString
(
"JOB_SIMPLE_CATEGORY_CRON"
),
propertiesUtil
.
getPropertyAsInt
(
"SHARDING_TOTAL_COUNT"
)).
build
();
SimpleJobConfiguration
simpleJobConfig
=
new
SimpleJobConfiguration
(
simpleCoreConfig
,
SkuSimpleCategoryJob
.
class
.
getCanonicalName
());
LiteJobConfiguration
simpleJobRootConfig
=
LiteJobConfiguration
.
newBuilder
(
simpleJobConfig
).
build
();
return
simpleJobRootConfig
;
}
private
static
JobEventConfiguration
createJobEventConfiguration
()
{
JobEventConfiguration
jobEventRdbConfig
=
new
JobEventRdbConfiguration
(
setUpEventTraceDataSource
());
...
...
data-base/base-sync-sku/src/main/java/com/bailuntec/domain/pojo/SkuSimpleCategory.java
0 → 100644
View file @
84bc64cd
package
com
.
bailuntec
.
domain
.
pojo
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
lombok.Data
;
@Data
public
class
SkuSimpleCategory
{
private
Integer
parentId
;
private
String
name
;
private
String
fullName
;
private
Integer
level
;
@JSONField
(
name
=
"id"
)
private
Integer
skumsId
;
}
data-base/base-sync-sku/src/main/java/com/bailuntec/domain/pojo/SkuSimpleCategoryResult.java
0 → 100644
View file @
84bc64cd
package
com
.
bailuntec
.
domain
.
pojo
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
SkuSimpleCategoryResult
{
private
List
<
SkuSimpleCategory
>
result
;
private
Integer
statusCode
;
private
String
message
;
}
data-base/base-sync-sku/src/main/java/com/bailuntec/job/SkuSimpleCategoryJob.java
0 → 100644
View file @
84bc64cd
package
com
.
bailuntec
.
job
;
import
com.alibaba.fastjson.JSON
;
import
com.bailuntec.domain.entity.DcBaseSkuSimpleCategory
;
import
com.bailuntec.domain.enumerate.HttpStatus
;
import
com.bailuntec.domain.example.DcBaseSkuSimpleCategoryExample
;
import
com.bailuntec.domain.pojo.SkuSimpleCategory
;
import
com.bailuntec.domain.pojo.SkuSimpleCategoryResult
;
import
com.bailuntec.mapper.DcBaseSkuSimpleCategoryMapper
;
import
com.bailuntec.utils.OkHttpUtil
;
import
com.bailuntec.utils.PropertiesUtil
;
import
com.bailuntec.utils.SessionUtil
;
import
com.dangdang.ddframe.job.api.ShardingContext
;
import
com.dangdang.ddframe.job.api.simple.SimpleJob
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.Response
;
import
org.apache.commons.beanutils.BeanUtils
;
import
java.io.IOException
;
import
java.time.LocalDateTime
;
public
class
SkuSimpleCategoryJob
implements
SimpleJob
{
private
PropertiesUtil
propertiesUtil
=
PropertiesUtil
.
getInstance
(
"const"
);
private
OkHttpClient
client
=
OkHttpUtil
.
getInstance
();
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
Request
request
=
new
Request
.
Builder
()
.
url
(
propertiesUtil
.
getPropertyAsString
(
"SKU_SIMPLE_CATEGORY_URL"
))
.
get
()
.
addHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
Response
response
=
null
;
try
{
response
=
client
.
newCall
(
request
).
execute
();
SkuSimpleCategoryResult
skuSimpleCategoryResult
=
JSON
.
parseObject
(
response
.
body
().
byteStream
(),
SkuSimpleCategoryResult
.
class
);
if
(
skuSimpleCategoryResult
.
getStatusCode
().
equals
(
200
))
{
if
(
skuSimpleCategoryResult
.
getResult
()
!=
null
&&
skuSimpleCategoryResult
.
getResult
().
size
()
>
0
)
{
DcBaseSkuSimpleCategory
dcBaseSkuSimpleCategory
=
new
DcBaseSkuSimpleCategory
();
DcBaseSkuSimpleCategoryMapper
mapper
=
SessionUtil
.
getSession
().
getMapper
(
DcBaseSkuSimpleCategoryMapper
.
class
);
for
(
SkuSimpleCategory
skuSimpleCategory
:
skuSimpleCategoryResult
.
getResult
())
{
try
{
BeanUtils
.
copyProperties
(
dcBaseSkuSimpleCategory
,
skuSimpleCategory
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"BeanUtils.copyProperties失败"
,
e
);
}
dcBaseSkuSimpleCategory
.
setBjModified
(
LocalDateTime
.
now
());
int
i
=
mapper
.
updateByExampleSelective
(
dcBaseSkuSimpleCategory
,
DcBaseSkuSimpleCategoryExample
.
newAndCreateCriteria
().
andSkumsIdEqualTo
(
dcBaseSkuSimpleCategory
.
getSkumsId
()).
example
());
if
(
i
==
0
)
{
dcBaseSkuSimpleCategory
.
setBjCreate
(
LocalDateTime
.
now
());
mapper
.
insertSelective
(
dcBaseSkuSimpleCategory
);
}
}
}
}
else
{
throw
new
RuntimeException
(
"调用SKU简单分类接口返回错误"
);
}
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"调用SKU简单分类接口失败"
+
e
.
getCause
().
getMessage
(),
e
);
}
finally
{
if
(
response
!=
null
)
{
response
.
close
();
}
}
}
}
data-base/base-sync-sku/src/main/java/com/bailuntec/mapper/DcBaseSkuSimpleCategoryMapper.java
0 → 100644
View file @
84bc64cd
package
com
.
bailuntec
.
mapper
;
import
com.bailuntec.domain.entity.DcBaseSkuSimpleCategory
;
import
com.bailuntec.domain.example.DcBaseSkuSimpleCategoryExample
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
DcBaseSkuSimpleCategoryMapper
{
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
long
countByExample
(
DcBaseSkuSimpleCategoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
int
deleteByExample
(
DcBaseSkuSimpleCategoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
int
deleteByPrimaryKey
(
Integer
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
int
insert
(
DcBaseSkuSimpleCategory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
int
insertSelective
(
DcBaseSkuSimpleCategory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
DcBaseSkuSimpleCategory
selectOneByExample
(
DcBaseSkuSimpleCategoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
List
<
DcBaseSkuSimpleCategory
>
selectByExample
(
DcBaseSkuSimpleCategoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
DcBaseSkuSimpleCategory
selectByPrimaryKey
(
Integer
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
int
updateByExampleSelective
(
@Param
(
"record"
)
DcBaseSkuSimpleCategory
record
,
@Param
(
"example"
)
DcBaseSkuSimpleCategoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
int
updateByExample
(
@Param
(
"record"
)
DcBaseSkuSimpleCategory
record
,
@Param
(
"example"
)
DcBaseSkuSimpleCategoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
int
updateByPrimaryKeySelective
(
DcBaseSkuSimpleCategory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
int
updateByPrimaryKey
(
DcBaseSkuSimpleCategory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int
upsert
(
DcBaseSkuSimpleCategory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int
upsertSelective
(
DcBaseSkuSimpleCategory
record
);
}
\ No newline at end of file
data-base/base-sync-sku/src/main/java/com/bailuntec/mapper/DcBaseSkuSimpleCategoryMapper.xml
0 → 100644
View file @
84bc64cd
This diff is collapsed.
Click to expand it.
data-base/base-sync-sku/src/main/resources/const.properties
View file @
84bc64cd
# \u751F\u4EA7\u73AF\u5883
SKU_URL
=
http://10.0.8.13:8000/api/sku/productsku/gmtproductskus
SKU_SIMPLE_CATEGORY_URL
=
http://10.0.8.13:8000/api/category/simplecategory/categoriessimplebylevel?level=0
# \u7EBF\u4E0B\u73AF\u5883
#SKU_URL=http://api.skums.bailuntec.com/api/sku/productsku/gmtproductskus
#
SKU_SIMPLE_CATEGORY_URL
=
http://api.skums.bailuntec.com/api/category/simplecategory/categoriessimplebylevel?level=0
\ No newline at end of file
data-base/base-sync-sku/src/main/resources/job.properties
View file @
84bc64cd
...
...
@@ -10,4 +10,6 @@ ZOOKEEPER_SERVER=172.31.255.120:2181
NAME_SPACE
=
data-center
JOB_NAME
=
base-sync-sku
JOB_CRON
=
0/10 * * * * ? *
JOB_SIMPLE_CATEGORY_NAME
=
base-sync-sku-simple-category
JOB_SIMPLE_CATEGORY_CRON
=
0 0 23 * * ? *
SHARDING_TOTAL_COUNT
=
1
\ No newline at end of file
data-base/base-sync-sku/src/test/java/SkuSimpleCategoryTest.java
0 → 100644
View file @
84bc64cd
import
com.bailuntec.job.SkuSimpleCategoryJob
;
import
org.junit.jupiter.api.Test
;
public
class
SkuSimpleCategoryTest
{
@Test
public
void
test
()
{
SkuSimpleCategoryJob
skuSimpleCategoryJob
=
new
SkuSimpleCategoryJob
();
skuSimpleCategoryJob
.
execute
(
null
);
}
}
data-common/src/main/java/com/bailuntec/domain/entity/DcBaseSkuSimpleCategory.java
0 → 100644
View file @
84bc64cd
package
com
.
bailuntec
.
domain
.
entity
;
import
lombok.Data
;
import
java.time.LocalDateTime
;
@Data
public
class
DcBaseSkuSimpleCategory
{
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_sku_simple_category.id
*
* @mbg.generated
*/
private
Integer
id
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_sku_simple_category.parent_id
*
* @mbg.generated
*/
private
Integer
parentId
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_sku_simple_category.name
*
* @mbg.generated
*/
private
String
name
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_sku_simple_category.full_name
*
* @mbg.generated
*/
private
String
fullName
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_sku_simple_category.level
*
* @mbg.generated
*/
private
Integer
level
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_sku_simple_category.skums_id
*
* @mbg.generated
*/
private
Integer
skumsId
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_sku_simple_category.bj_create
*
* @mbg.generated
*/
private
LocalDateTime
bjCreate
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_sku_simple_category.bj_modified
*
* @mbg.generated
*/
private
LocalDateTime
bjModified
;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
getClass
().
getSimpleName
());
sb
.
append
(
" ["
);
sb
.
append
(
"Hash = "
).
append
(
hashCode
());
sb
.
append
(
", id="
).
append
(
id
);
sb
.
append
(
", parentId="
).
append
(
parentId
);
sb
.
append
(
", name="
).
append
(
name
);
sb
.
append
(
", fullName="
).
append
(
fullName
);
sb
.
append
(
", level="
).
append
(
level
);
sb
.
append
(
", skumsId="
).
append
(
skumsId
);
sb
.
append
(
", bjCreate="
).
append
(
bjCreate
);
sb
.
append
(
", bjModified="
).
append
(
bjModified
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
@Override
public
boolean
equals
(
Object
that
)
{
if
(
this
==
that
)
{
return
true
;
}
if
(
that
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
that
.
getClass
())
{
return
false
;
}
DcBaseSkuSimpleCategory
other
=
(
DcBaseSkuSimpleCategory
)
that
;
return
(
this
.
getId
()
==
null
?
other
.
getId
()
==
null
:
this
.
getId
().
equals
(
other
.
getId
()))
&&
(
this
.
getParentId
()
==
null
?
other
.
getParentId
()
==
null
:
this
.
getParentId
().
equals
(
other
.
getParentId
()))
&&
(
this
.
getName
()
==
null
?
other
.
getName
()
==
null
:
this
.
getName
().
equals
(
other
.
getName
()))
&&
(
this
.
getFullName
()
==
null
?
other
.
getFullName
()
==
null
:
this
.
getFullName
().
equals
(
other
.
getFullName
()))
&&
(
this
.
getLevel
()
==
null
?
other
.
getLevel
()
==
null
:
this
.
getLevel
().
equals
(
other
.
getLevel
()))
&&
(
this
.
getSkumsId
()
==
null
?
other
.
getSkumsId
()
==
null
:
this
.
getSkumsId
().
equals
(
other
.
getSkumsId
()))
&&
(
this
.
getBjCreate
()
==
null
?
other
.
getBjCreate
()
==
null
:
this
.
getBjCreate
().
equals
(
other
.
getBjCreate
()))
&&
(
this
.
getBjModified
()
==
null
?
other
.
getBjModified
()
==
null
:
this
.
getBjModified
().
equals
(
other
.
getBjModified
()));
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_sku_simple_category
*
* @mbg.generated
*/
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
1
;
result
=
prime
*
result
+
((
getId
()
==
null
)
?
0
:
getId
().
hashCode
());
result
=
prime
*
result
+
((
getParentId
()
==
null
)
?
0
:
getParentId
().
hashCode
());
result
=
prime
*
result
+
((
getName
()
==
null
)
?
0
:
getName
().
hashCode
());
result
=
prime
*
result
+
((
getFullName
()
==
null
)
?
0
:
getFullName
().
hashCode
());
result
=
prime
*
result
+
((
getLevel
()
==
null
)
?
0
:
getLevel
().
hashCode
());
result
=
prime
*
result
+
((
getSkumsId
()
==
null
)
?
0
:
getSkumsId
().
hashCode
());
result
=
prime
*
result
+
((
getBjCreate
()
==
null
)
?
0
:
getBjCreate
().
hashCode
());
result
=
prime
*
result
+
((
getBjModified
()
==
null
)
?
0
:
getBjModified
().
hashCode
());
return
result
;
}
}
\ No newline at end of file
data-common/src/main/java/com/bailuntec/domain/example/DcBaseSkuSimpleCategoryExample.java
0 → 100644
View file @
84bc64cd
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment