From 86df207c37502cce1b2043e1c7c0486459eef1d6 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期四, 13 三月 2025 19:58:45 +0800
Subject: [PATCH] 党员、诉求评论基础代码

---
 springcloud_k8s_panzhihuazhihuishequ/auth/src/main/java/com/panzhihua/auth/service/impl/LoginServiceImpl.java |  346 +++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 297 insertions(+), 49 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/auth/src/main/java/com/panzhihua/auth/service/impl/LoginServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/auth/src/main/java/com/panzhihua/auth/service/impl/LoginServiceImpl.java
index dfd4782..d2bb502 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/auth/src/main/java/com/panzhihua/auth/service/impl/LoginServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/auth/src/main/java/com/panzhihua/auth/service/impl/LoginServiceImpl.java
@@ -1,11 +1,16 @@
 package com.panzhihua.auth.service.impl;
 
-import com.panzhihua.auth.service.LoginService;
-import com.panzhihua.common.constants.TokenConstant;
-import com.panzhihua.common.model.vos.LoginReturnVO;
-import com.panzhihua.common.utlis.JWTTokenUtil;
-import com.panzhihua.common.constants.UserConstants;
-import com.panzhihua.common.model.vos.LoginUserInfoVO;
+import java.util.Date;
+import java.util.concurrent.TimeUnit;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import com.panzhihua.common.model.vos.R;
+import com.panzhihua.common.model.vos.community.ComActVO;
+import com.panzhihua.common.model.vos.user.SysOperLogVO;
+import com.panzhihua.common.service.user.UserService;
+import com.panzhihua.common.utlis.IPUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.data.redis.core.ValueOperations;
@@ -14,8 +19,19 @@
 import org.springframework.security.core.Authentication;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.Resource;
-import java.util.concurrent.TimeUnit;
+import com.panzhihua.auth.service.LoginService;
+import com.panzhihua.common.constants.TokenConstant;
+import com.panzhihua.common.constants.UserConstants;
+import com.panzhihua.common.model.vos.LoginReturnVO;
+import com.panzhihua.common.model.vos.LoginReturnsVO;
+import com.panzhihua.common.model.vos.LoginUserInfoVO;
+import com.panzhihua.common.utlis.JWTTokenUtil;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import static java.util.Objects.nonNull;
 
 /**
  * @program: springcloud_k8s_panzhihuazhihuishequ
@@ -29,22 +45,25 @@
     private AuthenticationManager authenticationManager;
     @Autowired
     private StringRedisTemplate redisTemplate;
+    @Resource
+    private UserService userService;
 
     /**
      * 微信小程序登录
      *
-     * @param openId 微信标识
+     * @param openId
+     *            微信标识
      * @return jwt
      */
     @Override
