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
7ac03c9e
Commit
7ac03c9e
authored
Sep 18, 2019
by
何文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加权限相关的代码
parent
2278c67d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
4 deletions
+65
-4
GoodsBrandController.java
...m/gic/plug/web/controller/goods/GoodsBrandController.java
+32
-2
GoodsDomainController.java
.../gic/plug/web/controller/goods/GoodsDomainController.java
+33
-2
No files found.
src/main/java/com/gic/plug/web/controller/goods/GoodsBrandController.java
View file @
7ac03c9e
package
com
.
gic
.
plug
.
web
.
controller
.
goods
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.contants.SortType
;
import
com.gic.commons.util.PageHelperUtils
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.goods.api.dto.BrandDTO
;
import
com.gic.goods.api.dto.GoodsRightsSelectorDTO
;
import
com.gic.goods.api.service.BrandApiService
;
import
com.gic.goods.api.service.GoodsRightsSelectorApiService
;
import
com.gic.goods.api.util.Constant
;
import
com.gic.plug.web.vo.goods.GoodsBrandVO
;
@RestController
...
...
@@ -19,9 +28,30 @@ public class GoodsBrandController {
@Autowired
private
BrandApiService
brandApiService
;
@Autowired
private
GoodsRightsSelectorApiService
goodsRightsSelectorApiService
;
@RequestMapping
(
"/goods-brand-list"
)
public
RestResponse
goodsBrandList
(
int
pageSize
,
int
currentPage
,
String
search
,
Long
goodsDomainId
)
{
ServiceResponse
<
Page
<
BrandDTO
>>
serviceResponse
=
brandApiService
.
findBrandPage
(
currentPage
,
pageSize
,
goodsDomainId
,
search
,
SortType
.
sortDescType
);
public
RestResponse
goodsBrandList
(
int
pageSize
,
int
currentPage
,
String
search
,
Long
goodsDomainId
,
String
channelCode
)
{
// 是否最高权限
List
<
Long
>
branIdList
=
new
ArrayList
<>();
if
(
Constant
.
TEST_GOODS_RIGHTS_SELECTOR_ID
!=
null
)
{
ServiceResponse
<
GoodsRightsSelectorDTO
>
selectorDTOServiceResponse
=
goodsRightsSelectorApiService
.
getGoodsRightsSelector
(
Constant
.
TEST_GOODS_RIGHTS_SELECTOR_ID
);
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
);
}
}
}
}
}
ServiceResponse
<
Page
<
BrandDTO
>>
serviceResponse
=
brandApiService
.
findBrandPage
(
currentPage
,
pageSize
,
goodsDomainId
,
search
,
branIdList
,
SortType
.
sortDescType
);
if
(!
serviceResponse
.
isSuccess
())
{
return
RestResponse
.
failure
(
serviceResponse
.
getCode
(),
serviceResponse
.
getMessage
());
}
...
...
src/main/java/com/gic/plug/web/controller/goods/GoodsDomainController.java
View file @
7ac03c9e
...
...
@@ -7,10 +7,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.goods.api.dto.GoodsDomainDTO
;
import
com.gic.goods.api.dto.GoodsRightsSelectorDTO
;
import
com.gic.goods.api.service.GoodsDomainApiService
;
import
com.gic.goods.api.service.GoodsRightsSelectorApiService
;
import
com.gic.goods.api.util.Constant
;
import
com.gic.plug.web.vo.goods.GoodsChannelVO
;
import
com.gic.plug.web.vo.goods.GoodsDomainVO
;
...
...
@@ -21,6 +25,9 @@ public class GoodsDomainController {
@Autowired
private
GoodsDomainApiService
goodsDomainApiService
;
@Autowired
private
GoodsRightsSelectorApiService
goodsRightsSelectorApiService
;
/**
* @Title: getAllGoodsDomianListWith
* @Description: 查询企业下所有的域,拼接成channelVO返回
...
...
@@ -31,6 +38,19 @@ public class GoodsDomainController {
@RequestMapping
(
"/get-all-goods-domain-list"
)
private
RestResponse
getAllGoodsDomianListWith
()
{
ServiceResponse
<
List
<
GoodsDomainDTO
>>
serviceResponse
=
goodsDomainApiService
.
listAll
(
Constant
.
TEST_ENTERPRISE_ID
,
null
);
// 是否最高权限
boolean
isHighestRights
=
true
;
JSONObject
json
=
null
;
if
(
Constant
.
TEST_GOODS_RIGHTS_SELECTOR_ID
!=
null
)
{
isHighestRights
=
false
;
ServiceResponse
<
GoodsRightsSelectorDTO
>
selectorDTOServiceResponse
=
goodsRightsSelectorApiService
.
getGoodsRightsSelector
(
Constant
.
TEST_GOODS_RIGHTS_SELECTOR_ID
);
if
(
selectorDTOServiceResponse
.
isSuccess
())
{
GoodsRightsSelectorDTO
goodsRightsSelectorDTO
=
selectorDTOServiceResponse
.
getResult
();
if
(
goodsRightsSelectorDTO
!=
null
)
{
json
=
JSONObject
.
parseObject
(
goodsRightsSelectorDTO
.
getGoodsRightsDomains
());
}
}
}
if
(!
serviceResponse
.
isSuccess
())
{
return
RestResponse
.
failure
(
serviceResponse
.
getCode
(),
serviceResponse
.
getMessage
());
}
...
...
@@ -42,8 +62,19 @@ public class GoodsDomainController {
for
(
GoodsDomainDTO
goodsDomainDTO
:
goodsDomainDTOList
)
{
if
(
CollectionUtils
.
isNotEmpty
(
goodsDomainDTO
.
getChannels
())){
for
(
String
channelCode
:
goodsDomainDTO
.
getChannels
())
{
map
.
putIfAbsent
(
channelCode
,
new
ArrayList
<>());
map
.
get
(
channelCode
).
add
(
goodsDomainDTO
);
if
(
isHighestRights
)
{
// 最高权限所有都显示
map
.
putIfAbsent
(
channelCode
,
new
ArrayList
<>());
map
.
get
(
channelCode
).
add
(
goodsDomainDTO
);
}
else
{
//非最高权限按权限下有什么就刷什么来
if
(
json
!=
null
&&
json
.
containsKey
(
channelCode
))
{
map
.
putIfAbsent
(
channelCode
,
new
ArrayList
<>());
JSONArray
array
=
json
.
getJSONArray
(
channelCode
);
if
(
CollectionUtils
.
isNotEmpty
(
array
)
&&
array
.
contains
(
goodsDomainDTO
.
getGoodsDomainId
()))
{
map
.
get
(
channelCode
).
add
(
goodsDomainDTO
);
}
}
}
}
}
}
...
...
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