Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
ops
Commits
99aa73da
Commit
99aa73da
authored
Aug 28, 2024
by
wujipeng
Browse files
根据用户id查询用户有权查看的项目
parent
e0219c80
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/ruzhoukj/sms/controller/UserController.java
View file @
99aa73da
...
@@ -44,4 +44,10 @@ public class UserController {
...
@@ -44,4 +44,10 @@ public class UserController {
public
Result
getUserById
(
@PathVariable
Integer
id
)
{
public
Result
getUserById
(
@PathVariable
Integer
id
)
{
return
Result
.
success
(
userService
.
getById
(
id
));
return
Result
.
success
(
userService
.
getById
(
id
));
}
}
@ApiOperation
(
"根据用户id查询用户有权查看的项目"
)
@GetMapping
(
"/potency/{id}"
)
public
Result
listProjectByUserId
(
@PathVariable
Integer
id
)
{
return
Result
.
success
(
userService
.
listProjectByUserId
(
id
));
}
}
}
src/main/java/com/ruzhoukj/sms/dao/UserDao.java
View file @
99aa73da
package
com.ruzhoukj.sms.dao
;
package
com.ruzhoukj.sms.dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.ruzhoukj.sms.entity.ProjectEntity
;
import
com.ruzhoukj.sms.entity.UserEntity
;
import
com.ruzhoukj.sms.entity.UserEntity
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -30,4 +31,12 @@ public interface UserDao extends BaseMapper<UserEntity> {
...
@@ -30,4 +31,12 @@ public interface UserDao extends BaseMapper<UserEntity> {
* @return UserEntity
* @return UserEntity
*/
*/
UserEntity
getUserByLeader
(
@Param
(
"projectLeader"
)
String
projectLeader
);
UserEntity
getUserByLeader
(
@Param
(
"projectLeader"
)
String
projectLeader
);
/**
* 根据用户id查询用户有权查看的项目
*
* @param id id
* @return List<ProjectEntity>
*/
List
<
ProjectEntity
>
listProjectByUserId
(
@Param
(
"id"
)
Integer
id
);
}
}
src/main/java/com/ruzhoukj/sms/service/UserService.java
View file @
99aa73da
package
com.ruzhoukj.sms.service
;
package
com.ruzhoukj.sms.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.ruzhoukj.sms.entity.ProjectEntity
;
import
com.ruzhoukj.sms.entity.UserEntity
;
import
com.ruzhoukj.sms.entity.UserEntity
;
import
java.util.List
;
import
java.util.List
;
...
@@ -16,4 +17,12 @@ public interface UserService extends IService<UserEntity> {
...
@@ -16,4 +17,12 @@ public interface UserService extends IService<UserEntity> {
* @return UserEntity
* @return UserEntity
*/
*/
UserEntity
getUserByLeader
(
String
projectLeader
);
UserEntity
getUserByLeader
(
String
projectLeader
);
/**
* 根据用户id查询用户有权查看的项目
*
* @param id id
* @return List<ProjectEntity>
*/
List
<
ProjectEntity
>
listProjectByUserId
(
Integer
id
);
}
}
src/main/java/com/ruzhoukj/sms/service/impl/UserServiceImpl.java
View file @
99aa73da
...
@@ -2,6 +2,7 @@ package com.ruzhoukj.sms.service.impl;
...
@@ -2,6 +2,7 @@ package com.ruzhoukj.sms.service.impl;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.ruzhoukj.sms.dao.UserDao
;
import
com.ruzhoukj.sms.dao.UserDao
;
import
com.ruzhoukj.sms.entity.ProjectEntity
;
import
com.ruzhoukj.sms.entity.UserEntity
;
import
com.ruzhoukj.sms.entity.UserEntity
;
import
com.ruzhoukj.sms.service.UserService
;
import
com.ruzhoukj.sms.service.UserService
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -24,4 +25,9 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
...
@@ -24,4 +25,9 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
public
UserEntity
getUserByLeader
(
String
projectLeader
)
{
public
UserEntity
getUserByLeader
(
String
projectLeader
)
{
return
baseMapper
.
getUserByLeader
(
projectLeader
);
return
baseMapper
.
getUserByLeader
(
projectLeader
);
}
}
@Override
public
List
<
ProjectEntity
>
listProjectByUserId
(
Integer
id
)
{
return
baseMapper
.
listProjectByUserId
(
id
);
}
}
}
src/main/resources/com/ruzhoukj/sms/dao/UserDao.xml
View file @
99aa73da
...
@@ -34,4 +34,20 @@
...
@@ -34,4 +34,20 @@
where
where
id = #{projectLeader}
id = #{projectLeader}
</select>
</select>
<select
id=
"listProjectByUserId"
resultType=
"com.ruzhoukj.sms.entity.ProjectEntity"
>
select id,
project_leader as projectLeader,
start_time as startTime,
end_time as endTime,
`describe`,
project_name as projectName,
status,
create_user_id as createUserId
from
project
where
create_user_id = #{id}
or
visible_people like concat('%',#{id},'%')
</select>
</mapper>
</mapper>
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