-    public LoginReturnVO loginApplets(String openId) {
+    public LoginReturnVO loginApplets(String openId,String appId) {
         Authentication authentication = null;
         authentication = authenticationManager
-                .authenticate(new UsernamePasswordAuthenticationToken(openId+"_1", UserConstants.PASSWORD));
-        LoginUserInfoVO loginUser = (LoginUserInfoVO) authentication.getPrincipal();
+            .authenticate(new UsernamePasswordAuthenticationToken(openId + "_1"+"_"+appId, UserConstants.PASSWORD));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
         String token = JWTTokenUtil.generateToken(loginUser);
         String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
-        LoginReturnVO loginReturnVO=new LoginReturnVO();
+        LoginReturnVO loginReturnVO = new LoginReturnVO();
         loginReturnVO.setToken(token);
         loginReturnVO.setRefreshToken(refeshToken);
         return loginReturnVO;
@@ -53,31 +72,34 @@
     /**
      * 小程序用户登出
      *
-     * @param token 登录用户token
+     * @param token
+     *            登录用户token
      */
     @Override
     public void logoutApplets(String token) {
         ValueOperations<String, String> valueOperations = redisTemplate.opsForValue();
-        token= token.replaceAll(TokenConstant.TOKEN_PRE,"");
-        valueOperations.set(UserConstants.LOGOUT_TOKEN+token,token, TokenConstant.EXPIRETIME, TimeUnit.MINUTES);
+        token = token.replaceAll(TokenConstant.TOKEN_PRE, "");
+        valueOperations.set(UserConstants.LOGOUT_TOKEN + token, token, TokenConstant.EXPIRETIME, TimeUnit.MINUTES);
     }
 
     /**
      * 运营后台登录
      *
-     * @param account  账户
-     * @param password 密码
+     * @param account
+     *            账户
+     * @param password
+     *            密码
      * @return 登录结果
      */
     @Override
-    public LoginReturnVO loginAppletsBackStage(String account, String password) {
+    public LoginReturnVO loginAppletsBackStage(String account, String password,String appid) {
         Authentication authentication = null;
-        authentication = authenticationManager
-                .authenticate(new UsernamePasswordAuthenticationToken(account+"_2", password));
-        LoginUserInfoVO loginUser = (LoginUserInfoVO) authentication.getPrincipal();
+        authentication =
+            authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(account + "_2"+"_"+appid, password));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
         String token = JWTTokenUtil.generateToken(loginUser);
         String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
-        LoginReturnVO loginReturnVO=new LoginReturnVO();
+        LoginReturnVO loginReturnVO = new LoginReturnVO();
         loginReturnVO.setToken(token);
         loginReturnVO.setRefreshToken(refeshToken);
         return loginReturnVO;
@@ -86,19 +108,111 @@
     /**
      * 社区后台登录
      *
-     * @param account  账户
-     * @param password 密码
+     * @param account
+     *            账户
+     * @param password
+     *            密码
      * @return 登录结果
      */
     @Override
-    public LoginReturnVO loginCommunityBackage(String account, String password) {
+    public LoginReturnVO loginCommunityBackage(String account, String password,String appId) {
         Authentication authentication = null;
-        authentication = authenticationManager
-                .authenticate(new UsernamePasswordAuthenticationToken(account+"_3", password));
-        LoginUserInfoVO loginUser = (LoginUserInfoVO) authentication.getPrincipal();
+        authentication =
+            authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(account + "_3"+"_"+appId, password));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
         String token = JWTTokenUtil.generateToken(loginUser);
         String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
-        LoginReturnVO loginReturnVO=new LoginReturnVO();
+        ComActVO comActVO = loginUser.getComActVO();
+        LoginReturnVO loginReturnVO = new LoginReturnVO();
+        loginReturnVO.setToken(token);
+        loginReturnVO.setRefreshToken(refeshToken);
+        loginReturnVO.setCommunityId(loginUser.getCommunityId());
+        if (nonNull(comActVO)) {
+            loginReturnVO.setLat(comActVO.getLat());
+            loginReturnVO.setLng(comActVO.getLng());
+        }
+        //保存登录日志
+        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+        SysOperLogVO operlog = new SysOperLogVO();
+        operlog.setTitle("登录操作"); // 操作模块
+        operlog.setBusinessType(1); // 操作类型
+        operlog.setMethod("com.panzhihua.community_backstage.api.LoginApi.login"); // 请求方法
+        operlog.setAccount(loginUser.getAccount());
+        operlog.setOperName(loginUser.getName()); // 请求用户名称
+        operlog.setOperIp(IPUtil.getIpAddress(request)); // 请求IP
+        operlog.setOperUrl(request.getRequestURI()); // 请求URI
+        operlog.setRequestMethod(request.getMethod());
+        operlog.setOperLocation(IPUtil.getIpBelongAddress(request));
+        operlog.setOperTime(new Date()); // 创建时间
+        operlog.setCommunityId(loginUser.getCommunityId());
+        userService.addOperLog(operlog);
+        return loginReturnVO;
+    }
+
+    /**
+     * 商家后台登录
+     *
+     * @param account
+     *            账户
+     * @param password
+     *            密码
+     * @return 登录结果
+     */
+    @Override
+    public LoginReturnVO loginShopBackStage(String account, String password,String appId) {
+        Authentication authentication = null;
+        authentication =
+                authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(account + "_5"+"_"+appId, password));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
+        String token = JWTTokenUtil.generateToken(loginUser);
+        String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
+        ComActVO comActVO = loginUser.getComActVO();
+        LoginReturnVO loginReturnVO = new LoginReturnVO();
+        loginReturnVO.setToken(token);
+        loginReturnVO.setRefreshToken(refeshToken);
+        loginReturnVO.setCommunityId(loginUser.getCommunityId());
+        if (nonNull(comActVO)) {
+            loginReturnVO.setLat(comActVO.getLat());
+            loginReturnVO.setLng(comActVO.getLng());
+        }
+        //保存登录日志
+        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+        SysOperLogVO operlog = new SysOperLogVO();
+        operlog.setTitle("登录操作"); // 操作模块
+        operlog.setBusinessType(1); // 操作类型
+        operlog.setMethod("com.panzhihua.community_backstage.api.LoginApi.loginShopBackStage"); // 请求方法
+        operlog.setAccount(loginUser.getAccount());
+        operlog.setOperName(loginUser.getName()); // 请求用户名称
+        operlog.setOperIp(IPUtil.getIpAddress(request)); // 请求IP
+        operlog.setOperUrl(request.getRequestURI()); // 请求URI
+        operlog.setRequestMethod(request.getMethod());
+        operlog.setOperLocation(IPUtil.getIpBelongAddress(request));
+        operlog.setOperTime(new Date()); // 创建时间
+        operlog.setCommunityId(loginUser.getCommunityId());
+        userService.addOperLog(operlog);
+        return loginReturnVO;
+    }
+
+    /**
+     * 大数据统计平台(区、街道、社区三层登陆接口)
+     * 
+     * @param account
+     *            账户
+     * @param password
+     *            密码
+     * @author manailin
+     * @return 登录结果
+     * @date 2021-5-13 10:56
+     */
+    @Override
+    public LoginReturnVO loginBigDataBackStage(String account, String password,String appid) {
+        Authentication authentication = null;
+        authentication =
+            authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(account + "_8"+"_"+appid, password));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
+        String token = JWTTokenUtil.generateToken(loginUser);
+        String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
+        LoginReturnVO loginReturnVO = new LoginReturnVO();
         loginReturnVO.setToken(token);
         loginReturnVO.setRefreshToken(refeshToken);
         return loginReturnVO;
@@ -107,44 +221,178 @@
     /**
      * 商家后台登录
      *
-     * @param account  账户
+     * @param account
+     *            账户
+     * @param password
+     *            密码
+     * @return 登录结果
+     */
+    @Override
+    public LoginReturnsVO loginGridApp(String account, String password,String appid) {
+        Authentication authentication = null;
+        authentication =
+            authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(account + "_6"+"_"+appid, password));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
+        String token = JWTTokenUtil.generateToken(loginUser);
+        String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
+        LoginReturnsVO loginReturnVO = new LoginReturnsVO();
+        loginReturnVO.setToken(token);
+        loginReturnVO.setRefreshToken(refeshToken);
+        loginReturnVO.setUserId(loginUser.getUserId());
+        return loginReturnVO;
+    }
+
+    /**
+     * 商家后台登录
+     *
+     * @param account
+     *            账户
+     * @param password
+     *            密码
+     * @return 登录结果
+     */
+    @Override
+    public LoginReturnVO loginGridBackstage(String account, String password,String appid) {
+        Authentication authentication = null;
+        authentication =
+            authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(account + "_7"+"_"+appid, password));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
+        String token = JWTTokenUtil.generateToken(loginUser);
+        String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
+        LoginReturnVO loginReturnVO = new LoginReturnVO();
+        loginReturnVO.setToken(token);
+        loginReturnVO.setRefreshToken(refeshToken);
+        return loginReturnVO;
+    }
+
+    @Override
+    public LoginReturnVO loginCgBackage(String account, String password,String appid){
+        Authentication authentication = null;
+        authentication =
+                authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(account + "_9"+"_"+appid, password));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
+        String token = JWTTokenUtil.generateToken(loginUser);
+        String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
+        LoginReturnVO loginReturnVO = new LoginReturnVO();
+        loginReturnVO.setToken(token);
+        loginReturnVO.setRefreshToken(refeshToken);
+        return loginReturnVO;
+    }
+
+    @Override
+    public LoginReturnsVO loginAlarmApp(String account, String password,String appid) {
+        Authentication authentication = null;
+        authentication =
+                authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(account + "_10"+"_"+appid, password));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
+        String token = JWTTokenUtil.generateToken(loginUser);
+        String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
+        LoginReturnsVO loginReturnVO = new LoginReturnsVO();
+        loginReturnVO.setToken(token);
+        loginReturnVO.setRefreshToken(refeshToken);
+        loginReturnVO.setUserId(loginUser.getUserId());
+        return loginReturnVO;
+    }
+
+    /**
+     * 便民服务商家后台登录
+     * @param account 账户
      * @param password 密码
      * @return 登录结果
      */
     @Override
