{"id":14983125,"url":"https://github.com/hwywl/ant-nest","last_synced_at":"2026-03-06T12:01:53.622Z","repository":{"id":37169287,"uuid":"184045279","full_name":"HWYWL/ant-nest","owner":"HWYWL","description":"蚂蚁巢,专注于方便的注解","archived":false,"fork":false,"pushed_at":"2024-05-16T17:16:04.000Z","size":86,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-10T02:33:29.403Z","etag":null,"topics":["annotations","mybatis","spring","spring-mvc","sql"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HWYWL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-29T09:54:41.000Z","updated_at":"2022-04-13T07:57:57.000Z","dependencies_parsed_at":"2024-10-12T02:51:18.006Z","dependency_job_id":null,"html_url":"https://github.com/HWYWL/ant-nest","commit_stats":{"total_commits":58,"total_committers":2,"mean_commits":29.0,"dds":0.03448275862068961,"last_synced_commit":"fdd5ce97b486ee418d291c5574cf1cf849558c37"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/HWYWL/ant-nest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HWYWL%2Fant-nest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HWYWL%2Fant-nest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HWYWL%2Fant-nest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HWYWL%2Fant-nest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HWYWL","download_url":"https://codeload.github.com/HWYWL/ant-nest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HWYWL%2Fant-nest/sbom","scorecard":{"id":60593,"data":{"date":"2025-08-11","repo":{"name":"github.com/HWYWL/ant-nest","commit":"fdd5ce97b486ee418d291c5574cf1cf849558c37"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/26 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 4 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"136 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-vmq6-5m68-f53m","Warn: Project is vulnerable to: GHSA-668q-qrv7-99fm","Warn: Project is vulnerable to: GHSA-6v67-2wr5-gvf4","Warn: Project is vulnerable to: GHSA-pr98-23f8-jwxv","Warn: Project is vulnerable to: GHSA-6c25-cxcc-pmc4","Warn: Project is vulnerable to: GHSA-77h8-5j3h-jcjf","Warn: Project is vulnerable to: GHSA-pv7h-hx5h-mgfj","Warn: Project is vulnerable to: GHSA-h46c-h94j-95f3","Warn: Project is vulnerable to: GHSA-wf8f-6423-gfxg","Warn: Project is vulnerable to: GHSA-27xj-rqx5-2255","Warn: Project is vulnerable to: GHSA-288c-cq4h-88gq","Warn: Project is vulnerable to: GHSA-4w82-r329-3q67","Warn: Project is vulnerable to: GHSA-57j2-w4cx-62h2","Warn: Project is vulnerable to: GHSA-58pp-9c76-5625","Warn: Project is vulnerable to: GHSA-5949-rw7g-wx7w","Warn: Project is vulnerable to: GHSA-5p34-5m6p-p58g","Warn: Project is vulnerable to: GHSA-5r5r-6hpj-8gg9","Warn: Project is vulnerable to: GHSA-5ww9-j83m-q7qx","Warn: Project is vulnerable to: GHSA-6fpp-rgj9-8rwc","Warn: Project is vulnerable to: GHSA-758m-v56v-grj4","Warn: Project is vulnerable to: GHSA-85cw-hj65-qqv9","Warn: Project is vulnerable to: GHSA-89qr-369f-5m5x","Warn: Project is vulnerable to: GHSA-8c4j-34r4-xr8g","Warn: Project is vulnerable to: GHSA-8w26-6f25-cm9x","Warn: Project is vulnerable to: GHSA-95cm-88f5-f2c7","Warn: Project is vulnerable to: GHSA-9gph-22xh-8x98","Warn: Project is vulnerable to: GHSA-9m6f-7xcq-8vf8","Warn: Project is vulnerable to: GHSA-9vvp-fxw6-jcxr","Warn: Project is vulnerable to: GHSA-c265-37vj-cwcc","Warn: Project is vulnerable to: GHSA-c2q3-4qrh-fm48","Warn: Project is vulnerable to: GHSA-cf6r-3wgc-h863","Warn: Project is vulnerable to: GHSA-cmfg-87vq-g5g4","Warn: Project is vulnerable to: GHSA-cvm9-fjm9-3572","Warn: Project is vulnerable to: GHSA-f3j5-rmmp-3fc5","Warn: Project is vulnerable to: GHSA-f9xh-2qgp-cq57","Warn: Project is vulnerable to: GHSA-fmmc-742q-jg75","Warn: Project is vulnerable to: GHSA-fqwf-pjwf-7vqv","Warn: Project is vulnerable to: GHSA-gjmw-vf9h-g25v","Warn: Project is vulnerable to: GHSA-gwp4-hfv6-p7hw","Warn: Project is vulnerable to: GHSA-gww7-p5w4-wrfv","Warn: Project is vulnerable to: GHSA-h3cw-g4mq-c5x2","Warn: Project is vulnerable to: GHSA-h4rc-386g-6m85","Warn: Project is vulnerable to: GHSA-h822-r4r5-v8jg","Warn: Project is vulnerable to: GHSA-j823-4qch-3rgm","Warn: Project is vulnerable to: GHSA-jjjh-jjxp-wpff","Warn: Project is vulnerable to: GHSA-m6x4-97wx-4q27","Warn: Project is vulnerable to: GHSA-mc6h-4qgp-37qh","Warn: Project is vulnerable to: GHSA-mph4-vhrx-mv67","Warn: Project is vulnerable to: GHSA-mx7p-6679-8g3q","Warn: Project is vulnerable to: GHSA-p43x-xfjf-5jhr","Warn: Project is vulnerable to: GHSA-q93h-jc49-78gg","Warn: Project is vulnerable to: GHSA-qjw2-hr98-qgfh","Warn: Project is vulnerable to: GHSA-qmqc-x3r4-6v39","Warn: Project is vulnerable to: GHSA-r3gr-cxrf-hg25","Warn: Project is vulnerable to: GHSA-r695-7vr9-jgc2","Warn: Project is vulnerable to: GHSA-rf6r-2c4q-2vwg","Warn: Project is vulnerable to: GHSA-rgv9-q543-rqg4","Warn: Project is vulnerable to: GHSA-rpr3-cw39-3pxh","Warn: Project is vulnerable to: GHSA-v3xw-c963-f5hc","Warn: Project is vulnerable to: GHSA-v585-23hc-c647","Warn: Project is vulnerable to: GHSA-vfqx-33qm-g869","Warn: Project is vulnerable to: GHSA-wh8g-3j2c-rqj5","Warn: Project is vulnerable to: GHSA-5mg8-w23w-74h3","Warn: Project is vulnerable to: GHSA-7g45-4rm6-3mm3","Warn: Project is vulnerable to: GHSA-78wr-2p64-hpwj","Warn: Project is vulnerable to: GHSA-5mcr-gq6c-3hq2","Warn: Project is vulnerable to: GHSA-9vjp-v76f-g363","Warn: Project is vulnerable to: GHSA-cqqj-4p63-rrmm","Warn: Project is vulnerable to: GHSA-f256-j965-7f32","Warn: Project is vulnerable to: GHSA-grg4-wf29-r9vv","Warn: Project is vulnerable to: GHSA-p2v9-g2qv-p635","Warn: Project is vulnerable to: GHSA-wm47-8v5p-wjpj","Warn: Project is vulnerable to: GHSA-wx5j-54mm-rqqq","Warn: Project is vulnerable to: GHSA-2qrg-x229-3v8q","Warn: Project is vulnerable to: GHSA-65fg-84f6-3jq3","Warn: Project is vulnerable to: GHSA-f7vh-qwp3-x37m","Warn: Project is vulnerable to: GHSA-fp5r-v3w9-4333","Warn: Project is vulnerable to: GHSA-w9p3-5cr8-m3jj","Warn: Project is vulnerable to: GHSA-27hp-xhwr-wr2m","Warn: Project is vulnerable to: GHSA-2rvv-w9r2-rg7m","Warn: Project is vulnerable to: GHSA-5j33-cvvr-w245","Warn: Project is vulnerable to: GHSA-7w75-32cg-r6g2","Warn: Project is vulnerable to: GHSA-83qj-6fr2-vhqg","Warn: Project is vulnerable to: GHSA-9xcj-c8cr-8c3c","Warn: Project is vulnerable to: GHSA-c9hw-wf7x-jp9j","Warn: Project is vulnerable to: GHSA-fccv-jmmp-qg76","Warn: Project is vulnerable to: GHSA-g8pj-r55q-5c2v","Warn: Project is vulnerable to: GHSA-h2fw-rfh5-95r3","Warn: Project is vulnerable to: GHSA-h3gc-qfqq-6h8f","Warn: Project is vulnerable to: GHSA-hfrx-6qgj-fp6c","Warn: Project is vulnerable to: GHSA-hh3j-x4mc-g48r","Warn: Project is vulnerable to: GHSA-j39c-c8hj-x4j3","Warn: Project is vulnerable to: GHSA-jgwr-3qm3-26f3","Warn: Project is vulnerable to: GHSA-p22x-g9px-3945","Warn: Project is vulnerable to: GHSA-q3mw-pvr8-9ggc","Warn: Project is vulnerable to: GHSA-q4hg-rmq2-52q9","Warn: Project is vulnerable to: GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GHSA-qxf4-chvg-4r8r","Warn: Project is vulnerable to: GHSA-r6j3-px5g-cq3x","Warn: Project is vulnerable to: GHSA-wc4r-xq3c-5cf3","Warn: Project is vulnerable to: GHSA-wm9w-rjj3-j356","Warn: Project is vulnerable to: GHSA-v682-8vv8-vpwr","Warn: Project is vulnerable to: GHSA-2hw2-62cp-p9p7","Warn: Project is vulnerable to: GHSA-7286-pgfv-vxvh","Warn: Project is vulnerable to: GHSA-7v6m-28jr-rg84","Warn: Project is vulnerable to: GHSA-m8p2-495h-ccmh","Warn: Project is vulnerable to: GHSA-rmrm-75hp-phr2","Warn: Project is vulnerable to: GHSA-x83m-pf6f-pf9g","Warn: Project is vulnerable to: GHSA-qq48-m4jx-xqh8","Warn: Project is vulnerable to: GHSA-cm59-pr5q-cw85","Warn: Project is vulnerable to: GHSA-rc42-6c7j-7h5r","Warn: Project is vulnerable to: GHSA-xf96-w227-r7c4","Warn: Project is vulnerable to: GHSA-36p3-wjmg-h94x","Warn: Project is vulnerable to: GHSA-hh26-6xwr-ggv7","Warn: Project is vulnerable to: GHSA-4gc7-5j7h-4qph","Warn: Project is vulnerable to: GHSA-4wp7-92pw-q264","Warn: Project is vulnerable to: GHSA-g5mm-vmx4-3rg7","Warn: Project is vulnerable to: GHSA-558x-2xjg-6232","Warn: Project is vulnerable to: GHSA-564r-hj7v-mcr5","Warn: Project is vulnerable to: GHSA-9cmq-m9j5-mvww","Warn: Project is vulnerable to: GHSA-wxqc-pxw9-g2p8","Warn: Project is vulnerable to: GHSA-2rmj-mq67-h97g","Warn: Project is vulnerable to: GHSA-2wrp-6fg6-hmc5","Warn: Project is vulnerable to: GHSA-4wrc-f8pq-fpqp","Warn: Project is vulnerable to: GHSA-ccgv-vj62-xf9h","Warn: Project is vulnerable to: GHSA-hgjh-9rj2-g67j","Warn: Project is vulnerable to: GHSA-8wx2-9q48-vm9r","Warn: Project is vulnerable to: GHSA-g5vr-rgqm-vf78","Warn: Project is vulnerable to: GHSA-3mc7-4q67-w48m","Warn: Project is vulnerable to: GHSA-98wm-3w3q-mw94","Warn: Project is vulnerable to: GHSA-9w3m-gqgf-c4p9","Warn: Project is vulnerable to: GHSA-c4r9-r8fh-9vj2","Warn: Project is vulnerable to: GHSA-hhhw-99gj-p3c3","Warn: Project is vulnerable to: GHSA-mjmj-j48q-9wg2","Warn: Project is vulnerable to: GHSA-rvwf-54qp-4r6v","Warn: Project is vulnerable to: GHSA-w37g-rhq8-7m4j"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-15T01:36:46.082Z","repository_id":37169287,"created_at":"2025-08-15T01:36:46.083Z","updated_at":"2025-08-15T01:36:46.083Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30175874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T11:48:51.886Z","status":"ssl_error","status_checked_at":"2026-03-06T11:48:51.460Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["annotations","mybatis","spring","spring-mvc","sql"],"created_at":"2024-09-24T14:06:46.398Z","updated_at":"2026-03-06T12:01:53.598Z","avatar_url":"https://github.com/HWYWL.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ant-nest\n蚂蚁巢,专注于方便的注解\n\n[![author](https://img.shields.io/badge/author-HWY-red.svg)](https://github.com/HWYWL) [![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE) [![Maven Central](https://img.shields.io/badge/ant--nest-1.1.11--RELEASE-ff69b4.svg)](https://search.maven.org/artifact/com.github.hwywl/ant-nest/1.1.11-RELEASE/jar)\n### 说明\n我们通过注解可以干很多的事，也很方便，大大提高我的开发效率，至此开发常用的注解方便我们使用。\n\n### 版本\n现在最新的版本：\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.hwywl\u003c/groupId\u003e\n  \u003cartifactId\u003eant-nest\u003c/artifactId\u003e\n  \u003cversion\u003e1.1.11-RELEASE\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n如果想看看注解例子的使用可以参考这个项目：[spring-boot-mybatis-druid](https://github.com/HWYWL/spring-boot-2.x-examples/tree/master/spring-boot-mybatis-druid)\n\n**注解描述：**\n\n----------\n\n- [@WebLog 请求日志拦截](#WebLog)\n- [@SqlStatement mybatis SQL拦截](#SqlStatement)\n- [@OperatingTime 方法耗时计算](#OperatingTime)\n- [@AESEncryptBody @DESEncryptBody接口返回数据加密](#Encrypt)\n- [@AESDecryptBody @DESDecryptBody接口请求数据解密](#Decrypt)\n- [@MethodCounter 计算方法调用次数](#MethodCounter)\n- [@GetProperties 项目启动时加载自定义properties配置文件](#GetProperties)\n- [@ZooLock 分布式锁](#ZooLock)\n\n\n\u003cdiv id=\"WebLog\"\u003e\u003c/div\u003e\n\n### @WebLog 请求日志拦截\n我们只需要在controller接口中加入注解即可\n![](https://i.imgur.com/uanFdPX.png)\n\n加入注解之后会拦截请求的日志，日志被安排的整整齐齐，方便我们后端人员的调试工作。\n![](https://i.imgur.com/9Zmeyuu.png)\n\n\u003cdiv id=\"SqlStatement\"\u003e\u003c/div\u003e\n\n### @SqlStatement mybatis SQL拦截\n我们只需要在我们操作的接口实现中加入注解即可\n![](https://i.imgur.com/3PR2m1J.png)\n\n加入注解之后会拦截mybatis的SQL，日志被安排的整整齐齐，方便我们的调试查看和测试SQL性能。\n![](https://i.imgur.com/3YNBBZs.png)\n\n**注意：此注解不能在接口上使用，只能在方法上**\n\n\u003cdiv id=\"OperatingTime\"\u003e\u003c/div\u003e\n\n### @OperatingTime 方法耗时计算\n我们只需要在我们操作的接口/方法实现中加入注解即可\n![](https://i.imgur.com/0ciWYkr.png)\n\n加入注解之后我们就能看到方法耗时，方便我们的测试方法编写的性能。\n![](https://i.imgur.com/N0hSuUH.png)\n\n\u003cdiv id=\"Encrypt\"\u003e\u003c/div\u003e\n\n### @AESEncryptBody \u0026 @DESEncryptBody 接口返回数据加密\n使用之前我们先要在application.properties文件中进行参数配置,密钥至少16位，例如：\n```\nencrypt.body.aes-key=1234567812345678\nencrypt.body.des-key=1234567812345678\n```\n\n配置完成，接下来我们就可以愉快的使用了，注解可以使用在类上也可以使用在mvc接口上，例如：\n```java\n@RestController\n@DESEncryptBody\npublic class BaikeController {\n    @Autowired\n    BaikeService baikeService;\n\n    @RequestMapping(value = \"/selectByExample\", method = RequestMethod.POST)\n    public MessageResult selectByExample(){\n        BaikeExample example = new BaikeExample();\n        BaikeExample.Criteria criteria = example.createCriteria();\n        criteria.andNameEqualTo(\"海明威\");\n\n        List\u003cBaike\u003e baikes = baikeService.selectByExample(example);\n\n        return MessageResult.ok(baikes);\n    }\n\n    @RequestMapping(value = \"/selectById\", method = RequestMethod.POST)\n    public MessageResult selectById(){\n        Baike baike = baikeService.selectByPrimaryKey(1L);\n\n        return MessageResult.ok(baike);\n    }\n}\n```\n**写在类上则所有接口的返回数据都会被加密。**\n\n```java\n@DESEncryptBody\n@RequestMapping(value = \"/selectById\", method = RequestMethod.POST)\npublic MessageResult selectById(){\n    Baike baike = baikeService.selectByPrimaryKey(1L);\n\n    return MessageResult.ok(baike);\n}\n```\n**写在单个接口上可以使改接口返回的数据被加密，不影响其他接口。**\n\n\u003cdiv id=\"Decrypt\"\u003e\u003c/div\u003e\n\n我们只需要在请求接口的方法上加上解密的注解即可解密，例如：\n```java\n@DESDecryptBody\n@RequestMapping(value = \"/selectByIdDecrypt\", method = RequestMethod.GET)\npublic MessageResult selectByIdDecrypt(@RequestBody String content){\n\n    System.out.println(content);\n\n    return MessageResult.ok(content);\n}\n```\n**注意：请求参数必须写上@RequestBody注解，不然注解不会生效**\n\n我们使用postman来请求一下我们的接口\n![](https://i.imgur.com/d2TukWV.png)\n加密解密至此完成！！！\n\n- AES加密方式：加密模式:ECB、填充:pkcs5padding、数据块:128位、密码: 配置文件中的key、偏移量: ECB模式不需要、输出:hex、字符集：UTF-8\n\n- DES加密方式：加密模式:ECB、填充:pkcs5padding、数据块:128位、密码: 配置文件中的key、偏移量: ECB模式不需要、输出:hex、字符集：UTF-8\n\n返回的数据可以在这个网站上解密测试：http://tool.chacuo.net/cryptaes\n![](https://i.imgur.com/6RQTVG8.png)\n\n\n\u003cdiv id=\"MethodCounter\"\u003e\u003c/div\u003e\n\n### @MethodCounter 计算方法调用次数\n使用@MethodCounter注解在我们的方法上即可使用，例如：\n![](https://i.imgur.com/FKCepyl.png)\n\n获取调用的次数是：\n```java\nLong num = MethodCounterAspect.cacheMap.get(\"方法名\");\n```\n**注意：不支持分布式系统，只能计算当前服务器方法调用的次数。**\n\n\u003cdiv id=\"GetProperties\"\u003e\u003c/div\u003e\n\n### @GetProperties 项目启动时加载自定义properties配置文件\n作用就是标题所示啦，在我们需要使用配置一些东西但又不想写bean的时候可以使用此注解，下面我们来看看注解的使用方式。\n注解可以放在类上面也可以放在方法上面，效果其实是一样的，放在方法上本来是想实现用完立刻卸载，目前此功能还没实现。\n\n默认加载**resources**目录,好啦，我们来看看使用：\n类加载：表示加载**resources**目录下**aaaa**文件夹下的a.properties\n```java\n@Configuration\n@GetProperties(properties = \"aaaa/a.properties\")\npublic class Config {\n\n}\n```\n![](https://i.imgur.com/dG8j1Am.png)\n\n方法加载：表示加载**resources**目录下的c.properties和d.properties配置文件\n```java\n@RequestMapping(value = \"/selectByIdEncrypt\", method = RequestMethod.POST)\n@GetProperties(properties = {\"d.properties\", \"c.properties\"})\npublic MessageResult selectByIdEncrypt(){\n\n\n    Baike baike = baikeService.selectByPrimaryKey(1L);\n\n    Map cachemap = GetPropertiesListener.CACHEMAP;\n    System.out.println(cachemap.get(\"d.spring.datasource.username\"));\n\n    return MessageResult.ok(baike);\n}\n```\n\n获取配置信息：\n例如我们在**aaaa/a.properties**配置文件中配置了如下信息\n```\nmybatis.type-aliases-package=com.yi.mybatis.model\n```\n那么我们只需要使用：路径+文件名+配置key即可获取\n```\nObject value = GetPropertiesListener.CACHEMAP.get(\"aaaa.a.mybatis.type-aliases-package\");\n```\n\n例如我们在**d.properties**配置文件中配置了如下信息\n```\nmybatis.type-aliases-package=com.yi.mybatis.model\n```\n那么我们只需要使用：文件名+配置key即可获取\n```\nObject value = GetPropertiesListener.CACHEMAP.get(\"d.mybatis.type-aliases-package\");\n```\n\n**注意：在包含文件夹的路径下不用在路径前面加上“/”，例如：**\n```\n正确：@GetProperties(properties = \"aaaa/a.properties\")\n```\n```\n错误：@GetProperties(properties = \"/aaaa/a.properties\")\n```\n\n\u003cdiv id=\"ZooLock\"\u003e\u003c/div\u003e\n\n### @ZooLock 基于zookeeper的分布式锁\n这个注解作用于方法，让方法在分布式系统中拥有分布式锁的能力，当然也可以用于单体服务当普通锁用（不推荐）。\n使用也非常简单，我们来看一个最简单的例子，在写例子之前我们需要在application.properties配置文件中配置一些参数\n```\n# 基于zookeeper分布式锁配置\n# 要使用分布式锁，必须设置为true\nzk.lock.enabled=true\nzk.lock.url=127.0.0.1:2181\n# 重试次数，默认3\nzk.lock.retry=3\n# 超时时间(毫秒)\nzk.lock.timeout=1000\n```\n配置完成我们来看看简单使用此注解的例子：\n```java\n/**\n * 通过设置分布式锁，使得方法具有分布式锁的能力\n * \u003cp\u003e分布式锁key：/DISTRIBUTED_LOCK_books\u003c/p\u003e\n * @return\n * @throws InterruptedException\n */\n@ZooLock(key = \"books\")\n@RequestMapping(value = \"/selectByExample\", method = RequestMethod.POST)\npublic MessageResult selectByExample() throws InterruptedException {\n    BaikeExample example = new BaikeExample();\n    BaikeExample.Criteria criteria = example.createCriteria();\n\n    criteria.andNameEqualTo(\"海明威\");\n    List\u003cBaike\u003e hBaikes = baikeService.selectByExample(example);\n    List\u003cBaike\u003e allBooks = new ArrayList\u003c\u003e(hBaikes);\n\n    Thread.sleep(6000);\n\n    return MessageResult.ok(allBooks);\n}\n```\n默认如果没有设置，锁释放时间，默认五秒，我们延时是六秒钟，此时如果有两个请求过来，我们就会发现一个返回结果，一个如下图所示\n![](https://i.imgur.com/1rmzdpA.png)\n\n接一下我们看一个比较复杂的例子，可以生成分布式锁动态key\n```java\n/**\n * 通过@LockKeyParam 实现分布式锁动态key，如果对象中的id和book分别为 1 和 全职法师\n * \u003cp\u003e分布式锁key：/DISTRIBUTED_LOCK_books/1/全职法师\u003c/p\u003e\n * @param baike 前端传入对象参数\n * @return\n * @throws InterruptedException\n */\n@ZooLock(key = \"books\", timeout = 3000L)\n@RequestMapping(value = \"/getBaikes\", method = RequestMethod.POST)\npublic MessageResult getBaikes(@LockKeyParam(fields = {\"id\",\"book\"}) Baike baike) throws InterruptedException {\n    System.out.println(\"我进来啦！！！\");\n    Thread.sleep(5000);\n    System.out.println(\"我出来啦！！！\");\n\n    return MessageResult.ok(baike);\n}\n```\n在我们**Baike**的对象中包含id和book属性，通过@LockKeyParam注解就可以把这两个属性动态添加到key中，实现我们自定义key的操作。\n\n当然我们使用@LockKeyParam注解不一定要在对象中，普通参数属性也可以，例如：\n```java\n/**\n * 通过@LockKeyParam 实现分布式锁动态key，如果参数name为 全职法师\n * \u003cp\u003e分布式锁key：/DISTRIBUTED_LOCK_books/全职法师\u003c/p\u003e\n * @param name 前端书名参数\n * @return\n * @throws InterruptedException\n */\n@ZooLock(key = \"books\", timeout = 3000L)\n@RequestMapping(value = \"/getBaikeName\", method = RequestMethod.POST)\npublic MessageResult getBaikes(@LockKeyParam String name) throws InterruptedException {\n    System.out.println(\"我进来啦！！！\");\n    Thread.sleep(5000);\n    System.out.println(\"我出来啦！！！\");\n\n    return MessageResult.ok(name);\n}\n```\n是不是很简单，赶紧去试试吧\n\n### 问题建议\n\n- 联系我的邮箱：ilovey_hwy@163.com\n- 我的博客：https://www.hwy.ac.cn\n- GitHub：https://github.com/HWYWL\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwywl%2Fant-nest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhwywl%2Fant-nest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwywl%2Fant-nest/lists"}