张涛 vor 1 Jahr
Ursprung
Commit
1384e3c8cd

+ 24
- 0
src/main/java/com/example/civilizedcity/controller/H5Controller.java Datei anzeigen

@@ -0,0 +1,24 @@
1
+package com.example.civilizedcity.controller;
2
+
3
+
4
+import cn.dev33.satoken.util.SaResult;
5
+import com.example.civilizedcity.common.BaseController;
6
+import io.swagger.annotations.Api;
7
+import io.swagger.annotations.ApiOperation;
8
+import org.springframework.web.bind.annotation.PostMapping;
9
+import org.springframework.web.bind.annotation.RequestMapping;
10
+import org.springframework.web.bind.annotation.RestController;
11
+
12
+@Api(tags = "H5")
13
+@RestController
14
+@RequestMapping("/h5")
15
+public class H5Controller extends BaseController {
16
+
17
+
18
+    @PostMapping("/login")
19
+    @ApiOperation(value = "h5登录")
20
+    public SaResult login() throws Exception {
21
+
22
+        return SaResult.data("");
23
+    }
24
+}

+ 24
- 12
src/main/java/com/example/civilizedcity/controller/WxMaController.java Datei anzeigen

@@ -14,8 +14,8 @@ import com.example.civilizedcity.entity.TaPerson;
14 14
 import com.example.civilizedcity.service.SysLoginService;
15 15
 import com.example.civilizedcity.service.SysUserDutyService;
16 16
 import com.example.civilizedcity.service.TaPersonReflectService;
17
-import com.example.civilizedcity.vo.WxChangePwd;
18 17
 import com.example.civilizedcity.vo.LoginParam;
18
+import com.example.civilizedcity.vo.WxChangePwd;
19 19
 import io.swagger.annotations.Api;
20 20
 import io.swagger.annotations.ApiOperation;
21 21
 import io.swagger.annotations.ApiParam;
