张涛 1 vuosi sitten
vanhempi
commit
1384e3c8cd

+ 24
- 0
src/main/java/com/example/civilizedcity/controller/H5Controller.java Näytä tiedosto

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 Näytä tiedosto

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

+ 1
- 1
src/main/resources/application-dev.yml Näytä tiedosto

1
 
1
 
2
 spring:
2
 spring:
3
   datasource:
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
     username: civilizedcity
5
     username: civilizedcity
6
     password: civilizedcity@ABCD1234
6
     password: civilizedcity@ABCD1234
7
     hikari:
7
     hikari: