Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-auth
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-platform-auth
Commits
c8c347fd
Commit
c8c347fd
authored
Aug 29, 2019
by
zhiwj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资源组 除详情外
parent
ea6f6f61
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
349 additions
and
1 deletions
+349
-1
ResourceDTO.java
...-auth-api/src/main/java/com/gic/auth/dto/ResourceDTO.java
+9
-0
TabSysResourceMapper.java
...in/java/com/gic/auth/dao/mapper/TabSysResourceMapper.java
+4
-0
TabSysUserResourceMapper.java
...ava/com/gic/auth/dao/mapper/TabSysUserResourceMapper.java
+9
-0
ResourceService.java
...e/src/main/java/com/gic/auth/service/ResourceService.java
+2
-0
UserResourceService.java
...c/main/java/com/gic/auth/service/UserResourceService.java
+16
-0
ResourceServiceImpl.java
...n/java/com/gic/auth/service/impl/ResourceServiceImpl.java
+6
-0
ResourceApiServiceImpl.java
...m/gic/auth/service/outer/impl/ResourceApiServiceImpl.java
+28
-0
UserResourceServiceImpl.java
.../gic/auth/service/outer/impl/UserResourceServiceImpl.java
+48
-0
dubbo-gic-platform-auth-service.xml
...ce/src/main/resources/dubbo-gic-platform-auth-service.xml
+2
-1
TabSysResourceMapper.xml
...ervice/src/main/resources/mapper/TabSysResourceMapper.xml
+18
-0
TabSysUserResourceMapper.xml
...ce/src/main/resources/mapper/TabSysUserResourceMapper.xml
+24
-0
ResourceController.java
.../java/com/gic/auth/web/controller/ResourceController.java
+57
-0
ResourceQO.java
...uth-web/src/main/java/com/gic/auth/web/qo/ResourceQO.java
+121
-0
dubbo-gic-platform-auth-web.xml
...th-web/src/main/resources/dubbo-gic-platform-auth-web.xml
+5
-0
No files found.
gic-platform-auth-api/src/main/java/com/gic/auth/dto/ResourceDTO.java
View file @
c8c347fd
...
...
@@ -49,6 +49,7 @@ public class ResourceDTO implements Serializable {
* 商品资源
*/
private
Long
goodsResource
;
private
Integer
userResourceCount
;
public
Integer
getResourceId
()
{
return
resourceId
;
...
...
@@ -113,4 +114,12 @@ public class ResourceDTO implements Serializable {
public
void
setGoodsResource
(
Long
goodsResource
)
{
this
.
goodsResource
=
goodsResource
;
}
public
void
setUserResourceCount
(
Integer
userResourceCount
)
{
this
.
userResourceCount
=
userResourceCount
;
}
public
Integer
getUserResourceCount
()
{
return
userResourceCount
;
}
}
gic-platform-auth-service/src/main/java/com/gic/auth/dao/mapper/TabSysResourceMapper.java
View file @
c8c347fd
...
...
@@ -3,6 +3,7 @@ package com.gic.auth.dao.mapper;
import
com.gic.auth.dto.ResourceDTO
;
import
com.gic.auth.entity.TabSysResource
;
import
com.github.pagehelper.Page
;
import
org.apache.ibatis.annotations.Param
;
public
interface
TabSysResourceMapper
{
/**
...
...
@@ -54,4 +55,6 @@ public interface TabSysResourceMapper {
int
updateByPrimaryKey
(
TabSysResource
record
);
Page
<
TabSysResource
>
listResource
(
ResourceDTO
resourceDTO
);
TabSysResource
getBySelective
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
,
@Param
(
"resourceName"
)
String
resourceName
,
@Param
(
"resourceId"
)
Integer
resourceId
);
}
\ No newline at end of file
gic-platform-auth-service/src/main/java/com/gic/auth/dao/mapper/TabSysUserResourceMapper.java
View file @
c8c347fd
package
com
.
gic
.
auth
.
dao
.
mapper
;
import
com.gic.auth.entity.TabSysUserResource
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.Map
;
public
interface
TabSysUserResourceMapper
{
/**
...
...
@@ -50,4 +54,8 @@ public interface TabSysUserResourceMapper {
* @return 更新条目数
*/
int
updateByPrimaryKey
(
TabSysUserResource
record
);
TabSysUserResource
existUserResource
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
,
@Param
(
"resourceId"
)
Integer
resourceId
);
List
<
Map
<
String
,
Integer
>>
countByResourceIds
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
,
@Param
(
"ids"
)
List
<
Integer
>
resourceIds
);
}
\ No newline at end of file
gic-platform-auth-service/src/main/java/com/gic/auth/service/ResourceService.java
View file @
c8c347fd
...
...
@@ -20,4 +20,6 @@ public interface ResourceService {
Page
<
TabSysResource
>
listResource
(
ResourceDTO
resourceDTO
,
Integer
pageNum
,
Integer
pageSize
);
TabSysResource
getResource
(
Integer
resourceId
);
boolean
isRepeatByResourceName
(
Integer
enterpriseId
,
String
resourceName
,
Integer
resourceId
);
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/UserResourceService.java
0 → 100644
View file @
c8c347fd
package
com
.
gic
.
auth
.
service
;
import
java.util.List
;
import
java.util.Map
;
/**
*
* @Description:
* @author zhiwj
* @date 2019/8/29 10:03
*/
public
interface
UserResourceService
{
boolean
existUserResource
(
Integer
enterpriseId
,
Integer
resourceId
);
Map
<
Integer
,
Integer
>
countByResourceIds
(
Integer
enterpriseId
,
List
<
Integer
>
resourceIds
);
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/impl/ResourceServiceImpl.java
View file @
c8c347fd
...
...
@@ -57,4 +57,10 @@ public class ResourceServiceImpl implements ResourceService {
public
TabSysResource
getResource
(
Integer
resourceId
)
{
return
tabSysResourceMapper
.
selectByPrimaryKey
(
resourceId
);
}
@Override
public
boolean
isRepeatByResourceName
(
Integer
enterpriseId
,
String
resourceName
,
Integer
resourceId
)
{
TabSysResource
resource
=
tabSysResourceMapper
.
getBySelective
(
enterpriseId
,
resourceName
,
resourceId
);
return
resource
!=
null
;
}
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/ResourceApiServiceImpl.java
View file @
c8c347fd
...
...
@@ -6,13 +6,20 @@ import com.gic.auth.dto.ResourceDTO;
import
com.gic.auth.entity.TabSysResource
;
import
com.gic.auth.service.ResourceApiService
;
import
com.gic.auth.service.ResourceService
;
import
com.gic.auth.service.UserResourceService
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.PageHelperUtils
;
import
com.gic.enterprise.error.ErrorCode
;
import
org.apache.commons.collections.CollectionUtils
;
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
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
*
* @Description:
...
...
@@ -26,9 +33,16 @@ public class ResourceApiServiceImpl implements ResourceApiService {
@Autowired
private
ResourceService
resourceService
;
@Autowired
private
UserResourceService
userResourceService
;
@Override
public
ServiceResponse
<
Integer
>
saveOrUpdateResource
(
ResourceDTO
resourceDTO
)
{
boolean
repeat
=
resourceService
.
isRepeatByResourceName
(
resourceDTO
.
getEnterpriseId
(),
resourceDTO
.
getResourceName
(),
resourceDTO
.
getResourceId
());
if
(
repeat
)
{
logger
.
info
(
"enterpriseId:{} , resourceName:{}, 资源组名称重复 "
,
resourceDTO
.
getEnterpriseId
(),
resourceDTO
.
getResourceName
());
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"资源组名称重复"
);
}
if
(
resourceDTO
.
getResourceId
()
==
null
)
{
// save
resourceService
.
save
(
resourceDTO
);
...
...
@@ -41,6 +55,11 @@ public class ResourceApiServiceImpl implements ResourceApiService {
@Override
public
ServiceResponse
<
Integer
>
delResource
(
Integer
resourceId
)
{
TabSysResource
resource
=
resourceService
.
getResource
(
resourceId
);
boolean
exist
=
this
.
userResourceService
.
existUserResource
(
resource
.
getEnterpriseId
(),
resource
.
getResourceId
());
if
(
exist
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
OPERATION_FAILED
.
getCode
(),
"该资源组正在使用中,不能删除"
);
}
Integer
line
=
resourceService
.
delResource
(
resourceId
);
return
ServiceResponse
.
success
(
line
);
}
...
...
@@ -49,6 +68,15 @@ public class ResourceApiServiceImpl implements ResourceApiService {
public
ServiceResponse
<
Page
<
ResourceDTO
>>
listResource
(
ResourceDTO
resourceDTO
,
Integer
pageNum
,
Integer
pageSize
)
{
com
.
github
.
pagehelper
.
Page
<
TabSysResource
>
page
=
resourceService
.
listResource
(
resourceDTO
,
pageNum
,
pageSize
);
Page
<
ResourceDTO
>
resultPage
=
PageHelperUtils
.
changePageHelperToCurrentPage
(
page
,
ResourceDTO
.
class
);
List
<
ResourceDTO
>
resourceList
=
resultPage
.
getResult
();
if
(
CollectionUtils
.
isNotEmpty
(
resourceList
))
{
List
<
Integer
>
resourceIds
=
resourceList
.
stream
().
map
(
ResourceDTO:
:
getResourceId
).
collect
(
Collectors
.
toList
());
Map
<
Integer
,
Integer
>
map
=
userResourceService
.
countByResourceIds
(
resourceDTO
.
getEnterpriseId
(),
resourceIds
);
for
(
ResourceDTO
resource
:
resourceList
)
{
Integer
count
=
map
.
get
(
resource
.
getResourceId
());
resource
.
setUserResourceCount
(
count
==
null
?
0
:
count
);
}
}
return
ServiceResponse
.
success
(
resultPage
);
}
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/UserResourceServiceImpl.java
0 → 100644
View file @
c8c347fd
package
com
.
gic
.
auth
.
service
.
outer
.
impl
;
import
com.gic.auth.dao.mapper.TabSysUserResourceMapper
;
import
com.gic.auth.entity.TabSysUserResource
;
import
com.gic.auth.service.UserResourceService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
*
* @Description:
* @author zhiwj
* @date 2019/8/29 10:03
*/
@Service
public
class
UserResourceServiceImpl
implements
UserResourceService
{
@Autowired
private
TabSysUserResourceMapper
tabSysUserResourceMapper
;
@Override
public
boolean
existUserResource
(
Integer
enterpriseId
,
Integer
resourceId
)
{
TabSysUserResource
userResource
=
tabSysUserResourceMapper
.
existUserResource
(
enterpriseId
,
resourceId
);
return
userResource
!=
null
;
}
@Override
public
Map
<
Integer
,
Integer
>
countByResourceIds
(
Integer
enterpriseId
,
List
<
Integer
>
resourceIds
)
{
if
(
CollectionUtils
.
isNotEmpty
(
resourceIds
))
{
//
Map
<
Integer
,
Integer
>
map
=
new
HashMap
<>();
List
<
Map
<
String
,
Integer
>>
list
=
tabSysUserResourceMapper
.
countByResourceIds
(
enterpriseId
,
resourceIds
);
for
(
Map
<
String
,
Integer
>
integerIntegerMap
:
list
)
{
map
.
put
(
integerIntegerMap
.
get
(
"resourceId"
),
integerIntegerMap
.
get
(
"brandCount"
).
intValue
());
}
return
map
;
}
else
{
return
Collections
.
emptyMap
();
}
}
}
\ No newline at end of file
gic-platform-auth-service/src/main/resources/dubbo-gic-platform-auth-service.xml
View file @
c8c347fd
...
...
@@ -18,5 +18,6 @@
<dubbo:service
interface=
"com.gic.auth.service.UserApiService"
ref=
"userApiService"
timeout=
"6000"
/>
<dubbo:service
interface=
"com.gic.auth.service.MenuApiService"
ref=
"menuApiService"
timeout=
"6000"
/>
<dubbo:reference
interface=
"com.gic.log.api.service.LogApiService"
id=
"logApiService"
timeout=
"6000"
/>
<!--资源组-->
<dubbo:service
interface=
"com.gic.auth.service.ResourceApiService"
ref=
"resourceApiService"
timeout=
"6000"
/>
</beans>
gic-platform-auth-service/src/main/resources/mapper/TabSysResourceMapper.xml
View file @
c8c347fd
...
...
@@ -167,7 +167,24 @@
from tab_sys_resource
where status = 1
<if
test=
"resourceName != null and resourceName != '' "
>
and resource_name like concat('%', #{resourceName}, '%')
</if>
</select>
<select
id=
"getBySelective"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_sys_resource
where status = 1
<if
test=
"resourceId != null "
>
and resource_id
<>
#{resourceId}
</if>
<if
test=
"resourceName != null and resourceName != '' "
>
and resource_name = #{resourceName}
</if>
<if
test=
"enterpriseId != null "
>
and enterprise_id = #{enterpriseId}
</if>
limit 1
</select>
</mapper>
\ No newline at end of file
gic-platform-auth-service/src/main/resources/mapper/TabSysUserResourceMapper.xml
View file @
c8c347fd
...
...
@@ -114,4 +114,27 @@
update_time = #{updateTime,jdbcType=TIMESTAMP}
where user_resource_id = #{userResourceId,jdbcType=INTEGER}
</update>
<select
id=
"existUserResource"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_sys_user_resource
where status = 1
<if
test=
"resourceId != null "
>
and resource_id = #{resourceId}
</if>
<if
test=
"enterpriseId != null "
>
and enterprise_id = #{enterpriseId}
</if>
</select>
<!--List<Map<String,Integer>> countByResourceIds(List<Integer> resourceIds);-->
<select
id=
"countByResourceIds"
resultType=
"java.util.HashMap"
>
select resource_id resourceId , count(1) userResourceCount from tab_sys_user_resource where
status = 1
<if
test=
"null != ids"
>
and resource_id in
<foreach
collection=
"ids"
index=
"index"
item=
"item"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
gic-platform-auth-web/src/main/java/com/gic/auth/web/controller/ResourceController.java
0 → 100644
View file @
c8c347fd
package
com
.
gic
.
auth
.
web
.
controller
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.ResourceDTO
;
import
com.gic.auth.service.ResourceApiService
;
import
com.gic.auth.web.qo.PageQO
;
import
com.gic.auth.web.qo.ResourceQO
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.enterprise.utils.ResultControllerUtils
;
import
com.gic.enterprise.utils.UserDetailUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
*
* @Description:
* @author zhiwj
* @date 2019/8/29 9:09
*/
@RestController
public
class
ResourceController
{
@Autowired
private
ResourceApiService
resourceApiService
;
@RequestMapping
(
"/save-resource"
)
public
RestResponse
saveResource
(
ResourceQO
resourceQO
)
{
ResourceDTO
resourceDTO
=
EntityUtil
.
changeEntityByOrika
(
ResourceDTO
.
class
,
resourceQO
);
resourceDTO
.
setEnterpriseId
(
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
());
ServiceResponse
<
Integer
>
serviceResponse
=
resourceApiService
.
saveOrUpdateResource
(
resourceDTO
);
return
ResultControllerUtils
.
commonResult
(
serviceResponse
);
}
@RequestMapping
(
"/del-resource"
)
public
RestResponse
delResource
(
Integer
resourceId
)
{
ServiceResponse
<
Integer
>
serviceResponse
=
resourceApiService
.
delResource
(
resourceId
);
return
ResultControllerUtils
.
commonResult
(
serviceResponse
);
}
@RequestMapping
(
"/list-resource"
)
public
RestResponse
listResource
(
ResourceQO
resourceQO
,
PageQO
pageQO
)
{
ResourceDTO
resourceDTO
=
EntityUtil
.
changeEntityByOrika
(
ResourceDTO
.
class
,
resourceQO
);
resourceDTO
.
setEnterpriseId
(
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
());
ServiceResponse
<
Page
<
ResourceDTO
>>
serviceResponse
=
resourceApiService
.
listResource
(
resourceDTO
,
pageQO
.
getCurrentPage
(),
pageQO
.
getPageSize
());
return
ResultControllerUtils
.
commonResult
(
serviceResponse
);
}
@RequestMapping
(
"/get-resource"
)
public
RestResponse
getResource
(
Integer
resourceId
){
ServiceResponse
<
ResourceDTO
>
serviceResponse
=
resourceApiService
.
getResource
(
resourceId
);
return
ResultControllerUtils
.
commonResult
(
serviceResponse
);
}
}
gic-platform-auth-web/src/main/java/com/gic/auth/web/qo/ResourceQO.java
0 → 100644
View file @
c8c347fd
package
com
.
gic
.
auth
.
web
.
qo
;
import
javax.validation.constraints.NotBlank
;
import
java.io.Serializable
;
/**
*
* @Description:
* @author zhiwj
* @date 2019/8/29 10:54
*/
public
class
ResourceQO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
2010270945608110479L
;
public
interface
SaveValid
{}
/**
*
*/
private
Integer
resourceId
;
/**
* 资源名称
*/
@NotBlank
(
message
=
"资源名不能为空"
,
groups
=
SaveValid
.
class
)
private
String
resourceName
;
/**
*
*/
private
Integer
enterpriseId
;
/**
* 会员卡资源控件id
*/
private
Long
memberCardResource
;
/**
* 服务号资源
*/
private
Long
fwhResource
;
/**
* 小程序资源
*/
private
Long
appletResource
;
/**
* 门店资源
*/
private
Long
storeResource
;
/**
* 商品资源
*/
private
Long
goodsResource
;
public
Integer
getResourceId
()
{
return
resourceId
;
}
public
void
setResourceId
(
Integer
resourceId
)
{
this
.
resourceId
=
resourceId
;
}
public
String
getResourceName
()
{
return
resourceName
;
}
public
void
setResourceName
(
String
resourceName
)
{
this
.
resourceName
=
resourceName
;
}
public
Integer
getEnterpriseId
()
{
return
enterpriseId
;
}
public
void
setEnterpriseId
(
Integer
enterpriseId
)
{
this
.
enterpriseId
=
enterpriseId
;
}
public
Long
getMemberCardResource
()
{
return
memberCardResource
;
}
public
void
setMemberCardResource
(
Long
memberCardResource
)
{
this
.
memberCardResource
=
memberCardResource
;
}
public
Long
getFwhResource
()
{
return
fwhResource
;
}
public
void
setFwhResource
(
Long
fwhResource
)
{
this
.
fwhResource
=
fwhResource
;
}
public
Long
getAppletResource
()
{
return
appletResource
;
}
public
void
setAppletResource
(
Long
appletResource
)
{
this
.
appletResource
=
appletResource
;
}
public
Long
getStoreResource
()
{
return
storeResource
;
}
public
void
setStoreResource
(
Long
storeResource
)
{
this
.
storeResource
=
storeResource
;
}
public
Long
getGoodsResource
()
{
return
goodsResource
;
}
public
void
setGoodsResource
(
Long
goodsResource
)
{
this
.
goodsResource
=
goodsResource
;
}
}
gic-platform-auth-web/src/main/resources/dubbo-gic-platform-auth-web.xml
View file @
c8c347fd
...
...
@@ -36,4 +36,8 @@
<dubbo:reference
interface=
"com.gic.store.service.StoreStatusSettingApiService"
id=
"storeStatusSettingApiService"
timeout=
"60000"
/>
<dubbo:reference
interface=
"com.gic.log.api.service.LogApiService"
id=
"logApiService"
timeout=
"60000"
/>
<dubbo:reference
interface=
"com.gic.auth.service.MenuApiService"
id=
"menuApiService"
timeout=
"6000"
/>
<!--资源组-->
<dubbo:reference
interface=
"com.gic.auth.service.ResourceApiService"
id=
"resourceApiService"
timeout=
"6000"
/>
</beans>
\ 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