Pārlūkot izejas kodu

jwt校验更改以及分润报表查询更改

xie.kaifeng 1 gadu atpakaļ
vecāks
revīzija
3d8a550d36

+ 1 - 0
mtp3-century/src/main/java/com/muchinfo/mtp3century/filter/JwtAuthorizationFilter.java

@@ -84,6 +84,7 @@ public class JwtAuthorizationFilter extends BasicAuthenticationFilter {
     private void refreshToken(String token, HttpServletResponse response) {
         token = JwtUtil.refreshToken(token);
         // 将token添加到header中
+        response.setHeader("Access-Control-Expose-Headers","Authorization");
         response.setHeader(JwtUtil.TOKEN_HEADER, JwtUtil.TOKEN_PREFIX + token);
     }
 }

+ 8 - 10
mtp3-century/src/main/java/com/muchinfo/mtp3century/filter/JwtLoginFilter.java

@@ -61,14 +61,12 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
         StringBuilder strBuilder = new StringBuilder();
         String inputStr;
         while ((inputStr = streamReader.readLine()) != null) strBuilder.append(inputStr);
-        Systemmanager sysUser = JsonUtils.toBean(CenturyDecryptUtil.decryptForJson(strBuilder.toString(),request), Systemmanager.class);
+        Systemmanager sysUser = JsonUtils.toBean(CenturyDecryptUtil.decryptForJson(strBuilder.toString(), request), Systemmanager.class);
         assert sysUser != null;
         String username = sysUser.getUsername();
         username = username != null ? username : "";
         String password = sysUser.getPassword();
         password = password != null ? password : "";
-//        String lockPwd = EncryptionUtils.encryptSHA(username + password);
-//        UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, lockPwd);
         UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password);
         setDetails(request, authRequest);
         return getAuthenticationManager().authenticate(authRequest);
@@ -98,7 +96,7 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
         String token = JwtUtil.TOKEN_PREFIX + JwtUtil.generateToken(authResult.getName(), sb.toString());
         // 将token添加到header中
         response.setHeader(JwtUtil.TOKEN_HEADER, token);
-        ResponseUtils.writeSucceed(response, HttpServletResponse.SC_OK, "用户认证通过!", true ,token);
+        ResponseUtils.writeSucceed(response, HttpServletResponse.SC_OK, "用户认证通过!", true, token);
         log.info("登录成功,username: {}, token: {}", authResult.getName(), token);
     }
 
@@ -146,17 +144,17 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
 
         //判断异常类
         if (failed instanceof InternalAuthenticationServiceException) {
-            ResponseUtils.writeFiled(response, HttpServletResponse.SC_FORBIDDEN, "认证服务不正常!", false);
+            ResponseUtils.writeFiled(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "认证服务不正常!", false);
         } else if (failed instanceof UsernameNotFoundException) {
-            ResponseUtils.writeFiled(response, HttpServletResponse.SC_FORBIDDEN, "用户账户不存在!", false);
+            ResponseUtils.writeFiled(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "用户账户不存在!", false);
         } else if (failed instanceof BadCredentialsException) {
-            ResponseUtils.writeFiled(response, HttpServletResponse.SC_FORBIDDEN, loginPWDFail_msg, false);
+            ResponseUtils.writeFiled(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, loginPWDFail_msg == null ? failed.getMessage() : loginPWDFail_msg, false);
         } else if (failed instanceof LockedException) {
-            ResponseUtils.writeFiled(response, HttpServletResponse.SC_FORBIDDEN, "用户账户已被锁!", false);
+            ResponseUtils.writeFiled(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "用户账户已被锁!", false);
         } else if (failed instanceof CredentialsExpiredException) {
-            ResponseUtils.writeFiled(response, HttpServletResponse.SC_FORBIDDEN, "用户密码已失效!", false);
+            ResponseUtils.writeFiled(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "用户密码已失效!", false);
         } else if (failed instanceof DisabledException) {
-            ResponseUtils.writeFiled(response, HttpServletResponse.SC_FORBIDDEN, "用户账户已被锁!", false);
+            ResponseUtils.writeFiled(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "用户账户已被锁!", false);
         }
     }
 }

+ 15 - 34
mtp3-century/src/main/resources/mapper/ReckonDaydividecountdetailMapper.xml

@@ -69,17 +69,14 @@
                                 and u.parentuserid = #{vo.areaid} and u.usertype=2
                             </when>
                             <otherwise>
-                                and t.areaid = #{areaid}
+                                and t.areaid = #{vo.areaid}
                             </otherwise>
                         </choose>
                     </if>
 