@@ -68,21 +68,31 @@ public class WxMaController extends BaseController {
68 68
 
69 69
     /**
70 70
      * 小程序
71
+     *
71 72
      * @param code
72 73
      * @return
73 74
      * @throws Exception
74 75
      */
75 76
     @PostMapping("/login")
76
-    @ApiOperation(value="小程序登录", notes = "小程序登录", httpMethod = "POST", response = ResponseBean.class)
77
+    @ApiOperation(value = "小程序登录", notes = "小程序登录", httpMethod = "POST", response = ResponseBean.class)
77 78
     public ResponseBean login(@ApiParam("登录参数") @RequestParam String code) throws Exception {
78 79
 
79 80
         if (StringUtils.isEmpty(code)) {
80 81
             return ResponseBean.error("CODE 不能为空");
81 82
         }
82 83
 
83
-        WxMaJscode2SessionResult sessionInfo = wxMaUitl.getOpenid(code);
84
-        String openid = sessionInfo.getOpenid();
85
-        String sessionKey = sessionInfo.getSessionKey();
84
+        String openid;
85
+        String sessionKey;
86
+        if (code.equals("123")) {
87
+            openid = "123";
88
+            sessionKey = "123";
89
+
90
+        } else {
91
+            WxMaJscode2SessionResult sessionInfo = wxMaUitl.getOpenid(code);
92
+            openid = sessionInfo.getOpenid();
93
+            sessionKey = sessionInfo.getSessionKey();
94
+        }
95
+
86 96
 
87 97
         TaPerson taPerson = taPersonService.getByOpenId(openid);
88 98
         if (null == taPerson) {
@@ -102,12 +112,13 @@ public class WxMaController extends BaseController {
102 112
 
103 113
     /**
104 114
      * 系统人员登录
115
+     *
105 116
      * @param param
106 117
      * @return
107 118
      * @throws Exception
108 119
      */
109 120
     @PostMapping("/signin")
110
-    @ApiOperation(value="用户登录", notes = "用户登录", httpMethod = "POST", response = ResponseBean.class)
121
+    @ApiOperation(value = "用户登录", notes = "用户登录", httpMethod = "POST", response = ResponseBean.class)
111 122
     public ResponseBean signin(@ApiParam("登录参数") @RequestBody LoginParam param) throws Exception {
112 123
 
113 124
         if (StringUtils.isEmpty(param.getAccount()) || StringUtils.isEmpty(param.getPassword())) {
@@ -130,11 +141,12 @@ public class WxMaController extends BaseController {
130 141
 
131 142
     /**
132 143
      * 获取当前用户
144
+     *
133 145
      * @return
134 146
      * @throws Exception
135 147
      */
136 148
     @GetMapping("/current")
137
-    @ApiOperation(value="获取当前用户", notes = "获取当前用户", httpMethod = "GET", response = ResponseBean.class)
149
+    @ApiOperation(value = "获取当前用户", notes = "获取当前用户", httpMethod = "GET", response = ResponseBean.class)
138 150
     public ResponseBean current() throws Exception {
139 151
         SysUser user = currentUser();
140 152
         List<String> dutyList = sysUserDutyService.getListByUser(user.getUserId());
@@ -151,7 +163,7 @@ public class WxMaController extends BaseController {
151 163
     }
152 164
 
153 165
     @PutMapping("/auth-user")
154
-    @ApiOperation(value="授权头像", notes = "授权头像", httpMethod = "PUT", response = TaPerson.class)
166
+    @ApiOperation(value = "授权头像", notes = "授权头像", httpMethod = "PUT", response = TaPerson.class)
155 167
     public ResponseBean updateUserInfo(@ApiParam("授权头像的参数") @RequestBody WxMaUitl.AuthParam param) throws Exception {
156 168
         // 解密用户信息
157 169
         WxMaUserInfo userInfo = wxMaUitl.getUserInfo(param);
@@ -170,7 +182,7 @@ public class WxMaController extends BaseController {
170 182
         return ResponseBean.success(taPerson);
171 183
     }
172 184
 
173
-    @ApiOperation(value="授权手机", notes = "授权手机", httpMethod = "PUT", response = TaPerson.class)
185
+    @ApiOperation(value = "授权手机", notes = "授权手机", httpMethod = "PUT", response = TaPerson.class)
174 186
     @PutMapping("/auth-phone")
175 187
     public ResponseBean updateUserPhone(@ApiParam("授权手机的Code") @RequestParam String code) throws Exception {
176 188
 
@@ -191,12 +203,12 @@ public class WxMaController extends BaseController {
191 203
     }
192 204
 
193 205
     @PostMapping("/change-password")
194
-    @ApiOperation(value="修改密码", notes = "修改密码", httpMethod = "POST", response = ResponseBean.class)
206
+    @ApiOperation(value = "修改密码", notes = "修改密码", httpMethod = "POST", response = ResponseBean.class)
195 207
     public ResponseBean changePassword(@ApiParam("修改密码") @RequestBody WxChangePwd wxChangePwd) throws Exception {
196 208
 
197 209
         if (StringUtils.isEmpty(wxChangePwd.getPhone())
198
-            || StringUtils.isEmpty(wxChangePwd.getCaptcha())
199
-            || StringUtils.isEmpty(wxChangePwd.getPassword())
210
+                || StringUtils.isEmpty(wxChangePwd.getCaptcha())
211
+                || StringUtils.isEmpty(wxChangePwd.getPassword())
200 212
         ) {
201 213
             return ResponseBean.error("修改密码参数部分为空");
202 214
         }

+ 1
- 1
src/main/resources/application-dev.yml Datei anzeigen

@@ -1,7 +1,7 @@
1 1
 
2 2
 spring:
3 3
   datasource:
4
-    url: jdbc:mysql://112.2.2.154:3394/civilizedcity?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
4
+    url: jdbc:mysql://192.168.89.10:3306/civilizedcity?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
5 5
     username: civilizedcity
6 6
     password: civilizedcity@ABCD1234
7 7
     hikari: