Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-store
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
base_platform_enterprise
gic-store
Commits
20f37580
You need to sign in or sign up before continuing.
Commit
20f37580
authored
Jul 04, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分组策略
parent
d5c5c254
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
108 deletions
+23
-108
StoreGroupStrategyWeightsService.java
...m/gic/store/service/StoreGroupStrategyWeightsService.java
+0
-30
StoreGroupStrategyWeightsServiceImpl.java
...re/service/impl/StoreGroupStrategyWeightsServiceImpl.java
+0
-50
StoreStrategyApiServiceImpl.java
.../gic/store/service/outer/StoreStrategyApiServiceImpl.java
+15
-20
StoreStrategyController.java
...com/gic/store/web/controller/StoreStrategyController.java
+8
-8
No files found.
gic-store-service/src/main/java/com/gic/store/service/StoreGroupStrategyWeightsService.java
deleted
100644 → 0
View file @
d5c5c254
package
com
.
gic
.
store
.
service
;
import
com.gic.store.entity.TabStoreGroupStrategyWeights
;
/**
* @author guojx
* @date 2019/7/4 9:24 AM
*/
public
interface
StoreGroupStrategyWeightsService
{
/**
* 获取分组权重
* @param enterpriseId
* @return
*/
TabStoreGroupStrategyWeights
getWeightByEnterpriseId
(
Integer
enterpriseId
);
/**
* 保存数据
* @param record
* @return
*/
int
saveOrUpdate
(
TabStoreGroupStrategyWeights
record
);
/**
* 权重是否启用,如果启用,则不执行分组策略
* @return
*/
boolean
isEnabled
(
Integer
enterpriseId
);
}
gic-store-service/src/main/java/com/gic/store/service/impl/StoreGroupStrategyWeightsServiceImpl.java
deleted
100644 → 0
View file @
d5c5c254
package
com
.
gic
.
store
.
service
.
impl
;
import
com.gic.store.dao.mapper.TabStoreGroupStrategyWeightsMapper
;
import
com.gic.store.entity.TabStoreGroupStrategyWeights
;
import
com.gic.store.service.StoreGroupStrategyWeightsService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
/**
* @author guojx
* @date 2019/7/4 9:26 AM
*/
@Service
(
"storeGroupStrategyWeightsService"
)
public
class
StoreGroupStrategyWeightsServiceImpl
implements
StoreGroupStrategyWeightsService
{
@Autowired
private
TabStoreGroupStrategyWeightsMapper
tabStoreGroupStrategyWeightsMapper
;
@Override
public
TabStoreGroupStrategyWeights
getWeightByEnterpriseId
(
Integer
enterpriseId
)
{
TabStoreGroupStrategyWeights
record
=
new
TabStoreGroupStrategyWeights
();
record
.
setEnterpriseId
(
enterpriseId
);
return
tabStoreGroupStrategyWeightsMapper
.
selectByPrimary
(
record
);
}
@Override
public
int
saveOrUpdate
(
TabStoreGroupStrategyWeights
record
)
{
TabStoreGroupStrategyWeights
old
=
getWeightByEnterpriseId
(
record
.
getEnterpriseId
());
record
.
setUpdateTime
(
new
Date
());
if
(
old
!=
null
)
{
record
.
setCreateTime
(
old
.
getCreateTime
());
record
.
setWeightsId
(
old
.
getWeightsId
());
return
tabStoreGroupStrategyWeightsMapper
.
updateByPrimaryKeySelective
(
record
);
}
else
{
record
.
setCreateTime
(
new
Date
());
return
tabStoreGroupStrategyWeightsMapper
.
insert
(
record
);
}
}
@Override
public
boolean
isEnabled
(
Integer
enterpriseId
)
{
TabStoreGroupStrategyWeights
old
=
getWeightByEnterpriseId
(
enterpriseId
);
if
(
old
!=
null
&&
old
.
getStatus
()
!=
null
&&
old
.
getStatus
().
intValue
()
==
1
)
{
return
true
;
}
return
false
;
}
}
gic-store-service/src/main/java/com/gic/store/service/outer/StoreStrategyApiServiceImpl.java
View file @
20f37580
...
...
@@ -4,11 +4,9 @@ import com.gic.api.base.commons.Page;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.PageHelperUtils
;
import
com.gic.
store.constant.StoreGroupConstant
;
import
com.gic.
redis.data.util.RedisUtil
;
import
com.gic.store.dto.StoreStrategyDTO
;
import
com.gic.store.entity.TabStoreGroupStrategyWeights
;
import
com.gic.store.entity.TabStoreStrategy
;
import
com.gic.store.service.StoreGroupStrategyWeightsService
;
import
com.gic.store.service.StoreStrategyApiService
;
import
com.gic.store.service.StoreStrategyService
;
import
com.gic.store.utils.ErrorCode
;
...
...
@@ -28,11 +26,9 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
@Autowired
private
StoreStrategyService
storeStrategyService
;
@Autowired
private
StoreGroupStrategyWeightsService
storeGroupStrategyWeightsService
;
@Override
public
ServiceResponse
<
Integer
>
saveStore
Group
Strategy
(
StoreStrategyDTO
storeStrategyDTO
)
{
public
ServiceResponse
<
Integer
>
saveStoreStrategy
(
StoreStrategyDTO
storeStrategyDTO
)
{
if
(
StringUtils
.
isBlank
(
storeStrategyDTO
.
getStrategyName
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略名称不能为空"
);
}
...
...
@@ -45,8 +41,7 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
if
(
StringUtils
.
isBlank
(
storeStrategyDTO
.
getTargetValue
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略命中值不能为空"
);
}
//分组策略
storeStrategyDTO
.
setStrategyType
(
StoreGroupConstant
.
STORE_GROUP_STRATEGY_TYPE
);
storeStrategyDTO
.
setCreateTime
(
new
Date
());
storeStrategyDTO
.
setUpdateTime
(
new
Date
());
storeStrategyDTO
.
setStatus
(
1
);
...
...
@@ -62,7 +57,7 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
}
@Override
public
ServiceResponse
<
Integer
>
deleteStore
Group
Strategy
(
int
strategyId
)
{
public
ServiceResponse
<
Integer
>
deleteStoreStrategy
(
int
strategyId
)
{
TabStoreStrategy
storeStrategy
=
storeStrategyService
.
getStoreStrategyById
(
strategyId
);
if
(
storeStrategy
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略主键ID错误,查询不到数据"
);
...
...
@@ -71,7 +66,7 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
}
@Override
public
ServiceResponse
<
Integer
>
modifyStore
Group
Strategy
(
StoreStrategyDTO
storeStrategyDTO
)
{
public
ServiceResponse
<
Integer
>
modifyStoreStrategy
(
StoreStrategyDTO
storeStrategyDTO
)
{
TabStoreStrategy
storeStrategy
=
storeStrategyService
.
getStoreStrategyById
(
storeStrategyDTO
.
getStrategyId
());
if
(
storeStrategy
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略主键ID错误,查询不到数据"
);
...
...
@@ -89,7 +84,7 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
}
@Override
public
ServiceResponse
<
StoreStrategyDTO
>
getStore
Group
StrategyById
(
int
strategyId
)
{
public
ServiceResponse
<
StoreStrategyDTO
>
getStoreStrategyById
(
int
strategyId
)
{
TabStoreStrategy
storeStrategy
=
storeStrategyService
.
getStoreStrategyById
(
strategyId
);
if
(
storeStrategy
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略主键ID错误,查询不到数据"
);
...
...
@@ -163,17 +158,17 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
}
@Override
public
ServiceResponse
<
Integer
>
getWeightsByEnterpriseId
(
int
enterpriseId
)
{
TabStoreGroupStrategyWeights
weight
=
storeGroupStrategyWeightsService
.
getWeightByEnterpriseId
(
enterpriseId
);
int
result
=
weight
==
null
?
0
:
weight
.
getStatus
();
return
ServiceResponse
.
success
(
result
);
public
ServiceResponse
setStoreGroupStrategyWeight
(
Integer
enterpriseId
,
int
weight
)
{
RedisUtil
.
setCache
(
"enterprise:store:storeGroupStrategy:"
+
enterpriseId
,
weight
);
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
Integer
>
saveOrUpdateWeights
(
int
status
,
int
enterpriseId
)
{
TabStoreGroupStrategyWeights
record
=
new
TabStoreGroupStrategyWeights
();
record
.
setEnterpriseId
(
enterpriseId
);
record
.
setStatus
(
status
);
return
ServiceResponse
.
success
(
storeGroupStrategyWeightsService
.
saveOrUpdate
(
record
));
public
ServiceResponse
getStoreGroupStrategyWeight
(
Integer
enterpriseId
)
{
Object
value
=
RedisUtil
.
getCache
(
"enterprise:store:storeGroupStrategy:"
+
enterpriseId
);
if
(
value
==
null
){
ServiceResponse
.
success
(
0
);
}
return
ServiceResponse
.
success
(
Integer
.
valueOf
(
value
.
toString
()));
}
}
gic-store-web/src/main/java/com/gic/store/web/controller/StoreStrategyController.java
View file @
20f37580
...
...
@@ -35,7 +35,7 @@ public class StoreStrategyController {
public
RestResponse
saveStoreGroupStrategy
(
@Validated
({
StoreStrategyQO
.
SaveValidView
.
class
})
StoreStrategyQO
storeStrategyQO
)
{
//分组策略类型
storeStrategyQO
.
setStrategyType
(
StoreGroupConstant
.
STORE_GROUP_STRATEGY_TYPE
);
ServiceResponse
result
=
storeStrategyApiService
.
saveStore
Group
Strategy
(
transferQoToDTO
(
storeStrategyQO
));
ServiceResponse
result
=
storeStrategyApiService
.
saveStoreStrategy
(
transferQoToDTO
(
storeStrategyQO
));
if
(!
result
.
isSuccess
())
{
return
RestResponse
.
failure
(
result
.
getCode
(),
result
.
getMessage
());
}
...
...
@@ -46,7 +46,7 @@ public class StoreStrategyController {
@RequestMapping
(
"/edit-store-group-strategy"
)
public
RestResponse
editStoreGroupStrategy
(
@Validated
({
StoreStrategyQO
.
SaveValidView
.
class
,
StoreStrategyQO
.
RemoveValidView
.
class
})
StoreStrategyQO
storeStrategyQO
)
{
ServiceResponse
result
=
storeStrategyApiService
.
modifyStore
Group
Strategy
(
transferQoToDTO
(
storeStrategyQO
));
ServiceResponse
result
=
storeStrategyApiService
.
modifyStoreStrategy
(
transferQoToDTO
(
storeStrategyQO
));
if
(!
result
.
isSuccess
())
{
return
RestResponse
.
failure
(
result
.
getCode
(),
result
.
getMessage
());
}
...
...
@@ -55,7 +55,7 @@ public class StoreStrategyController {
@RequestMapping
(
"/get-store-group-strategy"
)
public
RestResponse
getStoreGroupStrategy
(
@Validated
({
StoreStrategyQO
.
RemoveValidView
.
class
})
StoreStrategyQO
storeStrategyQO
)
{
ServiceResponse
result
=
storeStrategyApiService
.
getStore
Group
StrategyById
(
storeStrategyQO
.
getStrategyId
());
ServiceResponse
result
=
storeStrategyApiService
.
getStoreStrategyById
(
storeStrategyQO
.
getStrategyId
());
if
(!
result
.
isSuccess
())
{
return
RestResponse
.
failure
(
result
.
getCode
(),
result
.
getMessage
());
}
...
...
@@ -64,7 +64,7 @@ public class StoreStrategyController {
@RequestMapping
(
"/delete-store-group-strategy"
)
public
RestResponse
deleteStoreGroupStrategy
(
@Validated
({
StoreStrategyQO
.
RemoveValidView
.
class
})
StoreStrategyQO
storeStrategyQO
)
{
ServiceResponse
result
=
storeStrategyApiService
.
deleteStore
Group
Strategy
(
storeStrategyQO
.
getStrategyId
());
ServiceResponse
result
=
storeStrategyApiService
.
deleteStoreStrategy
(
storeStrategyQO
.
getStrategyId
());
if
(!
result
.
isSuccess
())
{
return
RestResponse
.
failure
(
result
.
getCode
(),
result
.
getMessage
());
}
...
...
@@ -124,17 +124,17 @@ public class StoreStrategyController {
}
@RequestMapping
(
"/update-group-strategy-weights"
)
public
RestResponse
updateWeight
(
Integer
status
)
{
if
(
status
==
null
)
{
public
RestResponse
updateWeight
(
Integer
weight
)
{
if
(
weight
==
null
)
{
RestResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"参数错误"
);
}
ServiceResponse
<
Integer
>
result
=
storeStrategyApiService
.
s
aveOrUpdateWeights
(
status
,
StoreGroupConstant
.
TEST_ENTERPRISE_ID
);
ServiceResponse
<
Integer
>
result
=
storeStrategyApiService
.
s
etStoreGroupStrategyWeight
(
StoreGroupConstant
.
TEST_ENTERPRISE_ID
,
weight
);
return
RestResponse
.
success
(
result
.
getResult
());
}
@RequestMapping
(
"/get-group-strategy-weights"
)
public
RestResponse
getWeight
()
{
ServiceResponse
<
Integer
>
result
=
storeStrategyApiService
.
get
WeightsByEnterpriseId
(
StoreGroupConstant
.
TEST_ENTERPRISE_ID
);
ServiceResponse
<
Integer
>
result
=
storeStrategyApiService
.
get
StoreGroupStrategyWeight
(
StoreGroupConstant
.
TEST_ENTERPRISE_ID
);
return
RestResponse
.
success
(
result
.
getResult
());
}
...
...
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