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
b88c5de1
Commit
b88c5de1
authored
Jun 17, 2021
by
陶光胜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'developer' of
http://115.159.76.241/base_platform_enterprise/gic-store
into developer
parents
05405023
9fb0a694
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
679 additions
and
7 deletions
+679
-7
StoreESFieldsEnum.java
...c/main/java/com/gic/store/constant/StoreESFieldsEnum.java
+22
-0
ClerkSearchDTO.java
...e-api/src/main/java/com/gic/store/dto/ClerkSearchDTO.java
+79
-0
StoreResourceDTO.java
...api/src/main/java/com/gic/store/dto/StoreResourceDTO.java
+97
-0
StoreResourceApiService.java
...n/java/com/gic/store/service/StoreResourceApiService.java
+25
-0
TabClerkMapper.java
...rc/main/java/com/gic/store/dao/mapper/TabClerkMapper.java
+26
-2
ClerkService.java
...ice/src/main/java/com/gic/store/service/ClerkService.java
+10
-1
ClerkServiceImpl.java
...ain/java/com/gic/store/service/impl/ClerkServiceImpl.java
+13
-1
ClerkApiServiceImpl.java
...com/gic/store/service/outer/impl/ClerkApiServiceImpl.java
+14
-1
StoreResourceApiServiceImpl.java
...store/service/outer/impl/StoreResourceApiServiceImpl.java
+82
-0
ApplicationContextUtils.java
...ain/java/com/gic/store/utils/ApplicationContextUtils.java
+35
-0
ExceptionResultAop.java
...src/main/java/com/gic/store/utils/ExceptionResultAop.java
+61
-0
AbstractAuthDataUtils.java
...a/com/gic/store/utils/resource/AbstractAuthDataUtils.java
+27
-0
AuthDataHandleUtils.java
...ava/com/gic/store/utils/resource/AuthDataHandleUtils.java
+95
-0
BrandAbstractAuthData.java
...a/com/gic/store/utils/resource/BrandAbstractAuthData.java
+54
-0
dubbo-gic-store-service.xml
...re-service/src/main/resources/dubbo-gic-store-service.xml
+1
-0
TabClerkMapper.xml
...tore-service/src/main/resources/mapper/TabClerkMapper.xml
+34
-0
TabStoreBrandRefMapper.xml
...vice/src/main/resources/mapper/TabStoreBrandRefMapper.xml
+2
-1
TabStoreRegionRelMapper.xml
...ice/src/main/resources/mapper/TabStoreRegionRelMapper.xml
+2
-1
No files found.
gic-store-api/src/main/java/com/gic/store/constant/StoreESFieldsEnum.java
View file @
b88c5de1
package
com
.
gic
.
store
.
constant
;
import
java.util.HashSet
;
import
java.util.Set
;
/**
*
* @ClassName: StoreESFieldsEnum
...
...
@@ -197,6 +200,25 @@ public enum StoreESFieldsEnum {
this
.
desc
=
desc
;
}
/**
* 自定义字段的key
* @return
*/
public
static
Set
<
String
>
getStoreFieldKey
()
{
Set
<
String
>
storeField
=
new
HashSet
<>();
storeField
.
add
(
StoreESFieldsEnum
.
C1
.
getField
());
storeField
.
add
(
StoreESFieldsEnum
.
C2
.
getField
());
storeField
.
add
(
StoreESFieldsEnum
.
C3
.
getField
());
storeField
.
add
(
StoreESFieldsEnum
.
C4
.
getField
());
storeField
.
add
(
StoreESFieldsEnum
.
C5
.
getField
());
storeField
.
add
(
StoreESFieldsEnum
.
C6
.
getField
());
storeField
.
add
(
StoreESFieldsEnum
.
C7
.
getField
());
storeField
.
add
(
StoreESFieldsEnum
.
C8
.
getField
());
storeField
.
add
(
StoreESFieldsEnum
.
C9
.
getField
());
storeField
.
add
(
StoreESFieldsEnum
.
C10
.
getField
());
return
storeField
;
}
public
String
getField
()
{
return
field
;
}
...
...
gic-store-api/src/main/java/com/gic/store/dto/ClerkSearchDTO.java
View file @
b88c5de1
package
com
.
gic
.
store
.
dto
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
*
...
...
@@ -22,6 +25,22 @@ public class ClerkSearchDTO implements Serializable {
private
Integer
clerkType
;
private
String
storeSearch
;
/**
* 门店选择器ID
*/
private
Long
storeResource
;
/**
* 如果勾选了导购,导购ID,英文逗号隔开,用getClerkIdList方法 导出使用
*/
private
String
clerkIds
;
/**
* 为了不与storeInfoIds错乱使用,单独使用一个 导出使用
*/
private
String
storeInfoIdPram
;
private
String
fileName
;
private
Integer
excelExtension
;
private
List
<
String
>
fieldCodeList
;
...
...
@@ -157,6 +176,63 @@ public class ClerkSearchDTO implements Serializable {
this
.
searchType
=
searchType
;
}
public
Long
getStoreResource
()
{
return
storeResource
;
}
public
ClerkSearchDTO
setStoreResource
(
Long
storeResource
)
{
this
.
storeResource
=
storeResource
;
return
this
;
}
public
String
getClerkIds
()
{
return
clerkIds
;
}
public
ClerkSearchDTO
setClerkIds
(
String
clerkIds
)
{
this
.
clerkIds
=
clerkIds
;
return
this
;
}
public
List
<
Integer
>
getClerkIdList
(
String
suffix
)
{
if
(
clerkIds
!=
null
&&
clerkIds
!=
""
)
{
if
(
suffix
==
null
||
suffix
==
""
)
{
//默认空格
suffix
=
","
;
}
return
Arrays
.
stream
(
clerkIds
.
split
(
suffix
))
.
filter
(
e
->
e
!=
null
&&
e
!=
""
)
.
mapToInt
(
e
->
Integer
.
valueOf
(
e
))
.
boxed
()
.
collect
(
Collectors
.
toList
());
}
return
new
ArrayList
<>();
}
public
List
<
Integer
>
getStoreInfoIdParamList
(
String
suffix
)
{
if
(
storeInfoIdPram
!=
null
&&
storeInfoIdPram
!=
""
)
{
if
(
suffix
==
null
||
suffix
==
""
)
{
//默认空格
suffix
=
","
;
}
return
Arrays
.
stream
(
storeInfoIdPram
.
split
(
suffix
))
.
filter
(
e
->
e
!=
null
&&
e
!=
""
)
.
mapToInt
(
e
->
Integer
.
valueOf
(
e
))
.
boxed
()
.
collect
(
Collectors
.
toList
());
}
return
new
ArrayList
<>();
}
public
String
getStoreInfoIdPram
()
{
return
storeInfoIdPram
;
}
public
ClerkSearchDTO
setStoreInfoIdPram
(
String
storeInfoIdPram
)
{
this
.
storeInfoIdPram
=
storeInfoIdPram
;
return
this
;
}
@Override
public
String
toString
()
{
return
"ClerkSearchDTO{"
+
...
...
@@ -175,6 +251,9 @@ public class ClerkSearchDTO implements Serializable {
", fieldCodeList="
+
fieldCodeList
+
", dataType="
+
dataType
+
", status="
+
status
+
", storeResource="
+
storeResource
+
", clerkIds="
+
clerkIds
+
", storeInfoIdPram="
+
storeInfoIdPram
+
'}'
;
}
}
gic-store-api/src/main/java/com/gic/store/dto/StoreResourceDTO.java
0 → 100644
View file @
b88c5de1
package
com
.
gic
.
store
.
dto
;
import
java.io.Serializable
;
/**
* 门店选择器登录人权限
* @ClassName:
* @Description:
* @author guojuxing
* @date 2021/5/26 11:37 AM
*/
public
class
StoreResourceDTO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1670193003220258987L
;
private
String
id
;
private
String
name
;
/**
* 1自有 2共享
*/
private
Integer
ownType
;
/**
* 自有商户名称
*/
private
String
ownerEntName
;
private
Integer
ownerEntId
;
private
Integer
enterpriseId
;
public
String
getId
()
{
return
id
;
}
public
StoreResourceDTO
setId
(
String
id
)
{
this
.
id
=
id
;
return
this
;
}
public
String
getName
()
{
return
name
;
}
public
StoreResourceDTO
setName
(
String
name
)
{
this
.
name
=
name
;
return
this
;
}
public
Integer
getOwnType
()
{
return
ownType
;
}
public
StoreResourceDTO
setOwnType
(
Integer
ownType
)
{
this
.
ownType
=
ownType
;
return
this
;
}
public
String
getOwnerEntName
()
{
return
ownerEntName
;
}
public
StoreResourceDTO
setOwnerEntName
(
String
ownerEntName
)
{
this
.
ownerEntName
=
ownerEntName
;
return
this
;
}
public
Integer
getOwnerEntId
()
{
return
ownerEntId
;
}
public
StoreResourceDTO
setOwnerEntId
(
Integer
ownerEntId
)
{
this
.
ownerEntId
=
ownerEntId
;
return
this
;
}
public
Integer
getEnterpriseId
()
{
return
enterpriseId
;
}
public
StoreResourceDTO
setEnterpriseId
(
Integer
enterpriseId
)
{
this
.
enterpriseId
=
enterpriseId
;
return
this
;
}
@Override
public
String
toString
()
{
return
"StoreResourceDTO{"
+
"id='"
+
id
+
'\''
+
", name='"
+
name
+
'\''
+
", ownType="
+
ownType
+
", ownerEntName='"
+
ownerEntName
+
'\''
+
", ownerEntId="
+
ownerEntId
+
", enterpriseId="
+
enterpriseId
+
'}'
;
}
}
gic-store-api/src/main/java/com/gic/store/service/StoreResourceApiService.java
0 → 100644
View file @
b88c5de1
package
com
.
gic
.
store
.
service
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.store.dto.StoreResourceDTO
;
import
java.util.List
;
import
java.util.Set
;
/**
* 门店选择器资源过滤
* @ClassName:
* @Description:
* @author guojuxing
* @date 2021/5/26 10:49 AM
*/
public
interface
StoreResourceApiService
{
/**
* 获取登录人的权限
* @param userId 登录人ID
* @param esField StoreESFieldsEnum 枚举
* @return
*/
ServiceResponse
<
List
<
StoreResourceDTO
>>
getAuthDataFromStoreWidget
(
Integer
userId
,
String
esField
);
}
gic-store-service/src/main/java/com/gic/store/dao/mapper/TabClerkMapper.java
View file @
b88c5de1
...
...
@@ -104,7 +104,28 @@ public interface TabClerkMapper {
* @Description:
* @author zhiwj
*/
List
<
TabClerk
>
listClerkByStoreInfoId
(
@Param
(
"storeClerkIds"
)
List
<
Integer
>
storeClerkIds
,
@Param
(
"storeInfoIds"
)
String
storeInfoIds
,
@Param
(
"search"
)
String
search
,
@Param
(
"clerkType"
)
Integer
clerkType
,
@Param
(
"status"
)
Integer
status
);
List
<
TabClerk
>
listClerkByStoreInfoId
(
@Param
(
"storeClerkIds"
)
List
<
Integer
>
storeClerkIds
,
@Param
(
"storeInfoIds"
)
String
storeInfoIds
,
@Param
(
"search"
)
String
search
,
@Param
(
"clerkType"
)
Integer
clerkType
,
@Param
(
"status"
)
Integer
status
);
/**
* 查询导购
* @param storeClerkIds
* @param storeInfoIds
* @param search
* @param clerkType
* @param status
* @param clerkIdList
* @return
*/
List
<
TabClerk
>
listClerkByStoreInfoIdAndClerkId
(
@Param
(
"storeClerkIds"
)
List
<
Integer
>
storeClerkIds
,
@Param
(
"storeInfoIds"
)
String
storeInfoIds
,
@Param
(
"search"
)
String
search
,
@Param
(
"clerkType"
)
Integer
clerkType
,
@Param
(
"status"
)
Integer
status
,
@Param
(
"clerkIdList"
)
List
<
Integer
>
clerkIdList
);
/**
* getTotalClerk
...
...
@@ -118,7 +139,10 @@ public interface TabClerkMapper {
* @Description:
* @author zhiwj
*/
Integer
getTotalClerk
(
@Param
(
"storeClerkIds"
)
List
<
Integer
>
storeClerkIds
,
@Param
(
"search"
)
String
search
,
@Param
(
"status"
)
Integer
status
);
Integer
getTotalClerk
(
@Param
(
"storeClerkIds"
)
List
<
Integer
>
storeClerkIds
,
@Param
(
"search"
)
String
search
,
@Param
(
"status"
)
Integer
status
,
@Param
(
"clerkIdList"
)
List
<
Integer
>
clerkIdList
);
/**
* getStoreInfoIdsBySearch
...
...
gic-store-service/src/main/java/com/gic/store/service/ClerkService.java
View file @
b88c5de1
...
...
@@ -124,7 +124,16 @@ public interface ClerkService {
* @throws
*/
List
<
TabClerk
>
listClerkByStoreInfoId
(
Integer
enterpriseId
,
List
<
Integer
>
storeInfoIds
,
String
search
,
Integer
clerkType
);
/**
* listClerkByStoreInfoId
* @param enterpriseId
* @param storeInfoIds
* @param search
* @return
*/
List
<
TabClerk
>
listClerkByStoreInfoId
(
Integer
enterpriseId
,
List
<
Integer
>
storeInfoIds
,
ClerkSearchDTO
search
);
/**
* listClerkByStoreInfoId
* @Title: listClerkByStoreInfoId
...
...
gic-store-service/src/main/java/com/gic/store/service/impl/ClerkServiceImpl.java
View file @
b88c5de1
...
...
@@ -125,13 +125,25 @@ public class ClerkServiceImpl implements ClerkService {
}
@Override
public
List
<
TabClerk
>
listClerkByStoreInfoId
(
Integer
enterpriseId
,
List
<
Integer
>
storeInfoIdList
,
ClerkSearchDTO
search
)
{
// list 如果太大, 让 mybatis 解析 会打满内存
String
storeInfoIds
=
null
;
if
(
CollectionUtils
.
isNotEmpty
(
storeInfoIdList
))
{
storeInfoIds
=
"("
+
storeInfoIdList
.
stream
().
map
(
Object:
:
toString
).
collect
(
Collectors
.
joining
(
","
))
+
")"
;
}
return
tabClerkMapper
.
listClerkByStoreInfoIdAndClerkId
(
null
,
storeInfoIds
,
search
.
getSearch
(),
search
.
getClerkType
(),
null
,
search
.
getClerkIdList
(
null
));
}
@Override
public
List
<
TabClerk
>
listClerkByStoreInfoId
(
Integer
enterpriseId
,
List
<
Integer
>
storeInfoIds
,
Integer
status
,
String
search
)
{
return
tabClerkMapper
.
listClerkByStoreInfoId
(
storeInfoIds
,
null
,
search
,
null
,
status
);
}
@Override
public
Integer
getTotalClerk
(
Integer
enterpriseId
,
List
<
Integer
>
storeInfoIds
,
ClerkSearchDTO
search
)
{
return
tabClerkMapper
.
getTotalClerk
(
storeInfoIds
,
search
.
getSearch
(),
search
.
getStatus
());
return
tabClerkMapper
.
getTotalClerk
(
storeInfoIds
,
search
.
getSearch
(),
search
.
getStatus
()
,
search
.
getClerkIdList
(
null
)
);
}
@Override
...
...
gic-store-service/src/main/java/com/gic/store/service/outer/impl/ClerkApiServiceImpl.java
View file @
b88c5de1
...
...
@@ -396,8 +396,15 @@ public class ClerkApiServiceImpl implements ClerkApiService {
storeClerkDTOList
.
add
(
clerkStoreListDTO
);
storeInfoIds
.
add
(
store
.
getStoreInfoId
());
}
//交集
if
(
CollectionUtils
.
isNotEmpty
(
clerkSearchDTO
.
getStoreInfoIdParamList
(
null
)))
{
//前端勾选的门店数据
storeInfoIds
.
retainAll
(
clerkSearchDTO
.
getStoreInfoIdParamList
(
null
));
}
List
<
TabClerk
>
clerkList
=
clerkService
.
listClerkByStoreInfoId
(
enterpriseId
,
storeInfoIds
,
clerkSearchDTO
.
getSearch
(),
clerkSearchDTO
.
getClerkType
()
);
clerkSearchDTO
);
Map
<
Integer
,
List
<
TabClerk
>>
storeIdMap
=
CollectionUtil
.
group
(
clerkList
,
"storeInfoId"
);
for
(
ClerkStoreListDTO
clerkStoreListDTO
:
storeClerkDTOList
)
{
List
<
TabClerk
>
tabClerks
=
storeIdMap
.
get
(
clerkStoreListDTO
.
getStoreInfoId
());
...
...
@@ -447,6 +454,11 @@ public class ClerkApiServiceImpl implements ClerkApiService {
List
<
Integer
>
storeInfoIds
=
page
.
getResult
().
stream
().
map
(
StoreDTO:
:
getStoreInfoId
)
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
storeInfoIds
))
{
//交集
if
(
CollectionUtils
.
isNotEmpty
(
clerkSearchDTO
.
getStoreInfoIdParamList
(
null
)))
{
//前端勾选的门店数据
storeInfoIds
.
retainAll
(
clerkSearchDTO
.
getStoreInfoIdParamList
(
null
));
}
Integer
totalClerk
=
clerkService
.
getTotalClerk
(
enterpriseId
,
storeInfoIds
,
clerkSearchDTO
);
return
ServiceResponse
.
success
(
totalClerk
);
}
else
{
...
...
@@ -474,6 +486,7 @@ public class ClerkApiServiceImpl implements ClerkApiService {
storeSearchDTO
.
setStoreIds
(
clerkSearchDTO
.
getStoreIds
());
storeSearchDTO
.
setSearch
(
clerkSearchDTO
.
getStoreSearch
());
storeSearchDTO
.
setStoreInfoIds
(
clerkSearchDTO
.
getStoreInfoIds
());
storeSearchDTO
.
setStoreResource
(
clerkSearchDTO
.
getStoreResource
());
return
storeApiService
.
listStore
(
storeSearchDTO
,
pageNum
,
pageSize
,
"storeId,storeName,storeCode,storeInfoId,ownType"
);
...
...
gic-store-service/src/main/java/com/gic/store/service/outer/impl/StoreResourceApiServiceImpl.java
0 → 100644
View file @
b88c5de1
package
com
.
gic
.
store
.
service
.
outer
.
impl
;
import
java.util.Collections
;
import
java.util.List
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.UserDTO
;
import
com.gic.auth.service.ResourceGroupApiService
;
import
com.gic.auth.service.UserApiService
;
import
com.gic.enterprise.exception.CommonException
;
import
com.gic.store.dto.StoreResourceDTO
;
import
com.gic.store.dto.StoreWidgetDTO
;
import
com.gic.store.service.StoreResourceApiService
;
import
com.gic.store.service.StoreWidgetApiService
;
import
com.gic.store.utils.resource.AuthDataHandleUtils
;
/**
* 门店选择器资源过滤
* @ClassName:
* @Description:
* @author guojuxing
* @date 2021/5/26 10:54 AM
*/
@Service
(
"storeResourceApiService"
)
public
class
StoreResourceApiServiceImpl
implements
StoreResourceApiService
{
private
static
final
Logger
LOGGER
=
LogManager
.
getLogger
(
StoreResourceApiServiceImpl
.
class
);
@Autowired
private
StoreWidgetApiService
storeWidgetApiService
;
@Autowired
private
UserApiService
userApiService
;
@Autowired
private
ResourceGroupApiService
resourceGroupApiService
;
@Override
public
ServiceResponse
<
List
<
StoreResourceDTO
>>
getAuthDataFromStoreWidget
(
Integer
userId
,
String
esField
)
{
UserDTO
userDTO
=
getUser
(
userId
);
List
<
StoreResourceDTO
>
list
;
if
(
userDTO
.
getSuperAdmin
()
==
1
)
{
//超管
list
=
AuthDataHandleUtils
.
getAuthData
(
userDTO
.
getEnterpriseId
(),
esField
);
return
ServiceResponse
.
success
(
list
);
}
ServiceResponse
<
com
.
gic
.
auth
.
dto
.
StoreResourceDTO
>
storeResource
=
resourceGroupApiService
.
getStoreResourceByUserId
(
userId
);
boolean
hasStoreWidgetId
=
storeResource
.
isSuccess
()
&&
storeResource
.
getResult
()
!=
null
&&
storeResource
.
getResult
().
getStoreResourceId
()
!=
null
;
if
(!
hasStoreWidgetId
)
{
LOGGER
.
info
(
"该子管理员没有配置资源组门店选择器权限"
);
return
ServiceResponse
.
success
(
getAuthDataWhenNo
());
}
Integer
storeWidgetId
=
storeResource
.
getResult
().
getStoreResourceId
();
ServiceResponse
<
StoreWidgetDTO
>
storeWidget
=
storeWidgetApiService
.
getStoreWidget
(
storeWidgetId
);
if
(
storeWidget
.
isSuccess
())
{
//todo 目前做了品牌,待补充其他类型
return
ServiceResponse
.
success
(
AuthDataHandleUtils
.
getUserData
(
storeWidget
.
getResult
(),
esField
));
}
else
{
LOGGER
.
info
(
"该子管理员没有配置资源组门店选择器权限"
);
return
ServiceResponse
.
success
(
getAuthDataWhenNo
());
}
}
private
UserDTO
getUser
(
Integer
userId
)
{
ServiceResponse
<
UserDTO
>
response
=
userApiService
.
getUserInfoById
(
userId
);
if
(!
response
.
isSuccess
())
{
throw
new
CommonException
(
response
.
getCode
(),
response
.
getMessage
());
}
return
response
.
getResult
();
}
/**
* 没有资源的时候
* @return
*/
private
static
List
<
StoreResourceDTO
>
getAuthDataWhenNo
()
{
return
Collections
.
emptyList
();
}
}
gic-store-service/src/main/java/com/gic/store/utils/ApplicationContextUtils.java
0 → 100644
View file @
b88c5de1
package
com
.
gic
.
store
.
utils
;
import
org.springframework.beans.BeansException
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.stereotype.Component
;
/**
* Spring ApplicationContext 工具类
* @ClassName: ApplicationContextUtils
* @Description:
* @author guojuxing
* @date 2020/11/11 10:22 AM
*/
@Component
public
class
ApplicationContextUtils
implements
ApplicationContextAware
{
private
static
ApplicationContext
applicationContext
;
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
ApplicationContextUtils
.
applicationContext
=
applicationContext
;
}
public
static
<
T
>
T
getBean
(
String
beanName
)
{
if
(
applicationContext
.
containsBean
(
beanName
))
{
return
(
T
)
applicationContext
.
getBean
(
beanName
);
}
return
null
;
}
public
static
<
T
>
T
getBean
(
Class
<
T
>
clazz
)
{
return
applicationContext
.
getBean
(
clazz
);
}
}
gic-store-service/src/main/java/com/gic/store/utils/ExceptionResultAop.java
0 → 100644
View file @
b88c5de1
package
com
.
gic
.
store
.
utils
;
import
javax.validation.ConstraintViolationException
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.springframework.context.annotation.Configuration
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.enterprise.exception.CommonException
;
/**
* api层错误全部统一返回
* @ClassName:
* @Description:
* @author guojuxing
* @date 2021/2/9 9:46 AM
*/
@Aspect
@Configuration
public
class
ExceptionResultAop
{
private
Logger
logger
=
LogManager
.
getLogger
(
ExceptionResultAop
.
class
);
/**
* 环绕通知
*
* @param joinPoint
* @return
* @throws Throwable
*/
@Around
(
value
=
"execution(* com.gic.*.service.outer.impl..*.*(..))"
)
public
Object
around
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
try
{
// 执行当前方法
return
joinPoint
.
proceed
();
}
catch
(
Throwable
throwable
)
{
logger
.
warn
(
"拦截器错误"
,
throwable
);
return
handlerException
(
throwable
);
}
}
private
ServiceResponse
handlerException
(
Throwable
e
)
{
ServiceResponse
response
=
new
ServiceResponse
();
if
(
e
instanceof
CommonException
)
{
response
.
setCode
(((
CommonException
)
e
).
getErrorCode
());
}
else
if
(
e
instanceof
ConstraintViolationException
)
{
response
.
setCode
(
ErrorCode
.
SYSTEM_ERROR
.
getCode
());
}
else
{
response
.
setCode
(
ErrorCode
.
SYSTEM_ERROR
.
getCode
());
}
response
.
setMessage
(
e
.
getMessage
());
return
response
;
}
}
\ No newline at end of file
gic-store-service/src/main/java/com/gic/store/utils/resource/AbstractAuthDataUtils.java
0 → 100644
View file @
b88c5de1
package
com
.
gic
.
store
.
utils
.
resource
;
import
com.gic.store.dto.StoreResourceDTO
;
import
java.util.List
;
import
java.util.Set
;
/** 查询超管的权限
* @ClassName:
* @Description:
* @author guojuxing
* @date 2021/5/26 11:16 AM
*/
public
abstract
class
AbstractAuthDataUtils
{
/**
* 查询超管数据
* @param enterpriseId
* @return id集合
*/
abstract
List
<
StoreResourceDTO
>
getAuthData
(
Integer
enterpriseId
);
/**
* 子管理员权限过滤
* @param authIdSet 门店选择器配置的对应数据ID集合
* @return
*/
abstract
List
<
StoreResourceDTO
>
auth
(
Set
<
String
>
authIdSet
);
}
gic-store-service/src/main/java/com/gic/store/utils/resource/AuthDataHandleUtils.java
0 → 100644
View file @
b88c5de1
package
com
.
gic
.
store
.
utils
.
resource
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.store.constant.StoreESFieldsEnum
;
import
com.gic.store.dto.StoreResourceDTO
;
import
com.gic.store.dto.StoreWidgetDTO
;
import
java.util.*
;
/**
* 查询超管的权限
* @ClassName:
* @Description:
* @author guojuxing
* @date 2021/5/26 11:31 AM
*/
public
class
AuthDataHandleUtils
{
private
static
Map
<
String
,
AbstractAuthDataUtils
>
map
=
new
HashMap
<>(
16
);
public
final
static
String
STORE_FIELD_KEY
=
"storeFieldKey"
;
static
{
//门店分组不用过滤
map
.
put
(
StoreESFieldsEnum
.
STOREBRANDIDLIST
.
getField
(),
new
BrandAbstractAuthData
());
}
/**
* 查询超管数据
* @param enterpriseId
* @param esField
* @return
*/
public
static
List
<
StoreResourceDTO
>
getAuthData
(
Integer
enterpriseId
,
String
esField
)
{
return
map
.
get
(
esField
).
getAuthData
(
enterpriseId
);
}
/**
* 子管理员权限数据
* @param storeWidget 门店选择器记录
* @param esField
* @return
*/
public
static
List
<
StoreResourceDTO
>
getUserData
(
StoreWidgetDTO
storeWidget
,
String
esField
)
{
Set
<
String
>
authIdSet
=
getAuthData
(
storeWidget
,
esField
);
return
map
.
get
(
esField
).
auth
(
authIdSet
);
}
protected
static
Set
<
String
>
getAuthData
(
StoreWidgetDTO
storeWidget
,
String
field
)
{
Set
<
String
>
authRegionSet
=
new
HashSet
<>();
String
searchParam
=
storeWidget
.
getSearchParam
();
JSONArray
jsonArr
=
JSON
.
parseArray
(
searchParam
);
if
(
jsonArr
.
isEmpty
())
{
return
authRegionSet
;
}
JSONObject
json
=
jsonArr
.
getJSONObject
(
0
);
JSONArray
list
=
json
.
getJSONArray
(
"list"
);
Set
<
String
>
storeFieldKey
=
StoreESFieldsEnum
.
getStoreFieldKey
();
//是否是自定义字段类型的数据
//因为这两者解析不一致
boolean
isStoreField
=
isStoreField
(
field
);
for
(
int
i
=
0
,
len
=
list
.
size
();
i
<
len
;
i
++)
{
JSONObject
o
=
list
.
getJSONObject
(
i
).
getJSONObject
(
"data"
);
String
key
=
o
.
getString
(
"key"
);
o
.
put
(
"value"
,
o
.
getString
(
"value"
).
replaceAll
(
","
,
" "
));
if
(
isStoreField
)
{
//如果是自定义字段,应该存key,而不是value
if
(
storeFieldKey
.
contains
(
key
))
{
authRegionSet
.
add
(
key
);
}
continue
;
}
if
(
key
.
equals
(
field
))
{
String
[]
arr
=
o
.
getString
(
"value"
).
split
(
" "
);
for
(
String
s
:
arr
){
authRegionSet
.
add
(
s
);
}
}
}
return
authRegionSet
;
}
private
static
boolean
isStoreField
(
String
field
)
{
if
(
AuthDataHandleUtils
.
STORE_FIELD_KEY
.
equals
(
field
))
{
return
true
;
}
return
false
;
}
}
gic-store-service/src/main/java/com/gic/store/utils/resource/BrandAbstractAuthData.java
0 → 100644
View file @
b88c5de1
package
com
.
gic
.
store
.
utils
.
resource
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.store.dto.StoreBrandDTO
;
import
com.gic.store.dto.StoreResourceDTO
;
import
com.gic.store.dto.StoreWidgetDTO
;
import
com.gic.store.service.StoreBrandApiService
;
import
com.gic.store.utils.ApplicationContextUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
/**
* 品牌数据
* @ClassName:
* @Description:
* @author guojuxing
* @date 2021/5/26 11:18 AM
*/
public
class
BrandAbstractAuthData
extends
AbstractAuthDataUtils
{
@Override
public
List
<
StoreResourceDTO
>
getAuthData
(
Integer
enterpriseId
)
{
StoreBrandApiService
storeBrandApiService
=
ApplicationContextUtils
.
getBean
(
"storeBrandApiService"
);
ServiceResponse
<
List
<
StoreBrandDTO
>>
response
=
storeBrandApiService
.
listAllStoreBrand
(
enterpriseId
,
null
);
return
getData
(
response
);
}
@Override
public
List
<
StoreResourceDTO
>
auth
(
Set
<
String
>
authIdSet
)
{
StoreBrandApiService
storeBrandApiService
=
ApplicationContextUtils
.
getBean
(
"storeBrandApiService"
);
ServiceResponse
<
List
<
StoreBrandDTO
>>
response
=
storeBrandApiService
.
listAllStoreBrandInfoByIds
(
authIdSet
.
stream
()
.
filter
(
e
->
StringUtils
.
isNotBlank
(
e
))
.
mapToInt
(
e
->
Integer
.
valueOf
(
e
)).
boxed
()
.
collect
(
Collectors
.
toList
()));
return
getData
(
response
);
}
private
List
<
StoreResourceDTO
>
getData
(
ServiceResponse
<
List
<
StoreBrandDTO
>>
response
)
{
if
(
response
.
isSuccess
())
{
List
<
StoreBrandDTO
>
list
=
response
.
getResult
();
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
List
<
StoreResourceDTO
>
result
=
list
.
stream
().
map
(
e
->
new
StoreResourceDTO
().
setId
(
e
.
getStoreBrandId
().
toString
())
.
setName
(
e
.
getStoreBrandName
()).
setOwnType
(
e
.
getType
()).
setEnterpriseId
(
e
.
getEnterpriseId
())).
collect
(
Collectors
.
toList
());
return
result
;
}
}
return
Collections
.
EMPTY_LIST
;
}
}
gic-store-service/src/main/resources/dubbo-gic-store-service.xml
View file @
b88c5de1
...
...
@@ -66,6 +66,7 @@
<dubbo:service
interface=
"com.gic.store.service.StoreTransferApiService"
ref=
"storeTransferApiService"
timeout=
"6000"
/>
<dubbo:service
interface=
"com.gic.store.service.StoreWidgetLogApiService"
ref=
"storeWidgetLogApiService"
timeout=
"6000"
/>
<dubbo:service
interface=
"com.gic.store.service.UnionStoreChangeApiService"
ref=
"unionStoreChangeApiService"
timeout=
"6000"
/>
<dubbo:service
interface=
"com.gic.store.service.StoreResourceApiService"
ref=
"storeResourceApiService"
timeout=
"6000"
/>
<dubbo:reference
interface=
"com.gic.weimob.api.service.WeimobStoreSiteApiService"
id=
"weimobStoreSiteApiService"
timeout=
"6000"
/>
<dubbo:reference
interface=
"com.gic.enterprise.service.WmStoreSyncLogApiService"
id=
"wmStoreSyncLogApiService"
timeout=
"6000"
/>
...
...
gic-store-service/src/main/resources/mapper/TabClerkMapper.xml
View file @
b88c5de1
...
...
@@ -255,6 +255,34 @@
</if>
</where>
</select>
<select
id=
"listClerkByStoreInfoIdAndClerkId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_clerk
<where>
<if
test=
"null != storeClerkIds and storeClerkIds.size() > 0"
>
and store_info_id in
<foreach
close=
")"
collection=
"storeClerkIds"
index=
"index"
item=
"item"
open=
"("
separator=
","
>
#{item}
</foreach>
</if>
<if
test=
"storeInfoIds != null "
>
and store_info_id in ${storeInfoIds}
</if>
<if
test=
"null != clerkIdList and clerkIdList.size() > 0"
>
and clerk_id in
<foreach
close=
")"
collection=
"clerkIdList"
index=
"index"
item=
"item"
open=
"("
separator=
","
>
#{item}
</foreach>
</if>
<if
test=
"search != null and search != '' "
>
and (clerk_code like concat('%', #{search} ,'%') or clerk_name like concat('%', #{search} ,'%') or phone_number like concat('%', #{search} ,'%') )
</if>
<if
test=
"status != null "
>
and status = #{status}
</if>
</where>
</select>
<select
id=
"getTotalClerk"
resultType=
"int"
>
select
count(*)
...
...
@@ -269,6 +297,12 @@
#{item}
</foreach>
</if>
<if
test=
"null != clerkIdList and clerkIdList.size() > 0"
>
and clerk_id in
<foreach
close=
")"
collection=
"clerkIdList"
index=
"index"
item=
"item"
open=
"("
separator=
","
>
#{item}
</foreach>
</if>
<if
test=
"search != null and search != '' "
>
and (clerk_code like concat('%', #{search} ,'%') or clerk_name like concat('%', #{search} ,'%') or phone_number like concat('%', #{search} ,'%') )
</if>
...
...
gic-store-service/src/main/resources/mapper/TabStoreBrandRefMapper.xml
View file @
b88c5de1
...
...
@@ -173,6 +173,6 @@
<update
id=
"cancelBrandAuth"
>
update tab_store_brand_ref set delete_flag = 1
where enterprise_id=#{unionEnterpriseId} and from_enterprise
I
d = #{ownEnterpriseId} and delete_flag = 0
where enterprise_id=#{unionEnterpriseId} and from_enterprise
_i
d = #{ownEnterpriseId} and delete_flag = 0
</update>
</mapper>
\ No newline at end of file
gic-store-service/src/main/resources/mapper/TabStoreRegionRelMapper.xml
View file @
b88c5de1
...
...
@@ -186,6 +186,6 @@
<update
id=
"cancelRegionAuth"
>
update tab_store_region_rel set delete_flag = 1
where enterprise_id = #{unionEnterpriseId} and from_enterprise_id = #{ownEnterpriseId}
and de
tel
e_flag = 0
and de
let
e_flag = 0
</update>
</mapper>
\ No newline at end of file
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