{"id":41069164,"url":"https://github.com/cotide/moni-webapi","last_synced_at":"2026-01-22T12:59:41.077Z","repository":{"id":41046520,"uuid":"146997699","full_name":"cotide/moni-webapi","owner":"cotide","description":"🌴基于SpringBoot的WebApi示例项目(Swagger/sql2o-plus)","archived":false,"fork":false,"pushed_at":"2022-06-28T14:47:29.000Z","size":90,"stargazers_count":3,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-11-29T21:50:21.984Z","etag":null,"topics":["spring-boot","springmvc","sql2o-plus","swagger","swagger-ui","swagger2","webapi"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cotide.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-01T12:47:07.000Z","updated_at":"2023-11-29T21:50:21.985Z","dependencies_parsed_at":"2022-08-28T22:30:20.168Z","dependency_job_id":null,"html_url":"https://github.com/cotide/moni-webapi","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/cotide/moni-webapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cotide%2Fmoni-webapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cotide%2Fmoni-webapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cotide%2Fmoni-webapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cotide%2Fmoni-webapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cotide","download_url":"https://codeload.github.com/cotide/moni-webapi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cotide%2Fmoni-webapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28663774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["spring-boot","springmvc","sql2o-plus","swagger","swagger-ui","swagger2","webapi"],"created_at":"2026-01-22T12:59:36.943Z","updated_at":"2026-01-22T12:59:41.066Z","avatar_url":"https://github.com/cotide.png","language":"Java","readme":"## moni-webapi \n\n[![Build Status](https://travis-ci.org/cotide/moni-webapi.svg?branch=master)](https://travis-ci.org/cotide/moni-webapi)\n \n 基于SpringBoot的WebApi示例\n \n ## 访问地址\n \n \u003e http://localhost:9200/swagger-ui.html\n \n ## 引用\n \n - [spring-boot](https://github.com/spring-projects/spring-boot)\n - [swagger2](https://github.com/springfox/springfox) \n - [druid](https://github.com/alibaba/druid)\n - [sql2o-plus](https://github.com/cotide/sql2o-plus)\n - [log4j2](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-project/spring-boot-starters/spring-boot-starter-log4j2)\n - [fastjson](https://github.com/alibaba/fastjson) \n - [jwt](https://github.com/auth0/java-jwt)\n\n \u003e 访问 [pom.xml](pom.xml)\n \n \n## 特点\n \n### 1.统一结果返回(fastJson),格式如下:\n \n \n属性 | 描述  \n---|--- \ncode | 状态编码  \nisSuccess | 请求是否成功 (指当前业务处理是否正确)  \nmsg | 消息 \ndata | 数据 \n\n \n#### 1.1 没有结果数据-格式\n\n```json\n{\n  \"code\": 200,\n  \"isSuccess\": true, \n  \"msg\": \"\"\n}\n```\n\n#### 1.2 有结果数据-格式\n \n```json\n{\n  \"code\": 200,\n  \"data\": {\n    \"createTime\": \"2018-09-05 18:03:15\",\n    \"login\": 1000,\n    \"userId\": 29,\n    \"userName\": \"Hello World\"\n  },\n  \"isSuccess\": true,\n  \"msg\": \"\"\n}\n```\n \n#### 1.3 异常数据-格式 \n \n\n状态 | 描述 | JSON\n---|---|---\n401 | 非法权限 | {\"code\":401,\"isSuccess\":false,\"msg\":\"异常信息\"} \n500 | 服务器异常 | {\"code\":500,\"isSuccess\":false,\"msg\":\"异常信息\"}\n510 | 请求参数异常 | {\"code\":510,\"isSuccess\":false,\"msg\":\"异常信息\"}\n510 | 业务异常 | {\"code\":511,\"isSuccess\":false,\"msg\":\"异常信息\"}\n\n \n### 2.Swagger的集成 (多版本) \n\n![Swagger的集成 (多版本) ](http://ww1.sinaimg.cn/large/7c2c6ab7gy1fv82d53swlj20i3067glq.jpg)\n \n### 3.使用[sql2o-plus](https://github.com/cotide/sql2o-plus)\n \n### 4.权限控制\n\n![权限控制](http://ww1.sinaimg.cn/large/7c2c6ab7gy1fv82lnhijij20zk0clt9m.jpg)\n\n需要权限访问的接口,请求时候需要带访问Token信息（Token鉴权使用[jwt](https://github.com/auth0/java-jwt)）\n\n#### 4.1 @PowerFilter\n\n控制器级别 - 标记该注解的Class需要权限才允许访问  \n \n##### 4.1.1 使用\n\n继承[AuthApiController](src/main/java/com/gold/moni/webapi/controller/base/AuthApiController.java)  \n \n\n#### 4.2 @ActionPowerFilter  \n\nAction级别 - 标记该注解的方法需要权限才允许访问\n\n##### 4.2.1 使用\n\n对需要权限的方法标记@ActionPowerFilter注解 \n\n```java\n@ActionPowerFilter \n@RequestMapping(value = \"get\",method = RequestMethod.GET)\npublic void get(){}\n```\n\n\n### 5.自定义格式\n\n#### 5.1 @IgnoreRequestFilter \n\n忽略全局格式,使用自定义格式\n\n```java\n@ApiOperation(value = \"获取自定义格式\")\n@IgnoreRequestFilter\n@RequestMapping(value = \"getMyResult\",method = RequestMethod.GET)\npublic String getMyResult(){}\n```\n\n\n#### 5.2 @Download \n\n文件下载\n\n```java\n@ApiOperation(value = \"Excel下载\")\n@Download\n@RequestMapping(value = \"downloadExcel\",method = RequestMethod.GET)\npublic void downloadExcel(\n        HttpServletRequest request,\n        HttpServletResponse response)\n        throws IOException,\n        IllegalAccessException,\n        InstantiationException,\n        ClassNotFoundException {}\n```\n\n\n### 6 图片二维码合并输出 (缓存)\n\n```code\n@Download\n@Cacheable(value = \"qr_getGithubQR\",key = \"#userName\")\n@Scheduled(fixedRate = ONE_DAY )\n@ApiOperation(value = \"获取Github二维码\")\n@RequestMapping(\n        value = \"getGithubQR\",\n        method = RequestMethod.GET,\n        produces = MediaType.IMAGE_PNG_VALUE\n)\npublic byte[] getGithubQR(String userName)\n        throws IOException, WriterException {\n\n    BufferedImage in = ImageIO.read(getClass().getResourceAsStream(\"/static/img/rq_bg.png\"));\n    if(in==null)\n    {\n        throw new NullPointerException(\"未找到背景图\");\n    }\n    BufferedImage qrImg = QRCodeUtil.toBufferedImage(\"https://github.com/\"+userName,240,240);\n    BufferedImage outPut = QRCodeUtil.mergeImage(in,qrImg,200,170);\n    ByteArrayOutputStream output = new ByteArrayOutputStream();\n    try {\n        ImageIO.write(outPut, \"png\", output);\n        output.flush();\n        return output.toByteArray();\n    }finally {\n        output.close();\n    }\n}\n\n```\n\n![图片二维码合并输出 (缓存)](http://ww1.sinaimg.cn/large/7c2c6ab7gy1fw37s7urcqj20fj0bt74v.jpg)\n\n## 资源\n\n- [示例数据库脚本](https://github.com/cotide/moni-webapi/wiki/%E7%A4%BA%E4%BE%8B%E6%95%B0%E6%8D%AE%E5%BA%93%E8%84%9A%E6%9C%AC)\n\n ","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcotide%2Fmoni-webapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcotide%2Fmoni-webapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcotide%2Fmoni-webapi/lists"}