2929import javax .servlet .http .HttpSession ;
3030
3131import org .springframework .web .bind .annotation .PathVariable ;
32+ import org .springframework .web .bind .annotation .PostMapping ;
3233import org .springframework .web .bind .annotation .RequestBody ;
3334import org .springframework .web .bind .annotation .RequestMapping ;
3435import org .springframework .web .bind .annotation .RestController ;
@@ -74,7 +75,7 @@ public class Controller {
7475 * @return
7576 * @see {@link RequestMethod#GET}
7677 */
77- @ RequestMapping (value = "get" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
78+ @ PostMapping (value = "get" )
7879 public String get (@ RequestBody String request , HttpSession session ) {
7980 return new Parser (GET ).setSession (session ).parse (request );
8081 }
@@ -85,7 +86,7 @@ public String get(@RequestBody String request, HttpSession session) {
8586 * @return
8687 * @see {@link RequestMethod#HEAD}
8788 */
88- @ RequestMapping ( value = "head" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
89+ @ PostMapping ( "head" )
8990 public String head (@ RequestBody String request , HttpSession session ) {
9091 return new Parser (HEAD ).setSession (session ).parse (request );
9192 }
@@ -96,7 +97,7 @@ public String head(@RequestBody String request, HttpSession session) {
9697 * @return
9798 * @see {@link RequestMethod#GETS}
9899 */
99- @ RequestMapping ( value = "gets" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
100+ @ PostMapping ( "gets" )
100101 public String gets (@ RequestBody String request , HttpSession session ) {
101102 return new Parser (GETS ).setSession (session ).parse (request );
102103 }
@@ -107,7 +108,7 @@ public String gets(@RequestBody String request, HttpSession session) {
107108 * @return
108109 * @see {@link RequestMethod#HEADS}
109110 */
110- @ RequestMapping ( value = "heads" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
111+ @ PostMapping ( "heads" )
111112 public String heads (@ RequestBody String request , HttpSession session ) {
112113 return new Parser (HEADS ).setSession (session ).parse (request );
113114 }
@@ -118,7 +119,7 @@ public String heads(@RequestBody String request, HttpSession session) {
118119 * @return
119120 * @see {@link RequestMethod#POST}
120121 */
121- @ RequestMapping ( value = "post" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
122+ @ PostMapping ( "post" )
122123 public String post (@ RequestBody String request , HttpSession session ) {
123124 return new Parser (POST ).setSession (session ).parse (request );
124125 }
@@ -129,7 +130,7 @@ public String post(@RequestBody String request, HttpSession session) {
129130 * @return
130131 * @see {@link RequestMethod#PUT}
131132 */
132- @ RequestMapping ( value = "put" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
133+ @ PostMapping ( "put" )
133134 public String put (@ RequestBody String request , HttpSession session ) {
134135 return new Parser (PUT ).setSession (session ).parse (request );
135136 }
@@ -140,7 +141,7 @@ public String put(@RequestBody String request, HttpSession session) {
140141 * @return
141142 * @see {@link RequestMethod#DELETE}
142143 */
143- @ RequestMapping ( value = "delete" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
144+ @ PostMapping ( "delete" )
144145 public String delete (@ RequestBody String request , HttpSession session ) {
145146 return new Parser (DELETE ).setSession (session ).parse (request );
146147 }
@@ -211,6 +212,7 @@ public String open_head(@PathVariable String request, HttpSession session) {
211212 VERIFY_ = Verify .class .getSimpleName ();
212213 }
213214
215+ public static final String VERSION = JSONRequest .KEY_VERSION ;
214216 public static final String COUNT = JSONResponse .KEY_COUNT ;
215217 public static final String TOTAL = JSONResponse .KEY_TOTAL ;
216218
@@ -232,6 +234,7 @@ public String open_head(@PathVariable String request, HttpSession session) {
232234 public static final String TYPE = "type" ;
233235 public static final String WAY = "way" ;
234236 public static final String CONTENT = "content" ;
237+
235238
236239
237240
@@ -265,7 +268,7 @@ public String open_head(@PathVariable String request, HttpSession session) {
265268 * @param request
266269 * @return
267270 */
268- @ RequestMapping ( value = "post/verify" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
271+ @ PostMapping ( "post/verify" )
269272 public JSONObject postVerify (@ RequestBody String request ) {
270273 JSONObject requestObject = null ;
271274 int type ;
@@ -305,7 +308,7 @@ public JSONObject postVerify(@RequestBody String request) {
305308 * @param request
306309 * @return
307310 */
308- @ RequestMapping ( value = "gets/verify" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
311+ @ PostMapping ( "gets/verify" )
309312 public JSONObject getVerify (@ RequestBody String request ) {
310313 JSONObject requestObject = null ;
311314 int type ;
@@ -324,7 +327,7 @@ public JSONObject getVerify(@RequestBody String request) {
324327 * @param request
325328 * @return
326329 */
327- @ RequestMapping ( value = "heads/verify" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
330+ @ PostMapping ( "heads/verify" )
328331 public JSONObject headVerify (@ RequestBody String request ) {
329332 JSONObject requestObject = null ;
330333 int type ;
@@ -400,18 +403,20 @@ private JSONObject newVerifyRequest(int type, String phone, String verify) {
400403 * @see
401404 * <pre>
402405 {
403- "type": 0,
406+ "type": 0, //登录方式,非必须 0-密码 2-验证码
404407 "phone": "13000082001",
405- "password": "1234567"
408+ "password": "1234567",
409+ "version": 1 //全局版本号,非必须
406410 }
407411 * </pre>
408412 */
409- @ RequestMapping ( value = "login" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
413+ @ PostMapping ( "login" )
410414 public JSONObject login (@ RequestBody String request , HttpSession session ) {
411415 JSONObject requestObject = null ;
412416 boolean isPassword ;
413417 String phone ;
414418 String password ;
419+ int version ;
415420 try {
416421 requestObject = Parser .parseRequest (request , POST );
417422
@@ -432,6 +437,10 @@ public JSONObject login(@RequestBody String request, HttpSession session) {
432437 throw new IllegalArgumentException ("验证码不合法!" );
433438 }
434439 }
440+
441+ //全局版本号
442+ version = requestObject .getIntValue (VERSION );
443+ requestObject .remove (VERSION );
435444 } catch (Exception e ) {
436445 return Parser .extendErrorResult (requestObject , e );
437446 }
@@ -499,6 +508,7 @@ public JSONObject login(@RequestBody String request, HttpSession session) {
499508 session .setAttribute (TYPE , isPassword ? LOGIN_TYPE_PASSWORD : LOGIN_TYPE_VERIFY );//登录方式
500509 session .setAttribute (USER_ , user );//用户
501510 session .setAttribute (PRIVACY_ , privacy );//用户隐私信息
511+ session .setAttribute (VERSION , version );//用户隐私信息
502512 // session.setMaxInactiveInterval(1*60);//设置session过期时间
503513
504514 return response ;
@@ -508,7 +518,7 @@ public JSONObject login(@RequestBody String request, HttpSession session) {
508518 * @param session
509519 * @return
510520 */
511- @ RequestMapping ( value = "logout" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
521+ @ PostMapping ( "logout" )
512522 public JSONObject logout (HttpSession session ) {
513523 long userId ;
514524 try {
@@ -547,7 +557,7 @@ public JSONObject logout(HttpSession session) {
547557 }
548558 * </pre>
549559 */
550- @ RequestMapping ( value = REGISTER , method = org . springframework . web . bind . annotation . RequestMethod . POST )
560+ @ PostMapping ( REGISTER )
551561 public JSONObject register (@ RequestBody String request ) {
552562 JSONObject requestObject = null ;
553563
@@ -663,7 +673,7 @@ public static JSONObject newIllegalArgumentResult(JSONObject requestObject, Stri
663673 }
664674 * </pre>
665675 */
666- @ RequestMapping ( value = "put/password" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
676+ @ PostMapping ( "put/password" )
667677 public JSONObject putPassword (@ RequestBody String request ){
668678 JSONObject requestObject = null ;
669679 String old_password ;
@@ -780,7 +790,7 @@ else if (StringUtil.isPhone(phone) && StringUtil.isVerify(verify)) {
780790 }
781791 * </pre>
782792 */
783- @ RequestMapping ( value = "put/balance" , method = org . springframework . web . bind . annotation . RequestMethod . POST )
793+ @ PostMapping ( "put/balance" )
784794 public JSONObject putBalance (@ RequestBody String request , HttpSession session ) {
785795 JSONObject requestObject = null ;
786796 JSONObject privacyObj ;
0 commit comments