# richest-api **Repository Path**: zhaohc2279/richest-api ## Basic Information - **Project Name**: richest-api - **Description**: No description available - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-03-11 - **Last Updated**: 2022-10-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # richest-api 聚宝同城接口服务 # 项目采用:spring boot + mybatis + quartz + druid + Swagger2 说明:主要给用户端以及商户端前台提供接口服务。 环境准备: - jdk:1.8 - maven:3.6.0 - 开发工具:eclipse+git+tomcat 源码地址: gitosc: [https://gitee.com/zhcaqzx/richest-api.git](git@gitee.com:zhcaqzx/richest-api.git) 发布流程: 1. 编写好代码后,在eclipse中使用run as->maven clean,run as->maven install生成war包 2. 在工程目录下找到target文件夹,将richest-api.war文件复制到阿里云服务器的tomcat目录下 3. 重启tomcat服务,验证接口的正确性 测试地址: http://118.190.203.107/richest-api/swagger-ui.html **备注:** application.properties:这里主要配置针对于不同的环境用那个配置文件。配置如下: spring.profiles.active = dev 应用启动: //启动入口 @SpringBootApplication @ServletComponentScan // 扫描Servlet @MapperScan("com.richest.api.dao") // 扫描dao public class RichestApiApplication { public static void main(String[] args) { SpringApplication.run(RichestApiApplication.class, args); } } 启动之后访问: durid : http://localhost:8080/druid/index.html 配置代码: //过滤资源 @WebFilter(filterName="druidWebStatFilter",urlPatterns="/*", initParams={ @WebInitParam(name="exclusions",value="*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*")// 忽略资源 } ) public class DruidStatFilter extends WebStatFilter implements Serializable{ private static final long serialVersionUID = 1L; } @WebServlet(urlPatterns = "/druid/*", initParams={ @WebInitParam(name="allow",value=""),// IP白名单 (没有配置或者为空,则允许所有访问) @WebInitParam(name="deny",value=""),// IP黑名单 (存在共同时,deny优先于allow) @WebInitParam(name="loginUsername",value="root"),// 用户名 @WebInitParam(name="loginPassword",value="root"),// 密码 @WebInitParam(name="resetEnable",value="false")// 禁用HTML页面上的“Reset All”功能 }) public class DruidStatViewServlet extends StatViewServlet implements Serializable{ private static final long serialVersionUID = 1L; } swagger2 : http://localhost:8080/swagger-ui.html 配置代码: //SwaggerConfig @Configuration @EnableSwagger2 public class SwaggerConfig { /** * 可以定义多个组,比如本类中定义把test和demo区分开了 (访问页面就可以看到效果了) * */ @Bean public Docket testApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors .basePackage("com.richest.api.controller")) .paths(PathSelectors.any()).build(); } private ApiInfo apiInfo() { ApiInfo apiInfo = new ApiInfo("SpringBootDemo", // 大标题 "Spring boot + swagger + mybatis + druid", // 小标题 "1.0", // 版本 "spring-boot-demo", "zhengweishan", // 作者 "blog", // 链接显示文字 "http://zhengweishan.oschina.io/"// 网站链接 ); return apiInfo; } } spring boot 支持servlet配置: public class JspInitContext extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(RichestApiApplication.class); } } 日志说明: 使用logback进行日志管理,分等级输出日志,日志有日期的标志 日志路径,使用linux命令(cd)进入对应的路径,使用tail -f 日志文件名即可查看实时更新的日志,若需要可以将日志文件下载到本地进行查看,除启动日志外,其他的日志都是按照日志进行区分的,查看对应日志的日记文件即可: 启动日志:/www/server/apache-tomcat-8.5.32/logs/catalina.out error日志:/log/error debug日志:/log/debug info日志:/log/info warn日志:/log/warn 项目结构: 源代码说明:com.richest.api config 配置包 DruidDataSourceConfiguration druid配置 DruidStatFilter druid配置 DruidStatViewServlet druid配置 RedisConfiguration redis配置 controller 功能接口 cn 订餐 client 用户端 admart 店铺相关接口;完成接口:首页推荐商户列表、筛选商户列表、获取包房/桌信息、 extension 优惠相关接口;完成接口:领取优惠卷/赠送金、获取活动/优惠卷列表、获取已经拥有的优惠卷列表、 good 菜品相关接口;完成接口:根据商户获取商品列表(目前菜品)、 order 订单相关接口,订单相关接口有15分钟的自动处理逻辑,暂时没有加入,建议使用线程实现;完成接口:根据状态获取订单列表、生成就餐订单、整单退款、单品退款、取消订单、根据订单号获取订单详情 score 评价相关接口;完成接口:保存评价、获取店铺评分 merchant 商户端 common ? good 菜品相关接口;完成接口:菜品管理列表、菜品上架/下架、删除菜品、添加菜品 order 商户订单相关接口 common 通用接口;完成接口:搜索框、banner列表、首页分类列表、收藏、取消收藏、获取收藏列表、查看店铺是否被收藏 form 常用接口提交表单 messagerecord 消息先关;完成接口:获取消息列表 pay 支付相关;完成接口:微信支付、阿里支付、微信回调、阿里回调 user 用户相关;完成接口:登录、登出、发送验证码、忘记密码、用户注册1、用户注册2、修改信息发送短信验证码、修改密码、设置头像、设置昵称、实名认证(保存信息)、获取用户基本信息、绑定微信、修改手机号码、 course 微信相关工具类 dao mybatis的mapper entity 调度相关 filter 过滤器相关;解决跨域 job 调度的job相关 qiniu 七牛平台相关 quartz 调度相关 send 短信相关 service 服务层组件 swagger2 接口文档相关 utils 常用工具类 资源文件说明:src/main/resources mapping mybatis的xml文件 logback.xml 打印日志 application*.properties 工程配置文件 webxin.properties 暂时不用,所有配置都存在数据库中,后续考虑删除 特殊说明: 项目引用的jbRichestCommon-0.0.1.jar包是加入到本地的maven仓库中的; 方法:下载jb_richest_common[https://gitee.com/sangyiji/jb_richest_common.git]项目,配置环境后导出成jar,然后将jar包加入到本地的maven仓库更新本项目maven即可;导入命令可参考:mvn install:install-file -DgroupId=jb.richest.common -DartifactId=jbRichestCommon -Dversion=0.0.1 -Dpackaging=jar -Dfile=E:\richest\jbRichestCommon-0.0.1.jar