|
@@ -4,6 +4,7 @@ package com.community.huiju.controller;
|
4
|
4
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
5
|
5
|
import com.community.commom.mode.ResponseBean;
|
6
|
6
|
import com.community.commom.session.UserElement;
|
|
7
|
+import com.community.commom.utils.AccountValidatorUtil;
|
7
|
8
|
import com.community.huiju.common.base.BaseController;
|
8
|
9
|
import com.community.huiju.model.AnnouncementTel;
|
9
|
10
|
import com.community.huiju.model.Bill;
|
|
@@ -14,6 +15,7 @@ import io.swagger.annotations.ApiImplicitParams;
|
14
|
15
|
import io.swagger.annotations.ApiOperation;
|
15
|
16
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
17
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
18
|
+import org.springframework.validation.annotation.Validated;
|
17
|
19
|
import org.springframework.web.bind.annotation.PathVariable;
|
18
|
20
|
import org.springframework.web.bind.annotation.RequestBody;
|
19
|
21
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -23,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
|
23
|
25
|
|
24
|
26
|
import javax.servlet.http.HttpServletRequest;
|
25
|
27
|
import javax.servlet.http.HttpSession;
|
|
28
|
+import javax.validation.Valid;
|
26
|
29
|
import java.time.LocalDateTime;
|
27
|
30
|
import java.util.List;
|
28
|
31
|
|
|
@@ -75,8 +78,20 @@ public class AnnouncementTelController extends BaseController {
|
75
|
78
|
@ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token")
|
76
|
79
|
})
|
77
|
80
|
@RequestMapping(value = "/tel/add",method = RequestMethod.POST)
|
78
|
|
- public ResponseBean addTel(@RequestBody AnnouncementTel announcementTel, HttpSession session){
|
|
81
|
+ public ResponseBean addTel(@Valid @RequestBody AnnouncementTel announcementTel, HttpSession session){
|
79
|
82
|
ResponseBean responseBean = new ResponseBean();
|
|
83
|
+ boolean isPhone = true;
|
|
84
|
+ boolean isLandline = true;
|
|
85
|
+ if (!AccountValidatorUtil.isLandline(announcementTel.getTel())){
|
|
86
|
+ isLandline = false;
|
|
87
|
+ }
|
|
88
|
+ if (!AccountValidatorUtil.isPhone(announcementTel.getTel())){
|
|
89
|
+ isPhone = false;
|
|
90
|
+ }
|
|
91
|
+ if (isPhone == false && isLandline == false) {
|
|
92
|
+ responseBean.addError("输入的号码不正确!");
|
|
93
|
+ return responseBean;
|
|
94
|
+ }
|
80
|
95
|
UserElement userElement = getUserElement(session);
|
81
|
96
|
QueryWrapper<AnnouncementTel> announcementTelQueryWrapper = new QueryWrapper<>();
|
82
|
97
|
announcementTelQueryWrapper.eq("tel", announcementTel.getTel());
|
|
@@ -107,8 +122,20 @@ public class AnnouncementTelController extends BaseController {
|
107
|
122
|
@ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token")
|
108
|
123
|
})
|
109
|
124
|
@RequestMapping(value = "/tel/update", method = RequestMethod.PUT)
|
110
|
|
- public ResponseBean updateTel(@RequestBody AnnouncementTel announcementTel, HttpSession session) {
|
|
125
|
+ public ResponseBean updateTel(@Valid @RequestBody AnnouncementTel announcementTel, HttpSession session) {
|
111
|
126
|
ResponseBean responseBean = new ResponseBean();
|
|
127
|
+ boolean isPhone = true;
|
|
128
|
+ boolean isLandline = true;
|
|
129
|
+ if (!AccountValidatorUtil.isLandline(announcementTel.getTel())){
|
|
130
|
+ isLandline = false;
|
|
131
|
+ }
|
|
132
|
+ if (!AccountValidatorUtil.isPhone(announcementTel.getTel())){
|
|
133
|
+ isPhone = false;
|
|
134
|
+ }
|
|
135
|
+ if (isPhone == false && isLandline == false) {
|
|
136
|
+ responseBean.addError("输入的号码不正确!");
|
|
137
|
+ return responseBean;
|
|
138
|
+ }
|
112
|
139
|
UserElement userElement = getUserElement(session);
|
113
|
140
|
QueryWrapper<AnnouncementTel> announcementTelQueryWrapper = new QueryWrapper<>();
|
114
|
141
|
announcementTelQueryWrapper.eq("tel", announcementTel.getTel());
|