From d98c7875c62e6551ad8aee081242aad8d5f13efe Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Mon, 27 Apr 2026 17:14:18 +0800
Subject: [PATCH] 1

---
 src/main/java/com/nq/controller/AgentApiController.java |  117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 114 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/nq/controller/AgentApiController.java b/src/main/java/com/nq/controller/AgentApiController.java
index 53f182b..8884352 100644
--- a/src/main/java/com/nq/controller/AgentApiController.java
+++ b/src/main/java/com/nq/controller/AgentApiController.java
@@ -2,9 +2,14 @@
 
 
 import com.nq.common.ServerResponse;
-
+import com.nq.dao.AgentUserMapper;
+import com.nq.pojo.AgentUser;
+import com.nq.pojo.GoogleAuthDto;
+import com.nq.pojo.UserStockSubscribe;
 import com.nq.service.IAgentUserService;
 
+import com.nq.service.IUserStockSubscribeService;
+import com.nq.service.impl.GoogleAuthenticator;
 import com.nq.utils.PropertiesUtil;
 
 import com.nq.utils.redis.CookieUtils;
@@ -23,6 +28,7 @@
 
 import javax.servlet.http.HttpSession;
 
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 
 import org.slf4j.LoggerFactory;
@@ -46,11 +52,21 @@
     @Autowired
     IAgentUserService iAgentUserService;
 
+    @Autowired
+    IUserStockSubscribeService iUserStockSubscribeService;
+
+    @Autowired
+    AgentUserMapper agentUserMapper;
+
     //代理后台登录
     @RequestMapping({"login.do"})
     @ResponseBody
-    public ServerResponse login(@RequestParam("agentPhone") String agentPhone, @RequestParam("agentPwd") String agentPwd, @RequestParam(value = "verifyCode", required = false, defaultValue = "") String verifyCode, HttpSession httpSession, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
-        ServerResponse serverResponse = this.iAgentUserService.login(agentPhone, agentPwd, verifyCode, httpServletRequest);
+    public ServerResponse login(@RequestParam("agentPhone") String agentPhone,
+                                @RequestParam("agentPwd") String agentPwd,
+                                @RequestParam(value = "verifyCode", required = false, defaultValue = "") String verifyCode,
+                                @RequestParam(value = "googleAuthCode", required = false) Integer googleAuthCode,
+                                HttpSession httpSession, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
+        ServerResponse serverResponse = this.iAgentUserService.login(agentPhone, agentPwd, verifyCode, googleAuthCode, httpServletRequest);
         String token = RedisConst.getAgentRedisKey(httpSession.getId());
         if (serverResponse.isSuccess()) {
             String redisSetExResult = RedisShardedPoolUtils.setEx(token,
@@ -74,4 +90,99 @@
         CookieUtils.delLoginToken(httpServletRequest, httpServletResponse, cookie_name);
         return ServerResponse.createBySuccess();
     }
+
+    //申购信息列表查询
+    @RequestMapping({"getStockSubscribeList.do"})
+    @ResponseBody
+    public ServerResponse getStockSubscribeList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                @RequestParam(value = "pageSize", defaultValue = "12") int pageSize,
+                                                @RequestParam(value = "keyword", defaultValue = "") String keyword,
+                                                @RequestParam(value = "agentId", required = false) String agentId,
+                                                HttpServletRequest request) {
+        return this.iUserStockSubscribeService.getList(pageNum, pageSize, keyword,agentId, request);
+    }
+
+    //申购信息-添加 修改
+    @RequestMapping({"saveStockSubscribe.do"})
+    @ResponseBody
+    public ServerResponse saveStockSubscribe(UserStockSubscribe model, HttpServletRequest request) throws Exception {
+        return this.iUserStockSubscribeService.save(model, request);
+    }
+
+    //新股申购-删除
+    @RequestMapping({"delStockSubscribe.do"})
+    @ResponseBody
+    public ServerResponse delStockSubscribe(@RequestParam("id") int id, HttpServletRequest request) {
+        return this.iUserStockSubscribeService.del(id, request);
+    }
+
+    @RequestMapping({"getLoginGoogleAuthSecret"})
+    @ResponseBody
+    public ServerResponse getLoginGoogleAuthSecret(HttpServletRequest request) {
+        GoogleAuthDto dto = iAgentUserService.getGoogleAuth(request);
+        if (dto == null) {
+            return ServerResponse.createByErrorMsg("请先登录");
+        }
+        return ServerResponse.createBySuccess(dto);
+    }
+
+    @RequestMapping({"bindGoogleAuth"})
+    @ResponseBody
+    public ServerResponse bindGoogleAuth(@RequestParam("googleAuthCode") String googleAuthCode,
+                                         @RequestParam("secret") String secret,
+                                         HttpServletRequest request) {
+        AgentUser currentAgent = iAgentUserService.getCurrentAgent(request);
+        if (currentAgent == null) {
+            return ServerResponse.createByErrorMsg("请先登录");
+        }
+        AgentUser agentUser = agentUserMapper.selectByPrimaryKey(currentAgent.getId());
+        if (agentUser == null) {
+            return ServerResponse.createByErrorMsg("当前用户未找到");
+        }
+        if (Boolean.TRUE.equals(agentUser.getGoogleAuthBind())) {
+            return ServerResponse.createByErrorMsg("谷歌验证码已绑定");
+        }
+        if (StringUtils.isBlank(secret) || StringUtils.isBlank(googleAuthCode)) {
+            return ServerResponse.createByErrorMsg("参数不能为空");
+        }
+        long t = System.currentTimeMillis();
+        GoogleAuthenticator ga = new GoogleAuthenticator();
+        ga.setWindowSize(5);
+        boolean userFlag = ga.check_code(secret, Long.valueOf(googleAuthCode), t);
+        if (!userFlag) {
+            return ServerResponse.createByErrorMsg("谷歌验证码错误");
+        }
+        agentUser.setGoogleAuthBind(true);
+        agentUser.setGoogleAuthSecret(secret);
+        agentUserMapper.updateByPrimaryKeySelective(agentUser);
+        return ServerResponse.createBySuccess();
+    }
+
+    @RequestMapping({"unbindingGoogleAuth"})
+    @ResponseBody
+    public ServerResponse unbindingGoogleAuth(@RequestParam("rootGoogleAuthCode") String rootGoogleAuthCode,
+                                              HttpServletRequest request) {
+        AgentUser currentAgent = iAgentUserService.getCurrentAgent(request);
+        if (currentAgent == null) {
+            return ServerResponse.createByErrorMsg("请先登录");
+        }
+        AgentUser agentUser = agentUserMapper.selectByPrimaryKey(currentAgent.getId());
+        if (agentUser == null) {
+            return ServerResponse.createByErrorMsg("当前用户未找到");
+        }
+        if (!Boolean.TRUE.equals(agentUser.getGoogleAuthBind())) {
+            return ServerResponse.createByErrorMsg("谷歌验证码未绑定,无需解绑!");
+        }
+        long t = System.currentTimeMillis();
+        GoogleAuthenticator ga = new GoogleAuthenticator();
+        ga.setWindowSize(5);
+        boolean flag = ga.check_code(agentUser.getGoogleAuthSecret(), Long.valueOf(rootGoogleAuthCode), t);
+        if (!flag) {
+            return ServerResponse.createByErrorMsg("谷歌验证码错误");
+        }
+        agentUser.setGoogleAuthBind(false);
+        agentUser.setGoogleAuthSecret("");
+        agentUserMapper.updateByPrimaryKeySelective(agentUser);
+        return ServerResponse.createBySuccess();
+    }
 }

--
Gitblit v1.9.3