|
@@ -4,6 +4,7 @@ import com.idiot.operationbackend.entity.Account;
|
|
|
import com.idiot.operationbackend.entity.AuthUser;
|
|
|
import com.idiot.operationbackend.service.facade.AccountService;
|
|
|
import com.idiot.operationbackend.service.facade.AuthUserService;
|
|
|
+import com.idiot.operationbackend.service.facade.WeChatService;
|
|
|
import com.idiot.operationbackend.support.CustomException;
|
|
|
import com.idiot.operationbackend.support.JsonResult;
|
|
|
import com.idiot.operationbackend.util.JwtTokenUtil;
|
|
@@ -39,6 +40,10 @@ public class AccountController {
|
|
|
@Autowired
|
|
|
private AuthUserService userService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private WeChatService weChatService;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@GetMapping
|
|
|
@ApiOperation(value = "查询公众号列表")
|
|
@@ -76,6 +81,30 @@ public class AccountController {
|
|
|
return ResponseEntity.ok(JsonResult.success(account));
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/preAuth")
|
|
|
+ @ApiOperation(value = "获取预授权码地址,微信认证公众号")
|
|
|
+ public ResponseEntity<JsonResult<String>> getPreAuthUrl () {
|
|
|
+ return ResponseEntity.ok(JsonResult.success(weChatService.getPreAuthUrl()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/confirmAccount")
|
|
|
+ @ApiOperation(value = "确认授权的微信公众号")
|
|
|
+ public ResponseEntity<JsonResult<Boolean>> confirmAccount (@RequestHeader String token,
|
|
|
+ @RequestParam String accountId) {
|
|
|
+
|
|
|
+ String userId = JwtTokenUtil.getUserId(token);
|
|
|
+ logger.error("微信公众号:{}授权,用户:{}确认 ,",accountId,userId);
|
|
|
+ boolean ifUpdate = weChatService.confirmAccount(accountId,userId);
|
|
|
+ if (ifUpdate){
|
|
|
+ logger.error("微信公众号:{}授权,用户:{} 成功确认 ,开始同步用户标签数据",accountId,userId);
|
|
|
+ int userCount = weChatService.syncAccountUser(accountId);
|
|
|
+ logger.warn("同步用户数量:{}",userCount);
|
|
|
+ weChatService.syncTag(accountId);
|
|
|
+ }
|
|
|
+
|
|
|
+ return ResponseEntity.ok(JsonResult.success(ifUpdate));
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|