Commit a3b41cbf authored by cq990612's avatar cq990612

增加实体类,mapper,mapper.xml

parent 1eab6097
...@@ -45,6 +45,8 @@ public interface UsersMapper extends BaseMapper<Users> { ...@@ -45,6 +45,8 @@ public interface UsersMapper extends BaseMapper<Users> {
/*************** chenqi****************/ /*************** chenqi****************/
List<UsersInfoDto> getUsersById(Long userId); List<UsersInfoDto> getDownUsersById(Long userId);
UsersInfoDto getUsersById(Long userId);
} }
...@@ -159,15 +159,52 @@ ...@@ -159,15 +159,52 @@
<!--*****************************************chenqi***************************************--> <!--*****************************************chenqi***************************************-->
<select id="getUsersById" resultType="cn.wisenergy.model.app.dto.UsersInfoDto"> <select id="getDownUsersById" resultType="cn.wisenergy.model.app.dto.UsersInfoDto">
SELECT u.id,a.real_name,a.id_number,u.phone,u.rank SELECT
FROM users u LEFT actives a ON u.id = a.user_id u.id ,
LEFT user_recharge ur ON u.id = ur.user_id a.real_name ,
LEFT user_withdraws uw ON u.id = uw.user_id a.id_number ,
<where> u.phone ,
ur.totalRecharge ,
uw.totalWithdrawal,
u.rank
FROM
users u
LEFT JOIN actives a ON u.id = a.user_id
LEFT JOIN (
SELECT
sum(amount) 'totalRecharge',user_id
FROM
user_recharge
WHERE
STATUS = 1
GROUP BY user_id
) ur ON ur.user_id=u.id
LEFT JOIN (
SELECT
sum(amount) 'totalWithdrawal',user_id
FROM
user_withdraws
WHERE
STATUS = 1
GROUP BY user_id
) uw ON uw.user_id=u.id
WHERE
u.path LIKE CONCAT('%,',#{userId},',%')
GROUP BY
u.id
ORDER BY
u.rank
</select>
</where> <select id="getUsersById" resultType="cn.wisenergy.model.app.dto.UsersInfoDto">
SELECT id,
MAX(rank) 'bottom',
count(*)-1 'totalPeople'
FROM
users
WHERE
path LIKE CONCAT('%,',#{userId},',%')
</select> </select>
......
package cn.wisenergy.model.app.dto; package cn.wisenergy.model.app.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
/** /**
* @Authotr:陈奇 * @Authotr:陈奇
* @QQ1799796883 * @QQ1799796883
*/ */
@Data
@Accessors(chain = true)
@ApiModel(value="userDto类", description="返回dto")
public class UsersInfoDto { public class UsersInfoDto {
@ApiModelProperty(name = "id", value = "会员ID") @ApiModelProperty(name = "id", value = "会员ID")
......
...@@ -10,5 +10,5 @@ import java.util.List; ...@@ -10,5 +10,5 @@ import java.util.List;
*/ */
public interface TestUserService { public interface TestUserService {
List<UsersInfoDto> getByUserInfoById(Long userId); List<UsersInfoDto> getDownUserInfoById(Long userId);
} }
...@@ -24,8 +24,8 @@ public class TestUserServiceImpl implements TestUserService { ...@@ -24,8 +24,8 @@ public class TestUserServiceImpl implements TestUserService {
private UsersMapper usersMapper; private UsersMapper usersMapper;
@Override @Override
public List<UsersInfoDto> getByUserInfoById(Long userId) { public List<UsersInfoDto> getDownUserInfoById(Long userId) {
log.info("TestUserServiceImpl[]getByUserInfoById[]input.param.userId:" + userId); log.info("TestUserServiceImpl[]getDownUserInfoById[]input.param.userId:" + userId);
if (null == userId) { if (null == userId) {
throw new BaseCustomException(RespCodeEnum.INPUT_PARAMETER_ISEMPTY); throw new BaseCustomException(RespCodeEnum.INPUT_PARAMETER_ISEMPTY);
} }
...@@ -33,8 +33,18 @@ public class TestUserServiceImpl implements TestUserService { ...@@ -33,8 +33,18 @@ public class TestUserServiceImpl implements TestUserService {
if (null == user) { if (null == user) {
throw new BaseCustomException(RespCodeEnum.EMPLOYEE_IS_NOT_EXIST_ERROR); 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 null; return downUsersById;
} }
} }
package cn.wisenergy.web.admin.controller.app; package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.Users;
import cn.wisenergy.model.app.dto.UsersInfoDto; import cn.wisenergy.model.app.dto.UsersInfoDto;
import cn.wisenergy.service.app.TestUserService; import cn.wisenergy.service.app.TestUserService;
import cn.wisenergy.web.common.BaseController; import cn.wisenergy.web.common.BaseController;
...@@ -18,20 +17,20 @@ import java.util.List; ...@@ -18,20 +17,20 @@ import java.util.List;
/** /**
* @author ASUS * @author ASUS
*/ */
@Api(tags = "用户管理") @Api(tags = "用户管理(Test)")
@RestController("/user") @RestController("/users")
@Slf4j @Slf4j
public class TestUserController2 extends BaseController { public class TestUserController2 extends BaseController {
@Autowired @Autowired
private TestUserService testUserService; private TestUserService testUserService;
@ApiOperation(value = "获取用户信息", notes = "获取用户信息", httpMethod = "GET") @ApiOperation(value = "获取用户下用户的信息", notes = "获取用户下用户的信息", httpMethod = "GET")
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "int") @ApiImplicitParam(name = "userId", value = "用户id", dataType = "int")
@GetMapping("/getByUserId") @GetMapping("/getByUserId")
public R<List<UsersInfoDto>> getUserInfoById(Long userId) { public R<List<UsersInfoDto>> getDownUserInfoById(Long userId) {
log.info("TestUserController2[]getUserInfoById[]input.param.userId:" + userId); log.info("TestUserController2[]getDownUserInfoById[]input.param.userId:" + userId);
List<UsersInfoDto> users = testUserService.getByUserInfoById(userId); List<UsersInfoDto> users = testUserService.getDownUserInfoById(userId);
return R.ok(users); return R.ok(users);
} }
......
...@@ -46,7 +46,7 @@ public class UserController extends BaseController { ...@@ -46,7 +46,7 @@ public class UserController extends BaseController {
@ApiOperation(value = "获取用户信息", notes = "获取用户信息", httpMethod = "GET") @ApiOperation(value = "获取用户信息", notes = "获取用户信息", httpMethod = "GET")
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "int") @ApiImplicitParam(name = "userId", value = "用户id", dataType = "int")
@GetMapping("/user/getByUserId") @GetMapping("/user/getByUserId")
public Users getByUserId(Integer userId) { public Users getByUserId(Long userId) {
return userService.getById(userId); return userService.getById(userId);
} }
...@@ -57,7 +57,7 @@ public class UserController extends BaseController { ...@@ -57,7 +57,7 @@ public class UserController extends BaseController {
*/ */
@ApiOperation(value = "获取token接口", notes = "获取token接口", httpMethod = "POST") @ApiOperation(value = "获取token接口", notes = "获取token接口", httpMethod = "POST")
@PostMapping(value = "/user/login") @PostMapping(value = "/user/login")
public R<String> login(Integer id) { public R<String> login(Long id) {
if (null == id) { if (null == id) {
return R.error("入参为空!"); return R.error("入参为空!");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment