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
8b8765bd
Commit
8b8765bd
authored
Apr 24, 2020
by
何文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商品选择器
parent
28b05247
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
51 deletions
+83
-51
GoodsBrandController.java
...m/gic/plug/web/controller/goods/GoodsBrandController.java
+35
-23
GoodsDomainController.java
.../gic/plug/web/controller/goods/GoodsDomainController.java
+45
-27
GoodsSelectorController.java
...ic/plug/web/controller/goods/GoodsSelectorController.java
+3
-1
No files found.
src/main/java/com/gic/plug/web/controller/goods/GoodsBrandController.java
View file @
8b8765bd
...
...
@@ -10,11 +10,14 @@ import com.gic.commons.webapi.reponse.RestResponse;
import
com.gic.enterprise.utils.UserDetailUtils
;
import
com.gic.goods.api.dto.BrandDTO
;
import
com.gic.goods.api.dto.GoodsRightsSelectorDTO
;
import
com.gic.goods.api.dto.GoodsSelectorDTO
;
import
com.gic.goods.api.service.BrandApiService
;
import
com.gic.goods.api.service.GoodsRightsSelectorApiService
;
import
com.gic.goods.api.service.GoodsSelectorApiService
;
import
com.gic.goods.api.util.Constant
;
import
com.gic.plug.web.vo.goods.GoodsBrandVO
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -32,36 +35,45 @@ public class GoodsBrandController extends BaseGoodsController {
@Autowired
private
GoodsRightsSelectorApiService
goodsRightsSelectorApiService
;
@Autowired
private
GoodsSelectorApiService
goodsSelectorApiService
;
@RequestMapping
(
"/goods-brand-list"
)
public
RestResponse
goodsBrandList
(
int
pageSize
,
int
currentPage
,
String
search
,
Long
goodsDomainId
,
String
channelCode
)
{
Long
resourceId
=
UserDetailUtils
.
getUserDetail
().
getUserResourceInfo
()
==
null
?
null
:
UserDetailUtils
.
getUserDetail
().
getUserResourceInfo
().
getGoodsResourceId
();
ServiceResponse
<
GoodsRightsSelectorDTO
>
selectorDTOServiceResponse
=
goodsRightsSelectorApiService
.
getGoodsRightsSelector
(
resourceId
,
getEnterpriseId
()
,
UserDetailUtils
.
getUserDetail
().
getUserInfo
().
getSuperAdmin
());
if
(!
selectorDTOServiceResponse
.
isSuccess
()
||
selectorDTOServiceResponse
.
getResult
()
==
null
||
selectorDTOServiceResponse
.
getResult
().
getHasRights
()
==
Constant
.
NO
)
{
return
RestResponse
.
success
(
Collections
.
EMPTY_LIST
);
public
RestResponse
goodsBrandList
(
int
pageSize
,
int
currentPage
,
String
search
,
Long
goodsDomainId
,
String
channelCode
,
Long
goodsSelectorId
)
{
String
goodsRightsBrands
=
null
;
if
(
goodsSelectorId
!=
null
)
{
ServiceResponse
<
GoodsSelectorDTO
>
selectorServiceResponse
=
goodsSelectorApiService
.
getGoodsSelector
(
goodsSelectorId
,
getEnterpriseId
());
if
(
selectorServiceResponse
.
getResult
()
!=
null
)
{
goodsRightsBrands
=
selectorServiceResponse
.
getResult
().
getGoodsRightsBrands
();
}
else
{
return
RestResponse
.
success
(
Collections
.
EMPTY_LIST
);
}
}
else
{
Long
resourceId
=
UserDetailUtils
.
getUserDetail
().
getUserResourceInfo
()
==
null
?
null
:
UserDetailUtils
.
getUserDetail
().
getUserResourceInfo
().
getGoodsResourceId
();
ServiceResponse
<
GoodsRightsSelectorDTO
>
selectorDTOServiceResponse
=
goodsRightsSelectorApiService
.
getGoodsRightsSelector
(
resourceId
,
getEnterpriseId
()
,
UserDetailUtils
.
getUserDetail
().
getUserInfo
().
getSuperAdmin
());
if
(!
selectorDTOServiceResponse
.
isSuccess
()
||
selectorDTOServiceResponse
.
getResult
()
==
null
||
selectorDTOServiceResponse
.
getResult
().
getHasRights
()
==
Constant
.
NO
)
{
return
RestResponse
.
success
(
Collections
.
EMPTY_LIST
);
}
goodsRightsBrands
=
selectorDTOServiceResponse
.
getResult
().
getGoodsRightsBrands
();
}
// 是否最高权限
List
<
Long
>
branIdList
=
new
ArrayList
<>();
if
(
UserDetailUtils
.
getUserDetail
().
getUserResourceInfo
()
!=
null
&&
UserDetailUtils
.
getUserDetail
().
getUserResourceInfo
().
getGoodsResourceId
()
!=
null
)
{
if
(
selectorDTOServiceResponse
.
isSuccess
())
{
GoodsRightsSelectorDTO
goodsRightsSelectorDTO
=
selectorDTOServiceResponse
.
getResult
();
if
(
goodsRightsSelectorDTO
!=
null
)
{
JSONObject
brandRightsObject
=
JSONObject
.
parseObject
(
goodsRightsSelectorDTO
.
getGoodsRightsBrands
());
JSONArray
array
=
brandRightsObject
.
getJSONArray
(
channelCode
+
"_"
+
goodsDomainId
);
if
(
CollectionUtils
.
isNotEmpty
(
array
))
{
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
Long
brandId
=
array
.
getLong
(
i
);
branIdList
.
add
(
brandId
);
}
}
if
(
StringUtils
.
isNotBlank
(
goodsRightsBrands
))
{
JSONObject
brandRightsObject
=
JSONObject
.
parseObject
(
goodsRightsBrands
);
JSONArray
array
=
brandRightsObject
.
getJSONArray
(
channelCode
+
"_"
+
goodsDomainId
);
if
(
CollectionUtils
.
isNotEmpty
(
array
))
{
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
Long
brandId
=
array
.
getLong
(
i
);
branIdList
.
add
(
brandId
);
}
}
}
return
findBrandListByParams
(
currentPage
,
pageSize
,
goodsDomainId
,
search
,
getEnterpriseId
());
return
findBrandListByParams
(
currentPage
,
pageSize
,
goodsDomainId
,
search
,
getEnterpriseId
());
}
...
...
src/main/java/com/gic/plug/web/controller/goods/GoodsDomainController.java
View file @
8b8765bd
...
...
@@ -7,12 +7,15 @@ import com.gic.commons.webapi.reponse.RestResponse;
import
com.gic.enterprise.utils.UserDetailUtils
;
import
com.gic.goods.api.dto.GoodsDomainDTO
;
import
com.gic.goods.api.dto.GoodsRightsSelectorDTO
;
import
com.gic.goods.api.dto.GoodsSelectorDTO
;
import
com.gic.goods.api.service.GoodsDomainApiService
;
import
com.gic.goods.api.service.GoodsRightsSelectorApiService
;
import
com.gic.goods.api.service.GoodsSelectorApiService
;
import
com.gic.goods.api.util.Constant
;
import
com.gic.plug.web.vo.goods.GoodsChannelVO
;
import
com.gic.plug.web.vo.goods.GoodsDomainVO
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -28,12 +31,15 @@ public class GoodsDomainController extends BaseGoodsController {
@Autowired
private
GoodsRightsSelectorApiService
goodsRightsSelectorApiService
;
@Autowired
private
GoodsSelectorApiService
goodsSelectorApiService
;
/**
* @return com.gic.commons.webapi.reponse.RestResponse
* @throws
* @Title: getAllGoodsDomianListWith
* @Description: 权限筛选器选择权限
* @author majia
* @return com.gic.commons.webapi.reponse.RestResponse
* @throws
*/
@RequestMapping
(
"/get-all-goods-domain-list-for-rights"
)
public
RestResponse
getAllGoodsDomainListForRights
()
{
...
...
@@ -45,21 +51,36 @@ public class GoodsDomainController extends BaseGoodsController {
}
/**
* @Title: getAllGoodsDomianListWith
* @Description: 查询企业下所有的域,拼接成channelVO返回
* @author majia
* @return com.gic.commons.webapi.reponse.RestResponse
* @throws
*/
* @return com.gic.commons.webapi.reponse.RestResponse
* @throws
* @Title: getAllGoodsDomianListWith
* @Description: 查询企业下所有的域,拼接成channelVO返回
* @author majia
*/
@RequestMapping
(
"/get-all-goods-domain-list"
)
public
RestResponse
getAllGoodsDomianList
()
{
Long
resourceId
=
UserDetailUtils
.
getUserDetail
().
getUserResourceInfo
()
==
null
?
null
:
UserDetailUtils
.
getUserDetail
().
getUserResourceInfo
().
getGoodsResourceId
();
ServiceResponse
<
GoodsRightsSelectorDTO
>
selectorDTOServiceResponse
=
goodsRightsSelectorApiService
.
getGoodsRightsSelector
(
resourceId
,
getEnterpriseId
(),
UserDetailUtils
.
getUserDetail
().
getUserInfo
().
getSuperAdmin
());
if
(!
selectorDTOServiceResponse
.
isSuccess
()
||
selectorDTOServiceResponse
.
getResult
()
==
null
||
selectorDTOServiceResponse
.
getResult
().
getHasRights
()
==
Constant
.
NO
)
{
return
RestResponse
.
success
(
Collections
.
EMPTY_LIST
);
public
RestResponse
getAllGoodsDomianList
(
Long
goodsSelectorId
)
{
String
goodsDomian
=
null
;
Integer
hasRights
=
0
;
if
(
goodsSelectorId
!=
null
)
{
ServiceResponse
<
GoodsSelectorDTO
>
selectorServiceResponse
=
goodsSelectorApiService
.
getGoodsSelector
(
goodsSelectorId
,
getEnterpriseId
());
if
(
selectorServiceResponse
.
getResult
()
!=
null
)
{
goodsDomian
=
selectorServiceResponse
.
getResult
().
getGoodsRightsBrands
();
hasRights
=
selectorServiceResponse
.
getResult
().
getHasRights
();
}
else
{
return
RestResponse
.
success
(
Collections
.
EMPTY_LIST
);
}
}
else
{
Long
resourceId
=
UserDetailUtils
.
getUserDetail
().
getUserResourceInfo
()
==
null
?
null
:
UserDetailUtils
.
getUserDetail
().
getUserResourceInfo
().
getGoodsResourceId
();
ServiceResponse
<
GoodsRightsSelectorDTO
>
selectorDTOServiceResponse
=
goodsRightsSelectorApiService
.
getGoodsRightsSelector
(
resourceId
,
getEnterpriseId
(),
UserDetailUtils
.
getUserDetail
().
getUserInfo
().
getSuperAdmin
());
if
(!
selectorDTOServiceResponse
.
isSuccess
()
||
selectorDTOServiceResponse
.
getResult
()
==
null
||
selectorDTOServiceResponse
.
getResult
().
getHasRights
()
==
Constant
.
NO
)
{
return
RestResponse
.
success
(
Collections
.
EMPTY_LIST
);
}
goodsDomian
=
selectorDTOServiceResponse
.
getResult
().
getGoodsRightsDomains
();
hasRights
=
selectorDTOServiceResponse
.
getResult
().
getHasRights
();
}
ServiceResponse
<
List
<
GoodsDomainDTO
>>
serviceResponse
=
goodsDomainApiService
.
listAll
(
getEnterpriseId
(),
null
);
// 是否最高权限
...
...
@@ -67,16 +88,13 @@ public class GoodsDomainController extends BaseGoodsController {
JSONObject
json
=
null
;
if
(
UserDetailUtils
.
getUserDetail
().
getUserInfo
().
getSuperAdmin
()
!=
1
)
{
isHighestRights
=
false
;
if
(
selectorDTOServiceResponse
.
isSuccess
())
{
GoodsRightsSelectorDTO
goodsRightsSelectorDTO
=
selectorDTOServiceResponse
.
getResult
();
if
(
goodsRightsSelectorDTO
!=
null
)
{
if
(
goodsRightsSelectorDTO
.
getHasRights
()
==
0
)
{
json
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
Collections
.
EMPTY_LIST
));
}
else
{
json
=
JSONObject
.
parseObject
(
goodsRightsSelectorDTO
.
getGoodsRightsDomains
());
if
(
json
.
isEmpty
())
{
isHighestRights
=
true
;
}
if
(
StringUtils
.
isNotBlank
(
goodsDomian
))
{
if
(
hasRights
==
0
)
{
json
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
Collections
.
EMPTY_LIST
));
}
else
{
json
=
JSONObject
.
parseObject
(
goodsDomian
);
if
(
json
.
isEmpty
())
{
isHighestRights
=
true
;
}
}
}
...
...
@@ -93,7 +111,7 @@ public class GoodsDomainController extends BaseGoodsController {
return
RestResponse
.
success
(
Collections
.
EMPTY_LIST
);
}
for
(
GoodsDomainDTO
goodsDomainDTO
:
goodsDomainDTOList
)
{
if
(
CollectionUtils
.
isNotEmpty
(
goodsDomainDTO
.
getChannels
())){
if
(
CollectionUtils
.
isNotEmpty
(
goodsDomainDTO
.
getChannels
()))
{
for
(
String
channelCode
:
goodsDomainDTO
.
getChannels
())
{
if
(
isHighestRights
)
{
// 最高权限所有都显示
map
.
putIfAbsent
(
channelCode
,
new
ArrayList
<>());
...
...
src/main/java/com/gic/plug/web/controller/goods/GoodsSelectorController.java
View file @
8b8765bd
...
...
@@ -73,6 +73,8 @@ public class GoodsSelectorController extends BaseGoodsController {
goodsSelectorDTO
.
setHasRights
(
goodsRightsSelectorDTO
.
getHasRights
());
goodsSelectorDTO
.
setGoodsSearchRightValue
(
goodsRightsSelectorDTO
.
getGoodsRightsSearchValue
());
goodsSelectorDTO
.
setGoodsSearchRightText
(
goodsRightsSelectorDTO
.
getGoodsRightsSearchText
());
goodsSelectorDTO
.
setGoodsRightsBrands
(
goodsRightsSelectorDTO
.
getGoodsRightsBrands
());
goodsSelectorDTO
.
setGoodsRightsDomains
(
goodsRightsSelectorDTO
.
getGoodsRightsDomains
());
ServiceResponse
<
GoodsSelectorDTO
>
serviceResponse
=
goodsSelectorApiService
.
saveGoodsSelector
(
goodsSelectorDTO
);
if
(
serviceResponse
.
isSuccess
())
{
goodsSelectorDTO
=
serviceResponse
.
getResult
();
...
...
@@ -138,7 +140,7 @@ public class GoodsSelectorController extends BaseGoodsController {
}
GoodsRightsSelectorDTO
goodsRightsSelectorDTO
=
goodsRightsSelectorDTOServiceResponse
.
getResult
();
ServiceResponse
<
GoodsSelectorDTO
>
serviceResponse
=
goodsSelectorApiService
.
updateGoodsSelectorRights
(
goodsSelectorId
,
goodsRightsSelectorDTO
.
getGoodsRightsSearchText
(),
goodsRightsSelectorDTO
.
getGoodsRightsSearchValue
(),
goodsRightsSelectorDTO
.
getHasRights
(),
getEnterpriseId
());
goodsRightsSelectorDTO
.
getGoodsRightsSearchText
(),
goodsRightsSelectorDTO
.
getGoodsRightsSearchValue
(),
goodsRightsSelectorDTO
.
getHasRights
(),
g
oodsRightsSelectorDTO
.
getGoodsRightsBrands
(),
goodsRightsSelectorDTO
.
getGoodsRightsDomains
(),
g
etEnterpriseId
());
if
(!
serviceResponse
.
isSuccess
())
{
return
RestResponse
.
failure
(
serviceResponse
.
getCode
(),
serviceResponse
.
getMessage
());
}
...
...
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