Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
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
fangxinjiang
yifu-mvp
Commits
dfba77f2
Commit
dfba77f2
authored
Jun 14, 2022
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
ff8c24dc
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
101 additions
and
24 deletions
+101
-24
CommonConstants.java
...ud.plus.v1/yifu/common/core/constant/CommonConstants.java
+4
-4
MenuTypeEnum.java
...plus.v1/yifu/common/core/constant/enums/MenuTypeEnum.java
+5
-0
ErrorCodes.java
....cloud.plus.v1/yifu/common/core/exception/ErrorCodes.java
+5
-0
Common.java
.../com/yifu.cloud.plus.v1/yifu/common/core/util/Common.java
+7
-0
messages_zh_CN.properties
...on-core/src/main/resources/i18n/messages_zh_CN.properties
+2
-0
HttpDaprUtil.java
...ifu/cloud/plus/v1/yifu/common/dapr/util/HttpDaprUtil.java
+0
-2
GlobalExceptionHandler.java
...ifu/common/security/exception/GlobalExceptionHandler.java
+3
-1
UserDTO.java
...va/com/yifu.cloud.plus.v1/yifu/admin/api/dto/UserDTO.java
+0
-2
DictController.java
...u.cloud.plus.v1/yifu/admin/controller/DictController.java
+1
-1
MenuController.java
...u.cloud.plus.v1/yifu/admin/controller/MenuController.java
+2
-2
UserController.java
...u.cloud.plus.v1/yifu/admin/controller/UserController.java
+0
-4
SysDictService.java
...yifu.cloud.plus.v1/yifu/admin/service/SysDictService.java
+3
-0
SysMenuService.java
...yifu.cloud.plus.v1/yifu/admin/service/SysMenuService.java
+2
-0
SysDictServiceImpl.java
...d.plus.v1/yifu/admin/service/impl/SysDictServiceImpl.java
+35
-0
SysMenuServiceImpl.java
...d.plus.v1/yifu/admin/service/impl/SysMenuServiceImpl.java
+31
-7
SysRoleServiceImpl.java
...d.plus.v1/yifu/admin/service/impl/SysRoleServiceImpl.java
+1
-1
No files found.
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/constant/CommonConstants.java
View file @
dfba77f2
...
...
@@ -106,21 +106,21 @@ public interface CommonConstants {
/**
* number 0
*/
String
ZERO_S
tring
=
"0"
;
String
ZERO_S
TRING
=
"0"
;
/**
* number 1
*/
String
ONE_S
tring
=
"1"
;
String
ONE_S
TRING
=
"1"
;
/**
* number 2
*/
String
TWO_S
tring
=
"2"
;
String
TWO_S
TRING
=
"2"
;
/**
* number 3
*/
String
THREE_S
tring
=
"3"
;
String
THREE_S
TRING
=
"3"
;
}
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/constant/enums/MenuTypeEnum.java
View file @
dfba77f2
...
...
@@ -34,6 +34,11 @@ public enum MenuTypeEnum {
*/
SYSTEM
(
"0"
,
"系统内置"
),
/**
* 字典类型-数据权限配置表示
*/
DATA_FLAG
(
"0"
,
"是"
),
/**
* 左侧菜单
*/
...
...
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/exception/ErrorCodes.java
View file @
dfba77f2
...
...
@@ -68,6 +68,11 @@ public interface ErrorCodes {
*/
String
SYS_MENU_DELETE_SYSTEM
=
"sys.menu.delete.system"
;
/**
* 菜单上级菜单不可为数据权限配置类菜单
*/
String
SYS_MENU_ADD_PARENT_ERROR
=
"sys.menu.add.parent.error"
;
/**
* 菜单存在下级节点 删除失败
*/
...
...
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/util/Common.java
View file @
dfba77f2
...
...
@@ -34,4 +34,11 @@ public class Common {
public
static
boolean
isNotNull
(
Object
obj
)
{
return
null
!=
obj
;
}
public
static
boolean
isNotNull
(
String
obj
)
{
if
(
null
==
obj
||
""
.
equals
(
obj
)
||
"undefined"
.
equals
(
obj
)){
return
true
;
}
return
false
;
}
}
yifu-common/yifu-common-core/src/main/resources/i18n/messages_zh_CN.properties
View file @
dfba77f2
...
...
@@ -17,6 +17,8 @@ sys.param.config.error={0} \u7CFB\u7EDF\u53C2\u6570\u914D\u7F6E\u9519\u8BEF
sys.menu.delete.existing
=
\u
83DC
\u5355\u
542B
\u6709\u
4E0B
\u
7EA7
\u
4E0D
\u
80FD
\u5220\u9664
sys.menu.delete.system
=
\u
7CFB
\u
7EDF
\u5185\u
7F6E
\u
83DC
\u5355\u
4E0D
\u
80FD
\u5220\u9664
sys.menu.add.parent.error
=
\u
83DC
\u5355\u
4E0A
\u
7EA7
\u
83DC
\u5355\u
4E0D
\u
53EF
\u
4E3A
\u6570\u
636E
\u6743\u9650\u
914D
\u
7F6E
\u
7C7B
\u
83DC
\u5355
sys.app.sms.often
=
\u
9A8C
\u
8BC1
\u7801\u
53D1
\u9001\u
8FC7
\u9891\u
7E41
sys.app.phone.unregistered
=
{0}
\u
624B
\u
673A
\u
53F7
\u
672A
\u
6CE8
\u
518C
...
...
yifu-common/yifu-common-dapr/src/main/java/com/yifu/cloud/plus/v1/yifu/common/dapr/util/HttpDaprUtil.java
View file @
dfba77f2
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
dapr
.
util
;
import
cn.hutool.json.JSONUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
...
...
@@ -13,7 +12,6 @@ import org.springframework.web.bind.annotation.RequestHeader;
import
org.springframework.web.client.RestTemplate
;
import
java.net.URI
;
import
java.net.URL
;
/**
* @author fxj
...
...
yifu-common/yifu-common-security/src/main/java/com/yifu.cloud.plus.v1/yifu/common/security/exception/GlobalExceptionHandler.java
View file @
dfba77f2
...
...
@@ -13,6 +13,7 @@ import org.springframework.validation.BindException;
import
org.springframework.validation.FieldError
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
...
...
@@ -52,7 +53,8 @@ public class GlobalExceptionHandler {
* @ExceptionHandler:当这个Controller中任何一个方法发生异常,一定会被这个方法拦截到
*/
@ExceptionHandler
(
Exception
.
class
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
//@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public
R
exception
(
Exception
e
)
{
errorLog
(
e
);
if
(
null
!=
e
.
getMessage
()){
...
...
yifu-upms/yifu-upms-api/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/api/dto/UserDTO.java
View file @
dfba77f2
...
...
@@ -16,9 +16,7 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
admin
.
api
.
dto
;
import
com.baomidou.mybatisplus.annotation.TableLogic
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/controller/DictController.java
View file @
dfba77f2
...
...
@@ -72,7 +72,7 @@ public class DictController {
*/
@GetMapping
(
"/page"
)
public
R
<
IPage
<
SysDict
>>
getDictPage
(
Page
page
,
SysDict
sysDict
)
{
return
R
.
ok
(
sysDictService
.
page
(
page
,
Wrappers
.
query
(
sysDict
)
));
return
R
.
ok
(
sysDictService
.
page
Asso
(
page
,
sysDict
));
}
/**
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/controller/MenuController.java
View file @
dfba77f2
...
...
@@ -124,8 +124,8 @@ public class MenuController {
@PostMapping
@PreAuthorize
(
"@pms.hasPermission('sys_menu_add')"
)
public
R
<
SysMenu
>
save
(
@Valid
@RequestBody
SysMenu
sysMenu
)
{
sysMenuService
.
save
(
sysMenu
);
return
R
.
ok
(
sysM
enu
);
SysMenu
menu
=
sysMenuService
.
saveAsso
(
sysMenu
);
return
R
.
ok
(
m
enu
);
}
/**
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/controller/UserController.java
View file @
dfba77f2
...
...
@@ -96,10 +96,6 @@ public class UserController {
public
UserInfo
infoAPI
(
@RequestParam
(
required
=
true
,
name
=
"username"
)
String
username
)
{
SysUser
user
=
userService
.
getOne
(
Wrappers
.<
SysUser
>
query
().
lambda
().
eq
(
SysUser:
:
getUsername
,
username
));
return
userService
.
getUserInfo
(
user
);
/*if (user == null) {
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERINFO_EMPTY, username));
}
return R.ok(userService.getUserInfo(user));*/
}
/**
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/SysDictService.java
View file @
dfba77f2
...
...
@@ -15,6 +15,8 @@
*/
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
admin
.
service
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDict
;
...
...
@@ -45,4 +47,5 @@ public interface SysDictService extends IService<SysDict> {
*/
void
clearDictCache
();
IPage
<
SysDict
>
pageAsso
(
Page
page
,
SysDict
sysDict
);
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/SysMenuService.java
View file @
dfba77f2
...
...
@@ -80,4 +80,6 @@ public interface SysMenuService extends IService<SysMenu> {
IPage
<
List
<
SysMenu
>>
getMenuPage
(
Page
page
,
SysMenu
sysMenu
);
List
<
SysMenu
>
listOfPageMenu
(
SysMenu
sysMenu
);
SysMenu
saveAsso
(
SysMenu
sysMenu
);
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysDictServiceImpl.java
View file @
dfba77f2
...
...
@@ -15,7 +15,11 @@
*/
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
admin
.
service
.
impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDict
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem
;
...
...
@@ -82,4 +86,35 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
}
/**
* @Author fxj
* @Description
* @Date 10:49 2022/6/14
* @Param sysDict
* @return
**/
@Override
public
IPage
<
SysDict
>
pageAsso
(
Page
page
,
SysDict
sysDict
)
{
return
this
.
page
(
page
,
buildQueryWrapper
(
sysDict
));
}
/**
* 构建查询的 wrapper
* @param sysDict 查询条件
* @return LambdaQueryWrapper
*/
private
LambdaQueryWrapper
buildQueryWrapper
(
SysDict
sysDict
)
{
LambdaQueryWrapper
<
SysDict
>
wrapper
=
Wrappers
.
lambdaQuery
();
if
(
StrUtil
.
isNotBlank
(
sysDict
.
getSystemFlag
())){
wrapper
.
eq
(
SysDict:
:
getSystemFlag
,
sysDict
.
getSystemFlag
());
}
if
(
StrUtil
.
isNotBlank
(
sysDict
.
getType
())){
wrapper
.
likeRight
(
SysDict:
:
getType
,
sysDict
.
getType
());
}
if
(
StrUtil
.
isNotBlank
(
sysDict
.
getDescription
())){
wrapper
.
likeRight
(
SysDict:
:
getDescription
,
sysDict
.
getDescription
());
}
return
wrapper
;
}
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysMenuServiceImpl.java
View file @
dfba77f2
...
...
@@ -35,6 +35,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.enums.MenuTypeEnum
;
import
com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.cache.annotation.CacheEvict
;
...
...
@@ -52,19 +53,23 @@ import java.util.function.Function;
import
java.util.stream.Collectors
;
/**
* <p>
* 菜单权限表 服务实现类
* </p>
*
* @author lengleng
* @since 2017-10-29
*/
* @Author fxj
* @Description
* @Date 10:28 2022/6/14
**/
@Service
@RequiredArgsConstructor
public
class
SysMenuServiceImpl
extends
ServiceImpl
<
SysMenuMapper
,
SysMenu
>
implements
SysMenuService
{
private
final
SysRoleMenuMapper
sysRoleMenuMapper
;
/**
* @Author fxj
* @Description
* @Date 10:28 2022/6/14
* @Param
* @return
**/
@Override
@Cacheable
(
value
=
CacheConstants
.
MENU_DETAILS
,
key
=
"#roleId + '_menu'"
,
unless
=
"#result == null"
)
public
Set
<
SysMenu
>
findMenuByRoleId
(
Long
roleId
)
{
...
...
@@ -172,6 +177,25 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
return
baseMapper
.
selectList
(
buildQueryWrapper
(
sysMenu
));
}
/**
* @author fxj
* @Date 2022-06-14
* @param sysMenu
* @return
*/
@Override
public
SysMenu
saveAsso
(
SysMenu
sysMenu
)
{
if
(
Common
.
isNotNull
(
sysMenu
)
&&
Common
.
isNotNull
(
sysMenu
.
getParentId
())){
SysMenu
menu
=
baseMapper
.
selectById
(
sysMenu
.
getParentId
());
if
(
Common
.
isNotNull
(
menu
)
&&
CommonConstants
.
ONE_STRING
.
equals
(
menu
.
getFlag
())){
Assert
.
state
(!
MenuTypeEnum
.
DATA_FLAG
.
getType
().
equals
(
sysMenu
.
getSystemFlag
()),
MsgUtils
.
getMessage
(
ErrorCodes
.
SYS_MENU_ADD_PARENT_ERROR
));
}
}
this
.
save
(
sysMenu
);
return
sysMenu
;
}
/**
* 构建查询的 wrapper
* @param sysMenu 查询条件
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysRoleServiceImpl.java
View file @
dfba77f2
...
...
@@ -84,7 +84,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
//已存在用户
Assert
.
state
(
Common
.
isEmpty
(
userRole
),
MsgUtils
.
getMessage
(
ErrorCodes
.
SYS_ROLE_DELETE_EXIST_USER
));
//系统内置
Assert
.
state
(!
CommonConstants
.
ZERO_S
tring
.
equals
(
sysRole
.
getSystemFlag
()),
MsgUtils
.
getMessage
(
ErrorCodes
.
SYS_ROLE_DELETE_SYSTEM
));
Assert
.
state
(!
CommonConstants
.
ZERO_S
TRING
.
equals
(
sysRole
.
getSystemFlag
()),
MsgUtils
.
getMessage
(
ErrorCodes
.
SYS_ROLE_DELETE_SYSTEM
));
sysRoleMenuMapper
.
delete
(
Wrappers
.<
SysRoleMenu
>
update
().
lambda
().
eq
(
SysRoleMenu:
:
getRoleId
,
id
));
return
this
.
removeById
(
id
);
}
...
...
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