Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
21712f0c
Commit
21712f0c
authored
3 years ago
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加多级查询区域下站点
parent
2359447c
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
129 additions
and
54 deletions
+129
-54
base-manager/src/main/java/com/mortals/xhx/base/framework/config/CorsConfig.java
...ava/com/mortals/xhx/base/framework/config/CorsConfig.java
+22
-0
common-lib/src/main/java/com/mortals/xhx/common/pdu/SitePdu.java
...lib/src/main/java/com/mortals/xhx/common/pdu/SitePdu.java
+1
-1
portal-manager/doc/api.md
portal-manager/doc/api.md
+43
-0
portal-manager/src/main/java/com/mortals/xhx/module/area/service/AreaService.java
...java/com/mortals/xhx/module/area/service/AreaService.java
+1
-1
portal-manager/src/main/java/com/mortals/xhx/module/area/service/impl/AreaServiceImpl.java
...mortals/xhx/module/area/service/impl/AreaServiceImpl.java
+2
-5
portal-manager/src/main/java/com/mortals/xhx/module/area/web/AreaController.java
.../java/com/mortals/xhx/module/area/web/AreaController.java
+0
-18
portal-manager/src/main/java/com/mortals/xhx/module/user/model/UserEntityExt.java
...java/com/mortals/xhx/module/user/model/UserEntityExt.java
+8
-17
portal-manager/src/main/java/com/mortals/xhx/module/user/service/UserService.java
...java/com/mortals/xhx/module/user/service/UserService.java
+3
-0
portal-manager/src/main/java/com/mortals/xhx/module/user/service/impl/UserServiceImpl.java
...mortals/xhx/module/user/service/impl/UserServiceImpl.java
+21
-11
portal-manager/src/main/java/com/mortals/xhx/module/user/web/UserController.java
.../java/com/mortals/xhx/module/user/web/UserController.java
+27
-0
portal-manager/src/test/java/com/mortals/httpclient/area/AreaController.http
...test/java/com/mortals/httpclient/area/AreaController.http
+1
-1
No files found.
base-manager/src/main/java/com/mortals/xhx/base/framework/config/CorsConfig.java
View file @
21712f0c
package
com.mortals.xhx.base.framework.config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.UrlBasedCorsConfigurationSource
;
import
org.springframework.web.filter.CorsFilter
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
...
...
@@ -12,6 +16,24 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public
class
CorsConfig
implements
WebMvcConfigurer
{
@Bean
public
CorsFilter
corsFilter
(){
//初始化配置对象
CorsConfiguration
configuration
=
new
CorsConfiguration
();
//允许跨域访问的域名
configuration
.
addAllowedOrigin
(
"*"
);
// configuration.setAllowCredentials(true); //运行携带cookie
configuration
.
addAllowedMethod
(
"*"
);
//代表所有请求方法
configuration
.
addAllowedHeader
(
"*"
);
//允许携带任何头信息
//初始化cors配置源对象
UrlBasedCorsConfigurationSource
configurationSource
=
new
UrlBasedCorsConfigurationSource
();
configurationSource
.
registerCorsConfiguration
(
"/**"
,
configuration
);
//返回CorSfilter实例,参数
return
new
CorsFilter
(
configurationSource
);
}
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
)
...
...
This diff is collapsed.
Click to expand it.
common-lib/src/main/java/com/mortals/xhx/common/pdu/SitePdu.java
View file @
21712f0c
...
...
@@ -12,5 +12,5 @@ import java.util.List;
@Data
public
class
SitePdu
{
/** 区域IdList */
private
List
<
String
>
area
ID
List
;
private
List
<
String
>
area
Code
List
;
}
This diff is collapsed.
Click to expand it.
portal-manager/doc/api.md
View file @
21712f0c
...
...
@@ -471,6 +471,49 @@ msg|String|消息|-
```
### 用户站点授权
**请求URL:**
user/siteAuth
**请求方式:**
POST
**内容类型:**
application/json;charset=utf-8
**简要描述:**
给用户授权站点
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:-------
userId|Long|是|用户ID
areaCodeList|Arrays|否|所属区域code列表
**请求样例:**
```
{
"userId":2,
"areaCodeList":["510105521000","513400000000"]
}
```
**响应参数:**
参数名称 |参数类型|描述
:---|:---|:------
code|Integer|结果码(-1.失败,1.成功)
msg|String|消息
data|object|数据对象
**响应消息样例:**
```
{
"msg":"新增模块成功",
"code":1,
"data":{}
}
}
```
## 角色信息
### 查询角色信息列表
...
...
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/area/service/AreaService.java
View file @
21712f0c
...
...
@@ -62,6 +62,6 @@ public interface AreaService extends ICRUDService<AreaEntity, Long> {
* @param context
* @return
*/
String
getFlatSitesByArea
Id
s
(
AreaQuery
query
,
Context
context
);
String
getFlatSitesByArea
Code
s
(
AreaQuery
query
,
Context
context
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/area/service/impl/AreaServiceImpl.java
View file @
21712f0c
...
...
@@ -9,7 +9,6 @@ import com.mortals.xhx.common.pdu.SitePdu;
import
com.mortals.xhx.feign.area.IApiAreaFeign
;
import
com.mortals.xhx.module.area.model.AreaEntity
;
import
com.mortals.xhx.module.area.model.AreaQuery
;
import
com.mortals.xhx.module.area.model.AreaTreeSelect
;
import
com.mortals.xhx.feign.rsp.ApiResp
;
import
com.mortals.xhx.module.area.dao.AreaDao
;
import
com.mortals.xhx.module.area.service.AreaService
;
...
...
@@ -18,8 +17,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -89,10 +86,10 @@ public class AreaServiceImpl extends AbstractCRUDServiceImpl<AreaDao, AreaEntity
}
@Override
public
String
getFlatSitesByArea
Id
s
(
AreaQuery
query
,
Context
context
)
{
public
String
getFlatSitesByArea
Code
s
(
AreaQuery
query
,
Context
context
)
{
log
.
info
(
"getFlatSitesByAreaIds=={}"
,
JSON
.
toJSONString
(
query
));
SitePdu
sitePdu
=
new
SitePdu
();
sitePdu
.
setArea
IDList
(
query
.
getIdList
().
stream
().
map
(
item
->
item
.
toString
()).
collect
(
Collectors
.
toList
()
));
sitePdu
.
setArea
CodeList
(
query
.
getAreaCodeList
(
));
String
resp
=
apiAreaFeign
.
getFlatSitesByAreaIds
(
sitePdu
);
ApiResp
apiResp
=
JSON
.
parseObject
(
resp
,
ApiResp
.
class
);
if
(
apiResp
.
getCode
()
!=
YesNoEnum
.
YES
.
getValue
())
{
...
...
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/area/web/AreaController.java
View file @
21712f0c
...
...
@@ -123,24 +123,6 @@ public class AreaController extends BaseCRUDJsonBodyMappingController<AreaServic
}
@PostMapping
(
value
=
"getFlatSitesByAreaIds"
)
@UnAuth
public
String
getFlatSitesByAreaIds
(
@RequestBody
AreaQuery
query
)
{
JSONObject
ret
=
new
JSONObject
();
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
String
busiDesc
=
"查询"
+
this
.
getModuleDesc
()
+
"子节点"
;
try
{
String
retStr
=
this
.
service
.
getFlatSitesByAreaIds
(
query
,
getContext
());
recordSysLog
(
request
,
busiDesc
+
"【成功】"
);
return
retStr
;
}
catch
(
Exception
e
)
{
log
.
error
(
"查询站点信息错误"
,
e
);
this
.
doException
(
request
,
busiDesc
,
model
,
e
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
ret
.
put
(
KEY_RESULT_MSG
,
e
.
getMessage
());
}
return
ret
.
toJSONString
();
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/user/model/UserEntityExt.java
View file @
21712f0c
package
com.mortals.xhx.module.user.model
;
public
class
UserEntityExt
extends
UserEntity
{
/** 用户已分配角色id,多个角色使用“,”隔开 */
private
String
roleIds
;
/** 用户已分配角色名称,多个角色使用“,”隔开 */
private
String
roleNames
;
public
String
getRoleIds
()
{
return
roleIds
;
}
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
UserEntityExt
extends
UserEntity
{
public
void
setRoleIds
(
String
roleIds
)
{
this
.
roleIds
=
roleIds
;
}
private
Long
userId
;
public
String
getRoleNames
()
{
return
roleNames
;
}
private
List
<
String
>
areaCodeList
;
public
void
setRoleNames
(
String
roleNames
)
{
this
.
roleNames
=
roleNames
;
}
}
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/user/service/UserService.java
View file @
21712f0c
...
...
@@ -65,4 +65,7 @@ public interface UserService extends ICRUDService<UserEntity,Long>{
Result
<
UserEntityExt
>
findExt
(
UserEntity
params
,
PageInfo
pageInfo
,
Context
context
)
throws
AppException
;
void
siteAuth
(
UserEntityExt
entityExt
,
Context
context
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/user/service/impl/UserServiceImpl.java
View file @
21712f0c
...
...
@@ -6,15 +6,12 @@ import com.mortals.framework.exception.AppException;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.util.SecurityUtil
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.xhx.
common.utils.BeanUtil
;
import
com.mortals.xhx.module.
menu.model.MenuEntity
;
import
com.mortals.xhx.
module.area.model.AreaQuery
;
import
com.mortals.xhx.module.
area.service.AreaService
;
import
com.mortals.xhx.module.menu.service.MenuService
;
import
com.mortals.xhx.module.role.model.RoleQuery
;
import
com.mortals.xhx.module.role.model.RoleUserEntity
;
import
com.mortals.xhx.module.role.model.RoleUserQuery
;
import
com.mortals.xhx.module.role.service.RoleService
;
import
com.mortals.xhx.module.role.service.RoleUserService
;
...
...
@@ -46,6 +43,8 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
private
RoleUserService
roleUserService
;
@Autowired
private
RoleService
roleService
;
@Autowired
private
AreaService
areaService
;
/* @Override
...
...
@@ -81,7 +80,6 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
}
}
@Override
...
...
@@ -95,7 +93,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
throw
new
AppException
(
"你没有权限执行该操作"
);
}
this
.
doHandlerUser
(
entity
);
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getRoleId
()))
{
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getRoleId
()))
{
RoleUserQuery
roleUserQuery
=
new
RoleUserQuery
();
roleUserQuery
.
setUserId
(
entity
.
getId
());
roleUserQuery
.
setRoleIdList
(
Arrays
.
asList
(
Long
.
parseLong
(
entity
.
getRoleId
())));
...
...
@@ -180,8 +178,8 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
@Override
public
Result
<
UserEntityExt
>
findExt
(
UserEntity
params
,
PageInfo
pageInfo
,
Context
context
)
throws
AppException
{
UserQuery
query
=
new
UserQuery
();
BeanUtils
.
copyProperties
(
params
,
query
);
if
(
StringUtils
.
isNotEmpty
(
params
.
getQuery
()))
{
BeanUtils
.
copyProperties
(
params
,
query
);
if
(
StringUtils
.
isNotEmpty
(
params
.
getQuery
()))
{
StringBuffer
condition
=
new
StringBuffer
(
"%"
);
condition
.
append
(
params
.
getQuery
()).
append
(
"%"
);
UserQuery
condition1
=
new
UserQuery
();
...
...
@@ -199,14 +197,26 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
orConditionList
.
add
(
condition4
);
query
.
setOrConditionList
(
orConditionList
);
}
return
getDao
().
getListExt
(
query
,
pageInfo
);
return
getDao
().
getListExt
(
query
,
pageInfo
);
}
@Override
public
void
siteAuth
(
UserEntityExt
entityExt
,
Context
context
)
{
if
(!
ObjectUtils
.
isEmpty
(
entityExt
.
getUserId
()))
{
throw
new
AppException
(
"用户ID不能为空!"
);
}
String
siteIds
=
areaService
.
getFlatSitesByAreaCodes
(
new
AreaQuery
().
areaCodeList
(
entityExt
.
getAreaCodeList
()),
context
);
UserEntity
userEntity
=
this
.
get
(
entityExt
.
getUserId
(),
context
);
userEntity
.
setAreaCodes
(
entityExt
.
getAreaCodeList
().
stream
().
collect
(
Collectors
.
joining
(
","
)));
userEntity
.
setSiteIds
(
siteIds
);
this
.
update
(
userEntity
,
context
);
}
@Override
protected
void
saveAfter
(
UserEntity
entity
,
Context
context
)
throws
AppException
{
super
.
saveAfter
(
entity
,
context
);
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getRoleId
()))
{
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getRoleId
()))
{
RoleUserQuery
roleUserQuery
=
new
RoleUserQuery
();
roleUserQuery
.
setUserId
(
entity
.
getId
());
roleUserQuery
.
setRoleIdList
(
Arrays
.
asList
(
Long
.
parseLong
(
entity
.
getRoleId
())));
...
...
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/user/web/UserController.java
View file @
21712f0c
package
com.mortals.xhx.module.user.web
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.module.area.model.AreaQuery
;
import
com.mortals.xhx.module.param.service.ParamService
;
import
com.mortals.xhx.module.role.model.RoleEntity
;
import
com.mortals.xhx.module.role.model.RoleQuery
;
...
...
@@ -11,6 +13,7 @@ import com.mortals.xhx.module.role.model.RoleUserEntity;
import
com.mortals.xhx.module.role.model.RoleUserQuery
;
import
com.mortals.xhx.module.role.service.RoleService
;
import
com.mortals.xhx.module.role.service.RoleUserService
;
import
com.mortals.xhx.module.user.model.UserEntityExt
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -115,4 +118,28 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
ret
.
put
(
"data"
,
model
);
return
ret
.
toJSONString
();
}
/**
* 站点授权
* @param query
* @return
*/
@PostMapping
(
value
=
"siteAuth"
)
public
String
siteAuth
(
@RequestBody
UserEntityExt
query
)
{
JSONObject
ret
=
new
JSONObject
();
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
String
busiDesc
=
this
.
getModuleDesc
()
+
"站点授权"
;
try
{
//String retStr = this.service.getFlatSitesByAreaIds(query, getContext());
recordSysLog
(
request
,
busiDesc
+
"【成功】"
);
//return retStr;
}
catch
(
Exception
e
)
{
log
.
error
(
"查询站点信息错误"
,
e
);
this
.
doException
(
request
,
busiDesc
,
model
,
e
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
ret
.
put
(
KEY_RESULT_MSG
,
e
.
getMessage
());
}
return
ret
.
toJSONString
();
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
portal-manager/src/test/java/com/mortals/httpclient/area/AreaController.http
View file @
21712f0c
...
...
@@ -28,5 +28,5 @@ Authorization: {{authToken}}
Content-Type: application/json
{
"idList":[
1,2
]
"idList":[
510105521000,513425000000
]
}
This diff is collapsed.
Click to expand it.
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