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
7ee2d53e
Commit
7ee2d53e
authored
Aug 13, 2019
by
陶光胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
a9605d69
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
726 additions
and
122 deletions
+726
-122
MenuDTO.java
...form-auth-api/src/main/java/com/gic/auth/dto/MenuDTO.java
+159
-0
MenuApiService.java
...pi/src/main/java/com/gic/auth/service/MenuApiService.java
+16
-0
TabMenuMapper.java
.../src/main/java/com/gic/auth/dao/mapper/TabMenuMapper.java
+58
-0
TabMenu.java
...th-service/src/main/java/com/gic/auth/entity/TabMenu.java
+178
-0
MenuService.java
...rvice/src/main/java/com/gic/auth/service/MenuService.java
+11
-0
MenuServiceImpl.java
.../main/java/com/gic/auth/service/impl/MenuServiceImpl.java
+23
-0
MenuApiServiceImpl.java
...a/com/gic/auth/service/outer/impl/MenuApiServiceImpl.java
+45
-0
dubbo-gic-platform-auth-service.xml
...ce/src/main/resources/dubbo-gic-platform-auth-service.xml
+3
-3
TabMenuMapper.xml
...-auth-service/src/main/resources/mapper/TabMenuMapper.xml
+195
-0
pom.xml
gic-platform-auth-web/pom.xml
+5
-0
Main.java
...latform-auth-web/src/main/java/com/gic/auth/web/Main.java
+1
-1
MenuController.java
...main/java/com/gic/auth/web/controller/MenuController.java
+30
-0
StoreBrandController.java
...ava/com/gic/auth/web/controller/StoreBrandController.java
+0
-12
GlobalExceptionHandler.java
...va/com/gic/auth/web/exception/GlobalExceptionHandler.java
+0
-106
dubbo-gic-platform-auth-web.xml
...th-web/src/main/resources/dubbo-gic-platform-auth-web.xml
+2
-0
No files found.
gic-platform-auth-api/src/main/java/com/gic/auth/dto/MenuDTO.java
0 → 100644
View file @
7ee2d53e
package
com
.
gic
.
auth
.
dto
;
import
java.io.Serializable
;
import
java.util.List
;
public
class
MenuDTO
implements
Serializable
{
/**
*
*/
private
Integer
menuId
;
/**
* 菜单名称
*/
private
String
menuName
;
/**
* 所在项目
*/
private
String
project
;
/**
* 菜单路由
*/
private
String
menuUrl
;
/**
* 上级菜单id
*/
private
Integer
parentId
;
/**
* 0当前页1新开页
*/
private
Integer
target
;
/**
*
*/
private
String
iconUrl
;
/**
*
*/
private
Integer
sort
;
/**
* 0删除1有效
*/
private
Integer
status
;
/**
*
*/
private
Integer
level
;
/**
* 是否显示在菜单栏的菜单,0否1是
*/
private
Integer
isShow
;
private
List
<
MenuDTO
>
children
;
public
Integer
getMenuId
()
{
return
menuId
;
}
public
void
setMenuId
(
Integer
menuId
)
{
this
.
menuId
=
menuId
;
}
public
String
getMenuName
()
{
return
menuName
;
}
public
void
setMenuName
(
String
menuName
)
{
this
.
menuName
=
menuName
;
}
public
String
getProject
()
{
return
project
;
}
public
void
setProject
(
String
project
)
{
this
.
project
=
project
;
}
public
String
getMenuUrl
()
{
return
menuUrl
;
}
public
void
setMenuUrl
(
String
menuUrl
)
{
this
.
menuUrl
=
menuUrl
;
}
public
Integer
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
Integer
parentId
)
{
this
.
parentId
=
parentId
;
}
public
Integer
getTarget
()
{
return
target
;
}
public
void
setTarget
(
Integer
target
)
{
this
.
target
=
target
;
}
public
String
getIconUrl
()
{
return
iconUrl
;
}
public
void
setIconUrl
(
String
iconUrl
)
{
this
.
iconUrl
=
iconUrl
;
}
public
Integer
getSort
()
{
return
sort
;
}
public
void
setSort
(
Integer
sort
)
{
this
.
sort
=
sort
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
Integer
getLevel
()
{
return
level
;
}
public
void
setLevel
(
Integer
level
)
{
this
.
level
=
level
;
}
public
Integer
getIsShow
()
{
return
isShow
;
}
public
void
setIsShow
(
Integer
isShow
)
{
this
.
isShow
=
isShow
;
}
public
List
<
MenuDTO
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
MenuDTO
>
children
)
{
this
.
children
=
children
;
}
}
gic-platform-auth-api/src/main/java/com/gic/auth/service/MenuApiService.java
0 → 100644
View file @
7ee2d53e
package
com
.
gic
.
auth
.
service
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.MenuDTO
;
import
java.util.List
;
public
interface
MenuApiService
{
/**
* 获取登陆用户的菜单
* @param userId
* @param enterpriseId
* @return
*/
ServiceResponse
<
List
<
MenuDTO
>>
getUserMenu
(
Integer
userId
,
Integer
enterpriseId
,
Integer
currentMenu
);
}
gic-platform-auth-service/src/main/java/com/gic/auth/dao/mapper/TabMenuMapper.java
0 → 100644
View file @
7ee2d53e
package
com
.
gic
.
auth
.
dao
.
mapper
;
import
com.gic.auth.entity.TabMenu
;
import
java.util.List
;
public
interface
TabMenuMapper
{
/**
* 根据主键删除
*
* @param menuId 主键
* @return 更新条目数
*/
int
deleteByPrimaryKey
(
Integer
menuId
);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
insert
(
TabMenu
record
);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
insertSelective
(
TabMenu
record
);
/**
* 根据主键查询
*
* @param menuId 主键
* @return 实体对象
*/
TabMenu
selectByPrimaryKey
(
Integer
menuId
);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
updateByPrimaryKeySelective
(
TabMenu
record
);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
updateByPrimaryKey
(
TabMenu
record
);
List
<
TabMenu
>
listMenu
();
}
\ No newline at end of file
gic-platform-auth-service/src/main/java/com/gic/auth/entity/TabMenu.java
0 → 100644
View file @
7ee2d53e
package
com
.
gic
.
auth
.
entity
;
import
java.util.Date
;
/**
* tab_menu
*/
public
class
TabMenu
{
/**
*
*/
private
Integer
menuId
;
/**
* 菜单名称
*/
private
String
menuName
;
/**
* 所在项目
*/
private
String
project
;
/**
* 菜单路由
*/
private
String
menuUrl
;
/**
* 上级菜单id
*/
private
Integer
parentId
;
/**
* 0当前页1新开页
*/
private
Integer
target
;
/**
*
*/
private
String
iconUrl
;
/**
*
*/
private
Integer
sort
;
/**
* 0删除1有效
*/
private
Integer
status
;
/**
*
*/
private
Date
createTime
;
/**
*
*/
private
Date
updateTime
;
/**
*
*/
private
Integer
level
;
/**
* 是否显示在菜单栏的菜单,0否1是
*/
private
Integer
isShow
;
public
Integer
getMenuId
()
{
return
menuId
;
}
public
void
setMenuId
(
Integer
menuId
)
{
this
.
menuId
=
menuId
;
}
public
String
getMenuName
()
{
return
menuName
;
}
public
void
setMenuName
(
String
menuName
)
{
this
.
menuName
=
menuName
;
}
public
String
getProject
()
{
return
project
;
}
public
void
setProject
(
String
project
)
{
this
.
project
=
project
;
}
public
String
getMenuUrl
()
{
return
menuUrl
;
}
public
void
setMenuUrl
(
String
menuUrl
)
{
this
.
menuUrl
=
menuUrl
;
}
public
Integer
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
Integer
parentId
)
{
this
.
parentId
=
parentId
;
}
public
Integer
getTarget
()
{
return
target
;
}
public
void
setTarget
(
Integer
target
)
{
this
.
target
=
target
;
}
public
String
getIconUrl
()
{
return
iconUrl
;
}
public
void
setIconUrl
(
String
iconUrl
)
{
this
.
iconUrl
=
iconUrl
;
}
public
Integer
getSort
()
{
return
sort
;
}
public
void
setSort
(
Integer
sort
)
{
this
.
sort
=
sort
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
Integer
getLevel
()
{
return
level
;
}
public
void
setLevel
(
Integer
level
)
{
this
.
level
=
level
;
}
public
Integer
getIsShow
()
{
return
isShow
;
}
public
void
setIsShow
(
Integer
isShow
)
{
this
.
isShow
=
isShow
;
}
}
\ No newline at end of file
gic-platform-auth-service/src/main/java/com/gic/auth/service/MenuService.java
0 → 100644
View file @
7ee2d53e
package
com
.
gic
.
auth
.
service
;
import
com.gic.auth.entity.TabMenu
;
import
java.util.List
;
public
interface
MenuService
{
List
<
TabMenu
>
listMenu
();
TabMenu
getMenuById
(
Integer
menuId
);
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/impl/MenuServiceImpl.java
0 → 100644
View file @
7ee2d53e
package
com
.
gic
.
auth
.
service
.
impl
;
import
com.gic.auth.dao.mapper.TabMenuMapper
;
import
com.gic.auth.entity.TabMenu
;
import
com.gic.auth.service.MenuService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
(
"menuService"
)
public
class
MenuServiceImpl
implements
MenuService
{
@Autowired
private
TabMenuMapper
tabMenuMapper
;
@Override
public
List
<
TabMenu
>
listMenu
()
{
return
this
.
tabMenuMapper
.
listMenu
();
}
@Override
public
TabMenu
getMenuById
(
Integer
menuId
)
{
return
this
.
tabMenuMapper
.
selectByPrimaryKey
(
menuId
);
}
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/MenuApiServiceImpl.java
0 → 100644
View file @
7ee2d53e
package
com
.
gic
.
auth
.
service
.
outer
.
impl
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.MenuDTO
;
import
com.gic.auth.entity.TabMenu
;
import
com.gic.auth.service.MenuApiService
;
import
com.gic.auth.service.MenuService
;
import
com.gic.commons.util.EntityUtil
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
(
"menuApiService"
)
public
class
MenuApiServiceImpl
implements
MenuApiService
{
@Autowired
private
MenuService
menuService
;
@Override
public
ServiceResponse
<
List
<
MenuDTO
>>
getUserMenu
(
Integer
userId
,
Integer
enterpriseId
,
Integer
currentMenu
)
{
List
<
TabMenu
>
menuList
=
this
.
menuService
.
listMenu
();
int
level
=
1
;
int
parentId
=
0
;
if
(
currentMenu
!=
null
){
TabMenu
menu
=
this
.
menuService
.
getMenuById
(
currentMenu
);
parentId
=
menu
.
getParentId
();
level
=
menu
.
getLevel
()+
1
;
}
return
ServiceResponse
.
success
(
this
.
treeMenu
(
menuList
,
level
,
parentId
));
}
private
List
<
MenuDTO
>
treeMenu
(
List
<
TabMenu
>
menuList
,
int
level
,
int
parentId
){
List
<
MenuDTO
>
list
=
new
ArrayList
<>();
if
(
level
<
5
){
for
(
TabMenu
menu
:
menuList
){
if
(
level
==
menu
.
getLevel
()
&&
menu
.
getIsShow
().
intValue
()
==
1
&&
menu
.
getParentId
().
intValue
()
==
parentId
){
MenuDTO
menuDTO
=
EntityUtil
.
changeEntityByJSON
(
MenuDTO
.
class
,
menu
);
menuDTO
.
setChildren
(
this
.
treeMenu
(
menuList
,
menu
.
getLevel
().
intValue
()+
1
,
menuDTO
.
getMenuId
()));
list
.
add
(
menuDTO
);
}
}
}
return
list
;
}
}
gic-platform-auth-service/src/main/resources/dubbo-gic-platform-auth-service.xml
View file @
7ee2d53e
...
...
@@ -15,8 +15,8 @@
<dubbo:protocol
name=
"dubbo"
port=
"20320"
/>
<!--门店域-->
<dubbo:service
interface=
"com.gic.auth.service.UserApiService"
ref=
"userApiService"
timeout=
"6000
0
"
/>
<dubbo:reference
interface=
"com.gic.log.api.service.LogApiService"
id=
"logApiService"
timeout=
"6000
0
"
/>
<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"
/>
</beans>
gic-platform-auth-service/src/main/resources/mapper/TabMenuMapper.xml
0 → 100644
View file @
7ee2d53e
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.gic.auth.dao.mapper.TabMenuMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.gic.auth.entity.TabMenu"
>
<id
column=
"menu_id"
jdbcType=
"INTEGER"
property=
"menuId"
/>
<result
column=
"menu_name"
jdbcType=
"VARCHAR"
property=
"menuName"
/>
<result
column=
"project"
jdbcType=
"VARCHAR"
property=
"project"
/>
<result
column=
"menu_url"
jdbcType=
"VARCHAR"
property=
"menuUrl"
/>
<result
column=
"parent_id"
jdbcType=
"INTEGER"
property=
"parentId"
/>
<result
column=
"target"
jdbcType=
"INTEGER"
property=
"target"
/>
<result
column=
"icon_url"
jdbcType=
"VARCHAR"
property=
"iconUrl"
/>
<result
column=
"sort"
jdbcType=
"INTEGER"
property=
"sort"
/>
<result
column=
"status"
jdbcType=
"INTEGER"
property=
"status"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
<result
column=
"level"
jdbcType=
"INTEGER"
property=
"level"
/>
<result
column=
"is_show"
jdbcType=
"INTEGER"
property=
"isShow"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
menu_id, menu_name, project, menu_url, parent_id, target, icon_url, sort, status,
create_time, update_time, level, is_show
</sql>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_menu
where menu_id = #{menuId,jdbcType=INTEGER}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
delete from tab_menu
where menu_id = #{menuId,jdbcType=INTEGER}
</delete>
<insert
id=
"insert"
parameterType=
"com.gic.auth.entity.TabMenu"
>
insert into tab_menu (menu_id, menu_name, project,
menu_url, parent_id, target,
icon_url, sort, status,
create_time, update_time, level,
is_show)
values (#{menuId,jdbcType=INTEGER}, #{menuName,jdbcType=VARCHAR}, #{project,jdbcType=VARCHAR},
#{menuUrl,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER}, #{target,jdbcType=INTEGER},
#{iconUrl,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{level,jdbcType=INTEGER},
#{isShow,jdbcType=INTEGER})
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.gic.auth.entity.TabMenu"
>
insert into tab_menu
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"menuId != null"
>
menu_id,
</if>
<if
test=
"menuName != null"
>
menu_name,
</if>
<if
test=
"project != null"
>
project,
</if>
<if
test=
"menuUrl != null"
>
menu_url,
</if>
<if
test=
"parentId != null"
>
parent_id,
</if>
<if
test=
"target != null"
>
target,
</if>
<if
test=
"iconUrl != null"
>
icon_url,
</if>
<if
test=
"sort != null"
>
sort,
</if>
<if
test=
"status != null"
>
status,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"level != null"
>
level,
</if>
<if
test=
"isShow != null"
>
is_show,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"menuId != null"
>
#{menuId,jdbcType=INTEGER},
</if>
<if
test=
"menuName != null"
>
#{menuName,jdbcType=VARCHAR},
</if>
<if
test=
"project != null"
>
#{project,jdbcType=VARCHAR},
</if>
<if
test=
"menuUrl != null"
>
#{menuUrl,jdbcType=VARCHAR},
</if>
<if
test=
"parentId != null"
>
#{parentId,jdbcType=INTEGER},
</if>
<if
test=
"target != null"
>
#{target,jdbcType=INTEGER},
</if>
<if
test=
"iconUrl != null"
>
#{iconUrl,jdbcType=VARCHAR},
</if>
<if
test=
"sort != null"
>
#{sort,jdbcType=INTEGER},
</if>
<if
test=
"status != null"
>
#{status,jdbcType=INTEGER},
</if>
<if
test=
"createTime != null"
>
#{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"level != null"
>
#{level,jdbcType=INTEGER},
</if>
<if
test=
"isShow != null"
>
#{isShow,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.gic.auth.entity.TabMenu"
>
update tab_menu
<set>
<if
test=
"menuName != null"
>
menu_name = #{menuName,jdbcType=VARCHAR},
</if>
<if
test=
"project != null"
>
project = #{project,jdbcType=VARCHAR},
</if>
<if
test=
"menuUrl != null"
>
menu_url = #{menuUrl,jdbcType=VARCHAR},
</if>
<if
test=
"parentId != null"
>
parent_id = #{parentId,jdbcType=INTEGER},
</if>
<if
test=
"target != null"
>
target = #{target,jdbcType=INTEGER},
</if>
<if
test=
"iconUrl != null"
>
icon_url = #{iconUrl,jdbcType=VARCHAR},
</if>
<if
test=
"sort != null"
>
sort = #{sort,jdbcType=INTEGER},
</if>
<if
test=
"status != null"
>
status = #{status,jdbcType=INTEGER},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"level != null"
>
level = #{level,jdbcType=INTEGER},
</if>
<if
test=
"isShow != null"
>
is_show = #{isShow,jdbcType=INTEGER},
</if>
</set>
where menu_id = #{menuId,jdbcType=INTEGER}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.gic.auth.entity.TabMenu"
>
update tab_menu
set menu_name = #{menuName,jdbcType=VARCHAR},
project = #{project,jdbcType=VARCHAR},
menu_url = #{menuUrl,jdbcType=VARCHAR},
parent_id = #{parentId,jdbcType=INTEGER},
target = #{target,jdbcType=INTEGER},
icon_url = #{iconUrl,jdbcType=VARCHAR},
sort = #{sort,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
level = #{level,jdbcType=INTEGER},
is_show = #{isShow,jdbcType=INTEGER}
where menu_id = #{menuId,jdbcType=INTEGER}
</update>
<select
id=
"listMenu"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_menu
where status=1
</select>
</mapper>
\ No newline at end of file
gic-platform-auth-web/pom.xml
View file @
7ee2d53e
...
...
@@ -122,6 +122,11 @@
<artifactId>
gic-redis-data
</artifactId>
<version>
${gic-redis-data}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-platform-auth-api
</artifactId>
<version>
${gic-platform-auth-api}
</version>
</dependency>
</dependencies>
<build>
...
...
gic-platform-auth-web/src/main/java/com/gic/auth/web/Main.java
View file @
7ee2d53e
...
...
@@ -25,7 +25,7 @@ import org.springframework.context.annotation.ImportResource;
@ImportResource
(
value
=
{
"classpath*:applicationContext-init.xml"
,
"classpath*:dubbo-setting.xml"
,
"classpath*:dubbo-gic-platform-
enterprise
-web.xml"
,
"classpath*:dubbo-gic-platform-
auth
-web.xml"
,
"classpath*:spring-interceptor.xml"
,
"classpath*:redis-init.xml"
})
...
...
gic-platform-auth-web/src/main/java/com/gic/auth/web/controller/MenuController.java
0 → 100644
View file @
7ee2d53e
package
com
.
gic
.
auth
.
web
.
controller
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.MenuDTO
;
import
com.gic.auth.service.MenuApiService
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.enterprise.response.EnterpriseRestResponse
;
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
;
import
java.util.List
;
@RestController
public
class
MenuController
{
@Autowired
private
MenuApiService
menuApiService
;
@RequestMapping
(
"login-user-menu"
)
public
RestResponse
loginUserMenu
(
Integer
currentMenu
){
Integer
userId
=
UserDetailUtils
.
getUserDetail
().
getUserId
();
Integer
enterpriseId
=
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
();
ServiceResponse
<
List
<
MenuDTO
>>
userMenu
=
this
.
menuApiService
.
getUserMenu
(
userId
,
enterpriseId
,
currentMenu
);
if
(
userMenu
.
isSuccess
()){
return
RestResponse
.
success
(
userMenu
.
getResult
());
}
return
EnterpriseRestResponse
.
failure
(
userMenu
);
}
}
gic-platform-auth-web/src/main/java/com/gic/auth/web/controller/StoreBrandController.java
deleted
100644 → 0
View file @
a9605d69
package
com
.
gic
.
auth
.
web
.
controller
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author zhiwj
* @date 2019/6/27
*/
@RestController
public
class
StoreBrandController
{
}
gic-platform-auth-web/src/main/java/com/gic/auth/web/exception/GlobalExceptionHandler.java
deleted
100644 → 0
View file @
a9605d69
package
com
.
gic
.
auth
.
web
.
exception
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.store.constant.StoreGroupErrorEnum
;
import
com.gic.store.exception.StoreException
;
import
com.gic.store.exception.StoreGroupException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.validation.BindException
;
import
org.springframework.validation.FieldError
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.ConstraintViolation
;
import
javax.validation.ConstraintViolationException
;
import
java.io.ByteArrayOutputStream
;
import
java.io.PrintWriter
;
import
java.util.List
;
import
java.util.Set
;
/**
* 全局异常处理类
*
* @author hua
*/
@ControllerAdvice
public
class
GlobalExceptionHandler
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
GlobalExceptionHandler
.
class
);
@ResponseBody
@ExceptionHandler
(
Exception
.
class
)
public
RestResponse
controllerException
(
HttpServletResponse
response
,
Exception
ex
)
{
logger
.
error
(
"err"
,
ex
);
RestResponse
failureResponse
=
getRestResponse
(
ErrorCode
.
SYSTEM_ERROR
.
getCode
(),
ErrorCode
.
SYSTEM_ERROR
.
getMsg
());
StringBuilder
sb
=
new
StringBuilder
();
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
try
(
PrintWriter
printWriter
=
new
PrintWriter
(
baos
))
{
ex
.
printStackTrace
(
printWriter
);
}
try
{
sb
.
append
(
baos
.
toString
());
}
catch
(
Exception
ignored
)
{
}
if
(
sb
.
length
()
==
0
)
{
sb
.
append
(
ex
.
getMessage
());
}
// 输出详细错误信息,便于调试
failureResponse
.
setDetailError
(
sb
.
toString
());
return
failureResponse
;
}
/**
* 参数校验异常统一处理
* @param e
* @return
*/
@ResponseBody
@ExceptionHandler
(
BindException
.
class
)
public
RestResponse
customException
(
BindException
e
)
{
List
<
FieldError
>
fieldErrors
=
e
.
getFieldErrors
();
StringBuilder
errorMessage
=
new
StringBuilder
();
fieldErrors
.
forEach
(
fieldError
->
{
errorMessage
.
append
(
fieldError
.
getDefaultMessage
())
.
append
(
","
);
});
return
getRestResponse
(
ErrorCode
.
SYSTEM_ERROR
.
getErrorCode
(),
errorMessage
.
toString
());
}
@ResponseBody
@ExceptionHandler
(
ConstraintViolationException
.
class
)
public
RestResponse
constraintViolationException
(
ConstraintViolationException
e
)
{
Set
<
ConstraintViolation
<?>>
constraintViolations
=
e
.
getConstraintViolations
();
String
paramName
=
constraintViolations
.
iterator
().
next
().
getPropertyPath
().
toString
();
String
paramError
=
constraintViolations
.
iterator
().
next
().
getMessage
();
return
getRestResponse
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
getFailFastMsg
(
paramName
,
paramError
));
}
/**
* 自定义异常统一处理
* @param e
* @return
*/
@ResponseBody
@ExceptionHandler
(
StoreGroupException
.
class
)
public
RestResponse
customException
(
StoreGroupException
e
)
{
return
getRestResponse
(
e
.
getErrorCode
(),
e
.
getMessage
());
}
@ResponseBody
@ExceptionHandler
(
StoreException
.
class
)
public
RestResponse
customException
(
StoreException
e
)
{
return
getRestResponse
(
e
.
getErrorCode
(),
e
.
getMessage
());
}
private
RestResponse
getRestResponse
(
String
errorCode
,
String
message
)
{
return
RestResponse
.
failure
(
errorCode
,
message
);
}
private
static
String
getFailFastMsg
(
String
paramName
,
String
paramError
)
{
return
String
.
format
(
"%s:%s"
,
paramName
,
paramError
);
}
}
gic-platform-auth-web/src/main/resources/dubbo-gic-platform-auth-web.xml
View file @
7ee2d53e
...
...
@@ -35,4 +35,5 @@
<dubbo:reference
interface=
"com.gic.store.service.ProvincesApiService"
id=
"provincesApiService"
timeout=
"60000"
/>
<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"
/>
</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