ZhuDeKang 1 месяц назад
Родитель
Сommit
5616495c33

+ 3 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java

@@ -96,15 +96,15 @@ public class SysProfileController extends BaseController
         LoginUser loginUser = getLoginUser();
         String userName = loginUser.getUsername();
         String password = loginUser.getPassword();
-        if (!SecurityUtils.matchesPassword(sm4Util,oldPassword, password))
+        if (!SecurityUtils.matchesPassword(oldPassword, password))
         {
             return error("修改密码失败,旧密码错误");
         }
-        if (SecurityUtils.matchesPassword(sm4Util,newPassword, password))
+        if (SecurityUtils.matchesPassword(newPassword, password))
         {
             return error("新密码不能与旧密码相同");
         }
-        newPassword = SecurityUtils.encryptPassword(sm4Util,newPassword);
+        newPassword = SecurityUtils.encryptPassword(newPassword);
         if (userService.resetUserPwd(userName, newPassword) > 0)
         {
             // 更新缓存用户密码

+ 2 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java

@@ -128,7 +128,7 @@ public class SysUserController extends BaseController
             return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
         }
         user.setCreateBy(getUsername());
-        user.setPassword(SecurityUtils.encryptPassword(sm4Util,user.getPassword()));
+        user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
 
         user.setPhonenumber(sm4Util.encrypt(user.getPhonenumber()));
         user.setEmail(sm4Util.encrypt(user.getEmail()));
@@ -184,7 +184,7 @@ public class SysUserController extends BaseController
     {
         userService.checkUserAllowed(user);
         userService.checkUserDataScope(user.getUserId());
-        user.setPassword(SecurityUtils.encryptPassword(sm4Util,user.getPassword()));
+        user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
         user.setUpdateBy(getUsername());
         return toAjax(userService.resetPwd(user));
     }

+ 5 - 360
ruoyi-admin/src/test/java/com/ruoyi/JasyptTest.java

@@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysRole;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.SM4Util;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.file.FileUtils;
 import com.ruoyi.interfaces.domain.MdModelInfo;
 import com.ruoyi.interfaces.domain.PtService;
@@ -56,366 +57,10 @@ public class JasyptTest {
 
     @Test
     public void test() throws IOException {
-String s = "{\n" +
-        "  \"nodes\": [\n" +
-        "    {\n" +
-        "      \"id\": \"1\",\n" +
-        "      \"type\": \"startNode\",\n" +
-        "      \"initialized\": false,\n" +
-        "      \"position\": {\n" +
-        "        \"x\": -600,\n" +
-        "        \"y\": -300\n" +
-        "      },\n" +
-        "      \"data\": {\n" +
-        "        \"label\": \"开始\",\n" +
-        "        \"parameters\": [\n" +
-        "          {\n" +
-        "            \"name\": \"beginTm\",\n" +
-        "            \"dataType\": \"string\",\n" +
-        "            \"refType\": \"input\"\n" +
-        "          }\n" +
-        "        ],\n" +
-        "        \"loading\": false,\n" +
-        "        \"isSuccess\": true,\n" +
-        "        \"isFail\": false\n" +
-        "      }\n" +
-        "    },\n" +
-        "    {\n" +
-        "      \"id\": \"2\",\n" +
-        "      \"type\": \"endNode\",\n" +
-        "      \"initialized\": false,\n" +
-        "      \"position\": {\n" +
-        "        \"x\": 885,\n" +
-        "        \"y\": 90\n" +
-        "      },\n" +
-        "      \"data\": {\n" +
-        "        \"label\": \"结束\",\n" +
-        "        \"outputDefs\": [\n" +
-        "          {\n" +
-        "            \"name\": \"data\",\n" +
-        "            \"dataType\": \"array\",\n" +
-        "            \"refType\": \"ref\",\n" +
-        "            \"ref\": \"1763516549902862.data\"\n" +
-        "          }\n" +
-        "        ]\n" +
-        "      }\n" +
-        "    },\n" +
-        "    {\n" +
-        "      \"id\": \"1763515700772804\",\n" +
-        "      \"type\": \"serviceNode\",\n" +
-        "      \"initialized\": false,\n" +
-        "      \"position\": {\n" +
-        "        \"x\": -240,\n" +
-        "        \"y\": -135\n" +
-        "      },\n" +
-        "      \"data\": {\n" +
-        "        \"id\": \"2ae45987679c46248a95bc14432844b1\",\n" +
-        "        \"pid\": \"56d0db1d-27fe-4a9c-9060-c1429f3d2c8d\",\n" +
-        "        \"label\": \"获取雨量数据列表\",\n" +
-        "        \"nodeType\": \"SERVICE\",\n" +
-        "\n" +
-        "        \"appId\":123,\n" +
-        "\n" +
-        "        \"service\": {\n" +
-        "          \"srvId\": \"2ae45987679c46248a95bc14432844b1\",\n" +
-        "          \"mdid\": \"56d0db1d-27fe-4a9c-9060-c1429f3d2c8d\",\n" +
-        "          \"cateCode\": \"\",\n" +
-        "          \"name\": \"获取雨量数据列表\",\n" +
-        "          \"intro\": \"获取雨量数据\",\n" +
-        "          \"serviceSource\": null,\n" +
-        "          \"serviceDept\": null,\n" +
-        "          \"manageName\": null,\n" +
-        "          \"developUnit\": null,\n" +
-        "          \"developContacter\": null,\n" +
-        "          \"maintainUnit\": null,\n" +
-        "          \"maintainContacer\": null,\n" +
-        "          \"upCycl\": null,\n" +
-        "          \"openCndtn\": null,\n" +
-        "          \"adName\": null,\n" +
-        "          \"dataField\": null,\n" +
-        "          \"dataRange\": null,\n" +
-        "          \"userId\": \"1\",\n" +
-        "          \"status\": null,\n" +
-        "          \"note\": null,\n" +
-        "          \"type\": \"HTTP\",\n" +
-        "          \"url\": \"/sh-api/getPptnList\",\n" +
-        "          \"rqtype\": \"POST\",\n" +
-        "          \"rptype\": \"1\",\n" +
-        "          \"rpcontent\": \"{\\\"msg\\\":\\\"操作成功\\\",\\\"code\\\":200,\\\"data\\\":[{\\\"stcd\\\":\\\"1111111\\\",\\\"stnm\\\":null,\\\"tm\\\":\\\"2025-11-18 16:29:32\\\",\\\"drp\\\":0.0,\\\"intv\\\":1.0,\\\"pdr\\\":null,\\\"dyp\\\":null,\\\"wth\\\":\\\"\\\",\\\"tmy\\\":null,\\\"lgtd\\\":1.0,\\\"lttd\\\":1.0},{\\\"stcd\\\":\\\"1111111\\\",\\\"stnm\\\":null,\\\"tm\\\":\\\"2025-11-18 16:29:32\\\",\\\"drp\\\":0.0,\\\"intv\\\":1.0,\\\"pdr\\\":null,\\\"dyp\\\":null,\\\"wth\\\":\\\"\\\",\\\"tmy\\\":null,\\\"lgtd\\\":1.0,\\\"lttd\\\":1.0},{\\\"stcd\\\":\\\"1111111\\\",\\\"stnm\\\":null,\\\"tm\\\":\\\"2025-11-18 16:29:32\\\",\\\"drp\\\":0.0,\\\"intv\\\":1.0,\\\"pdr\\\":null,\\\"dyp\\\":null,\\\"wth\\\":\\\"\\\",\\\"tmy\\\":null,\\\"lgtd\\\":1.0,\\\"lttd\\\":1.0},{\\\"stcd\\\":\\\"1111111\\\",\\\"stnm\\\":null,\\\"tm\\\":\\\"2025-11-18 16:29:32\\\",\\\"drp\\\":0.0,\\\"intv\\\":1.0,\\\"pdr\\\":null,\\\"dyp\\\":null,\\\"wth\\\":\\\"\\\",\\\"tmy\\\":null,\\\"lgtd\\\":1.0,\\\"lttd\\\":1.0}]}\",\n" +
-        "          \"proxyAddress\": null,\n" +
-        "          \"proxyPath\": \"\",\n" +
-        "          \"gatewayId\": \"f9d56764047a49ea957163e87f3492dc\",\n" +
-        "          \"example\": \"\",\n" +
-        "          \"cnt\": 0,\n" +
-        "          \"viewNum\": 0,\n" +
-        "          \"applyNum\": 0,\n" +
-        "          \"dataNum\": 0,\n" +
-        "          \"tm\": \"2025-11-18\",\n" +
-        "          \"uptm\": \"2025-11-18\",\n" +
-        "          \"rlstm\": \"2025-11-18\",\n" +
-        "          \"releaseTime\": \"2025-11-18\",\n" +
-        "          \"attentionId\": null,\n" +
-        "          \"params\": [\n" +
-        "            {\n" +
-        "              \"srvId\": \"2ae45987679c46248a95bc14432844b1\",\n" +
-        "              \"paramCode\": \"beginTm\",\n" +
-        "              \"paramName\": \"开始时间\",\n" +
-        "              \"paramType\": \"string\",\n" +
-        "              \"paramValue\": \"\",\n" +
-        "              \"paramFormat\": null,\n" +
-        "              \"paramNote\": null,\n" +
-        "              \"sort\": 0,\n" +
-        "              \"paramObject\": \"\"\n" +
-        "            },\n" +
-        "            {\n" +
-        "              \"srvId\": \"2ae45987679c46248a95bc14432844b1\",\n" +
-        "              \"paramCode\": \"endTm\",\n" +
-        "              \"paramName\": \"结束时间\",\n" +
-        "              \"paramType\": \"string\",\n" +
-        "              \"paramValue\": null,\n" +
-        "              \"paramFormat\": null,\n" +
-        "              \"paramNote\": null,\n" +
-        "              \"sort\": 1,\n" +
-        "              \"paramObject\": null\n" +
-        "            }\n" +
-        "          ],\n" +
-        "          \"state\": \"1\",\n" +
-        "          \"sort\": null,\n" +
-        "          \"audit\": \"0\",\n" +
-        "          \"auditBy\": null,\n" +
-        "          \"auditRemark\": null,\n" +
-        "          \"auditTime\": null,\n" +
-        "          \"publish\": \"0\",\n" +
-        "          \"publishBy\": null,\n" +
-        "          \"publishTime\": null,\n" +
-        "          \"senState\": null,\n" +
-        "          \"dataSignature\": \"3045022067c584d2219e519ea682b2d48062f3042b1ed7b72ca485153d8cb9c99b6f30a9022100c565ca82582ad864210782988f9043a815e9778f55a9836d2fcba5cd424bf3f4\"\n" +
-        "        },\n" +
-        "        \"parameters\": [\n" +
-        "          {\n" +
-        "            \"name\": \"beginTm\",\n" +
-        "            \"ref\": \"1.beginTm\",\n" +
-        "            \"dataType\": \"string\",\n" +
-        "            \"refType\": \"ref\"\n" +
-        "          },\n" +
-        "          {\n" +
-        "            \"name\": \"endTm\",\n" +
-        "            \"ref\": \"1.beginTm\",\n" +
-        "            \"dataType\": \"string\",\n" +
-        "            \"refType\": \"ref\"\n" +
-        "          }\n" +
-        "        ],\n" +
-        "        \"loading\": false,\n" +
-        "        \"isSuccess\": true,\n" +
-        "        \"isFail\": false\n" +
-        "      }\n" +
-        "    },\n" +
-        "    {\n" +
-        "      \"id\": \"1763516549902862\",\n" +
-        "      \"type\": \"serviceNode\",\n" +
-        "      \"initialized\": false,\n" +
-        "      \"position\": {\n" +
-        "        \"x\": 150,\n" +
-        "        \"y\": -60\n" +
-        "      },\n" +
-        "      \"data\": {\n" +
-        "        \"id\": \"c48bb6d3a73f41a19d0eccb33fe34424\",\n" +
-        "        \"pid\": \"56d0db1d-27fe-4a9c-9060-c1429f3d2c8d\",\n" +
-        "        \"label\": \"等值面数据计算\",\n" +
-        "        \"nodeType\": \"SERVICE\",\n" +
-        "        \"service\": {\n" +
-        "          \"srvId\": \"c48bb6d3a73f41a19d0eccb33fe34424\",\n" +
-        "          \"mdid\": \"56d0db1d-27fe-4a9c-9060-c1429f3d2c8d\",\n" +
-        "          \"cateCode\": \"\",\n" +
-        "          \"name\": \"等值面数据计算\",\n" +
-        "          \"intro\": \"\",\n" +
-        "          \"serviceSource\": null,\n" +
-        "          \"serviceDept\": null,\n" +
-        "          \"manageName\": null,\n" +
-        "          \"developUnit\": null,\n" +
-        "          \"developContacter\": null,\n" +
-        "          \"maintainUnit\": null,\n" +
-        "          \"maintainContacer\": null,\n" +
-        "          \"upCycl\": null,\n" +
-        "          \"openCndtn\": null,\n" +
-        "          \"adName\": null,\n" +
-        "          \"dataField\": null,\n" +
-        "          \"dataRange\": null,\n" +
-        "          \"userId\": \"1\",\n" +
-        "          \"status\": null,\n" +
-        "          \"note\": null,\n" +
-        "          \"type\": \"HTTP\",\n" +
-        "          \"url\": \"/sh-api/getRain\",\n" +
-        "          \"rqtype\": \"POST\",\n" +
-        "          \"rptype\": \"1\",\n" +
-        "          \"rpcontent\": \"{\\n    \\\"msg\\\": \\\"操作成功\\\",\\n    \\\"code\\\": 200,\\n    \\\"data\\\": {\\n        \\\"features\\\": [\\n            {\\n                \\\"type\\\": \\\"Feature\\\",\\n                \\\"geometry\\\": {\\n                    \\\"type\\\": \\\"MultiPolygon\\\",\\n                    \\\"coordinates\\\": [\\n                        [\\n                            [\\n                                [\\n                                    106.739,\\n                                    39.8614\\n                                ]\\n                            ]\\n                        ]\\n                    ]\\n                },\\n                \\\"properties\\\": {\\n                    \\\"lvalue\\\": 0.4,\\n                    \\\"hvalue\\\": 0.4\\n                },\\n                \\\"id\\\": \\\"fid-69939b06_19a96366106_-7e6d\\\"\\n            }\\n        ],\\n        \\\"type\\\": \\\"FeatureCollection\\\"\\n    }\\n}\",\n" +
-        "          \"proxyAddress\": null,\n" +
-        "          \"proxyPath\": \"\",\n" +
-        "          \"gatewayId\": \"f9d56764047a49ea957163e87f3492dc\",\n" +
-        "          \"example\": \"\",\n" +
-        "          \"cnt\": 0,\n" +
-        "          \"viewNum\": 0,\n" +
-        "          \"applyNum\": 0,\n" +
-        "          \"dataNum\": 0,\n" +
-        "          \"tm\": \"2025-11-18\",\n" +
-        "          \"uptm\": \"2025-11-18\",\n" +
-        "          \"rlstm\": \"2025-11-18\",\n" +
-        "          \"releaseTime\": \"2025-11-18\",\n" +
-        "          \"attentionId\": null,\n" +
-        "          \"params\": null,\n" +
-        "          \"state\": \"1\",\n" +
-        "          \"sort\": 2,\n" +
-        "          \"audit\": \"0\",\n" +
-        "          \"auditBy\": null,\n" +
-        "          \"auditRemark\": null,\n" +
-        "          \"auditTime\": null,\n" +
-        "          \"publish\": \"0\",\n" +
-        "          \"publishBy\": null,\n" +
-        "          \"publishTime\": null,\n" +
-        "          \"senState\": null,\n" +
-        "          \"dataSignature\": \"3044022072b3deb5ac7987334ca811e4099f74b56987e21fec2f0fac7639d3d71a449f570220218fe9b942f5a20733988f2225b0096c50b84e127948601c9ecd79ee720791c2\"\n" +
-        "        }\n" +
-        "      }\n" +
-        "    },\n" +
-        "    {\n" +
-        "      \"id\": \"1763608793434362\",\n" +
-        "      \"type\": \"saveNode\",\n" +
-        "      \"initialized\": false,\n" +
-        "      \"position\": {\n" +
-        "        \"x\": 570,\n" +
-        "        \"y\": 30\n" +
-        "      },\n" +
-        "      \"data\": {\n" +
-        "        \"label\": \"存储节点\",\n" +
-        "        \"nodeType\": \"tool\",\n" +
-        "\n" +
-        "        \"appId\":123,\n" +
-        "\n" +
-        "        \"value\": \"存储节点\"\n" +
-        "      }\n" +
-        "    }\n" +
-        "  ],\n" +
-        "  \"edges\": [\n" +
-        "    {\n" +
-        "      \"id\": \"vueflow__edge-1-1763515700772804\",\n" +
-        "      \"type\": \"default\",\n" +
-        "      \"source\": \"1\",\n" +
-        "      \"target\": \"1763515700772804\",\n" +
-        "      \"sourceHandle\": null,\n" +
-        "      \"targetHandle\": null,\n" +
-        "      \"data\": {},\n" +
-        "      \"label\": \"\",\n" +
-        "      \"style\": {\n" +
-        "        \"stroke\": \"#79bbff\",\n" +
-        "        \"strokeWidth\": 2,\n" +
-        "        \"type\": \"bezier\",\n" +
-        "        \"fill\": \"none\"\n" +
-        "      },\n" +
-        "      \"markerEnd\": {\n" +
-        "        \"type\": \"arrow\",\n" +
-        "        \"color\": \"#79bbff\",\n" +
-        "        \"width\": 15,\n" +
-        "        \"height\": 15\n" +
-        "      },\n" +
-        "      \"sourceX\": -388.32869182527065,\n" +
-        "      \"sourceY\": -270.06712341308594,\n" +
-        "      \"targetX\": -242.99760034195967,\n" +
-        "      \"targetY\": -85.79632097846783\n" +
-        "    },\n" +
-        "    {\n" +
-        "      \"id\": \"vueflow__edge-1763515700772804-1763516549902862\",\n" +
-        "      \"type\": \"default\",\n" +
-        "      \"source\": \"1763515700772804\",\n" +
-        "      \"target\": \"1763516549902862\",\n" +
-        "      \"sourceHandle\": null,\n" +
-        "      \"targetHandle\": null,\n" +
-        "      \"data\": {},\n" +
-        "      \"label\": \"\",\n" +
-        "      \"style\": {\n" +
-        "        \"stroke\": \"#79bbff\",\n" +
-        "        \"strokeWidth\": 2,\n" +
-        "        \"type\": \"bezier\",\n" +
-        "        \"fill\": \"none\"\n" +
-        "      },\n" +
-        "      \"markerEnd\": {\n" +
-        "        \"type\": \"arrow\",\n" +
-        "        \"color\": \"#79bbff\",\n" +
-        "        \"width\": 15,\n" +
-        "        \"height\": 15\n" +
-        "      },\n" +
-        "      \"sourceX\": 9.61110267965904,\n" +
-        "      \"sourceY\": -85.79632097846783,\n" +
-        "      \"targetX\": 147.00239965804033,\n" +
-        "      \"targetY\": -10.79632097846784\n" +
-        "    },\n" +
-        "    {\n" +
-        "      \"id\": \"vueflow__edge-1763516549902862-1763608793434362\",\n" +
-        "      \"type\": \"default\",\n" +
-        "      \"source\": \"1763516549902862\",\n" +
-        "      \"target\": \"1763608793434362\",\n" +
-        "      \"sourceHandle\": null,\n" +
-        "      \"targetHandle\": null,\n" +
-        "      \"data\": {},\n" +
-        "      \"label\": \"\",\n" +
-        "      \"style\": {\n" +
-        "        \"stroke\": \"#79bbff\",\n" +
-        "        \"strokeWidth\": 2,\n" +
-        "        \"type\": \"bezier\",\n" +
-        "        \"fill\": \"none\"\n" +
-        "      },\n" +
-        "      \"markerEnd\": {\n" +
-        "        \"type\": \"arrow\",\n" +
-        "        \"color\": \"#79bbff\",\n" +
-        "        \"width\": 15,\n" +
-        "        \"height\": 15\n" +
-        "      },\n" +
-        "      \"sourceX\": 399.61110267965904,\n" +
-        "      \"sourceY\": -10.79632097846784,\n" +
-        "      \"targetX\": 567.0020866090777,\n" +
-        "      \"targetY\": 59.932854453569774\n" +
-        "    },\n" +
-        "    {\n" +
-        "      \"id\": \"vueflow__edge-1763608793434362-2\",\n" +
-        "      \"type\": \"default\",\n" +
-        "      \"source\": \"1763608793434362\",\n" +
-        "      \"target\": \"2\",\n" +
-        "      \"sourceHandle\": null,\n" +
-        "      \"targetHandle\": null,\n" +
-        "      \"data\": {},\n" +
-        "      \"label\": \"\",\n" +
-        "      \"style\": {\n" +
-        "        \"stroke\": \"#79bbff\",\n" +
-        "        \"strokeWidth\": 2,\n" +
-        "        \"type\": \"bezier\",\n" +
-        "        \"fill\": \"none\"\n" +
-        "      },\n" +
-        "      \"markerEnd\": {\n" +
-        "        \"type\": \"arrow\",\n" +
-        "        \"color\": \"#79bbff\",\n" +
-        "        \"width\": 15,\n" +
-        "        \"height\": 15\n" +
-        "      },\n" +
-        "      \"sourceX\": 781.67129017445,\n" +
-        "      \"sourceY\": 59.932854453569774,\n" +
-        "      \"targetX\": 882.0023193359375,\n" +
-        "      \"targetY\": 119.932861328125\n" +
-        "    }\n" +
-        "  ],\n" +
-        "  \"position\": [\n" +
-        "    335.5230568199554,\n" +
-        "    402.6419012459621\n" +
-        "  ],\n" +
-        "  \"zoom\": 0.7798800184586985,\n" +
-        "  \"viewport\": {\n" +
-        "    \"x\": 335.5230568199554,\n" +
-        "    \"y\": 402.6419012459621,\n" +
-        "    \"zoom\": 0.7798800184586985\n" +
-        "  }\n" +
-        "}";
-        String s1 = FileUtils.writeImportBytes(s.getBytes(StandardCharsets.UTF_8), "json");
-
-        System.out.println(s1);
-
+        String s = SecurityUtils.encryptPassword( "Gw#$1601");
+        System.out.println(s);
+        boolean b = SecurityUtils.matchesPassword( "Gw#$1601", s);
+        System.out.println(b);
 
 /*
         List<MdModelInfo> mdModelInfos = modelMapper.selectMdModelInfoList(new MdModelInfo());

+ 1 - 1
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/service/impl/PtServiceLogStatisServiceImpl.java

@@ -88,7 +88,7 @@ public class PtServiceLogStatisServiceImpl implements IPtServiceLogStatisService
     public List<PtServiceLogStatisVo> selectMdEfficiency(MdModelInfo modelInfo) {
         List<PtServiceLogStatisVo> ptServiceLogStatisVos = ptServiceLogStatisMapper.selectMdEfficiency(modelInfo);
         ptServiceLogStatisVos.forEach(v -> {
-            if (StringUtils.isNotNull(v.getStatisNum())) {
+            if (StringUtils.isNotNull(v.getStatisNum()) && StringUtils.isNotNull(v.getExecTm())) {
                 v.setRate(Arith.div(v.getExecTm(), v.getStatisNum(), 0));
                 if (v.getRate() >= 6000) {
                     v.setRateLv("差");

+ 39 - 62
ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java

@@ -6,6 +6,7 @@ import java.util.Base64;
 import java.util.Collection;
 import java.util.List;
 import java.util.stream.Collectors;
+
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@@ -18,23 +19,18 @@ import com.ruoyi.common.exception.ServiceException;
 
 /**
  * 安全服务工具类
- * 
+ *
  * @author ruoyi
  */
-public class SecurityUtils
-{
+public class SecurityUtils {
 
     /**
      * 用户ID
      **/
-    public static Long getUserId()
-    {
-        try
-        {
+    public static Long getUserId() {
+        try {
             return getLoginUser().getUserId();
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED);
         }
     }
@@ -42,14 +38,10 @@ public class SecurityUtils
     /**
      * 获取部门ID
      **/
-    public static Long getDeptId()
-    {
-        try
-        {
+    public static Long getDeptId() {
+        try {
             return getLoginUser().getDeptId();
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED);
         }
     }
@@ -57,14 +49,10 @@ public class SecurityUtils
     /**
      * 获取用户账户
      **/
-    public static String getUsername()
-    {
-        try
-        {
+    public static String getUsername() {
+        try {
             return getLoginUser().getUsername();
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
         }
     }
@@ -72,14 +60,10 @@ public class SecurityUtils
     /**
      * 获取用户
      **/
-    public static LoginUser getLoginUser()
-    {
-        try
-        {
+    public static LoginUser getLoginUser() {
+        try {
             return (LoginUser) getAuthentication().getPrincipal();
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED);
         }
     }
@@ -87,10 +71,10 @@ public class SecurityUtils
     /**
      * 获取Authentication
      */
-    public static Authentication getAuthentication()
-    {
+    public static Authentication getAuthentication() {
         return SecurityContextHolder.getContext().getAuthentication();
     }
+
     // 可选的加盐密钥,可以从配置文件中读取
     private static final String SM3_SECRET = "your-sm3-secret-key";
 
@@ -100,11 +84,10 @@ public class SecurityUtils
      * @param password 密码
      * @return 加密字符串
      */
-    public static String encryptPassword(SM4Util sm4Util,String password)
-    {
+    public static String encryptPassword( String password) {
 /*        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
         return passwordEncoder.encode(password);*/
-/*        try {
+        try {
             // 密码+密钥进行SM3哈希
             String passwordToEncode = password + SM3_SECRET;
 
@@ -115,29 +98,28 @@ public class SecurityUtils
             return Base64.getEncoder().encodeToString(hash);
         } catch (Exception e) {
             throw new RuntimeException("SM3密码加密失败", e);
-        }*/
-        return sm4Util.encrypt(password);
+        }
+        //return sm4Util.encrypt(password);
 
     }
 
     /**
      * 判断密码是否相同
      *
-     * @param rawPassword 真实密码
+     * @param rawPassword     真实密码
      * @param encodedPassword 加密后字符
      * @return 结果
      */
-    public static boolean matchesPassword(SM4Util sm4Util,String rawPassword, String encodedPassword)
-    {
+    public static boolean matchesPassword( String rawPassword, String encodedPassword) {
 /*        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
         return passwordEncoder.matches(rawPassword, encodedPassword);*/
+/*
         if (rawPassword == null || encodedPassword == null) {
             return false;
         }
-
         return sm4Util.decrypt(encodedPassword).equals(rawPassword);
-
- /*       try {
+*/
+        try {
             // 使用相同的逻辑计算输入密码的哈希值
             String passwordToCheck = rawPassword + SM3_SECRET;
 
@@ -148,52 +130,48 @@ public class SecurityUtils
             return encodedPassword.equals(checkEncoded);
         } catch (Exception e) {
             return false;
-        }*/
+        }
     }
 
     /**
      * 是否为管理员
-     * 
+     *
      * @param userId 用户ID
      * @return 结果
      */
-    public static boolean isAdmin(Long userId)
-    {
+    public static boolean isAdmin(Long userId) {
         return userId != null && 1L == userId;
     }
 
     /**
      * 验证用户是否具备某权限
-     * 
+     *
      * @param permission 权限字符串
      * @return 用户是否具备某权限
      */
-    public static boolean hasPermi(String permission)
-    {
+    public static boolean hasPermi(String permission) {
         return hasPermi(getLoginUser().getPermissions(), permission);
     }
 
     /**
      * 判断是否包含权限
-     * 
+     *
      * @param authorities 权限列表
-     * @param permission 权限字符串
+     * @param permission  权限字符串
      * @return 用户是否具备某权限
      */
-    public static boolean hasPermi(Collection<String> authorities, String permission)
-    {
+    public static boolean hasPermi(Collection<String> authorities, String permission) {
         return authorities.stream().filter(StringUtils::hasText)
                 .anyMatch(x -> Constants.ALL_PERMISSION.equals(x) || PatternMatchUtils.simpleMatch(x, permission));
     }
 
     /**
      * 验证用户是否拥有某个角色
-     * 
+     *
      * @param role 角色标识
      * @return 用户是否具备某角色
      */
-    public static boolean hasRole(String role)
-    {
+    public static boolean hasRole(String role) {
         List<SysRole> roleList = getLoginUser().getUser().getRoles();
         Collection<String> roles = roleList.stream().map(SysRole::getRoleKey).collect(Collectors.toSet());
         return hasRole(roles, role);
@@ -201,13 +179,12 @@ public class SecurityUtils
 
     /**
      * 判断是否包含角色
-     * 
+     *
      * @param roles 角色列表
-     * @param role 角色
+     * @param role  角色
      * @return 用户是否具备某角色权限
      */
-    public static boolean hasRole(Collection<String> roles, String role)
-    {
+    public static boolean hasRole(Collection<String> roles, String role) {
         return roles.stream().filter(StringUtils::hasText)
                 .anyMatch(x -> Constants.SUPER_ADMIN.equals(x) || PatternMatchUtils.simpleMatch(x, role));
     }

+ 23 - 4
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -86,16 +86,35 @@ public class SecurityConfig {
 */
 
     /**
-     * 身份验证实现 - 使用 SM4 密码编码器
+     * 身份验证实现 - 使用 SM3 密码编码器
      */
     @Bean
     public AuthenticationManager authenticationManager() {
         DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();
         daoAuthenticationProvider.setUserDetailsService(userDetailsService);
-        daoAuthenticationProvider.setPasswordEncoder(sm4PasswordEncoder()); // 改为 SM4 编码器
+        daoAuthenticationProvider.setPasswordEncoder(sm3PasswordEncoder()); // 改为 SM3 编码器
         return new ProviderManager(daoAuthenticationProvider);
     }
 
+    /**
+     * SM3 密码编码器 Bean
+     */
+    @Bean
+    public PasswordEncoder sm3PasswordEncoder() {
+        return new PasswordEncoder() {
+            @Override
+            public String encode(CharSequence rawPassword) {
+                return SecurityUtils.encryptPassword(rawPassword.toString());
+            }
+
+            @Override
+            public boolean matches(CharSequence rawPassword, String encodedPassword) {
+                return SecurityUtils.matchesPassword(rawPassword.toString(), encodedPassword);
+            }
+        };
+    }
+
+
     /**
      * SM4 密码编码器 Bean
      */
@@ -104,12 +123,12 @@ public class SecurityConfig {
         return new PasswordEncoder() {
             @Override
             public String encode(CharSequence rawPassword) {
-                return SecurityUtils.encryptPassword(sm4Util,rawPassword.toString());
+                return SecurityUtils.encryptPassword(rawPassword.toString());
             }
 
             @Override
             public boolean matches(CharSequence rawPassword, String encodedPassword) {
-                return SecurityUtils.matchesPassword(sm4Util,rawPassword.toString(), encodedPassword);
+                return SecurityUtils.matchesPassword(rawPassword.toString(), encodedPassword);
             }
         };
     }

+ 1 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPasswordService.java

@@ -79,7 +79,7 @@ public class SysPasswordService
 
     public boolean matches(SysUser user, String rawPassword)
     {
-        return SecurityUtils.matchesPassword(sm4Util,rawPassword, user.getPassword());
+        return SecurityUtils.matchesPassword(rawPassword, user.getPassword());
     }
 
     public void clearLoginRecordCache(String loginName)

+ 1 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysRegisterService.java

@@ -82,7 +82,7 @@ public class SysRegisterService
         else
         {
             sysUser.setNickName(username);
-            sysUser.setPassword(SecurityUtils.encryptPassword(sm4Util,password));
+            sysUser.setPassword(SecurityUtils.encryptPassword(password));
             boolean regFlag = userService.registerUser(sysUser);
             if (!regFlag)
             {

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -502,7 +502,7 @@ public class SysUserServiceImpl implements ISysUserService {
                     BeanValidators.validateWithException(validator, user);
                     deptService.checkDeptDataScope(user.getDeptId());
                     String password = configService.selectConfigByKey("sys.user.initPassword");
-                    user.setPassword(SecurityUtils.encryptPassword(sm4Util, password));
+                    user.setPassword(SecurityUtils.encryptPassword( password));
                     user.setCreateBy(operName);
                     user.sign();
                     userMapper.insertUser(user);