Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
data-server
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
licc
data-server
Commits
4e52601c
Commit
4e52601c
authored
Jun 16, 2021
by
cq990612
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加获取用户详细信息和下级用户信息接口
parent
9faf969e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
178 additions
and
37 deletions
+178
-37
UsersMapper.java
...mapper/src/main/java/cn/wisenergy/mapper/UsersMapper.java
+12
-2
UsersMapper.xml
wisenergy-mapper/src/main/resources/mapper/UsersMapper.xml
+34
-13
UserSimpleInfoDto.java
...c/main/java/cn/wisenergy/model/dto/UserSimpleInfoDto.java
+30
-0
TestUserService.java
...c/main/java/cn/wisenergy/service/app/TestUserService.java
+15
-1
TestUserServiceImpl.java
...va/cn/wisenergy/service/app/impl/TestUserServiceImpl.java
+69
-14
TestUserController2.java
...senergy/web/admin/controller/app/TestUserController2.java
+17
-7
ShiroConfig.java
...in/src/main/java/cn/wisenergy/web/config/ShiroConfig.java
+1
-0
No files found.
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/UsersMapper.java
View file @
4e52601c
...
...
@@ -2,6 +2,7 @@ package cn.wisenergy.mapper;
import
cn.wisenergy.model.app.Users
;
import
cn.wisenergy.model.dto.UserSimpleInfoDto
;
import
cn.wisenergy.model.dto.UsersInfoDto
;
import
cn.wisenergy.model.vo.UserVo
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
...
...
@@ -70,8 +71,17 @@ public interface UsersMapper extends BaseMapper<Users> {
/*************** chenqi****************/
List
<
UsersInfoDto
>
getDownUsersById
(
Long
userId
);
/**
* 获取伞下有那些用户
* @param userId 用户id
* */
List
<
UserSimpleInfoDto
>
getDownUsersById
(
Long
userId
);
UsersInfoDto
getUsersById
(
Long
userId
);
/**
* 获取用户向下最深层级层级数,伞下人员总和
* @param userId 用户
* @return
*/
UsersInfoDto
getDownLevelAndTotalPeopleByUserId
(
Long
userId
);
}
wisenergy-mapper/src/main/resources/mapper/UsersMapper.xml
View file @
4e52601c
...
...
@@ -171,19 +171,6 @@
</select>
<!--*****************************************chenqi***************************************-->
<select
id=
"getUsersById"
resultType=
"cn.wisenergy.model.dto.UsersInfoDto"
>
SELECT u.id,a.real_name,a.id_number,u.phone,u.rank
FROM users u LEFT actives a ON u.id = a.user_id
LEFT user_recharge ur ON u.id = ur.user_id
LEFT user_withdraws uw ON u.id = uw.user_id
<where>
</where>
</select>
<select
id=
"getDownLevel"
resultType=
"java.lang.Double"
>
select
...
...
@@ -201,4 +188,38 @@
</where>
</select>
<!--*****************************************chenqi***************************************-->
<select
id=
"getDownLevelAndTotalPeopleByUserId"
resultType=
"cn.wisenergy.model.dto.UsersInfoDto"
>
SELECT id 'userId',
MAX(rank)-rank 'bottom',
count(*)-1 'totalPeople'
FROM
users
WHERE
FIND_IN_SET(#{userId},path)
</select>
<select
id=
"getDownUsersById"
resultType=
"cn.wisenergy.model.dto.UserSimpleInfoDto"
>
SELECT
u.id 'userId',
a.real_name ,
u.rank,
u.parent_id,
aa.real_name 'parentName'
FROM users u
LEFT JOIN actives a ON u.id = a.user_id
LEFT JOIN actives aa ON u.parent_id = aa.user_id
WHERE
u.parent_id = #{userId}
</select>
</mapper>
wisenergy-model/src/main/java/cn/wisenergy/model/dto/UserSimpleInfoDto.java
0 → 100644
View file @
4e52601c
package
cn
.
wisenergy
.
model
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
/**
* @Authotr:陈奇
* @QQ1799796883
*/
@Data
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"UserSimpleInfoDto类"
,
description
=
"user简单信息"
)
public
class
UserSimpleInfoDto
{
@ApiModelProperty
(
name
=
"userId"
,
value
=
"会员ID"
)
private
Long
userId
;
@ApiModelProperty
(
name
=
"realName"
,
value
=
"姓名"
)
private
String
realName
;
@ApiModelProperty
(
name
=
"rank"
,
value
=
"层级"
)
private
Integer
rank
;
@ApiModelProperty
(
name
=
"parentId"
,
value
=
"直接上级id"
)
private
Integer
parentId
;
@ApiModelProperty
(
name
=
"parentName"
,
value
=
"直接上级姓名"
)
private
String
parentName
;
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/TestUserService.java
View file @
4e52601c
package
cn
.
wisenergy
.
service
.
app
;
import
cn.wisenergy.model.dto.UserSimpleInfoDto
;
import
cn.wisenergy.model.dto.UsersInfoDto
;
import
java.util.List
;
...
...
@@ -10,5 +11,18 @@ import java.util.List;
*/
public
interface
TestUserService
{
List
<
UsersInfoDto
>
getDownUserInfoById
(
Long
userId
);
/**
* 查询下级用户的基本信息
* @param userId 用户id
* @return
*/
List
<
UserSimpleInfoDto
>
getDownUserInfoById
(
Long
userId
);
/**
* 查询用户详细信息
* @param userId 用户id
* @return
*/
UsersInfoDto
getUserInfoById
(
Long
userId
);
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/TestUserServiceImpl.java
View file @
4e52601c
...
...
@@ -2,11 +2,17 @@ package cn.wisenergy.service.app.impl;
import
cn.wisenergy.common.enums.RespCodeEnum
;
import
cn.wisenergy.common.utils.exception.BaseCustomException
;
import
cn.wisenergy.mapper.ActivesMapper
;
import
cn.wisenergy.mapper.UserRechargeMapper
;
import
cn.wisenergy.mapper.UserWithdrawsMapper
;
import
cn.wisenergy.mapper.UsersMapper
;
import
cn.wisenergy.model.app.Actives
;
import
cn.wisenergy.model.app.Users
;
import
cn.wisenergy.model.dto.UserSimpleInfoDto
;
import
cn.wisenergy.model.dto.UsersInfoDto
;
import
cn.wisenergy.service.app.TestUserService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -23,9 +29,70 @@ public class TestUserServiceImpl implements TestUserService {
@Autowired
private
UsersMapper
usersMapper
;
@Autowired
private
UserRechargeMapper
userRechargeMapper
;
@Autowired
private
UserWithdrawsMapper
userWithdrawsMapper
;
@Autowired
private
ActivesMapper
activesMapper
;
/**
* 查询下级用户的基本信息
* @param userId 用户id
* @return
*/
@Override
public
List
<
User
s
InfoDto
>
getDownUserInfoById
(
Long
userId
)
{
public
List
<
User
Simple
InfoDto
>
getDownUserInfoById
(
Long
userId
)
{
log
.
info
(
"TestUserServiceImpl[]getDownUserInfoById[]input.param.userId:"
+
userId
);
long
startTime
=
System
.
currentTimeMillis
();
// 1.判断用户是否存在
userIsEmpty
(
userId
);
// 2.获取用户伞下所有用户的信息
List
<
UserSimpleInfoDto
>
downUsersById
=
usersMapper
.
getDownUsersById
(
userId
);
return
downUsersById
;
}
/**
* 查询用户详细信息
* @param userId 用户id
* @return
*/
@Override
public
UsersInfoDto
getUserInfoById
(
Long
userId
)
{
log
.
info
(
"TestUserServiceImpl[]getUserInfoById[]input.param.userId:"
+
userId
);
// 1.判断用户是否存在
Users
user
=
userIsEmpty
(
userId
);
// 2.获取用户详细信息
Actives
userInfo
=
activesMapper
.
getByUserId
(
userId
);
// 3.查询最深层级数和伞下人员总和
UsersInfoDto
userInfoDto
=
usersMapper
.
getDownLevelAndTotalPeopleByUserId
(
userId
);
// 4.查询用户充值和提现总额
Double
totalRecharge
=
userRechargeMapper
.
getTotalRecharge
(
userId
);
Double
totalWithdrawal
=
userWithdrawsMapper
.
getTotalWithdrawal
(
userId
);
// 5.将查询出来的信息整合到dto类
BeanUtils
.
copyProperties
(
user
,
userInfoDto
);
if
(
null
!=
userInfo
)
{
BeanUtils
.
copyProperties
(
userInfo
,
userInfoDto
);
}
if
(
null
!=
totalRecharge
)
{
userInfoDto
.
setTotalRecharge
(
totalRecharge
.
toString
());
}
if
(
null
!=
totalWithdrawal
)
{
userInfoDto
.
setTotalWithdrawal
(
totalWithdrawal
.
toString
());
}
return
userInfoDto
;
}
/**
* 判断用户是否存在,存在并返回user信息
* @param userId
* @return
*/
private
Users
userIsEmpty
(
Long
userId
)
{
if
(
null
==
userId
)
{
throw
new
BaseCustomException
(
RespCodeEnum
.
INPUT_PARAMETER_ISEMPTY
);
}
...
...
@@ -33,18 +100,6 @@ public class TestUserServiceImpl implements TestUserService {
if
(
null
==
user
)
{
throw
new
BaseCustomException
(
RespCodeEnum
.
EMPLOYEE_IS_NOT_EXIST_ERROR
);
}
// 1.获取用户伞下所有用户的信息
List
<
UsersInfoDto
>
downUsersById
=
usersMapper
.
getDownUsersById
(
userId
);
// 2.获取当前用户的向下最深层级层级数,伞下人员总和
UsersInfoDto
usersInfoDto
=
usersMapper
.
getUsersById
(
userId
);
for
(
UsersInfoDto
u
:
downUsersById
)
{
if
(
u
.
getId
().
equals
(
userId
))
{
u
.
setBottom
(
usersInfoDto
.
getBottom
()).
setTotalPeople
(
usersInfoDto
.
getTotalPeople
());
break
;
}
}
return
downUsersById
;
return
user
;
}
}
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/TestUserController2.java
View file @
4e52601c
package
cn
.
wisenergy
.
web
.
admin
.
controller
.
app
;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.model.app.dto.UsersInfoDto
;
import
cn.wisenergy.model.dto.UserSimpleInfoDto
;
import
cn.wisenergy.model.dto.UsersInfoDto
;
import
cn.wisenergy.service.app.TestUserService
;
import
cn.wisenergy.web.common.BaseController
;
import
io.swagger.annotations.Api
;
...
...
@@ -18,20 +19,29 @@ import java.util.List;
* @author ASUS
*/
@Api
(
tags
=
"用户管理(Test)"
)
@RestController
(
"/users"
)
@RestController
@Slf4j
public
class
TestUserController2
extends
BaseController
{
@Autowired
private
TestUserService
testUserService
;
@ApiOperation
(
value
=
"获取
用户下用户的信息"
,
notes
=
"获取用户下用户的
信息"
,
httpMethod
=
"GET"
)
@ApiOperation
(
value
=
"获取
下一级用户得信息"
,
notes
=
"获取下一级用户得
信息"
,
httpMethod
=
"GET"
)
@ApiImplicitParam
(
name
=
"userId"
,
value
=
"用户id"
,
dataType
=
"int"
)
@GetMapping
(
"/
getByUser
Id"
)
public
R
<
List
<
User
s
InfoDto
>>
getDownUserInfoById
(
Long
userId
)
{
log
.
info
(
"TestUserController2[]getDownUserInfoById[]input.param.userId:"
+
userId
);
List
<
User
s
InfoDto
>
users
=
testUserService
.
getDownUserInfoById
(
userId
);
@GetMapping
(
"/
users/getDownUsersInfoBy
Id"
)
public
R
<
List
<
User
Simple
InfoDto
>>
getDownUserInfoById
(
Long
userId
)
{
log
.
info
(
"TestUserController2[]getDownUser
s
InfoById[]input.param.userId:"
+
userId
);
List
<
User
Simple
InfoDto
>
users
=
testUserService
.
getDownUserInfoById
(
userId
);
return
R
.
ok
(
users
);
}
@ApiOperation
(
value
=
"获取用户详细信息"
,
notes
=
"获取用户详细信息"
,
httpMethod
=
"GET"
)
@ApiImplicitParam
(
name
=
"userId"
,
value
=
"用户id"
,
dataType
=
"int"
)
@GetMapping
(
"/users/getUserInfoById"
)
public
R
<
UsersInfoDto
>
getUserInfoById
(
Long
userId
)
{
log
.
info
(
"TestUserController2[]getUserInfoById[]input.param.userId:"
+
userId
);
UsersInfoDto
user
=
testUserService
.
getUserInfoById
(
userId
);
return
R
.
ok
(
user
);
}
}
wisenergy-web-admin/src/main/java/cn/wisenergy/web/config/ShiroConfig.java
View file @
4e52601c
...
...
@@ -67,6 +67,7 @@ public class ShiroConfig {
filterChainDefinitionMap
.
put
(
"/webjars/springfox-swagger-ui/**"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/v2/api-docs"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/user/**"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/users/**"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/ZX/**"
,
"anon"
);
//资讯的访问地址
filterChainDefinitionMap
.
put
(
"/api/user/**"
,
"anon"
);
//登录注册路径
filterChainDefinitionMap
.
put
(
"/api/sms/verifyCode"
,
"anon"
);
...
...
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