-    public LoginReturnVO loginShopBackStage(String account, String password) {
-        Authentication authentication = null;
-        authentication = authenticationManager
-                .authenticate(new UsernamePasswordAuthenticationToken(account+"_5", password));
-        LoginUserInfoVO loginUser = (LoginUserInfoVO) authentication.getPrincipal();
+    public LoginReturnVO loginMerchantBackStage(String account, String password,String appid) {
+        Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(account + "_10"+"_"+appid, password));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
         String token = JWTTokenUtil.generateToken(loginUser);
         String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
-        LoginReturnVO loginReturnVO=new LoginReturnVO();
+        LoginReturnVO loginReturnVO = new LoginReturnVO();
         loginReturnVO.setToken(token);
         loginReturnVO.setRefreshToken(refeshToken);
         return loginReturnVO;
     }
 
     /**
-     * 大数据统计平台(区、街道、社区三层登陆接口)
-     * @param account 账户
-     * @param password 密码
-     * @author manailin
-     * @return 登录结果
-     * @date 2021-5-13 10:56
+     * 西区大屏登录
+     * @param account   账号
+     * @param password  密码
+     * @return  登录结果
      */
     @Override
-    public LoginReturnVO loginBigDataBackStage(String account, String password) {
-        Authentication authentication = null;
-        authentication = authenticationManager
-                .authenticate(new UsernamePasswordAuthenticationToken(account+"_8", password));
-        LoginUserInfoVO loginUser = (LoginUserInfoVO) authentication.getPrincipal();
+    public LoginReturnVO loginXQDP(String account, String password,String appid){
+        Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(account + "_15"+"_"+appid, password));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
         String token = JWTTokenUtil.generateToken(loginUser);
         String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
-        LoginReturnVO loginReturnVO=new LoginReturnVO();
+        LoginReturnVO loginReturnVO = new LoginReturnVO();
         loginReturnVO.setToken(token);
         loginReturnVO.setRefreshToken(refeshToken);
         return loginReturnVO;
     }
 
