Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
李苗
/
Vion-DevOps
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 35883028
authored
Nov 29, 2023
by
HlQ
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[add]
1.项目列表添加维保状态字段 2.添加根据角色id查询所绑定资源列表接口
1 parent
cc04b388
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
22 deletions
src/main/java/vion/advice/ResBodyAdvice.java
src/main/java/vion/controller/RoleController.java
src/main/java/vion/controller/StoreController.java
src/main/java/vion/controller/UserController.java
src/main/java/vion/service/impl/StoreServiceImpl.java
src/main/java/vion/vo/StoreVO.java
src/main/java/vion/advice/ResBodyAdvice.java
View file @
3588302
...
@@ -68,7 +68,7 @@ public class ResBodyAdvice implements ResponseBodyAdvice<Object> {
...
@@ -68,7 +68,7 @@ public class ResBodyAdvice implements ResponseBodyAdvice<Object> {
@ExceptionHandler
(
NotLoginException
.
class
)
@ExceptionHandler
(
NotLoginException
.
class
)
public
ResultVO
notLoginExceptionHandler
(
Exception
e
)
{
public
ResultVO
notLoginExceptionHandler
(
Exception
e
)
{
log
.
error
(
"未登录"
,
e
);
log
.
error
(
"未登录"
,
e
.
getMessage
()
);
return
ResultUtil
.
error
(
401
,
"请重新登录"
);
return
ResultUtil
.
error
(
401
,
"请重新登录"
);
}
}
}
}
...
...
src/main/java/vion/controller/RoleController.java
View file @
3588302
package
vion
.
controller
;
package
vion
.
controller
;
import
cn.dev33.satoken.annotation.SaCheckPermission
;
import
cn.dev33.satoken.annotation.SaCheckPermission
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.lang.Opt
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
io.github.linpeilie.Converter
;
import
io.github.linpeilie.Converter
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
vion.dto.RoleDTO
;
import
vion.dto.RoleDTO
;
import
vion.model.RUserRole
;
import
vion.model.*
;
import
vion.model.Role
;
import
vion.service.*
;
import
vion.model.User
;
import
vion.vo.ResourceVO
;
import
vion.service.IRUserRoleService
;
import
vion.service.IRoleService
;
import
vion.service.IUserService
;
import
vion.vo.RoleVO
;
import
vion.vo.RoleVO
;
import
vion.vo.UserVO
;
import
vion.vo.UserVO
;
...
@@ -30,6 +30,8 @@ public class RoleController {
...
@@ -30,6 +30,8 @@ public class RoleController {
private
final
IRoleService
roleService
;
private
final
IRoleService
roleService
;
private
final
IRUserRoleService
userRoleService
;
private
final
IRUserRoleService
userRoleService
;
private
final
IUserService
userService
;
private
final
IUserService
userService
;
private
final
IResourceService
resourceService
;
private
final
IRRoleResourceService
roleResourceService
;
private
final
Converter
converter
;
private
final
Converter
converter
;
@GetMapping
(
"/role"
)
@GetMapping
(
"/role"
)
...
@@ -70,8 +72,24 @@ public class RoleController {
...
@@ -70,8 +72,24 @@ public class RoleController {
@SaCheckPermission
(
value
=
"role:user"
,
orRole
=
"admin"
)
@SaCheckPermission
(
value
=
"role:user"
,
orRole
=
"admin"
)
public
List
<
UserVO
>
listUserById
(
@PathVariable
Long
id
)
{
public
List
<
UserVO
>
listUserById
(
@PathVariable
Long
id
)
{
List
<
RUserRole
>
userRoleList
=
userRoleService
.
lambdaQuery
().
eq
(
RUserRole:
:
getRoleId
,
id
).
list
();
List
<
RUserRole
>
userRoleList
=
userRoleService
.
lambdaQuery
().
eq
(
RUserRole:
:
getRoleId
,
id
).
list
();
List
<
Long
>
userIdList
=
userRoleList
.
stream
().
map
(
RUserRole:
:
getUserId
).
collect
(
Collectors
.
toList
());
List
<
User
>
userList
=
Opt
.
ofEmptyAble
(
userRoleList
)
List
<
User
>
userList
=
userService
.
lambdaQuery
().
in
(
User:
:
getId
,
userIdList
).
list
();
.
map
(
l
->
l
.
stream
().
map
(
RUserRole:
:
getUserId
).
collect
(
Collectors
.
toList
()))
.
filter
(
CollUtil:
:
isNotEmpty
)
.
map
(
userIdList
->
userService
.
lambdaQuery
().
in
(
User:
:
getId
,
userIdList
).
list
())
.
orElse
(
ListUtil
.
empty
());
return
converter
.
convert
(
userList
,
UserVO
.
class
);
return
converter
.
convert
(
userList
,
UserVO
.
class
);
}
}
@GetMapping
(
"/role/resource/{id}"
)
@SaCheckPermission
(
value
=
"role:resource"
,
orRole
=
"admin"
)
public
List
<
ResourceVO
>
listResourceById
(
@PathVariable
Long
id
)
{
List
<
RRoleResource
>
roleResourceList
=
roleResourceService
.
lambdaQuery
().
eq
(
RRoleResource:
:
getRoleId
,
id
).
list
();
List
<
Resource
>
resourceList
=
Opt
.
ofEmptyAble
(
roleResourceList
)
.
map
(
l
->
l
.
stream
().
map
(
RRoleResource:
:
getResourceId
).
collect
(
Collectors
.
toList
()))
.
filter
(
CollUtil:
:
isNotEmpty
)
.
map
(
resourceIdList
->
resourceService
.
lambdaQuery
().
in
(
Resource:
:
getId
,
resourceIdList
).
list
())
.
orElse
(
ListUtil
.
empty
());
return
converter
.
convert
(
resourceList
,
ResourceVO
.
class
);
}
}
}
src/main/java/vion/controller/StoreController.java
View file @
3588302
...
@@ -82,7 +82,9 @@ public class StoreController {
...
@@ -82,7 +82,9 @@ public class StoreController {
public
List
<
ContractVO
>
listContractById
(
@PathVariable
Long
id
)
{
public
List
<
ContractVO
>
listContractById
(
@PathVariable
Long
id
)
{
List
<
RContractStore
>
contractStoreList
=
contractStoreService
.
lambdaQuery
().
eq
(
RContractStore:
:
getStoreId
,
id
).
list
();
List
<
RContractStore
>
contractStoreList
=
contractStoreService
.
lambdaQuery
().
eq
(
RContractStore:
:
getStoreId
,
id
).
list
();
List
<
Long
>
contractIdList
=
contractStoreList
.
stream
().
map
(
RContractStore:
:
getContractId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
contractIdList
=
contractStoreList
.
stream
().
map
(
RContractStore:
:
getContractId
).
collect
(
Collectors
.
toList
());
List
<
Contract
>
contractList
=
contractService
.
lambdaQuery
().
in
(
Contract:
:
getId
,
contractIdList
).
list
();
List
<
Contract
>
contractList
=
contractService
.
lambdaQuery
()
.
select
(
Contract:
:
getContractNo
,
Contract:
:
getName
,
Contract:
:
getSubject
,
Contract:
:
getCustomerName
,
Contract:
:
getSignDate
,
Contract:
:
getType
,
Contract:
:
getMaintainSdate
,
Contract:
:
getMaintainEdate
,
Contract:
:
getStatus
)
.
in
(
Contract:
:
getId
,
contractIdList
).
list
();
return
converter
.
convert
(
contractList
,
ContractVO
.
class
);
return
converter
.
convert
(
contractList
,
ContractVO
.
class
);
}
}
}
}
src/main/java/vion/controller/UserController.java
View file @
3588302
...
@@ -2,6 +2,8 @@ package vion.controller;
...
@@ -2,6 +2,8 @@ package vion.controller;
import
cn.dev33.satoken.annotation.SaCheckPermission
;
import
cn.dev33.satoken.annotation.SaCheckPermission
;
import
cn.dev33.satoken.stp.StpUtil
;
import
cn.dev33.satoken.stp.StpUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.lang.Opt
;
import
cn.hutool.core.lang.Opt
;
import
cn.hutool.core.lang.tree.Tree
;
import
cn.hutool.core.lang.tree.Tree
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
@@ -81,8 +83,11 @@ public class UserController {
...
@@ -81,8 +83,11 @@ public class UserController {
// todo 权限未加库
// todo 权限未加库
public
List
<
RoleVO
>
listRoleById
(
@PathVariable
Long
id
)
{
public
List
<
RoleVO
>
listRoleById
(
@PathVariable
Long
id
)
{
List
<
RUserRole
>
userRoleList
=
userRoleService
.
lambdaQuery
().
eq
(
RUserRole:
:
getUserId
,
id
).
list
();
List
<
RUserRole
>
userRoleList
=
userRoleService
.
lambdaQuery
().
eq
(
RUserRole:
:
getUserId
,
id
).
list
();
List
<
Long
>
roleIdList
=
userRoleList
.
stream
().
map
(
RUserRole:
:
getRoleId
).
collect
(
Collectors
.
toList
());
List
<
Role
>
roleList
=
Opt
.
ofEmptyAble
(
userRoleList
)
List
<
Role
>
roleList
=
roleService
.
lambdaQuery
().
in
(
Role:
:
getId
,
roleIdList
).
list
();
.
map
(
l
->
l
.
stream
().
map
(
RUserRole:
:
getRoleId
).
collect
(
Collectors
.
toList
()))
.
filter
(
CollUtil:
:
isNotEmpty
)
.
map
(
roleIdList
->
roleService
.
lambdaQuery
().
in
(
Role:
:
getId
,
roleIdList
).
list
())
.
orElse
(
ListUtil
.
empty
());
return
converter
.
convert
(
roleList
,
RoleVO
.
class
);
return
converter
.
convert
(
roleList
,
RoleVO
.
class
);
}
}
...
...
src/main/java/vion/service/impl/StoreServiceImpl.java
View file @
3588302
package
vion
.
service
.
impl
;
package
vion
.
service
.
impl
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.lang.Opt
;
import
cn.hutool.core.lang.Opt
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
@@ -16,20 +19,14 @@ import vion.Global;
...
@@ -16,20 +19,14 @@ import vion.Global;
import
vion.dto.StatusDTO
;
import
vion.dto.StatusDTO
;
import
vion.dto.StoreDTO
;
import
vion.dto.StoreDTO
;
import
vion.mapper.StoreMapper
;
import
vion.mapper.StoreMapper
;
import
vion.model.Account
;
import
vion.model.*
;
import
vion.model.FileInfo
;
import
vion.service.*
;
import
vion.model.Store
;
import
vion.service.IAccountService
;
import
vion.service.IFileService
;
import
vion.service.IStoreService
;
import
vion.vo.StoreVO
;
import
vion.vo.StoreVO
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.function.Function
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Service
@Service
...
@@ -37,6 +34,8 @@ import java.util.stream.Collectors;
...
@@ -37,6 +34,8 @@ import java.util.stream.Collectors;
public
class
StoreServiceImpl
extends
ServiceImpl
<
StoreMapper
,
Store
>
implements
IStoreService
{
public
class
StoreServiceImpl
extends
ServiceImpl
<
StoreMapper
,
Store
>
implements
IStoreService
{
private
final
IAccountService
accountService
;
private
final
IAccountService
accountService
;
private
final
IRContractStoreService
contractStoreService
;
private
final
IContractService
contractService
;
private
final
IFileService
fileService
;
private
final
IFileService
fileService
;
private
final
Converter
converter
;
private
final
Converter
converter
;
...
@@ -53,11 +52,46 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements
...
@@ -53,11 +52,46 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements
List
<
FileInfo
>
fileInfoList
=
fileService
.
lambdaQuery
().
eq
(
FileInfo:
:
getSourceType
,
1
).
list
();
List
<
FileInfo
>
fileInfoList
=
fileService
.
lambdaQuery
().
eq
(
FileInfo:
:
getSourceType
,
1
).
list
();
Map
<
Long
,
Long
>
store2CntMap
=
fileInfoList
.
stream
().
collect
(
Collectors
.
groupingBy
(
FileInfo:
:
getStoreId
,
Collectors
.
counting
()));
Map
<
Long
,
Long
>
store2CntMap
=
fileInfoList
.
stream
().
collect
(
Collectors
.
groupingBy
(
FileInfo:
:
getStoreId
,
Collectors
.
counting
()));
List
<
Long
>
storeIdList
=
Opt
.
ofEmptyAble
(
storeList
.
getRecords
())
.
map
(
recs
->
recs
.
stream
().
map
(
Store:
:
getId
).
collect
(
Collectors
.
toList
()))
.
orElse
(
ListUtil
.
empty
());
Map
<
Long
,
List
<
RContractStore
>>
storeIdMap
=
Opt
.
ofEmptyAble
(
storeIdList
)
.
map
(
l
->
contractStoreService
.
lambdaQuery
().
in
(
RContractStore:
:
getStoreId
,
l
).
list
())
.
map
(
contractStoreList
->
contractStoreList
.
stream
().
collect
(
Collectors
.
groupingBy
(
RContractStore:
:
getStoreId
)))
.
orElse
(
MapUtil
.
empty
());
Map
<
Long
,
Contract
>
id2ContractMap
=
Opt
.
ofEmptyAble
(
storeIdMap
.
values
())
.
map
(
l
->
l
.
stream
().
flatMap
(
List:
:
stream
).
collect
(
Collectors
.
toList
()))
.
filter
(
CollUtil:
:
isNotEmpty
)
.
map
(
contractStoreList
->
{
List
<
Contract
>
contractList
=
contractService
.
lambdaQuery
().
in
(
Contract:
:
getId
,
contractStoreList
.
stream
().
map
(
RContractStore:
:
getContractId
).
collect
(
Collectors
.
toList
())).
list
();
return
contractList
.
stream
().
collect
(
Collectors
.
toMap
(
Contract:
:
getId
,
Function
.
identity
()));
})
.
orElse
(
MapUtil
.
empty
());
List
<
StoreVO
>
storeVOList
=
new
ArrayList
<>();
List
<
StoreVO
>
storeVOList
=
new
ArrayList
<>();
storeList
.
getRecords
().
forEach
(
item
->
{
storeList
.
getRecords
().
forEach
(
item
->
{
StoreVO
storeVO
=
converter
.
convert
(
item
,
new
StoreVO
());
StoreVO
storeVO
=
converter
.
convert
(
item
,
new
StoreVO
());
storeVO
.
setAccountName
(
accountList
.
stream
().
filter
(
v
->
v
.
getId
().
equals
(
item
.
getAccountId
())).
map
(
Account:
:
getName
).
findFirst
().
orElse
(
"--"
));
storeVO
.
setAccountName
(
accountList
.
stream
().
filter
(
v
->
v
.
getId
().
equals
(
item
.
getAccountId
())).
map
(
Account:
:
getName
).
findFirst
().
orElse
(
"--"
));
storeVO
.
setFileNum
(
store2CntMap
.
getOrDefault
(
item
.
getId
(),
0L
));
storeVO
.
setFileNum
(
store2CntMap
.
getOrDefault
(
item
.
getId
(),
0L
));
Long
storeId
=
item
.
getId
();
List
<
RContractStore
>
contractStores
=
storeIdMap
.
get
(
storeId
);
if
(
CollUtil
.
isEmpty
(
contractStores
))
{
storeVO
.
setMaintainStatus
(
"--"
);
}
else
{
List
<
Long
>
contractIds
=
contractStores
.
stream
().
map
(
RContractStore:
:
getContractId
).
collect
(
Collectors
.
toList
());
Set
<
Boolean
>
maintainStatusSet
=
new
HashSet
<>();
contractIds
.
forEach
(
id
->
{
Contract
contract
=
id2ContractMap
.
get
(
id
);
Date
maintainSdate
=
contract
.
getMaintainSdate
();
Date
maintainEdate
=
contract
.
getMaintainEdate
();
boolean
isIn
=
DateUtil
.
isIn
(
new
Date
(),
maintainSdate
,
maintainEdate
);
maintainStatusSet
.
add
(
isIn
);
});
storeVO
.
setMaintainStatus
(
maintainStatusSet
.
contains
(
true
)
?
"在保"
:
"脱保"
);
}
storeVOList
.
add
(
storeVO
);
storeVOList
.
add
(
storeVO
);
});
});
return
Page
.<
StoreVO
>
of
(
data
.
getPageNum
(),
data
.
getPageSize
(),
storeList
.
getTotal
()).
setRecords
(
storeVOList
);
return
Page
.<
StoreVO
>
of
(
data
.
getPageNum
(),
data
.
getPageSize
(),
storeList
.
getTotal
()).
setRecords
(
storeVOList
);
...
...
src/main/java/vion/vo/StoreVO.java
View file @
3588302
...
@@ -70,4 +70,6 @@ public class StoreVO {
...
@@ -70,4 +70,6 @@ public class StoreVO {
private
String
accountName
;
private
String
accountName
;
private
Long
fileNum
;
private
Long
fileNum
;
/** 维保状态(在保、脱保、--) */
private
String
maintainStatus
;
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment