Skip to content

Commit 948c332

Browse files
committed
6-10 用户管理完成功能
1 parent eef2b57 commit 948c332

File tree

7 files changed

+69
-43
lines changed

7 files changed

+69
-43
lines changed

src/main/java/com/zzq/ebook/constant/constant.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,13 @@ public class constant {
5050
public static final String PUBLISHER = "publisher";
5151
public static final String DESCRIPTION = "description";
5252

53+
54+
55+
// 注册字段的变量
56+
public static final String LOCATION = "location";
57+
public static final String PHONE = "phone";
58+
public static final String CONFIRM = "confirm";
59+
60+
61+
public static final String AGREEMENT ="agreement";
5362
}

src/main/java/com/zzq/ebook/controller/bookControl.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import javax.crypto.Mac;
1717
import javax.crypto.spec.SecretKeySpec;
1818
import java.security.SignatureException;
19+
import java.util.ArrayList;
1920
import java.util.List;
2021
import java.util.Map;
2122
import java.util.Objects;
@@ -36,6 +37,32 @@ public Book getBook(@PathVariable("bookid") Integer id){
3637
return null;
3738
}
3839

40+
@GetMapping(value = "/queryMainPageBooks")
41+
public List<Book> getBook(){
42+
List<Book> result = new ArrayList<Book>();
43+
result.add(bookService.getBookByID(1));
44+
result.add(bookService.getBookByID(2));
45+
result.add(bookService.getBookByID(3));
46+
result.add(bookService.getBookByID(4));
47+
result.add(bookService.getBookByID(5));
48+
result.add(bookService.getBookByID(6));
49+
result.add(bookService.getBookByID(1));
50+
result.add(bookService.getBookByID(2));
51+
result.add(bookService.getBookByID(3));
52+
result.add(bookService.getBookByID(4));
53+
result.add(bookService.getBookByID(5));
54+
result.add(bookService.getBookByID(6));
55+
result.add(bookService.getBookByID(1));
56+
result.add(bookService.getBookByID(2));
57+
result.add(bookService.getBookByID(3));
58+
result.add(bookService.getBookByID(4));
59+
result.add(bookService.getBookByID(5));
60+
result.add(bookService.getBookByID(6));
61+
return result;
62+
}
63+
64+
65+
3966
@RequestMapping("/queryBook/All")
4067
public List<Book> getAllBook(@RequestBody Map<String, String> params){
4168
return bookService.getBookAll();

src/main/java/com/zzq/ebook/controller/loginControl.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,15 @@ public Msg checkSession(){
8686
}
8787
}
8888

89-
@RequestMapping("/register")
90-
public Msg register(@RequestBody Map<String, String> params){
91-
//agreement: true
92-
//confirm: "1231231"
93-
//email: "zhangziqian@sjtu.edu.cn"
94-
//location: "123123123"
95-
//password: "1231231"
96-
//phone: "18062765851"
97-
//username: "123123123"
98-
String username = params.get(constant.USERNAME);
99-
String email = params.get(constant.EMAIL);
100-
String location = params.get("location");
101-
String password = params.get(constant.PASSWORD);
102-
String phone = params.get("phone");
89+
//agreement: true
90+
//confirm: "1231231"
91+
//email: "zhangziqian@sjtu.edu.cn"
92+
//location: "123123123"
93+
//password: "1231231"
94+
//phone: "18062765851"
95+
//username: "123123123"
10396

10497

105-
return null;
106-
}
107-
10898

10999

110100

src/main/java/com/zzq/ebook/controller/orderControl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public Msg addToChart(@RequestBody Map<String, String> params){
3636

3737
// 拒绝非法的用户添加购物车到他人用户
3838
JSONObject auth = SessionUtil.getAuth();
39+
assert auth != null;
3940
if(!Objects.equals((String) auth.get(constant.USERNAME), username)){
4041
return MsgUtil.makeMsg(MsgCode.ERROR, MsgUtil.NOT_LOGGED_IN_ERROR_MSG);
4142
}

src/main/java/com/zzq/ebook/controller/statisticControl.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class statisticControl {
4040
@Autowired
4141
private StatisticService statisticService;
4242

43-
// 函数用途:统计用户的消费数据,如果请求的时候说明了开始和终止日期,就按照设定,否则就是所有时间段
43+
// 函数用途:统计![所有]!用户的消费数据,如果请求的时候说明了开始和终止日期,就按照设定,否则就是所有时间段
4444
// 返回的格式是数组,以 [用户:消费金额] 的形式呈现
4545
// 使用场景:管理员 统计用户的消费数据
4646
// 权限要求:管理员(权限号-0)
@@ -49,12 +49,9 @@ public JSONArray userConsumeData(@RequestBody Map<String, String> params) throws
4949
if(params.get("startDate")!=null && params.get("endDate")!=null){
5050
String startstr = params.get("startDate");
5151
String endstr = params.get("endDate");
52-
5352
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
54-
5553
Date datastart = sdf1.parse(startstr);
5654
Date dataend = sdf1.parse(endstr);
57-
5855
return statisticService.userConsumeStatistic(datastart,dataend);
5956
}
6057

@@ -68,37 +65,31 @@ public JSONArray userConsumeData(@RequestBody Map<String, String> params) throws
6865
}
6966
}
7067

71-
68+
// 函数用途:统计![所有]!用户的购买书籍的数量,如果请求的时候说明了开始和终止日期,就按照设定,否则就是所有时间段
69+
// 返回的格式是数组,以 [用户:买的书籍本数] 的形式呈现
70+
// 使用场景:管理员 统计用户的购买书籍的数量
71+
// 权限要求:管理员(权限号-0)
7272
@RequestMapping("/statistic/bookSellnum")
7373
public JSONArray bookSellnum(@RequestBody Map<String, String> params) throws ParseException {
7474
if(params.get("startDate")!=null && params.get("endDate")!=null){
7575
String startstr = params.get("startDate");
7676
String endstr = params.get("endDate");
77-
7877
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
79-
8078
Date datastart = sdf1.parse(startstr);
8179
Date dataend = sdf1.parse(endstr);
82-
8380
return statisticService.bookSellnumStatistic(datastart,dataend);
8481
}
85-
8682
else{
87-
8883
String startstr = "1000-01-01 00:00:00";
8984
String endstr = "9999-12-31 12:59:59";
9085
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
9186
Date datastart = sdf1.parse(startstr);
9287
Date dataend = sdf1.parse(endstr);
93-
9488
return statisticService.bookSellnumStatistic(datastart,dataend);
9589
}
96-
9790
}
9891

9992

100-
101-
10293
@RequestMapping("/statistic/userStatistic/bookTotalPay")
10394
public JSONArray userBookTotalPay(@RequestBody Map<String, String> params) throws ParseException {
10495
JSONObject auth = SessionUtil.getAuth();
@@ -167,9 +158,7 @@ public JSONArray userbookWithBuyNum(@RequestBody Map<String, String> params) thr
167158
if(params.get("startDate")!=null && params.get("endDate")!=null){
168159
String startstr = params.get("startDate");
169160
String endstr = params.get("endDate");
170-
171161
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
172-
173162
Date datastart = sdf1.parse(startstr);
174163
Date dataend = sdf1.parse(endstr);
175164

src/main/java/com/zzq/ebook/controller/userControl.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ public Msg requestUserInfo(@RequestBody Map<String, String> params){
4646
// 拒绝非法的用户获取用户的信息
4747
assert auth != null;
4848
if(!Objects.equals((String) auth.get(constant.USERNAME), username)){
49-
50-
System.out.println(username);
51-
System.out.println((String) auth.get(constant.USERNAME));
5249
return null;
5350
}
5451
User user = userService.getUserByusername(username);
@@ -97,6 +94,25 @@ public List<User> queryAllUserInfo(){
9794
return null;
9895
}
9996

97+
98+
// 函数用途:请求所有的用户信息列表,接收POST请求,接口返回用户的信息数据表,当然会移除密码等敏感信息
99+
// 使用场景:登录页面的注册按钮,注册完成后,信息发送到这个端点
100+
// 权限要求:无限制
101+
@RequestMapping("/user/register")
102+
public Msg register(@RequestBody Map<String, String> params){
103+
String email = params.get(constant.EMAIL);
104+
String location = params.get(constant.LOCATION);
105+
String password = params.get(constant.PASSWORD);
106+
String phone = params.get(constant.PHONE);
107+
String username = params.get(constant.USERNAME);
108+
String confirm = params.get(constant.CONFIRM);
109+
String agreement = params.get(constant.AGREEMENT);
110+
return null;
111+
}
112+
113+
114+
115+
100116
// 函数用途:修改用户的登录许可,接收POST请求,接口返回修改的结果是否成功
101117
// 使用场景:管理员 用户管理页面的表格,管理员设置用户是否允许登录
102118
// 权限要求:管理员(权限号-0)
@@ -109,16 +125,11 @@ public Msg setUserLoginPermit(@RequestBody Map<String, String> params){
109125
JSONObject auth = SessionUtil.getAuth();
110126
// 检查是全局管理员,才允许设置
111127
if(auth != null && Objects.equals(auth.get(constant.PRIVILEGE),0)){
112-
113128
String setObjUsername = params.get(constant.SET_OBJ_USERNAME);
114129
String setObjPermitState = params.get(constant.SET_OBJ_PERMITSTATE);
115130
int setObjPermitStateVal = Integer.parseInt(setObjPermitState);
116-
System.out.println(setObjUsername);
117-
System.out.println(setObjPermitState);
118-
System.out.println(setObjPermitStateVal);
119131
userService.setUserLoginPermit(setObjUsername,setObjPermitStateVal);
120132

121-
122133
// 自己修改自己的登录状态,会被拒绝 这在逻辑上也是不好的一个操作
123134
if(Objects.equals(auth.get(constant.USERNAME),setObjUsername))
124135
return MsgUtil.makeMsg(MsgCode.ERROR,MsgUtil.SET_LOGIN_PERMISSION_FAIL);

src/main/java/com/zzq/ebook/privateKey/keyInfoexample.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
// 源文件名称 keyinfo.java
55

66
public class keyInfoexample {
7-
public static final String accessId = "阿里云accessId ";
8-
public static final String picKey = "阿里云 key ";
7+
public static final String accessKey = "[阿里云accessKey!]";
98
}

0 commit comments

Comments
 (0)