-                    <if test="vo.parentareaid != null">
+                    <if test="vo.parentuserid != null">
                         and t.areaid in (select userid from useraccount uo where
-                        uo.userid=${vo.parentareaid} or uo.parentuserid=${vo.parentareaid})
-                    </if>
-                    <if test="vo.areatype != null and vo.areatype != ''">
-                        and t.areatype = #{areatype}
+                        uo.userid=${vo.parentuserid} or uo.parentuserid=${vo.parentuserid})
                     </if>
                 </where>
             </when>
@@ -121,16 +118,13 @@
                                 )
                             </when>
                             <otherwise>
-                                and t.areaid = #{areaid}
+                                and t.areaid = #{vo.areaid}
                             </otherwise>
                         </choose>
                     </if>
-                    <if test="vo.parentareaid != null">
+                    <if test="vo.parentuserid != null">
                         and t.areaid in (select userid from useraccount uo where
-                        uo.userid=${vo.parentareaid} or uo.parentuserid=${vo.parentareaid})
-                    </if>
-                    <if test="vo.areatype != null and vo.areatype != ''">
-                        and t.areatype = #{vo.areatype}
+                        uo.userid=${vo.parentuserid} or uo.parentuserid=${vo.parentuserid})
                     </if>
                 </where>
                 group by t.goodsid,t.marketid, t.areaid, t.areatype,t.tradedate, t.areaaccountid, t.tradefeetype
@@ -165,16 +159,13 @@
                                 )
                             </when>
                             <otherwise>
-                                and t.areaid = #{areaid}
+                                and t.areaid = #{vo.areaid}
                             </otherwise>
                         </choose>
                     </if>
-                    <if test="vo.parentareaid != null">
+                    <if test="vo.parentuserid != null">
                         and t.areaid in (select userid from useraccount uo where
-                        uo.userid=${vo.parentareaid} or uo.parentuserid=${vo.parentareaid})
-                    </if>
-                    <if test="vo.areatype != null and vo.areatype != ''">
-                        and t.areatype = #{vo.areatype}
+                        uo.userid=${vo.parentuserid} or uo.parentuserid=${vo.parentuserid})
                     </if>
                 </where>
                 group by t.goodsid, t.marketid,t.areaid, t.areatype,t.tradedate, t.areaaccountid, t.tradefeetype
@@ -222,9 +213,6 @@
                 ) g on t.goodsid = g.goodsid
                 left join market m on g.marketid = m.marketid
                 <where>
-                    <if test="vo.areatype != null and vo.areatype != ''">
-                        and t.areatype = #{vo.areatype}
-                    </if>
                     <if test="vo.cycletype !=null and vo.cycletype != ''">
                         and t.cycletype=#{vo.cycletype}
                     </if>
@@ -251,9 +239,8 @@
                             </otherwise>
                         </choose>
                     </if>
-                    <if test="vo.parentareaid != null">
-                        and t.areaid like concat('#{vo.parentareaid}', '%')
-
+                    <if test="vo.parentuserid != null">
+                        and t.areaid like concat('#{vo.parentuserid}', '%')
                     </if>
                 </where>
                 order by t.updatetime
@@ -286,12 +273,9 @@
                             </otherwise>
                         </choose>
                     </if>
-                    <if test="vo.parentareaid != null">
+                    <if test="vo.parentuserid != null">
                         and t.areaid in (select userid from useraccount uo where
-                        uo.userid=${vo.parentareaid} or uo.parentuserid=${vo.parentareaid})
-                    </if>
-                    <if test="vareatype != null and vo.areatype != ''">
-                        and t.areatype = #{vo.areatype}
+                        uo.userid=${vo.parentuserid} or uo.parentuserid=${vo.parentuserid})
                     </if>
                     <if test="vo.cycletype !=null and vo.cycletype != ''">
                         and t.cycletype=#{vo.cycletype}
@@ -350,12 +334,9 @@
                             </otherwise>
                         </choose>
                     </if>
-                    <if test="vo.parentareaid != null">
+                    <if test="vo.parentuserid != null">
                         and t.areaid in (select userid from useraccount uo where
-                        uo.userid=${vo.parentareaid} or uo.parentuserid=${vo.parentareaid})
-                    </if>
-                    <if test="vo.areatype != null and vo.areatype != ''">
-                        and t.areatype = #{vo.areatype}
+                        uo.userid=${vo.parentuserid} or uo.parentuserid=${vo.parentuserid})
                     </if>
                     <if test="vo.cycletype !=null and vo.cycletype != ''">
                         and t.cycletype=#{vo.cycletype}