{"id":64049,"date":"2026-01-22T18:17:41","date_gmt":"2026-01-22T10:17:41","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/64049.html"},"modified":"2026-01-22T18:17:41","modified_gmt":"2026-01-22T10:17:41","slug":"%e8%8b%8d%e7%a9%b9%e5%a4%96%e5%8d%96","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/64049.html","title":{"rendered":"\u82cd\u7a79\u5916\u5356"},"content":{"rendered":"<p>\u9879\u76ee\u6574\u4f53\u5c55\u793a&#xff1a;<\/p>\n<h2><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"397\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101728-6971f938693b5.png\" width=\"1008\" \/><\/h2>\n<h2>\u5f00\u53d1\u73af\u5883\u642d\u5efa&#xff1a;<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"398\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101728-6971f93892cb6.png\" width=\"855\" \/><\/p>\n<h3>\u524d\u7aef\u73af\u5883\u642d\u5efa&#xff1a;<\/h3>\n<p>\u524d\u7aef\u5de5\u7a0b\u57fa\u4e8e nginx&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"470\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101728-6971f938b5bb7.png\" width=\"1704\" \/><\/p>\n<p>\u542f\u52a8 nginx \u670d\u52a1\u8bbf\u95ee\u6d4b\u8bd5&#xff1a;<\/p>\n<h3><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"961\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101729-6971f9391abda.png\" width=\"1920\" \/><\/h3>\n<h3>\u540e\u7aef\u73af\u5883\u642d\u5efa&#xff1a;<\/h3>\n<h4>\u9879\u76ee\u7ed3\u6784&#xff1a;<\/h4>\n<p>\u540e\u7aef\u5de5\u7a0b\u57fa\u4e8e maven \u8fdb\u884c\u9879\u76ee\u6784\u5efa&#xff0c;\u5e76\u4e14\u8fdb\u884c\u5206\u6a21\u5757\u5f00\u53d1<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"275\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101729-6971f939d0b3a.png\" width=\"954\" \/><\/p>\n<p>\u5de5\u7a0b\u7684\u5404\u4e2a\u6a21\u5757\u4f5c\u7528\u8bf4\u660e&#xff1a;<\/p>\n<table>\n<tbody>\n<tr>\n<td>\u540d\u79f0<\/td>\n<td>\u8bf4\u660e<\/td>\n<\/tr>\n<tr>\n<td>sky-take-out<\/td>\n<td>maven \u7236\u5de5\u7a0b&#xff0c;\u7edf\u4e00\u7ba1\u7406\u4f9d\u8d56\u7248\u672c&#xff0c;\u805a\u5408\u5176\u4ed6\u5b50\u6a21\u5757<\/td>\n<\/tr>\n<tr>\n<td>sky-common<\/td>\n<td>\u5b50\u6a21\u5757&#xff0c;\u5b58\u653e\u516c\u5171\u7c7b&#xff0c;\u4f8b\u5982&#xff1a;\u5de5\u5177\u7c7b\u3001\u5e38\u91cf\u7c7b\u3001\u5f02\u5e38\u7c7b\u7b49<\/td>\n<\/tr>\n<tr>\n<td>sky-pojo<\/td>\n<td>\u5b50\u6a21\u5757&#xff0c;\u5b58\u653e\u5b9e\u4f53\u7c7b\u3001VO\u3001DTO \u7b49<\/td>\n<\/tr>\n<tr>\n<td>sky-server<\/td>\n<td>\u5b50\u6a21\u5757&#xff0c;\u540e\u7aef\u670d\u52a1&#xff0c;\u5b58\u653e\u914d\u7f6e\u6587\u4ef6\u3001Controller\u3001Service\u3001Mapper \u7b49<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>sky-common&#xff1a;\u6a21\u5757\u4e2d\u5b58\u653e\u7684\u662f\u4e00\u4e9b\u516c\u5171\u7c7b&#xff0c;\u53ef\u4ee5\u4f9b\u5176\u4ed6\u6a21\u5757\u4f7f\u7528<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1020\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101729-6971f939eb6d2.png\" width=\"1920\" \/><\/p>\n<p>sky-common \u6a21\u5757\u4e0b\u6bcf\u4e2a\u5305\u7684\u4f5c\u7528&#xff1a;<\/p>\n<table>\n<tr>\u540d\u79f0\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>constant<\/td>\n<td>\u5b58\u653e\u76f8\u5173\u5e38\u91cf\u7c7b<\/td>\n<\/tr>\n<tr>\n<td>context<\/td>\n<td>\u5b58\u653e\u4e0a\u4e0b\u6587\u7c7b<\/td>\n<\/tr>\n<tr>\n<td>enumeration<\/td>\n<td>\u9879\u76ee\u7684\u679a\u4e3e\u7c7b\u5b58\u50a8<\/td>\n<\/tr>\n<tr>\n<td>exception<\/td>\n<td>\u5b58\u653e\u81ea\u5b9a\u4e49\u5f02\u5e38\u7c7b<\/td>\n<\/tr>\n<tr>\n<td>json<\/td>\n<td>\u5904\u7406 json \u8f6c\u6362\u7684\u7c7b<\/td>\n<\/tr>\n<tr>\n<td>properties<\/td>\n<td>\u5b58\u653e SpringBoot \u76f8\u5173\u7684\u914d\u7f6e\u5c5e\u6027\u7c7b<\/td>\n<\/tr>\n<tr>\n<td>result<\/td>\n<td>\u8fd4\u56de\u7ed3\u679c\u7c7b\u7684\u5c01\u88c5<\/td>\n<\/tr>\n<tr>\n<td>utils<\/td>\n<td>\u5e38\u7528\u5de5\u5177\u7c7b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>sky-pojo&#xff1a;\u6a21\u5757\u4e2d\u5b58\u653e\u7684\u662f\u4e00\u4e9b entity\u3001DTO\u3001VO<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1020\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101730-6971f93a896cc.png\" width=\"1920\" \/><\/p>\n<p>sky-pojo \u6a21\u5757\u4e0b\u6bcf\u4e2a\u5305\u7684\u4f5c\u7528&#xff1a;<\/p>\n<table>\n<tr>\u540d\u79f0\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>entity<\/td>\n<td>\u5b9e\u4f53&#xff0c;\u901a\u5e38\u548c\u6570\u636e\u5e93\u4e2d\u7684\u8868\u5bf9\u5e94<\/td>\n<\/tr>\n<tr>\n<td>dto<\/td>\n<td>\u6570\u636e\u4f20\u8f93\u5bf9\u8c61&#xff0c;\u901a\u5e38\u7528\u4e8e\u7a0b\u5e8f\u4e2d\u5404\u5c42\u4e4b\u95f4\u4f20\u9012\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td>vo<\/td>\n<td>\u89c6\u56fe\u5bf9\u8c61&#xff0c;\u4e3a\u524d\u7aef\u5c55\u793a\u6570\u636e\u63d0\u4f9b\u7684\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td>pojo<\/td>\n<td>\u666e\u901a Java \u5bf9\u8c61&#xff0c;\u53ea\u6709\u5c5e\u6027\u548c\u5bf9\u5e94\u7684 getter \u548c setter<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>sky-server&#xff1a;\u6a21\u5757\u4e2d\u5b58\u653e\u7684\u662f \u914d\u7f6e\u6587\u4ef6\u3001\u914d\u7f6e\u7c7b\u3001\u62e6\u622a\u5668\u3001controller\u3001service\u3001mapper\u3001\u542f\u52a8\u7c7b\u7b49<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1020\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101731-6971f93b24826.png\" width=\"1920\" \/><\/p>\n<p>sky-server \u6a21\u5757\u4e0b\u6bcf\u4e2a\u5305\u7684\u4f5c\u7528&#xff1a;<\/p>\n<table>\n<tr>\u540d\u79f0\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>config<\/td>\n<td>\u5b58\u653e\u914d\u7f6e\u7c7b<\/td>\n<\/tr>\n<tr>\n<td>controller<\/td>\n<td>\u5b58\u653econtroller\u7c7b<\/td>\n<\/tr>\n<tr>\n<td>interceptor<\/td>\n<td>\u5b58\u653e\u62e6\u622a\u5668\u7c7b<\/td>\n<\/tr>\n<tr>\n<td>mapper<\/td>\n<td>\u5b58\u653emapper\u63a5\u53e3<\/td>\n<\/tr>\n<tr>\n<td>service<\/td>\n<td>\u5b58\u653eservice\u7c7b<\/td>\n<\/tr>\n<tr>\n<td>SkyApplication<\/td>\n<td>\u542f\u52a8\u7c7b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Git \u7248\u672c\u63a7\u5236&#xff1a;<\/h4>\n<p>\u4f7f\u7528 Git \u8fdb\u884c\u9879\u76ee\u4ee3\u7801\u7684\u7248\u672c\u63a7\u5236&#xff0c;\u5177\u4f53\u64cd\u4f5c&#xff1a;<\/p>\n<h5>\u521b\u5efa Git \u672c\u5730\u4ed3\u5e93&#xff1a;<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"972\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101731-6971f93bd2563.png\" width=\"1920\" \/><\/p>\n<h5>\u521b\u5efa Git \u8fdc\u7a0b\u4ed3\u5e93&#xff1a;<\/h5>\n<p>\u8bbf\u95ee https:\/\/gitee.com\/&#xff0c;\u65b0\u5efa\u4ed3\u5e93<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1014\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101732-6971f93c80643.png\" width=\"1920\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1013\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101733-6971f93d37fda.png\" width=\"1914\" \/><\/p>\n<h5>\u5c06\u672c\u5730\u6587\u4ef6\u63a8\u9001\u5230 Git \u8fdc\u7a0b\u4ed3\u5e93&#xff1a;<\/h5>\n<p>\u63d0\u4ea4\u6587\u4ef6\u81f3\u672c\u5730\u4ed3\u5e93<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1020\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101734-6971f93e0ad1a.png\" width=\"1920\" \/><\/p>\n<p>\u6dfb\u52a0 Git \u8fdc\u7a0b\u4ed3\u5e93\u5730\u5740<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1017\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101734-6971f93eb55b0.png\" width=\"1920\" \/><\/p>\n<p>\u63a8\u9001\u81f3\u8fdc\u7a0b\u4ed3\u5e93<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1020\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101735-6971f93f61036.png\" width=\"1920\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1013\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101736-6971f9402eaaa.png\" width=\"1920\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1015\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101737-6971f9410cbdf.png\" width=\"1920\" \/><\/p>\n<h4>\u6570\u636e\u5e93\u642d\u5efa&#xff1a;<\/h4>\n<p>\u5728 MySQL Workbench \u4e2d\u6267\u884c sky.sql \u6587\u4ef6\u521b\u5efa\u6570\u636e\u5e93<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1016\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101738-6971f94222a7e.png\" width=\"1920\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1019\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101739-6971f94305bd1.png\" width=\"1920\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1013\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101739-6971f943a6613.png\" width=\"1920\" \/><\/p>\n<p>\u6bcf\u5f20\u8868\u7684\u8bf4\u660e&#xff1a;<\/p>\n<table>\n<tr>\u8868\u540d\u4e2d\u6587\u540d<\/tr>\n<tbody>\n<tr>\n<td>employee<\/td>\n<td>\u5458\u5de5\u8868<\/td>\n<\/tr>\n<tr>\n<td>category<\/td>\n<td>\u5206\u7c7b\u8868<\/td>\n<\/tr>\n<tr>\n<td>dish<\/td>\n<td>\u83dc\u54c1\u8868<\/td>\n<\/tr>\n<tr>\n<td>dish_flavor<\/td>\n<td>\u83dc\u54c1\u53e3\u5473\u8868<\/td>\n<\/tr>\n<tr>\n<td>setmeal<\/td>\n<td>\u5957\u9910\u8868<\/td>\n<\/tr>\n<tr>\n<td>setmeal_dish<\/td>\n<td>\u5957\u9910\u83dc\u54c1\u5173\u7cfb\u8868<\/td>\n<\/tr>\n<tr>\n<td>user<\/td>\n<td>\u7528\u6237\u8868<\/td>\n<\/tr>\n<tr>\n<td>address_book<\/td>\n<td>\u5730\u5740\u8868<\/td>\n<\/tr>\n<tr>\n<td>shopping_cart<\/td>\n<td>\u8d2d\u7269\u8f66\u8868<\/td>\n<\/tr>\n<tr>\n<td>orders<\/td>\n<td>\u8ba2\u5355\u8868<\/td>\n<\/tr>\n<tr>\n<td>order_detail<\/td>\n<td>\u8ba2\u5355\u660e\u7ec6\u8868<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u524d\u540e\u7aef\u8054\u8c03&#xff1a;<\/h4>\n<p>\u540e\u7aef\u7684\u521d\u59cb\u5de5\u7a0b\u4e2d\u5df2\u7ecf\u5b9e\u73b0\u4e86\u767b\u5f55\u529f\u80fd&#xff0c;\u76f4\u63a5\u8fdb\u884c\u524d\u540e\u7aef\u8054\u8c03\u6d4b\u8bd5\u5373\u53ef<\/p>\n<p>\u5b9e\u73b0\u601d\u8def&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"317\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101740-6971f9446523e.png\" width=\"1164\" \/><\/p>\n<h5>Controller \u5c42&#xff1a;<\/h5>\n<p>EmployeeController&#xff1a;<\/p>\n<p>\/**<br \/>\n * \u767b\u5f55<br \/>\n *<br \/>\n * &#064;param employeeLoginDTO \u767b\u5f55\u8bf7\u6c42\u53c2\u6570<br \/>\n * &#064;return \u767b\u5f55\u7ed3\u679c&#xff08;\u5305\u542bJWT\u4ee4\u724c\u548c\u5458\u5de5\u4fe1\u606f&#xff09;<br \/>\n *\/<br \/>\n&#064;PostMapping(&#034;\/login&#034;)<br \/>\npublic Result&lt;EmployeeLoginVO&gt; login(&#064;RequestBody EmployeeLoginDTO employeeLoginDTO){<br \/>\n    log.info(&#034;\u5458\u5de5\u767b\u5f55&#xff1a;{}&#034;, employeeLoginDTO);<br \/>\n    \/\/\u8c03\u7528\u670d\u52a1\u5c42\u5b8c\u6210\u767b\u5f55\u6821\u9a8c<br \/>\n    Employee employee &#061; employeeService.login(employeeLoginDTO);<br \/>\n    \/\/\u767b\u5f55\u6210\u529f\u540e&#xff0c;\u751f\u6210jwt\u4ee4\u724c<br \/>\n    Map&lt;String, Object&gt; claims &#061; new HashMap&lt;&gt;();<br \/>\n    claims.put(JwtClaimsConstant.EMP_ID, employee.getId());<br \/>\n    String token &#061; JwtUtil.createJWT(<br \/>\n            jwtProperties.getAdminSecretKey(),<br \/>\n            jwtProperties.getAdminTtl(),<br \/>\n            claims<br \/>\n    );<br \/>\n    \/\/\u5c01\u88c5\u767b\u5f55\u8fd4\u56deVO<br \/>\n    EmployeeLoginVO employeeLoginVO &#061; EmployeeLoginVO.builder()<br \/>\n            .id(employee.getId())<br \/>\n            .userName(employee.getUsername())<br \/>\n            .name(employee.getName())<br \/>\n            .token(token)<br \/>\n            .build();<br \/>\n    return Result.success(employeeLoginVO);<br \/>\n} <\/p>\n<h5>Service \u5c42&#xff1a;<\/h5>\n<p>EmployeeServiceImpl&#xff1a;<\/p>\n<p>\/**<br \/>\n * \u5458\u5de5\u767b\u5f55\u6821\u9a8c<br \/>\n *<br \/>\n * &#064;param employeeLoginDTO \u5458\u5de5\u767b\u5f55\u8bf7\u6c42\u53c2\u6570&#xff08;\u5305\u542b\u7528\u6237\u540d\u3001\u5bc6\u7801&#xff09;<br \/>\n * &#064;return \u767b\u5f55\u6210\u529f\u7684\u5458\u5de5\u5b9e\u4f53<br \/>\n * &#064;throws AccountNotFoundException  \u8d26\u53f7\u4e0d\u5b58\u5728\u5f02\u5e38<br \/>\n * &#064;throws PasswordErrorException    \u5bc6\u7801\u9519\u8bef\u5f02\u5e38<br \/>\n * &#064;throws AccountLockedException    \u8d26\u53f7\u88ab\u9501\u5b9a\u5f02\u5e38<br \/>\n *\/<br \/>\npublic Employee login(EmployeeLoginDTO employeeLoginDTO){<br \/>\n    \/\/\u83b7\u53d6\u767b\u5f55\u8bf7\u6c42\u4e2d\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801<br \/>\n    String username &#061; employeeLoginDTO.getUsername();<br \/>\n    String password &#061; employeeLoginDTO.getPassword();<br \/>\n    \/\/\u6839\u636e\u7528\u6237\u540d\u67e5\u8be2\u6570\u636e\u5e93\u4e2d\u7684\u5458\u5de5\u4fe1\u606f<br \/>\n    Employee employee &#061; employeeMapper.getByUsername(username);<br \/>\n    \/\/\u6821\u9a8c\u8d26\u53f7\u6709\u6548\u6027&#xff1a;\u7528\u6237\u540d\u4e0d\u5b58\u5728<br \/>\n    if(employee &#061;&#061; null){<br \/>\n        throw new AccountNotFoundException(MessageConstant.ACCOUNT_NOT_FOUND);<br \/>\n    }<br \/>\n    \/\/\u6821\u9a8c\u5bc6\u7801\u6b63\u786e\u6027&#xff08;TODO&#xff1a;\u540e\u7eed\u9700\u5bf9\u5bc6\u7801\u505aMD5\u52a0\u5bc6\u540e\u518d\u6bd4\u5bf9&#xff09;<br \/>\n    if(!password.equals(employee.getPassword())){<br \/>\n        \/\/\u5bc6\u7801\u9519\u8bef<br \/>\n        throw new PasswordErrorException(MessageConstant.PASSWORD_ERROR);<br \/>\n    }<br \/>\n    \/\/\u6821\u9a8c\u8d26\u53f7\u72b6\u6001&#xff1a;\u662f\u5426\u88ab\u9501\u5b9a<br \/>\n    if(employee.getStatus() &#061;&#061; StatusConstant.DISABLE){<br \/>\n        throw new AccountLockedException(MessageConstant.ACCOUNT_LOCKED);<br \/>\n    }<br \/>\n    \/\/\u6240\u6709\u6821\u9a8c\u901a\u8fc7&#xff0c;\u8fd4\u56de\u5458\u5de5\u5b9e\u4f53<br \/>\n    return employee;<br \/>\n} <\/p>\n<h5>Mapper \u5c42&#xff1a;<\/h5>\n<p>EmployeeMapper&#xff1a;<\/p>\n<p>\/**<br \/>\n * \u6839\u636e\u7528\u6237\u540d\u67e5\u8be2\u5458\u5de5\u4fe1\u606f<br \/>\n *<br \/>\n * &#064;param username \u5458\u5de5\u7528\u6237\u540d&#xff08;\u552f\u4e00\u6807\u8bc6&#xff09;<br \/>\n * &#064;return \u5339\u914d\u7684\u5458\u5de5\u5b9e\u4f53&#xff0c;\u65e0\u5339\u914d\u6570\u636e\u65f6\u8fd4\u56denull<br \/>\n *\/<br \/>\n&#064;Select(&#034;select * from employee where username &#061; #{username}&#034;)<br \/>\nEmployee getByUsername(String username); <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"967\" src=\"2026-01-22syd5oya5yg2.png\" width=\"1920\" \/><\/p>\n<h4>Nginx&#xff1a;<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"184\" src=\"2026-01-22urn4sls1f3t.png\" width=\"1120\" \/><\/p>\n<p>\u524d\u7aef\u8bf7\u6c42\u5730\u5740&#xff1a;http:\/\/localhost\/api\/employee\/login<\/p>\n<p>\u540e\u7aef\u63a5\u53e3\u5730\u5740&#xff1a;http:\/\/localhost:8080\/admin\/employee\/login<\/p>\n<h5>\u53cd\u5411\u4ee3\u7406&#xff1a;<\/h5>\n<p>Nginx \u53cd\u5411\u4ee3\u7406&#xff0c;\u662f\u6307\u5ba2\u6237\u7aef\u8bf7\u6c42\u4e0d\u76f4\u63a5\u8bbf\u95ee\u540e\u7aef\u670d\u52a1\u5668&#xff0c;\u800c\u662f\u5148\u53d1\u9001\u5230 Nginx \u670d\u52a1\u5668&#xff0c;\u7531 Nginx \u4ee3\u66ff\u5ba2\u6237\u7aef\u5411\u540e\u7aef\u670d\u52a1\u5668\u53d1\u8d77\u8bf7\u6c42&#xff0c;\u518d\u5c06\u540e\u7aef\u7684\u54cd\u5e94\u7ed3\u679c\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u7684\u4e00\u79cd\u7f51\u7edc\u67b6\u6784\u6a21\u5f0f&#xff0c;\u53ef\u4ee5\u63d0\u9ad8\u8bbf\u95ee\u901f\u5ea6&#xff0c;\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861&#xff0c;\u4fdd\u8bc1\u540e\u7aef\u670d\u52a1\u5b89\u5168<\/p>\n<p>\u914d\u7f6e\u65b9\u5f0f&#xff1a;<\/p>\n<p>server{<br \/>\n    listen 80;<br \/>\n    server_name localhost;<\/p>\n<p>    location \/api\/{<br \/>\n        proxy_pass http:\/\/localhost:8080\/admin\/; #\u53cd\u5411\u4ee3\u7406<br \/>\n    }<br \/>\n} <\/p>\n<p>\u542b\u4e49&#xff1a;\u76d1\u542c 80 \u7aef\u53e3\u53f7&#xff0c;\u5f53\u8bbf\u95ee http:\/\/localhost:80\/api\/..\/..\u00a0\u8fd9\u6837\u7684\u63a5\u53e3\u65f6&#xff0c;\u5b83\u4f1a\u901a\u8fc7 location \/api\/ {} \u8fd9\u6837\u7684\u53cd\u5411\u4ee3\u7406\u5230 http:\/\/localhost:8080\/admin\/\u00a0\u4e0a<\/p>\n<p>proxy_pass&#xff1a;\u8be5\u6307\u4ee4\u662f\u7528\u6765\u8bbe\u7f6e\u4ee3\u7406\u670d\u52a1\u5668\u7684\u5730\u5740&#xff0c;\u53ef\u4ee5\u662f\u4e3b\u673a\u540d\u79f0&#xff0c;IP \u5730\u5740\u52a0\u7aef\u53e3\u53f7\u7b49\u5f62\u5f0f<\/p>\n<p>\u914d\u7f6e\u6587\u4ef6 nginx.conf &#xff1a;<\/p>\n<p># \u53cd\u5411\u4ee3\u7406,\u5904\u7406\u7ba1\u7406\u7aef\u53d1\u9001\u7684\u8bf7\u6c42<br \/>\nlocation \/api\/ {<br \/>\nproxy_pass   http:\/\/localhost:8080\/admin\/;<br \/>\n    #proxy_pass   http:\/\/webservers\/admin\/;<br \/>\n} <\/p>\n<p>\u8bbf\u95ee\u00a0http:\/\/localhost\/api\/employee\/login\u00a0\u65f6&#xff0c;nginx \u63a5\u6536\u8bf7\u6c42\u540e\u8f6c\u5230 http:\/\/localhost:8080\/admin\/&#xff0c;\u6545\u6700\u7ec8\u7684\u8bf7\u6c42\u5730\u5740\u4e3a http:\/\/localhost:8080\/admin\/employee\/login&#xff0c;\u548c\u540e\u53f0\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u4e00\u81f4<\/p>\n<h5>\u8d1f\u8f7d\u5747\u8861&#xff1a;<\/h5>\n<p>Nginx \u8d1f\u8f7d\u5747\u8861&#xff0c;\u662f\u6307\u901a\u8fc7 Nginx \u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668&#xff0c;\u5c06\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u5747\u5300\u5730\u5206\u53d1\u5230\u540e\u7aef\u591a\u53f0\u5e94\u7528\u670d\u52a1\u5668&#xff0c;\u907f\u514d\u5355\u53f0\u670d\u52a1\u5668\u56e0\u8bf7\u6c42\u8fc7\u8f7d\u5b95\u673a&#xff0c;\u540c\u65f6\u63d0\u5347\u7cfb\u7edf\u7684\u5e76\u53d1\u5904\u7406\u80fd\u529b\u3001\u53ef\u7528\u6027\u548c\u5bb9\u707e\u80fd\u529b<\/p>\n<p>\u914d\u7f6e\u65b9\u5f0f&#xff1a;<\/p>\n<p>upstream webservers{<br \/>\n    server 192.168.100.128:8080;<br \/>\n    server 192.168.100.129:8080;<br \/>\n}<br \/>\nserver{<br \/>\n    listen 80;<br \/>\n    server_name localhost;<\/p>\n<p>    location \/api\/{<br \/>\n        proxy_pass http:\/\/webservers\/admin;#\u8d1f\u8f7d\u5747\u8861<br \/>\n    }<br \/>\n} <\/p>\n<p>\u542b\u4e49&#xff1a;\u00a0\u76d1\u542c 80 \u7aef\u53e3\u53f7&#xff0c;\u5f53\u8bbf\u95ee http:\/\/localhost:80\/api\/..\/..\u00a0\u8fd9\u6837\u7684\u63a5\u53e3\u65f6&#xff0c;\u5b83\u4f1a\u901a\u8fc7 location \/api\/ {} \u8fd9\u6837\u7684\u53cd\u5411\u4ee3\u7406\u5230\u00a0http:\/\/webservers\/admin&#xff0c;\u901a\u8fc7 webservers\u00a0\u6807\u8bc6\u7684\u540e\u7aef\u670d\u52a1\u5668\u96c6\u7fa4&#xff0c;\u4f9d\u636e\u9884\u8bbe\u8d1f\u8f7d\u5747\u8861\u7b56\u7565&#xff08;\u9ed8\u8ba4\u8f6e\u8be2&#xff09;&#xff0c;\u5c06\u5ba2\u6237\u7aef\u8bf7\u6c42\u5206\u53d1\u81f3\u96c6\u7fa4\u5185\u7684\u5177\u4f53\u670d\u52a1\u5668<\/p>\n<p>\u8d1f\u8f7d\u5747\u8861\u7b56\u7565&#xff1a;<\/p>\n<table>\n<tr>\u540d\u79f0\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u8f6e\u8be2<\/td>\n<td>\u9ed8\u8ba4\u65b9\u5f0f<\/td>\n<\/tr>\n<tr>\n<td>weight<\/td>\n<td>\u6743\u91cd\u65b9\u5f0f&#xff0c;\u9ed8\u8ba4\u4e3a 1&#xff0c;\u6743\u91cd\u8d8a\u9ad8&#xff0c;\u88ab\u5206\u914d\u7684\u5ba2\u6237\u7aef\u8bf7\u6c42\u5c31\u8d8a\u591a<\/td>\n<\/tr>\n<tr>\n<td>ip_hash<\/td>\n<td>\u4f9d\u636e ip \u5206\u914d\u65b9\u5f0f&#xff0c;\u8fd9\u6837\u6bcf\u4e2a\u8bbf\u5ba2\u53ef\u4ee5\u56fa\u5b9a\u8bbf\u95ee\u4e00\u4e2a\u540e\u7aef\u670d\u52a1<\/td>\n<\/tr>\n<tr>\n<td>least_conn<\/td>\n<td>\u4f9d\u636e\u6700\u5c11\u8fde\u63a5\u65b9\u5f0f&#xff0c;\u628a\u8bf7\u6c42\u4f18\u5148\u5206\u914d\u7ed9\u8fde\u63a5\u6570\u5c11\u7684\u540e\u7aef\u670d\u52a1<\/td>\n<\/tr>\n<tr>\n<td>url_hash<\/td>\n<td>\u4f9d\u636e url \u5206\u914d\u65b9\u5f0f&#xff0c;\u8fd9\u6837\u76f8\u540c\u7684 url \u4f1a\u88ab\u5206\u914d\u5230\u540c\u4e00\u4e2a\u540e\u7aef\u670d\u52a1<\/td>\n<\/tr>\n<tr>\n<td>fair<\/td>\n<td>\u4f9d\u636e\u54cd\u5e94\u65f6\u95f4\u65b9\u5f0f&#xff0c;\u54cd\u5e94\u65f6\u95f4\u77ed\u7684\u670d\u52a1\u5c06\u4f1a\u88ab\u4f18\u5148\u5206\u914d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5177\u4f53\u914d\u7f6e\u65b9\u5f0f&#xff1a;<\/p>\n<p>\u8f6e\u8be2&#xff1a;<\/p>\n<p>upstream webservers{<br \/>\n    server 192.168.100.128:8080;<br \/>\n    server 192.168.100.129:8080;<br \/>\n} <\/p>\n<p>weight&#xff1a;<\/p>\n<p>upstream webservers{<br \/>\n    server 192.168.100.128:8080 weight&#061;90;<br \/>\n    server 192.168.100.129:8080 weight&#061;10;<br \/>\n} <\/p>\n<p>ip_hash&#xff1a;<\/p>\n<p>upstream webservers{<br \/>\n    ip_hash;<br \/>\n    server 192.168.100.128:8080;<br \/>\n    server 192.168.100.129:8080;<br \/>\n} <\/p>\n<p>least_conn&#xff1a;<\/p>\n<p>upstream webservers{<br \/>\n    least_conn;<br \/>\n    server 192.168.100.128:8080;<br \/>\n    server 192.168.100.129:8080;<br \/>\n} <\/p>\n<p>url_hash&#xff1a;<\/p>\n<p>upstream webservers{<br \/>\n    hash &amp;request_uri;<br \/>\n    server 192.168.100.128:8080;<br \/>\n    server 192.168.100.129:8080;<br \/>\n} <\/p>\n<p>fair&#xff1a;<\/p>\n<p>upstream webservers{<br \/>\n    server 192.168.100.128:8080;<br \/>\n    server 192.168.100.129:8080;<br \/>\n    fair;<br \/>\n} <\/p>\n<h3>\u5b8c\u5584\u767b\u5f55\u529f\u80fd&#xff1a;<\/h3>\n<p>\u5b58\u5728\u95ee\u9898&#xff1a;\u5458\u5de5\u8868\u4e2d\u7684\u5bc6\u7801\u662f\u660e\u6587\u5b58\u50a8&#xff0c;\u5b89\u5168\u6027\u592a\u4f4e<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"61\" src=\"2026-01-22ovl3abzpvde.png\" width=\"1391\" \/><\/p>\n<p>\u89e3\u51b3\u601d\u8def&#xff1a;\u4f7f\u7528 MD5 \u52a0\u5bc6\u65b9\u5f0f\u5bf9\u660e\u6587\u5bc6\u7801\u52a0\u5bc6\u540e\u5b58\u50a8<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"80\" src=\"2026-01-22k5wltnobgsb.png\" width=\"733\" \/><\/p>\n<p>\u4ee3\u7801\u5b9e\u73b0&#xff1a;<\/p>\n<p>\u4fee\u6539\u6570\u636e\u5e93\u4e2d\u660e\u6587\u5bc6\u7801&#xff0c;\u6539\u4e3a MD5 \u52a0\u5bc6\u540e\u7684\u5bc6\u6587<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"44\" src=\"2026-01-220vdjepqbmqq.png\" width=\"1341\" \/><\/p>\n<p>EmployeeServiceImpl&#xff1a;<\/p>\n<p>password &#061; DigestUtils.md5DigestAsHex(password.getBytes());<br \/>\nif(!password.equals(employee.getPassword())){<br \/>\n   \/\/\u5bc6\u7801\u9519\u8bef<br \/>\n   throw new PasswordErrorException(MessageConstant.PASSWORD_ERROR);<br \/>\n} <\/p>\n<h2>\u5bfc\u5165\u63a5\u53e3\u6587\u6863&#xff1a;<\/h2>\n<h3>\u524d\u540e\u7aef\u5206\u79bb&#xff1a;<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"375\" src=\"2026-01-225cvnzexer5f.png\" width=\"733\" \/><\/p>\n<p>\u5f00\u53d1\u6d41\u7a0b&#xff1a;\u5b9a\u4e49\u63a5\u53e3&#xff0c;\u786e\u5b9a\u63a5\u53e3\u7684\u8def\u5f84\u3001\u8bf7\u6c42\u65b9\u5f0f\u3001\u4f20\u5165\u53c2\u6570\u3001\u8fd4\u56de\u53c2\u6570&#xff1b;\u524d\u7aef\u5f00\u53d1\u4eba\u5458\u548c\u540e\u7aef\u5f00\u53d1\u4eba\u5458\u5e76\u884c\u5f00\u53d1&#xff0c;\u540c\u65f6\u4e5f\u53ef\u81ea\u6d4b&#xff1b;\u524d\u540e\u7aef\u4eba\u5458\u8fdb\u884c\u8fde\u8c03\u6d4b\u8bd5&#xff1b;\u63d0\u4ea4\u7ed9\u6d4b\u8bd5\u4eba\u5458\u8fdb\u884c\u6700\u7ec8\u6d4b\u8bd5<\/p>\n<h3>\u64cd\u4f5c\u6b65\u9aa4&#xff1a;<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1020\" src=\"2026-01-22wtbrp1gpf2b.png\" width=\"1920\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1020\" src=\"2026-01-22imkq1jnl4ya.png\" width=\"1920\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1020\" src=\"2026-01-22mdyvtcmq4yv.png\" width=\"1920\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1020\" src=\"2026-01-22qjs0w3i3r4g.png\" width=\"1920\" \/><\/p>\n<h2>Swagger&#xff1a;<\/h2>\n<h3>\u4ecb\u7ecd&#xff1a;<\/h3>\n<p>\u5b98\u7f51&#xff1a;https:\/\/swagger.io\/<\/p>\n<p>Swagger \u662f\u4e00\u5957\u6807\u51c6\u5316\u6846\u67b6&#xff0c;\u7528\u4e8e RESTful Web \u670d\u52a1\u7684\u63a5\u53e3\u751f\u6210\u3001\u63cf\u8ff0\u3001\u8c03\u7528\u548c\u53ef\u89c6\u5316&#xff0c;\u6838\u5fc3\u4ef7\u503c\u662f\u964d\u4f4e\u63a5\u53e3\u6587\u6863\u7f16\u5199\u6210\u672c\u3001\u7b80\u5316\u524d\u540e\u7aef\u534f\u4f5c&#xff0c;\u8fd8\u652f\u6301\u63a5\u53e3\u529f\u80fd\u6d4b\u8bd5&#xff1b;Spring \u57fa\u4e8e Swagger \u5c01\u88c5\u4e86 Springfox \u9879\u76ee&#xff0c;\u4fbf\u4e8e Java \u9879\u76ee\u5feb\u901f\u96c6\u6210<\/p>\n<p>Knife4j \u662f\u9002\u914d Java MVC \u6846\u67b6\u7684 Swagger \u589e\u5f3a\u65b9\u6848&#xff08;\u524d\u8eab\u662f swagger-bootstrap-ui&#xff09;&#xff0c;\u4ee5\u8f7b\u91cf\u3001\u529f\u80fd\u5f3a\u4e3a\u7279\u70b9&#xff0c;\u662f\u76ee\u524d Java \u9879\u76ee\u4e2d\u96c6\u6210 Swagger \u7684\u4e3b\u6d41\u9009\u62e9<\/p>\n<h3>\u4f7f\u7528\u6b65\u9aa4&#xff1a;<\/h3>\n<p>\u5bfc\u5165 knife4j \u7684 maven \u5750\u6807&#xff1a;<\/p>\n<p>&lt;dependency&gt;<br \/>\n   &lt;groupId&gt;com.github.xiaoymin&lt;\/groupId&gt;<br \/>\n   &lt;artifactId&gt;knife4j-spring-boot-starter&lt;\/artifactId&gt;<br \/>\n&lt;\/dependency&gt; <\/p>\n<p>\u5728 WebMvcConfiguration \u914d\u7f6e\u7c7b\u4e2d\u52a0\u5165 knife4j \u76f8\u5173\u914d\u7f6e&#xff1a;<\/p>\n<p>\/**<br \/>\n * \u914d\u7f6eKnife4j\u751f\u6210\u63a5\u53e3\u6587\u6863<br \/>\n * &#064;return Docket Swagger\u6838\u5fc3\u914d\u7f6e\u5bf9\u8c61<br \/>\n *\/<br \/>\n&#064;Bean<br \/>\npublic Docket docket(){<br \/>\n    log.info(&#034;\u51c6\u5907\u751f\u6210\u63a5\u53e3\u6587\u6863&#8230;&#034;);<br \/>\n    \/\/\u6784\u5efa\u63a5\u53e3\u6587\u6863\u7684\u57fa\u7840\u4fe1\u606f&#xff08;\u6807\u9898\u3001\u7248\u672c\u3001\u63cf\u8ff0&#xff09;<br \/>\n    ApiInfo apiInfo &#061; new ApiInfoBuilder()<br \/>\n            .title(&#034;\u82cd\u7a79\u5916\u5356\u9879\u76ee\u63a5\u53e3\u6587\u6863&#034;)<br \/>\n            .version(&#034;2.0&#034;)<br \/>\n            .description(&#034;\u82cd\u7a79\u5916\u5356\u9879\u76ee\u63a5\u53e3\u6587\u6863&#034;)<br \/>\n            .build();<\/p>\n<p>    \/\/\u6784\u5efaSwagger\/Docket\u6838\u5fc3\u914d\u7f6e<br \/>\n    Docket docket &#061; new Docket(DocumentationType.SWAGGER_2)<br \/>\n            .apiInfo(apiInfo)          \/\/\u7ed1\u5b9a\u63a5\u53e3\u6587\u6863\u57fa\u7840\u4fe1\u606f<br \/>\n            .select()                  \/\/\u5f00\u542f\u63a5\u53e3\u626b\u63cf\u914d\u7f6e<br \/>\n            \/\/\u626b\u63cf\u6307\u5b9a\u5305\u4e0b\u7684\u6240\u6709\u63a7\u5236\u5668&#xff08;\u6838\u5fc3\u4e1a\u52a1\u63a5\u53e3&#xff09;<br \/>\n            .apis(RequestHandlerSelectors.basePackage(&#034;com.sky.controller&#034;))<br \/>\n            .paths(PathSelectors.any())\/\/\u5339\u914d\u6240\u6709\u8def\u5f84\u7684\u63a5\u53e3<br \/>\n            .build();<\/p>\n<p>    return docket;<br \/>\n} <\/p>\n<p>\u5e76\u8bbe\u7f6e\u9759\u6001\u8d44\u6e90\u6620\u5c04&#xff0c;\u5426\u5219\u63a5\u53e3\u6587\u6863\u9875\u9762\u65e0\u6cd5\u8bbf\u95ee<\/p>\n<p>\/**<br \/>\n * \u8bbe\u7f6e\u9759\u6001\u8d44\u6e90\u6620\u5c04<br \/>\n * &#064;param registry<br \/>\n *\/<br \/>\nprotected void addResourceHandlers(ResourceHandlerRegistry registry){<br \/>\n        log.info(&#034;\u5f00\u59cb\u8bbe\u7f6e\u9759\u6001\u8d44\u6e90\u6620\u5c04&#8230;&#034;);<br \/>\n        \/\/\u6620\u5c04Knife4j\u63a5\u53e3\u6587\u6863\u9996\u9875&#xff08;doc.html&#xff09;\u7684\u9759\u6001\u8d44\u6e90<br \/>\n        registry.addResourceHandler(&#034;\/doc.html&#034;).addResourceLocations(&#034;classpath:\/META-INF\/resources\/&#034;);<br \/>\n        \/\/\u6620\u5c04Knife4j\u4f9d\u8d56\u7684webjars\u9759\u6001\u8d44\u6e90&#xff08;\u5982CSS\/JS\/\u5b57\u4f53\u7b49&#xff09;<br \/>\n        registry.addResourceHandler(&#034;\/webjars\/**&#034;).addResourceLocations(&#034;classpath:\/META-INF\/resources\/webjars\/&#034;);<br \/>\n} <\/p>\n<p>\u8bbf\u95ee\u6d4b\u8bd5&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"964\" src=\"2026-01-22riv3hrx1zak.png\" width=\"1920\" \/><\/p>\n<p>\u63a5\u53e3\u6d4b\u8bd5&#xff1a;\u6d4b\u8bd5\u767b\u5f55\u529f\u80fd<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"962\" src=\"2026-01-22dsmi5iyt5rm.png\" width=\"1920\" \/><\/p>\n<h3>\u5e38\u7528\u6ce8\u89e3&#xff1a;<\/h3>\n<p>\u901a\u8fc7\u6ce8\u89e3\u53ef\u4ee5\u63a7\u5236\u751f\u6210\u7684\u63a5\u53e3\u6587\u6863&#xff0c;\u4f7f\u63a5\u53e3\u6587\u6863\u62e5\u6709\u66f4\u597d\u7684\u53ef\u8bfb\u6027&#xff0c;\u5e38\u7528\u6ce8\u89e3\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>\u6ce8\u89e3\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>&#064;Api<\/td>\n<td>\u7528\u5728\u7c7b\u4e0a&#xff0c;\u4f8b\u5982 Controller&#xff0c;\u8868\u793a\u5bf9\u7c7b\u7684\u8bf4\u660e<\/td>\n<\/tr>\n<tr>\n<td>&#064;ApiModel<\/td>\n<td>\u7528\u5728\u7c7b\u4e0a&#xff0c;\u4f8b\u5982 entity\u3001DTO\u3001VO<\/td>\n<\/tr>\n<tr>\n<td>&#064;ApiModelProperty<\/td>\n<td>\u7528\u5728\u5c5e\u6027\u4e0a&#xff0c;\u63cf\u8ff0\u5c5e\u6027\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td>&#064;ApiOperation<\/td>\n<td>\u7528\u5728\u65b9\u6cd5\u4e0a&#xff0c;\u4f8b\u5982Controller\u7684\u65b9\u6cd5&#xff0c;\u8bf4\u660e\u65b9\u6cd5\u7684\u7528\u9014\u3001\u4f5c\u7528<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>EmployeeLoginDTO&#xff1a;<\/p>\n<p>&#064;Data<br \/>\n&#064;ApiModel(description &#061; &#034;\u5458\u5de5\u767b\u5f55\u65f6\u4f20\u9012\u7684\u6570\u636e\u6a21\u578b&#034;)<br \/>\npublic class EmployeeLoginDTO implements Serializable{<\/p>\n<p>    &#064;ApiModelProperty(&#034;\u7528\u6237\u540d&#034;)<br \/>\n    private String username;<\/p>\n<p>    &#064;ApiModelProperty(&#034;\u5bc6\u7801&#034;)<br \/>\n    private String password;<\/p>\n<p>} <\/p>\n<p>EmployeeLoginVo&#xff1a;<\/p>\n<p>&#064;Data<br \/>\n&#064;Builder<br \/>\n&#064;NoArgsConstructor<br \/>\n&#064;AllArgsConstructor<br \/>\n&#064;ApiModel(description &#061; &#034;\u5458\u5de5\u767b\u5f55\u8fd4\u56de\u7684\u6570\u636e\u683c\u5f0f&#034;)<br \/>\npublic class EmployeeLoginVO implements Serializable{<\/p>\n<p>    &#064;ApiModelProperty(&#034;\u4e3b\u952e\u503c&#034;)<br \/>\n    private Long id;<\/p>\n<p>    &#064;ApiModelProperty(&#034;\u7528\u6237\u540d&#034;)<br \/>\n    private String userName;<\/p>\n<p>    &#064;ApiModelProperty(&#034;\u59d3\u540d&#034;)<br \/>\n    private String name;<\/p>\n<p>    &#064;ApiModelProperty(&#034;jwt\u4ee4\u724c&#034;)<br \/>\n    private String token;<\/p>\n<p>} <\/p>\n<p>EmployeeController&#xff1a;<\/p>\n<p>\/**<br \/>\n * \u5458\u5de5\u7ba1\u7406<br \/>\n *\/<br \/>\n&#064;RestController<br \/>\n&#064;RequestMapping(&#034;\/admin\/employee&#034;)<br \/>\n&#064;Slf4j<br \/>\n&#064;Api(tags &#061; &#034;\u5458\u5de5\u76f8\u5173\u63a5\u53e3&#034;)<br \/>\npublic class EmployeeController{<\/p>\n<p>    &#064;Autowired<br \/>\n    private EmployeeService employeeService;<br \/>\n    &#064;Autowired<br \/>\n    private JwtProperties jwtProperties;<\/p>\n<p>    \/**<br \/>\n     * \u767b\u5f55<br \/>\n     *<br \/>\n     * &#064;param employeeLoginDTO \u767b\u5f55\u8bf7\u6c42\u53c2\u6570<br \/>\n     * &#064;return \u767b\u5f55\u7ed3\u679c&#xff08;\u5305\u542bJWT\u4ee4\u724c\u548c\u5458\u5de5\u4fe1\u606f&#xff09;<br \/>\n     *\/<br \/>\n    &#064;PostMapping(&#034;\/login&#034;)<br \/>\n    &#064;ApiOperation(value &#061; &#034;\u5458\u5de5\u767b\u5f55&#034;)<br \/>\n    public Result&lt;EmployeeLoginVO&gt; login(&#064;RequestBody EmployeeLoginDTO employeeLoginDTO){<br \/>\n        log.info(&#034;\u5458\u5de5\u767b\u5f55&#xff1a;{}&#034;, employeeLoginDTO);<br \/>\n        \/\/\u8c03\u7528\u670d\u52a1\u5c42\u5b8c\u6210\u767b\u5f55\u6821\u9a8c<br \/>\n        Employee employee &#061; employeeService.login(employeeLoginDTO);<br \/>\n        \/\/\u767b\u5f55\u6210\u529f\u540e&#xff0c;\u751f\u6210jwt\u4ee4\u724c<br \/>\n        Map&lt;String, Object&gt; claims &#061; new HashMap&lt;&gt;();<br \/>\n        claims.put(JwtClaimsConstant.EMP_ID, employee.getId());<br \/>\n        String token &#061; JwtUtil.createJWT(<br \/>\n                jwtProperties.getAdminSecretKey(),<br \/>\n                jwtProperties.getAdminTtl(),<br \/>\n                claims<br \/>\n        );<br \/>\n        \/\/\u5c01\u88c5\u767b\u5f55\u8fd4\u56deVO<br \/>\n        EmployeeLoginVO employeeLoginVO &#061; EmployeeLoginVO.builder()<br \/>\n                .id(employee.getId())<br \/>\n                .userName(employee.getUsername())<br \/>\n                .name(employee.getName())<br \/>\n                .token(token)<br \/>\n                .build();<br \/>\n        return Result.success(employeeLoginVO);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * \u9000\u51fa<br \/>\n     *<br \/>\n     * &#064;return<br \/>\n     *\/<br \/>\n    &#064;PostMapping(&#034;\/logout&#034;)<br \/>\n    &#064;ApiOperation(&#034;\u5458\u5de5\u9000\u51fa&#034;)<br \/>\n    public Result&lt;String&gt; logout() {<br \/>\n        return Result.success();<br \/>\n    }<\/p>\n<p>} <\/p>\n<p>\u542f\u52a8\u670d\u52a1&#xff1a;\u8bbf\u95ee\u00a0http:\/\/localhost:8080\/doc.html<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"970\" src=\"2026-01-22xrxz43usyef.png\" width=\"1920\" \/><\/p>\n<\/p>\n<h2>\u65b0\u589e\u5458\u5de5&#xff1a;<\/h2>\n<h3>\u9700\u6c42\u5206\u6790\u548c\u8bbe\u8ba1&#xff1a;<\/h3>\n<h4>\u4ea7\u54c1\u539f\u578b&#xff1a;<\/h4>\n<p>\u65b0\u589e\u5458\u5de5\u539f\u578b&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"662\" src=\"2026-01-22og4win5h1ji.png\" width=\"1303\" \/><\/p>\n<h4>\u63a5\u53e3\u8bbe\u8ba1&#xff1a;<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1178\" src=\"2026-01-22a4a15vwnaxu.png\" width=\"1428\" \/><\/p>\n<p>\u9879\u76ee\u7ea6\u5b9a&#xff1a;\u7ba1\u7406\u7aef\u53d1\u51fa\u7684\u8bf7\u6c42&#xff0c;\u7edf\u4e00\u4f7f\u7528\u00a0\/admin\u00a0\u4f5c\u4e3a\u524d\u7f00&#xff1b;\u7528\u6237\u7aef\u53d1\u51fa\u7684\u8bf7\u6c42&#xff0c;\u7edf\u4e00\u4f7f\u7528\u00a0\/user\u4f5c\u4e3a\u524d\u7f00<\/p>\n<h4>\u8868\u8bbe\u8ba1&#xff1a;<\/h4>\n<p>employee \u8868\u7ed3\u6784&#xff1a;<\/p>\n<table>\n<tr>\u5b57\u6bb5\u540d\u6570\u636e\u7c7b\u578b\u8bf4\u660e\u5907\u6ce8<\/tr>\n<tbody>\n<tr>\n<td>id<\/td>\n<td>bigint<\/td>\n<td>\u4e3b\u952e<\/td>\n<td>\u81ea\u589e<\/td>\n<\/tr>\n<tr>\n<td>name<\/td>\n<td>varchar(32)<\/td>\n<td>\u59d3\u540d<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>username<\/td>\n<td>varchar(32)<\/td>\n<td>\u7528\u6237\u540d<\/td>\n<td>\u552f\u4e00<\/td>\n<\/tr>\n<tr>\n<td>password<\/td>\n<td>varchar(64)<\/td>\n<td>\u5bc6\u7801<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>phone<\/td>\n<td>varchar(11)<\/td>\n<td>\u624b\u673a\u53f7<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>sex<\/td>\n<td>varchar(2)<\/td>\n<td>\u6027\u522b<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>id_number<\/td>\n<td>varchar(18)<\/td>\n<td>\u8eab\u4efd\u8bc1\u53f7<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>status<\/td>\n<td>Int<\/td>\n<td>\u8d26\u53f7\u72b6\u6001<\/td>\n<td>1 \u6b63\u5e38 0 \u9501\u5b9a<\/td>\n<\/tr>\n<tr>\n<td>create_time<\/td>\n<td>Datetime<\/td>\n<td>\u521b\u5efa\u65f6\u95f4<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>update_time<\/td>\n<td>datetime<\/td>\n<td>\u6700\u540e\u4fee\u6539\u65f6\u95f4<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>create_user<\/td>\n<td>bigint<\/td>\n<td>\u521b\u5efa\u4ebaid<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>update_user<\/td>\n<td>bigint<\/td>\n<td>\u6700\u540e\u4fee\u6539\u4ebaid<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8868\u4e2d\u7684 status \u5b57\u6bb5\u5df2\u8bbe\u7f6e\u9ed8\u8ba4\u503c 1 \u8868\u793a\u72b6\u6001\u6b63\u5e38<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"351\" src=\"2026-01-22apenmq5himd.png\" width=\"1393\" \/><\/p>\n<h3>\u4ee3\u7801\u5f00\u53d1&#xff1a;<\/h3>\n<h4>\u8bbe\u8ba1 DTO \u7c7b&#xff1a;<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"726\" src=\"2026-01-22ctlamijwie0.png\" width=\"1369\" \/><\/p>\n<p>EmployeeDTO&#xff1a;<\/p>\n<p>&#064;Data<br \/>\npublic class EmployeeDTO implements Serializable{<\/p>\n<p>    private Long id;<\/p>\n<p>    private String username;<\/p>\n<p>    private String name;<\/p>\n<p>    private String phone;<\/p>\n<p>    private String sex;<\/p>\n<p>    private String idNumber;<\/p>\n<p>} <\/p>\n<h4>Controller \u5c42&#xff1a;<\/h4>\n<p>EmployeeController&#xff1a;<\/p>\n<p>\/**<br \/>\n * \u65b0\u589e\u5458\u5de5<br \/>\n * &#064;param employeeDTO<br \/>\n * &#064;return<br \/>\n *\/<br \/>\n&#064;PostMapping<br \/>\n&#064;ApiOperation(&#034;\u65b0\u589e\u5458\u5de5&#034;)<br \/>\npublic Result save(&#064;RequestBody EmployeeDTO employeeDTO){<br \/>\n    log.info(&#034;\u65b0\u589e\u5458\u5de5&#xff1a;{}&#034;, employeeDTO);<br \/>\n    employeeService.save(employeeDTO);<br \/>\n    return Result.success();<br \/>\n} <\/p>\n<p>Result \u7c7b\u5b9a\u4e49\u4e86\u540e\u7aef\u7edf\u4e00\u8fd4\u56de\u7ed3\u679c\u683c\u5f0f&#xff1a;<\/p>\n<p>\/**<br \/>\n * \u540e\u7aef\u7edf\u4e00\u8fd4\u56de\u7ed3\u679c<br \/>\n * &#064;param &lt;T&gt;<br \/>\n *\/<br \/>\n&#064;Data<br \/>\npublic class Result&lt;T&gt; implements Serializable{<\/p>\n<p>    private Integer code; \/\/\u7f16\u7801&#xff1a;1\u6210\u529f&#xff0c;0\u548c\u5176\u5b83\u6570\u5b57\u4e3a\u5931\u8d25<br \/>\n    private String msg; \/\/\u9519\u8bef\u4fe1\u606f<br \/>\n    private T data; \/\/\u6570\u636e<\/p>\n<p>    public static &lt;T&gt; Result&lt;T&gt; success() {<br \/>\n        Result&lt;T&gt; result &#061; new Result&lt;T&gt;();<br \/>\n        result.code &#061; 1;<br \/>\n        return result;<br \/>\n    }<\/p>\n<p>    public static &lt;T&gt; Result&lt;T&gt; success(T object) {<br \/>\n        Result&lt;T&gt; result &#061; new Result&lt;T&gt;();<br \/>\n        result.data &#061; object;<br \/>\n        result.code &#061; 1;<br \/>\n        return result;<br \/>\n    }<\/p>\n<p>    public static &lt;T&gt; Result&lt;T&gt; error(String msg) {<br \/>\n        Result result &#061; new Result();<br \/>\n        result.msg &#061; msg;<br \/>\n        result.code &#061; 0;<br \/>\n        return result;<br \/>\n    }<\/p>\n<p>} <\/p>\n<h4>Service \u5c42&#xff1a;<\/h4>\n<p>EmployeeService&#xff1a;<\/p>\n<p>\/**<br \/>\n * \u65b0\u589e\u5458\u5de5<br \/>\n * &#064;param employeeDTO<br \/>\n *\/<br \/>\nvoid save(EmployeeDTO employeeDTO); <\/p>\n<p>EmployeeServiceImpl&#xff1a;<\/p>\n<p>\/**<br \/>\n * \u65b0\u589e\u5458\u5de5<br \/>\n *<br \/>\n * &#064;param employeeDTO<br \/>\n *\/<br \/>\npublic void save(EmployeeDTO employeeDTO){<br \/>\n    Employee employee &#061; new Employee();<br \/>\n    \/\/\u5bf9\u8c61\u5c5e\u6027\u62f7\u8d1d<br \/>\n    BeanUtils.copyProperties(employeeDTO,employee);<br \/>\n    \/\/\u8bbe\u7f6e\u8d26\u53f7\u7684\u72b6\u6001&#xff0c;\u9ed8\u8ba4\u6b63\u5e38\u72b6\u6001 1 \u6b63\u5e38 0 \u9501\u5b9a<br \/>\n    employee.setStatus(StatusConstant.ENABLE);<br \/>\n    \/\/\u8bbe\u7f6e\u5bc6\u7801&#xff0c;\u9ed8\u8ba4\u5bc6\u7801123456<br \/>\n    employee.setPassword(DigestUtils.md5DigestAsHex(PasswordConstant.DEFAULT_PASSWORD.getBytes()));<br \/>\n    \/\/\u8bbe\u7f6e\u5f53\u524d\u8bb0\u5f55\u7684\u521b\u5efa\u65f6\u95f4\u548c\u4fee\u6539\u65f6\u95f4<br \/>\n    employee.setCreateTime(LocalDateTime.now());<br \/>\n    employee.setUpdateTime(LocalDateTime.now());<br \/>\n    \/\/\u8bbe\u7f6e\u5f53\u524d\u8bb0\u5f55\u521b\u5efa\u4ebaid\u548c\u4fee\u6539\u4ebaid<br \/>\n    employee.setCreateUser(10L);\/\/\u5047\u6570\u636e<br \/>\n    employee.setUpdateUser(10L);<\/p>\n<p>    employeeMapper.insert(employee);<br \/>\n} <\/p>\n<p>StatusConstant&#xff1a;<\/p>\n<p>\/**<br \/>\n * \u72b6\u6001\u5e38\u91cf&#xff0c;\u542f\u7528\u6216\u8005\u7981\u7528<br \/>\n *\/<br \/>\npublic class StatusConstant{<\/p>\n<p>    \/\/\u542f\u7528<br \/>\n    public static final Integer ENABLE &#061; 1;<\/p>\n<p>    \/\/\u7981\u7528<br \/>\n    public static final Integer DISABLE &#061; 0;<br \/>\n} <\/p>\n<h4>Mapper \u5c42&#xff1a;<\/h4>\n<p>EmployeeMapper&#xff1a;<\/p>\n<p>\/**<br \/>\n * \u63d2\u5165\u5458\u5de5\u6570\u636e<br \/>\n * &#064;param employee<br \/>\n *\/<br \/>\n&#064;Insert(&#034;insert into employee (name, username, password, phone, sex, id_number, create_time, update_time, create_user, update_user,status) &#034; &#043;<br \/>\n        &#034;values &#034; &#043;<br \/>\n        &#034;(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{createTime},#{updateTime},#{createUser},#{updateUser},#{status})&#034;)<br \/>\nvoid insert(Employee employee); <\/p>\n<p>\u5728 application.yml \u4e2d\u5df2\u5f00\u542f\u9a7c\u5cf0\u547d\u540d&#xff0c;\u6545 id_number \u548c idNumber \u53ef\u5bf9\u5e94<\/p>\n<p>mybatis:<br \/>\n  configuration:<br \/>\n    #\u5f00\u542f\u9a7c\u5cf0\u547d\u540d<br \/>\n    map-underscore-to-camel-case: true <\/p>\n<h3>\u529f\u80fd\u6d4b\u8bd5&#xff1a;<\/h3>\n<h4>\u63a5\u53e3\u6587\u6863\u6d4b\u8bd5&#xff1a;<\/h4>\n<p>\u542f\u52a8\u670d\u52a1&#xff1a;\u8bbf\u95ee http:\/\/localhost:8080\/doc.html&#xff0c;\u8fdb\u5165\u65b0\u589e\u5458\u5de5\u63a5\u53e3<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"967\" src=\"2026-01-223q3aciiihw0.png\" width=\"1920\" \/><\/p>\n<p>\u54cd\u5e94\u7801&#xff1a;401 \u62a5\u9519&#xff1b;\u539f\u56e0&#xff1a;JWT \u4ee4\u724c\u6821\u9a8c\u5931\u8d25<\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5&#xff1a;\u8c03\u7528\u5458\u5de5\u767b\u5f55\u63a5\u53e3\u83b7\u5f97\u4e00\u4e2a\u5408\u6cd5\u7684 JWT \u4ee4\u724c<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"966\" src=\"2026-01-22uhd00fl1agb.png\" width=\"1920\" \/><\/p>\n<p>\u5c06\u5408\u6cd5\u7684 JWT \u4ee4\u724c\u6dfb\u52a0\u5230\u5168\u5c40\u53c2\u6570\u4e2d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"964\" src=\"2026-01-224t0ibp0bbjv.png\" width=\"1920\" \/><\/p>\n<p>\u63a5\u53e3\u6d4b\u8bd5&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"969\" src=\"2026-01-22uzx1l1s34uq.png\" width=\"1920\" \/><\/p>\n<p>\u67e5\u770b employee \u8868&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"69\" src=\"2026-01-22vhqsqxdepww.png\" width=\"1344\" \/><\/p>\n<h4>\u524d\u540e\u7aef\u8054\u8c03\u6d4b\u8bd5&#xff1a;<\/h4>\n<p>\u8bbf\u95ee http:\/\/localhost<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"967\" src=\"2026-01-225u1cbldvpfr.png\" width=\"1920\" \/><\/p>\n<p>\u67e5\u770b employee \u8868&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"91\" src=\"2026-01-22vwao4deuu2y.png\" width=\"1345\" \/><\/p>\n<h3>\u4ee3\u7801\u5b8c\u5584&#xff1a;<\/h3>\n<p>\u95ee\u9898\u4e00&#xff1a;<\/p>\n<p>\u5f55\u5165\u7684\u7528\u6237\u540d\u5df2\u5b58&#xff0c;\u629b\u51fa\u7684\u5f02\u5e38\u540e\u6ca1\u6709\u5904\u7406<\/p>\n<p>GlobalExceptionHandler&#xff1a;<\/p>\n<p>\/**<br \/>\n * \u5904\u7406SQL\u5f02\u5e38<br \/>\n * &#064;param ex<br \/>\n * &#064;return<br \/>\n *\/<br \/>\n&#064;ExceptionHandler<br \/>\npublic Result exceptionHandler(SQLIntegrityConstraintViolationException ex){<br \/>\n    String message &#061; ex.getMessage();<br \/>\n    if(message.contains(&#034;Duplicate entry&#034;)){<br \/>\n        String[] split &#061; message.split(&#034; &#034;);<br \/>\n        String username &#061; split[2];<br \/>\n        String msg &#061; username &#043; MessageConstant.ALREADY_EXISTS;<br \/>\n        return Result.error(msg);<br \/>\n    }else{<br \/>\n        return Result.error(MessageConstant.UNKNOWN_ERROR);<br \/>\n    }<br \/>\n} <\/p>\n<p>\u5728 MessageConstant \u4e2d\u6dfb\u52a0<\/p>\n<p>public static final String ALREADY_EXISTS &#061; &#034;\u5df2\u5b58\u5728&#034;; <\/p>\n<p>\u63a5\u53e3\u6d4b\u8bd5&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"963\" src=\"2026-01-22w1o50nbjwoj.png\" width=\"1920\" \/><\/p>\n<p>\u95ee\u9898\u4e8c&#xff1a;<\/p>\n<p>\u65b0\u589e\u5458\u5de5\u65f6&#xff0c;\u521b\u5efa\u4eba id \u548c\u4fee\u6539\u4eba id \u8bbe\u7f6e\u4e3a\u56fa\u5b9a\u503c<\/p>\n<p>employee.setCreateUser(10L);<br \/>\nemployee.setUpdateUser(10L); <\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5&#xff1a;\u5458\u5de5\u767b\u5f55\u6210\u529f\u540e\u751f\u6210 JWT \u4ee4\u724c\u5e76\u8fd4\u56de\u81f3\u524d\u7aef&#xff1b;\u524d\u7aef\u540e\u7eed\u53d1\u8d77\u8bf7\u6c42\u65f6\u643a\u5e26\u8be5\u4ee4\u724c&#xff0c;\u540e\u7aef\u89e3\u6790\u4ee4\u724c\u83b7\u53d6\u5f53\u524d\u767b\u5f55\u5458\u5de5 ID&#xff0c;\u901a\u8fc7 ThreadLocal \u5c06\u8be5 ID \u4f20\u9012\u81f3 Service \u5c42\u7684 save \u65b9\u6cd5\u4e2d\u4f7f\u7528<\/p>\n<p>ThreadLocal&#xff1a;<\/p>\n<p>\u4ecb\u7ecd&#xff1a;ThreadLocal \u5e76\u4e0d\u662f\u4e00\u4e2aThread&#xff0c;\u800c\u662fThread\u7684\u5c40\u90e8\u53d8\u91cf&#xff1b;ThreadLocal \u4e3a\u6bcf\u4e2a\u7ebf\u7a0b\u63d0\u4f9b\u5355\u72ec\u4e00\u4efd\u5b58\u50a8\u7a7a\u95f4&#xff0c;\u5177\u6709\u7ebf\u7a0b\u9694\u79bb\u7684\u6548\u679c&#xff0c;\u53ea\u6709\u5728\u7ebf\u7a0b\u5185\u624d\u80fd\u83b7\u53d6\u5230\u5bf9\u5e94\u7684\u503c&#xff0c;\u7ebf\u7a0b\u5916\u5219\u4e0d\u80fd\u8bbf\u95ee<\/p>\n<p>\u5e38\u7528\u65b9\u6cd5&#xff1a;<\/p>\n<p>public void set(T value)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8bbe\u7f6e\u5f53\u524d\u7ebf\u7a0b\u7684\u7ebf\u7a0b\u5c40\u90e8\u53d8\u91cf\u7684\u503c<\/p>\n<p>public T get()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8fd4\u56de\u5f53\u524d\u7ebf\u7a0b\u6240\u5bf9\u5e94\u7684\u7ebf\u7a0b\u5c40\u90e8\u53d8\u91cf\u7684\u503c<\/p>\n<p>public void remove()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u79fb\u9664\u5f53\u524d\u7ebf\u7a0b\u7684\u7ebf\u7a0b\u5c40\u90e8\u53d8\u91cf<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"379\" src=\"2026-01-220gqadq2mcst.png\" width=\"975\" \/><\/p>\n<p>\u521d\u59cb\u5de5\u7a0b\u4e2d\u5df2\u7ecf\u5c01\u88c5\u4e86 ThreadLocal \u64cd\u4f5c\u7684\u5de5\u5177\u7c7b&#xff1a;<\/p>\n<p>public class BaseContext{<\/p>\n<p>    public static ThreadLocal&lt;Long&gt; threadLocal &#061; new ThreadLocal&lt;&gt;();<\/p>\n<p>    public static void setCurrentId(Long id){<br \/>\n        threadLocal.set(id);<br \/>\n    }<\/p>\n<p>    public static Long getCurrentId(){<br \/>\n        return threadLocal.get();<br \/>\n    }<\/p>\n<p>    public static void removeCurrentId(){<br \/>\n        threadLocal.remove();<br \/>\n    }<\/p>\n<p>} <\/p>\n<p>\u5728\u62e6\u622a\u5668\u4e2d\u89e3\u6790\u51fa\u5f53\u524d\u767b\u5f55\u5458\u5de5 id&#xff0c;\u5e76\u653e\u5165\u7ebf\u7a0b\u5c40\u90e8\u53d8\u91cf\u4e2d&#xff1a;<\/p>\n<p>\/**<br \/>\n * jwt\u4ee4\u724c\u6821\u9a8c\u7684\u62e6\u622a\u5668<br \/>\n *\/<br \/>\n&#064;Component<br \/>\n&#064;Slf4j<br \/>\npublic class JwtTokenAdminInterceptor implements HandlerInterceptor{<\/p>\n<p>    &#064;Autowired<br \/>\n    private JwtProperties jwtProperties;<\/p>\n<p>    \/**<br \/>\n     * \u6821\u9a8cjwt<br \/>\n     *<br \/>\n     * &#064;param request<br \/>\n     * &#064;param response<br \/>\n     * &#064;param handler<br \/>\n     * &#064;return<br \/>\n     * &#064;throws Exception<br \/>\n     *\/<br \/>\n    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception{<br \/>\n        \/\/\u5224\u65ad\u5f53\u524d\u62e6\u622a\u5230\u7684\u662fController\u7684\u65b9\u6cd5\u8fd8\u662f\u5176\u4ed6\u8d44\u6e90<br \/>\n        if(!(handler instanceof HandlerMethod)){<br \/>\n            \/\/\u5f53\u524d\u62e6\u622a\u5230\u7684\u4e0d\u662f\u52a8\u6001\u65b9\u6cd5&#xff0c;\u76f4\u63a5\u653e\u884c<br \/>\n            return true;<br \/>\n        }<\/p>\n<p>        \/\/\u4ece\u8bf7\u6c42\u5934\u4e2d\u83b7\u53d6\u4ee4\u724c<br \/>\n        String token &#061; request.getHeader(jwtProperties.getAdminTokenName());<\/p>\n<p>        \/\/\u6821\u9a8c\u4ee4\u724c<br \/>\n        try{<br \/>\n            log.info(&#034;jwt\u6821\u9a8c:{}&#034;, token);<br \/>\n            Claims claims &#061; JwtUtil.parseJWT(jwtProperties.getAdminSecretKey(), token);<br \/>\n            Long empId &#061; Long.valueOf(claims.get(JwtClaimsConstant.EMP_ID).toString());<br \/>\n            log.info(&#034;\u5f53\u524d\u5458\u5de5id&#xff1a;&#034;, empId);<br \/>\n            \/\/\u5c06\u7528\u6237id\u5b58\u50a8\u5230ThreadLocal<br \/>\n            BaseContext.setCurrentId(empId);<br \/>\n            \/\/\u901a\u8fc7&#xff0c;\u653e\u884c<br \/>\n            return true;<br \/>\n        }catch (Exception ex){<br \/>\n            \/\/\u4e0d\u901a\u8fc7&#xff0c;\u54cd\u5e94401\u72b6\u6001\u7801<br \/>\n            response.setStatus(401);<br \/>\n            return false;<br \/>\n        }<br \/>\n    }<br \/>\n} <\/p>\n<p>\u5728 Service \u4e2d\u83b7\u53d6\u7ebf\u7a0b\u5c40\u90e8\u53d8\u91cf\u4e2d\u7684\u503c&#xff1a;<\/p>\n<p>\/**<br \/>\n * \u65b0\u589e\u5458\u5de5<br \/>\n *<br \/>\n * &#064;param employeeDTO<br \/>\n *\/<br \/>\npublic void save(EmployeeDTO employeeDTO){<br \/>\n    Employee employee &#061; new Employee();<br \/>\n    \/\/\u5bf9\u8c61\u5c5e\u6027\u62f7\u8d1d<br \/>\n    BeanUtils.copyProperties(employeeDTO,employee);<br \/>\n    \/\/\u8bbe\u7f6e\u8d26\u53f7\u7684\u72b6\u6001&#xff0c;\u9ed8\u8ba4\u6b63\u5e38\u72b6\u6001 1 \u6b63\u5e38 0 \u9501\u5b9a<br \/>\n    employee.setStatus(StatusConstant.ENABLE);<br \/>\n    \/\/\u8bbe\u7f6e\u5bc6\u7801&#xff0c;\u9ed8\u8ba4\u5bc6\u7801123456<br \/>\n    employee.setPassword(DigestUtils.md5DigestAsHex(PasswordConstant.DEFAULT_PASSWORD.getBytes()));<br \/>\n    \/\/\u8bbe\u7f6e\u5f53\u524d\u8bb0\u5f55\u7684\u521b\u5efa\u65f6\u95f4\u548c\u4fee\u6539\u65f6\u95f4<br \/>\n    employee.setCreateTime(LocalDateTime.now());<br \/>\n    employee.setUpdateTime(LocalDateTime.now());<br \/>\n    \/\/\u8bbe\u7f6e\u5f53\u524d\u8bb0\u5f55\u521b\u5efa\u4ebaid\u548c\u4fee\u6539\u4ebaid<br \/>\n    employee.setCreateUser(BaseContext.getCurrentId());<br \/>\n    employee.setUpdateUser(BaseContext.getCurrentId());<\/p>\n<p>    employeeMapper.insert(employee);<br \/>\n} <\/p>\n<p>\u6d4b\u8bd5&#xff1a;\u4f7f\u7528 admin&#xff08;id&#061;1&#xff09;\u7528\u6237\u767b\u5f55\u540e\u6dfb\u52a0\u4e00\u6761\u8bb0\u5f55<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"967\" src=\"2026-01-2242yrwwtnpz5.png\" width=\"1920\" \/><\/p>\n<p>\u67e5\u770b employee \u8868&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"113\" src=\"2026-01-22eoa5wjqutea.png\" width=\"1338\" \/><\/p>\n<h3>\u4ee3\u7801\u63d0\u4ea4&#xff1a;<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1020\" src=\"2026-01-22qq1yux2mhg2.png\" width=\"1920\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1020\" src=\"2026-01-224yqzactzs40.png\" width=\"1920\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9879\u76ee\u6574\u4f53\u5c55\u793a&#xff1a; \u5f00\u53d1\u73af\u5883\u642d\u5efa&#xff1a; \u524d\u7aef\u73af\u5883\u642d\u5efa&#xff1a;<br \/>\n\u524d\u7aef\u5de5\u7a0b\u57fa\u4e8e nginx&#xff1a; \u542f\u52a8 nginx \u670d\u52a1\u8bbf\u95ee\u6d4b\u8bd5&#xff1a; \u540e\u7aef\u73af\u5883\u642d\u5efa&#xff1a;<br \/>\n\u9879\u76ee\u7ed3\u6784&#xff1a;<br \/>\n\u540e\u7aef\u5de5\u7a0b\u57fa\u4e8e maven \u8fdb\u884c\u9879\u76ee\u6784\u5efa&#xff0c;\u5e76\u4e14\u8fdb\u884c\u5206\u6a21\u5757\u5f00\u53d1 \u5de5\u7a0b\u7684\u5404\u4e2a\u6a21\u5757\u4f5c\u7528\u8bf4\u660e&#xff1a;<br \/>\n\u540d\u79f0\u8bf4\u660esky-take-outmaven \u7236\u5de5\u7a0b&#xff0c;\u7edf\u4e00\u7ba1\u7406\u4f9d\u8d56\u7248\u672c&#xff0c;\u805a\u5408\u5176\u4ed6\u5b50\u6a21\u5757sky-c<\/p>\n","protected":false},"author":2,"featured_media":64029,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[292],"topic":[],"class_list":["post-64049","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-292"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u82cd\u7a79\u5916\u5356 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/64049.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u82cd\u7a79\u5916\u5356 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u9879\u76ee\u6574\u4f53\u5c55\u793a&#xff1a; \u5f00\u53d1\u73af\u5883\u642d\u5efa&#xff1a; \u524d\u7aef\u73af\u5883\u642d\u5efa&#xff1a; \u524d\u7aef\u5de5\u7a0b\u57fa\u4e8e nginx&#xff1a; \u542f\u52a8 nginx \u670d\u52a1\u8bbf\u95ee\u6d4b\u8bd5&#xff1a; \u540e\u7aef\u73af\u5883\u642d\u5efa&#xff1a; \u9879\u76ee\u7ed3\u6784&#xff1a; \u540e\u7aef\u5de5\u7a0b\u57fa\u4e8e maven \u8fdb\u884c\u9879\u76ee\u6784\u5efa&#xff0c;\u5e76\u4e14\u8fdb\u884c\u5206\u6a21\u5757\u5f00\u53d1 \u5de5\u7a0b\u7684\u5404\u4e2a\u6a21\u5757\u4f5c\u7528\u8bf4\u660e&#xff1a; \u540d\u79f0\u8bf4\u660esky-take-outmaven \u7236\u5de5\u7a0b&#xff0c;\u7edf\u4e00\u7ba1\u7406\u4f9d\u8d56\u7248\u672c&#xff0c;\u805a\u5408\u5176\u4ed6\u5b50\u6a21\u5757sky-c\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/64049.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-22T10:17:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101728-6971f938693b5.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/64049.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/64049.html\",\"name\":\"\u82cd\u7a79\u5916\u5356 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-22T10:17:41+00:00\",\"dateModified\":\"2026-01-22T10:17:41+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/64049.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/64049.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/64049.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u82cd\u7a79\u5916\u5356\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u82cd\u7a79\u5916\u5356 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/64049.html","og_locale":"zh_CN","og_type":"article","og_title":"\u82cd\u7a79\u5916\u5356 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u9879\u76ee\u6574\u4f53\u5c55\u793a&#xff1a; \u5f00\u53d1\u73af\u5883\u642d\u5efa&#xff1a; \u524d\u7aef\u73af\u5883\u642d\u5efa&#xff1a; \u524d\u7aef\u5de5\u7a0b\u57fa\u4e8e nginx&#xff1a; \u542f\u52a8 nginx \u670d\u52a1\u8bbf\u95ee\u6d4b\u8bd5&#xff1a; \u540e\u7aef\u73af\u5883\u642d\u5efa&#xff1a; \u9879\u76ee\u7ed3\u6784&#xff1a; \u540e\u7aef\u5de5\u7a0b\u57fa\u4e8e maven \u8fdb\u884c\u9879\u76ee\u6784\u5efa&#xff0c;\u5e76\u4e14\u8fdb\u884c\u5206\u6a21\u5757\u5f00\u53d1 \u5de5\u7a0b\u7684\u5404\u4e2a\u6a21\u5757\u4f5c\u7528\u8bf4\u660e&#xff1a; \u540d\u79f0\u8bf4\u660esky-take-outmaven \u7236\u5de5\u7a0b&#xff0c;\u7edf\u4e00\u7ba1\u7406\u4f9d\u8d56\u7248\u672c&#xff0c;\u805a\u5408\u5176\u4ed6\u5b50\u6a21\u5757sky-c","og_url":"https:\/\/www.wsisp.com\/helps\/64049.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-22T10:17:41+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260122101728-6971f938693b5.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/64049.html","url":"https:\/\/www.wsisp.com\/helps\/64049.html","name":"\u82cd\u7a79\u5916\u5356 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-22T10:17:41+00:00","dateModified":"2026-01-22T10:17:41+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/64049.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/64049.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/64049.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u82cd\u7a79\u5916\u5356"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/64049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=64049"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/64049\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/64029"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=64049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=64049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=64049"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=64049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}