Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-webapp-plug
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-webapp-plug
Commits
5600b31d
Commit
5600b31d
authored
May 06, 2020
by
陶光胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
门店标签回写
parent
780ce788
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
28 deletions
+67
-28
StoreController.java
...ain/java/com/gic/plug/web/controller/StoreController.java
+8
-24
StoreFieldController.java
...ava/com/gic/plug/web/controller/StoreFieldController.java
+11
-4
StoreRegionAuthUtil.java
...main/java/com/gic/plug/web/utils/StoreRegionAuthUtil.java
+48
-0
No files found.
src/main/java/com/gic/plug/web/controller/StoreController.java
View file @
5600b31d
...
...
@@ -15,6 +15,7 @@ import com.gic.enterprise.utils.UserDetailUtils;
import
com.gic.plug.web.qo.StoreWidgetCountQO
;
import
com.gic.plug.web.qo.StoreWidgetQO
;
import
com.gic.plug.web.strategy.init.StrategyInit
;
import
com.gic.plug.web.utils.StoreRegionAuthUtil
;
import
com.gic.plug.web.vo.StoreRegionVO
;
import
com.gic.plug.web.vo.StoreResourceVO
;
import
com.gic.plug.web.vo.StoreVO
;
...
...
@@ -36,7 +37,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
* @author zhiwj
...
...
@@ -63,40 +66,21 @@ public class StoreController {
public
RestResponse
listStoreRegion
(
String
search
)
{
UserDetail
userDetail
=
UserDetailUtils
.
getUserDetail
();
Integer
enterpriseId
=
userDetail
.
getEnterpriseId
();
String
[]
authRegionArr
=
null
;
if
(
userDetail
.
getUserInfo
().
getSuperAdmin
()
!=
1
&&
userDetail
.
getUserResourceInfo
()
!=
null
){
Long
storeResource
=
userDetail
.
getUserResourceInfo
().
getStoreResource
();
if
(
storeResource
!=
null
){
ServiceResponse
<
StoreWidgetDTO
>
storeWidget
=
this
.
storeWidgetApiService
.
getStoreWidget
(
storeResource
.
intValue
());
if
(
storeWidget
.
getResult
()
!=
null
){
String
searchParam
=
storeWidget
.
getResult
().
getSearchParam
();
JSONObject
json
=
JSON
.
parseArray
(
searchParam
).
getJSONObject
(
0
);
JSONArray
list
=
json
.
getJSONArray
(
"list"
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
JSONObject
o
=
list
.
getJSONObject
(
i
).
getJSONObject
(
"data"
);
if
(
o
.
getString
(
"key"
).
equals
(
StoreESFieldsEnum
.
REGIONID
.
getField
())){
authRegionArr
=
o
.
getString
(
"value"
).
split
(
" "
);
}
}
}
}
}
Set
<
String
>
authRegionSet
=
StoreRegionAuthUtil
.
getUserRegion
(
storeWidgetApiService
);
ServiceResponse
<
List
<
StoreRegionDTO
>>
serviceResponse
=
storeRegionApiService
.
listStoreRegion
(
enterpriseId
,
search
);
if
(
serviceResponse
.
isSuccess
())
{
List
<
StoreRegionDTO
>
result
=
serviceResponse
.
getResult
();
List
<
StoreRegionVO
>
regionList
=
new
ArrayList
<>();
for
(
StoreRegionDTO
storeRegionDTO
:
result
){
if
(
authRegionArr
!=
null
){
for
(
String
s
:
authRegionArr
){
if
(
storeRegionDTO
.
getRegionId
()
==
Integer
.
valueOf
(
s
)){
regionList
.
add
(
EntityUtil
.
changeEntityByJSON
(
StoreRegionVO
.
class
,
storeRegionDTO
));
}
if
(!
authRegionSet
.
isEmpty
()){
if
(
authRegionSet
.
contains
(
storeRegionDTO
.
getRegionId
()+
""
)){
regionList
.
add
(
EntityUtil
.
changeEntityByJSON
(
StoreRegionVO
.
class
,
storeRegionDTO
));
}
}
else
{
regionList
.
add
(
EntityUtil
.
changeEntityByJSON
(
StoreRegionVO
.
class
,
storeRegionDTO
));
}
}
return
RestResponse
.
success
(
EntityUtil
.
changeEntityListByOrika
(
StoreRegionVO
.
class
,
result
)
);
return
RestResponse
.
success
(
regionList
);
}
else
{
return
RestResponse
.
failure
(
serviceResponse
.
getCode
(),
serviceResponse
.
getMessage
());
}
...
...
src/main/java/com/gic/plug/web/controller/StoreFieldController.java
View file @
5600b31d
package
com
.
gic
.
plug
.
web
.
controller
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
com.gic.plug.web.utils.StoreRegionAuthUtil
;
import
com.gic.store.service.StoreWidgetApiService
;
import
com.gic.store.utils.StoreRedisKeyUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -43,6 +42,8 @@ public class StoreFieldController {
private
StoreFieldApiService
storeFieldApiService
;
@Autowired
private
StoreFieldSelectApiService
storeFieldSelectApiService
;
@Autowired
private
StoreWidgetApiService
widgetApiService
;
@RequestMapping
(
"/list-store-field-type"
)
public
RestResponse
listStoreFieldType
()
{
...
...
@@ -115,8 +116,14 @@ public class StoreFieldController {
String
key
=
"enterprise:store:storeField:"
+
enterpriseId
+
":"
;
List
<
StoreFieldRegionVO
>
voList
=
new
ArrayList
<>(
dtoList
.
size
());
Set
<
String
>
userRegion
=
StoreRegionAuthUtil
.
getUserRegion
(
widgetApiService
);
for
(
StoreFieldDTO
dto
:
dtoList
)
{
//不需要文本类型字段
if
(!
userRegion
.
isEmpty
()){
if
(!
userRegion
.
contains
(
dto
.
getStoreRegionId
())){
continue
;
}
}
if
(
dto
.
getStoreFieldType
().
intValue
()
!=
StoreFieldTypeEnum
.
TEXT
.
getCode
())
{
Object
obj
=
RedisUtil
.
getCache
(
StoreRedisKeyUtils
.
getStoreFieldKey
(
enterpriseId
,
dto
.
getStoreFieldId
()));
if
(
obj
!=
null
)
{
...
...
src/main/java/com/gic/plug/web/utils/StoreRegionAuthUtil.java
0 → 100644
View file @
5600b31d
package
com
.
gic
.
plug
.
web
.
utils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.enterprise.utils.UserDetail
;
import
com.gic.enterprise.utils.UserDetailUtils
;
import
com.gic.store.constant.StoreESFieldsEnum
;
import
com.gic.store.dto.StoreWidgetDTO
;
import
com.gic.store.service.StoreWidgetApiService
;
import
org.apache.commons.collections.CollectionUtils
;
import
java.util.HashSet
;
import
java.util.Set
;
public
class
StoreRegionAuthUtil
{
public
static
Set
<
String
>
getUserRegion
(
StoreWidgetApiService
storeWidgetApiService
){
Set
<
String
>
authRegionSet
=
new
HashSet
<>();
UserDetail
userDetail
=
UserDetailUtils
.
getUserDetail
();
if
(
userDetail
.
getUserInfo
().
getSuperAdmin
()
!=
1
&&
userDetail
.
getUserResourceInfo
()
!=
null
){
Long
storeResource
=
userDetail
.
getUserResourceInfo
().
getStoreResource
();
if
(
storeResource
!=
null
){
ServiceResponse
<
StoreWidgetDTO
>
storeWidget
=
storeWidgetApiService
.
getStoreWidget
(
storeResource
.
intValue
());
if
(
storeWidget
.
getResult
()
!=
null
){
String
searchParam
=
storeWidget
.
getResult
().
getSearchParam
();
JSONObject
json
=
JSON
.
parseArray
(
searchParam
).
getJSONObject
(
0
);
JSONArray
list
=
json
.
getJSONArray
(
"list"
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
JSONObject
o
=
list
.
getJSONObject
(
i
).
getJSONObject
(
"data"
);
if
(
o
.
getString
(
"key"
).
equals
(
StoreESFieldsEnum
.
REGIONID
.
getField
())){
String
[]
arr
=
o
.
getString
(
"value"
).
split
(
" "
);
Set
<
String
>
set
=
new
HashSet
<>();
for
(
String
s
:
arr
){
set
.
add
(
s
);
}
authRegionSet
.
addAll
(
set
);
}
}
}
}
if
(
CollectionUtils
.
isEmpty
(
authRegionSet
)){
authRegionSet
.
add
(
"-1"
);
}
}
return
authRegionSet
;
}
}
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