feat: 分离不同状态的数据

This commit is contained in:
禾几海
2020-08-31 00:53:48 +08:00
parent a54e04abf3
commit 01407aba7e
6 changed files with 32 additions and 19 deletions

View File

@@ -116,8 +116,8 @@ public class UserController {
} }
@GetMapping("/admin/users") @GetMapping("/admin/users")
public Response getAllUser(@RequestParam("page") int pageNum, @RequestParam("count") int count) { public Response getAllUser(@RequestParam("page") int pageNum, @RequestParam("count") int count, @RequestParam(name = "status", required = false) Integer status) {
return Response.success(userService.getUserList(pageNum, count)); return Response.success(userService.getUserList(pageNum, count, status));
} }
@GetMapping("/emailStatus/{email}") @GetMapping("/emailStatus/{email}")

View File

@@ -53,6 +53,8 @@ public interface UserMapper {
int setUserRole(Long id, String role); int setUserRole(Long id, String role);
List<User> findAll(Integer status);
List<User> findAll(); List<User> findAll();
int update(User user); int update(User user);

View File

@@ -129,7 +129,7 @@ public interface UserService {
* @param page 数据页 * @param page 数据页
* @return 分页数据 * @return 分页数据
*/ */
PageData<UserModel> getUserList(Integer page, Integer count); PageData<UserModel> getUserList(Integer page, Integer count, Integer status);
/** /**
* 更改用户信息 * 更改用户信息

View File

@@ -28,6 +28,7 @@ import java.beans.Transient;
import java.io.InputStream; import java.io.InputStream;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/** /**
* @author : xiaohai * @author : xiaohai
@@ -338,12 +339,11 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public PageData<UserModel> getUserList(Integer page, Integer count) { public PageData<UserModel> getUserList(Integer page, Integer count, Integer status) {
PageHelper.startPage(page, count); PageHelper.startPage(page, count);
List<User> all = userMapper.findAll(); List<User> all = userMapper.findAll(status);
List<UserModel> modelList = new ArrayList<>(); List<UserModel> modelList = all.stream().map(ModalTrans::userFullInfo).collect(Collectors.toList());
all.forEach(user -> modelList.add(ModalTrans.userFullInfo(user))); return new PageData<>(PageInfo.of(all), modelList);
return new PageData<UserModel>(PageInfo.of(all), modelList);
} }
@Override @Override

View File

@@ -130,5 +130,8 @@
<select id="findAll" resultMap="userResultMap"> <select id="findAll" resultMap="userResultMap">
select * select *
from user from user
<if test="_parameter != null">
where status=#{status}
</if>
</select> </select>
</mapper> </mapper>

View File

@@ -1,3 +1,22 @@
INSERT INTO `user` (`u_id`, `u_email`, `u_pwd`, `u_email_status`, `u_avatar`, `u_desc`, `u_recently_landed_time`,
`u_display_name`, `u_role`, `status`)
VALUES (1, 'a@celess.cn', '25f9e794323b453885f5181f1b624d0b', 1, 'a@celess.cn_2.png', '禾几海不需要自我介绍',
'2020-07-02 11:30:38', '禾几海', 'admin', 0),
(3, 'zh56462271@qq.com', '25f9e794323b453885f5181f1b624d0b', 1, NULL, NULL, '2020-05-16 13:21:35', NULL, 'user',
0),
(2, 'b@celess.cn', '25f9e794323b453885f5181f1b624d0b', 1, NULL, NULL, '2020-05-16 13:21:35', NULL, 'user', 0),
(4, 'c@celess.cn', '25f9e794323b453885f5181f1b624d0b', 1, NULL, NULL, '2020-05-16 13:21:35', NULL, 'user', 1),
(5, 'd@celess.cn', '25f9e794323b453885f5181f1b624d0b', 1, NULL, NULL, '2020-05-16 13:21:35', NULL, 'user', 1),
(6, 'e@celess.cn', '25f9e794323b453885f5181f1b624d0b', 1, NULL, NULL, '2020-05-16 13:21:35', NULL, 'user', 2),
(7, 'f@celess.cn', '25f9e794323b453885f5181f1b624d0b', 1, NULL, NULL, '2020-05-16 13:21:35', NULL, 'user', 2),
(8, 'g@celess.cn', '25f9e794323b453885f5181f1b624d0b', 1, NULL, NULL, '2020-05-16 13:21:35', NULL, 'user', 0),
(9, 'h@celess.cn', '25f9e794323b453885f5181f1b624d0b', 1, NULL, NULL, '2020-05-16 13:21:35', NULL, 'user', 1),
(10, 'i@celess.cn', '25f9e794323b453885f5181f1b624d0b', 1, NULL, NULL, '2020-05-16 13:21:35', NULL, 'user', 2),
(11, 'j@celess.cn', '25f9e794323b453885f5181f1b624d0b', 1, NULL, NULL, '2020-05-16 13:21:35', NULL, 'user', 0),
(12, 'k@celess.cn', '25f9e794323b453885f5181f1b624d0b', 1, NULL, NULL, '2020-05-16 13:21:35', NULL, 'user', 1);
-- 密码123456789
INSERT INTO `tag_category` (`t_id`, `t_name`, `is_category`, `is_delete`) INSERT INTO `tag_category` (`t_id`, `t_name`, `is_category`, `is_delete`)
VALUES (1, '随笔', 1, 0), VALUES (1, '随笔', 1, 0),
(2, '后端', 1, 0), (2, '后端', 1, 0),
@@ -28,17 +47,6 @@ VALUES (1, '随笔', 1, 0),
(27, '网课', 0, 0); (27, '网课', 0, 0);
-- 密码123456789
INSERT INTO `user` (`u_id`, `u_email`, `u_pwd`, `u_email_status`, `u_avatar`, `u_desc`, `u_recently_landed_time`,
`u_display_name`, `u_role`, `status`)
VALUES (1, 'a@celess.cn', '25f9e794323b453885f5181f1b624d0b', 1, 'a@celess.cn_2.png', '禾几海不需要自我介绍',
'2020-07-02 11:30:38', '禾几海', 'admin', 0),
(2, 'b@celess.cn', '25f9e794323b453885f5181f1b624d0b', 1, NULL, NULL, '2020-05-16 13:21:35', NULL, 'user',
0),
(3, 'zh56462271@qq.com', '25f9e794323b453885f5181f1b624d0b', 1, NULL, NULL, '2020-05-16 13:21:35', NULL, 'user',
0);
INSERT INTO `article` (`a_id`, `a_title`, `a_summary`, `a_md_content`, `a_url`, `a_author_id`, `a_is_original`, INSERT INTO `article` (`a_id`, `a_title`, `a_summary`, `a_md_content`, `a_url`, `a_author_id`, `a_is_original`,
`a_reading_number`, `a_like`, `a_dislike`, `a_category_id`, `a_publish_date`, `a_update_date`, `a_reading_number`, `a_like`, `a_dislike`, `a_category_id`, `a_publish_date`, `a_update_date`,
`a_is_open`, `is_delete`) `a_is_open`, `is_delete`)