Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3cd9e996
authored
Nov 23, 2023
by
huangjinxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:用户菜单设置
1 parent
385c258f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
197 additions
and
0 deletions
project-interface/src/main/java/com/dituhui/pea/pojo/user/UserMenuSettingInfo.java
project-interface/src/main/java/com/dituhui/pea/user/IUser.java
project-user/src/main/java/com/dituhui/pea/user/controller/UserController.java
project-user/src/main/java/com/dituhui/pea/user/dao/UserMenuSettingDao.java
project-user/src/main/java/com/dituhui/pea/user/entity/UserMenuSettingEntity.java
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
project-interface/src/main/java/com/dituhui/pea/pojo/user/UserMenuSettingInfo.java
0 → 100644
View file @
3cd9e99
package
com
.
dituhui
.
pea
.
pojo
.
user
;
import
lombok.Data
;
import
org.springframework.data.annotation.CreatedDate
;
import
org.springframework.data.annotation.LastModifiedDate
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
public
class
UserMenuSettingInfo
implements
Serializable
{
private
static
final
long
serialVersionUID
=
7231322653202273612L
;
/**
* 主键
*/
private
String
id
;
/**
* 账号
*/
private
String
userId
;
/**
* 菜单
*/
private
String
menu
;
/**
* 设置
*/
private
String
setting
;
}
project-interface/src/main/java/com/dituhui/pea/user/IUser.java
View file @
3cd9e99
...
@@ -3,6 +3,7 @@ package com.dituhui.pea.user;
...
@@ -3,6 +3,7 @@ package com.dituhui.pea.user;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.pojo.*
;
import
com.dituhui.pea.pojo.*
;
import
com.dituhui.pea.pojo.user.OrgInfo
;
import
com.dituhui.pea.pojo.user.OrgInfo
;
import
com.dituhui.pea.pojo.user.UserMenuSettingInfo
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestHeader
;
...
@@ -184,4 +185,21 @@ public interface IUser {
...
@@ -184,4 +185,21 @@ public interface IUser {
@RequestMapping
(
value
=
"/pea-user/orgsNoName"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/pea-user/orgsNoName"
,
method
=
RequestMethod
.
GET
)
Result
<
List
<
OrgInfo
>>
orgsNoName
(
@RequestParam
(
"userId"
)
String
userId
);
Result
<
List
<
OrgInfo
>>
orgsNoName
(
@RequestParam
(
"userId"
)
String
userId
);
/**
* 获取用户组织
*
* @param userId 查询条件
* @return
*/
@RequestMapping
(
value
=
"/pea-user/getSettings"
,
method
=
RequestMethod
.
GET
)
Result
<
List
<
UserMenuSettingInfo
>>
getSettings
(
@RequestHeader
(
"userId"
)
String
userId
);
/**
* 获取用户组织
*
* @return
*/
@RequestMapping
(
value
=
"/pea-user/getSettings"
,
method
=
RequestMethod
.
POST
)
Result
saveSetting
(
@RequestBody
UserMenuSettingInfo
menuSettingInfo
);
}
}
project-user/src/main/java/com/dituhui/pea/user/controller/UserController.java
View file @
3cd9e99
...
@@ -4,6 +4,7 @@ package com.dituhui.pea.user.controller;
...
@@ -4,6 +4,7 @@ package com.dituhui.pea.user.controller;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.pojo.*
;
import
com.dituhui.pea.pojo.*
;
import
com.dituhui.pea.pojo.user.OrgInfo
;
import
com.dituhui.pea.pojo.user.OrgInfo
;
import
com.dituhui.pea.pojo.user.UserMenuSettingInfo
;
import
com.dituhui.pea.user.dao.UserOrgDao
;
import
com.dituhui.pea.user.dao.UserOrgDao
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -173,4 +174,24 @@ public class UserController implements IUser {
...
@@ -173,4 +174,24 @@ public class UserController implements IUser {
return
Result
.
success
(
orgInfos
);
return
Result
.
success
(
orgInfos
);
}
}
@Override
public
Result
<
List
<
UserMenuSettingInfo
>>
getSettings
(
String
userId
)
{
if
(
StringUtils
.
isBlank
(
userId
))
{
return
Result
.
failed
(
StatusCodeEnum
.
COMMON_PARAM_EMPTY
);
}
List
<
UserMenuSettingInfo
>
settingInfos
=
userService
.
getSettings
(
userId
);
return
Result
.
success
(
settingInfos
);
}
@Override
public
Result
<
List
<
UserMenuSettingInfo
>>
saveSetting
(
UserMenuSettingInfo
userMenuSettingInfo
)
{
if
(
StringUtils
.
isBlank
(
userMenuSettingInfo
.
getSetting
())
||
StringUtils
.
isBlank
(
userMenuSettingInfo
.
getMenu
())
||
StringUtils
.
isBlank
(
userMenuSettingInfo
.
getUserId
()))
{
return
Result
.
failed
(
StatusCodeEnum
.
COMMON_PARAM_EMPTY
);
}
userService
.
saveSetting
(
userMenuSettingInfo
);
return
Result
.
success
();
}
}
}
project-user/src/main/java/com/dituhui/pea/user/dao/UserMenuSettingDao.java
0 → 100644
View file @
3cd9e99
package
com
.
dituhui
.
pea
.
user
.
dao
;
import
com.dituhui.pea.user.entity.UserMenuSettingEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.repository.CrudRepository
;
import
java.util.List
;
public
interface
UserMenuSettingDao
extends
JpaRepository
<
UserMenuSettingEntity
,
String
>,
JpaSpecificationExecutor
<
UserMenuSettingEntity
>,
CrudRepository
<
UserMenuSettingEntity
,
String
>
{
List
<
UserMenuSettingEntity
>
findByUserId
(
String
userId
);
UserMenuSettingEntity
findByUserIdAndMenu
(
String
userId
,
String
menu
);
}
project-user/src/main/java/com/dituhui/pea/user/entity/UserMenuSettingEntity.java
0 → 100644
View file @
3cd9e99
package
com
.
dituhui
.
pea
.
user
.
entity
;
import
lombok.Data
;
import
org.hibernate.annotations.GenericGenerator
;
import
org.springframework.data.annotation.CreatedDate
;
import
org.springframework.data.annotation.LastModifiedDate
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.Date
;
@Entity
@Table
(
name
=
"sys_user_menu_setting"
)
@Data
@EntityListeners
(
AuditingEntityListener
.
class
)
public
class
UserMenuSettingEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
2359135550756920074L
;
/**
* 主键
*/
@Id
@GeneratedValue
(
generator
=
"uuid"
)
@GenericGenerator
(
name
=
"uuid"
,
strategy
=
"uuid"
)
@Column
(
name
=
"ID"
,
unique
=
true
,
nullable
=
false
,
length
=
32
)
private
String
id
;
/**
* 账号
*/
@Column
(
name
=
"user_id"
)
private
String
userId
;
/**
* 菜单
*/
@Column
(
name
=
"menu"
)
private
String
menu
;
/**
* 设置
*/
@Column
(
name
=
"setting"
)
private
String
setting
;
/**
* 创建人
*/
@Column
(
name
=
"CREATED_BY"
)
private
String
createdBy
;
/**
* 创建时间
*/
@Column
(
name
=
"CREATED_TIME"
)
@CreatedDate
private
Date
createdTime
;
/**
* 更新人
*/
@Column
(
name
=
"UPDATED_BY"
)
private
String
updatedBy
;
/**
* 更新时间
*/
@Column
(
name
=
"UPDATED_TIME"
)
@LastModifiedDate
private
Date
updatedTime
;
}
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
View file @
3cd9e99
...
@@ -14,6 +14,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -14,6 +14,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.pojo.*
;
import
com.dituhui.pea.pojo.*
;
import
com.dituhui.pea.pojo.user.OrgInfo
;
import
com.dituhui.pea.pojo.user.OrgInfo
;
import
com.dituhui.pea.pojo.user.UserMenuSettingInfo
;
import
com.dituhui.pea.user.dao.*
;
import
com.dituhui.pea.user.dao.*
;
import
com.dituhui.pea.user.entity.*
;
import
com.dituhui.pea.user.entity.*
;
import
com.dituhui.pea.user.utils.LevelUtils
;
import
com.dituhui.pea.user.utils.LevelUtils
;
...
@@ -100,6 +101,9 @@ public class UserService {
...
@@ -100,6 +101,9 @@ public class UserService {
@Autowired
@Autowired
UserOrgDao
userOrgDao
;
UserOrgDao
userOrgDao
;
@Autowired
UserMenuSettingDao
userMenuSettingDao
;
public
Result
<
UserLoginDTO
>
userLogin
(
String
account
,
String
password
)
{
public
Result
<
UserLoginDTO
>
userLogin
(
String
account
,
String
password
)
{
UserEntity
user
=
userDao
.
findByLoginnameAndPass
(
account
,
SecureUtil
.
md5
(
password
));
UserEntity
user
=
userDao
.
findByLoginnameAndPass
(
account
,
SecureUtil
.
md5
(
password
));
log
.
info
(
"{}/{} login"
,
account
,
password
);
log
.
info
(
"{}/{} login"
,
account
,
password
);
...
@@ -915,4 +919,45 @@ public class UserService {
...
@@ -915,4 +919,45 @@ public class UserService {
});
});
return
orgInfos
;
return
orgInfos
;
}
}
/**
* 查询用户菜单配置
*
* @param userId
* @return
*/
public
List
<
UserMenuSettingInfo
>
getSettings
(
String
userId
)
{
List
<
UserMenuSettingInfo
>
settingInfos
=
new
ArrayList
<>();
// 获取角色
List
<
UserMenuSettingEntity
>
menuSettingEntities
=
userMenuSettingDao
.
findByUserId
(
userId
);
if
(
CollectionUtils
.
isEmpty
(
menuSettingEntities
))
{
return
settingInfos
;
}
menuSettingEntities
.
forEach
(
e
->
{
UserMenuSettingInfo
settingInfo
=
new
UserMenuSettingInfo
();
settingInfo
.
setId
(
e
.
getId
());
settingInfo
.
setUserId
(
e
.
getUserId
());
settingInfo
.
setMenu
(
e
.
getMenu
());
settingInfo
.
setSetting
(
e
.
getSetting
());
settingInfos
.
add
(
settingInfo
);
});
return
settingInfos
;
}
/**
* 用户菜单配置新增修改
*
* @param userMenuSettingInfo
* @return
*/
public
void
saveSetting
(
UserMenuSettingInfo
userMenuSettingInfo
)
{
UserMenuSettingEntity
menuSetting
=
userMenuSettingDao
.
findByUserIdAndMenu
(
userMenuSettingInfo
.
getUserId
(),
userMenuSettingInfo
.
getMenu
());
if
(
ObjectUtil
.
isNull
(
menuSetting
))
{
menuSetting
=
new
UserMenuSettingEntity
();
}
menuSetting
.
setSetting
(
userMenuSettingInfo
.
getSetting
());
menuSetting
.
setUserId
(
userMenuSettingInfo
.
getUserId
());
menuSetting
.
setMenu
(
userMenuSettingInfo
.
getMenu
());
userMenuSettingDao
.
save
(
menuSetting
);
}
}
}
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