+    /**
+     * 微商业街用户登录
+     * @param account 账户
+     * @param password 密码
+     * @return 登录结果
+     */
+    @Override
+    public LoginReturnVO loginMcsUser(String account, String password,String appid) {
+        Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(account + "_11"+"_"+appid, password));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
+        String token = JWTTokenUtil.generateToken(loginUser);
+        String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
+        LoginReturnVO loginReturnVO = new LoginReturnVO();
+        loginReturnVO.setToken(token);
+        loginReturnVO.setRefreshToken(refeshToken);
+        return loginReturnVO;
+    }
+
+    @Override
+    public LoginReturnVO tfLogin(String account, String password, String appid) {
+        Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(account + "_16"+"_"+appid, password));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
+        String token = JWTTokenUtil.generateToken(loginUser);
+        String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
+        LoginReturnVO loginReturnVO = new LoginReturnVO();
+        loginReturnVO.setToken(token);
+        loginReturnVO.setRefreshToken(refeshToken);
+        return loginReturnVO;
+    }
+
+    /**
+     * 电动车商城后台用户登录
+     *
+     * @param account
+     *            账户
+     * @param password
+     *            密码
+     * @return 登录结果
+     */
+    @Override
+    public LoginReturnVO loginBatteryUser(String account, String password,String appid) {
+        Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(account + "_20"+"_"+appid, password));
+        LoginUserInfoVO loginUser = (LoginUserInfoVO)authentication.getPrincipal();
+        String token = JWTTokenUtil.generateToken(loginUser);
+        String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
+        LoginReturnVO loginReturnVO = new LoginReturnVO();
+        loginReturnVO.setToken(token);
+        loginReturnVO.setRefreshToken(refeshToken);
+        return loginReturnVO;
+    }
+    /**
+     * 三个身边后台用户登录
+     */
+    @Override
+    public LoginReturnVO loginThreeAround(Integer userId) {
+        LoginUserInfoVO loginUser = new LoginUserInfoVO();
+        loginUser.setUserId(userId.longValue());
+        loginUser.setType(21);
+        String token = JWTTokenUtil.generateToken(loginUser);
+        String refeshToken = JWTTokenUtil.generateRefeshToken(loginUser);
+        LoginReturnVO loginReturnVO = new LoginReturnVO();
+        loginReturnVO.setToken(token);
+        loginReturnVO.setRefreshToken(refeshToken);
+        return loginReturnVO;
+    }
 }

--
Gitblit v1.7.1