数据库表结构
名称 |
介绍 |
参考版本 |
开发环境 |
开发环境 |
Windows10 / MAC |
JDK |
java开发者工具集 |
1.8 |
MAVEN |
java项目构建工具 |
Apache Maven 3.5.0 |
IDE |
集成开发工具 |
IntelliJ IDEA (Ultimate) Version: 2018.2.5 |
Mysql |
数据库 |
5.7.17 |
Redis |
缓存服务 |
3.2.8 |
Zookeeper |
服务注册中心 |
3.4.6 |
ActiveMQ |
消息中间件 |
5.15.8 |
公共返回错误信息: org.xxpay.core.common.constant.RetEnum
支付中心返回code和Msg: org.xxpay.core.common.constant.PayEnum
系统常量: org.xxpay.core.common.constant.Constant
业务常量: org.xxpay.core.common.constant.MchConstant
支付业务常量: org.xxpay.core.common.constant.PayConstant
rpc调用service / spring注入service: org.xxpay.业务包名.common.service.RpcCommonService
项目sql语句: 项目根目录下:*.sql
init.sql
:项目所有用到的DDL、DML语句;
init_sys_code.sql
:省市县、行业编码初始化语句;
t_bank_card_bin.sql
:卡bin导入语句;
环境变量配置文件: profiles/commons-{env}-filter.properties
{env}说明:
dev:开发环境, 一般用于本地启动项目时的配置信息;
test: 测试环境, 一般用于测试环境中的配置信息;
prod: 生产环境, 一般用于生产正式环境下的配置信息;
env配置在 pom.xml文件下 profiles -> profile 节点, 默认设置的dev为默认节点。
如切换环境进行编译, 请使用 $ mvn compile -Ptest
进行切换。
maven 命令详见: http://maven.apache.org/settings.html Profiles节点
本地启动:
init.sql、init_sys_code.sql、t_bank_card_bin.sql
;包括 Redis, Zookeeper, ActiveMQ
;
变更启动端口:
请修改每个项目下的 application.yml 中的 server -> port节点。
测试环境/生产环境打包:
$ mvn package -Ptest
(测试环境) 、 $ mvn package -Pprod
(生产环境) ;./target
目录下, 将 tar.gz
格式的文件拷贝到对应服务器目录即可。
初始化语句描述:
INSERT INTO `t_mgr_sys_resource` VALUES (
'ID',
'模块名称,需与静态页面对应',
'菜单显示名称',
'跳转URL, 一般为空,当与模块不在一个目录需变更',
'授权名: ROLE开头',
'授权URL 如:mch_info/**',
'1-菜单, 2-按钮',
'所属系统: 1-商户 2-代理商 3-平台 4-服务商',
'菜单图标, 支持layui所有图标, 详见layui.com',
'排序值: 数值越小越靠前',
'父资源ID,一级为0',
'状态:0:禁用 1:正常',
'属性, 一般为空',
'创建时间',
'更新时间');
示例:
INSERT INTO `t_mgr_sys_resource` VALUES (16, 'user', '用户管理', '/sys/user/config', 'ROLE_SYS_USER', '/sys/user/**', 1, 3, 'layui-icon-user', 100, 15, 1, '', '2018-01-23 23:18:24', '2018-02-10 03:45:20');
简述:
建议新建的Controller继承每个项目下的BaseController, 并且为 @RestController
获取请求参数:
获取String类型参数的值(非必填): |
protected String getValString(String key) |
获取String类型参数的值(必填): |
protected String getValStringRequired(String key) |
获取Byte类型参数的值(非必填): |
protected Byte getValByte(String key) |
获取Byte类型参数的值(必填): |
protected Byte getValByteRequired(String key) |
获取Integer类型参数的值(非必填): |
protected Integer getValInteger(String key) |
获取Integer类型参数的值(必填): |
protected Integer getValIntegerRequired(String key) |
获取Long类型参数的值(非必填): |
protected Long getValLong(String key) |
获取Long类型参数的值(必填): |
protected Long getValLongRequired(String key) |
获取前端参数并自动转换为对象类型: |
protected <T> T getObject(Class<T> clazz) |
获取金额类型的参数并将 元->分(非必填): |
public Long getAmountL(String name) |
获取金额类型的参数并将 元->分(必填): |
public Long getRequiredAmountL(String name) |
Controller接口函数返回说明:
业务处理成功:
return XxPayResponse.buildSuccess(); 或者添加任意参数: return XxPayResponse.buildSuccess(message);
业务处理失败:
return XxPayResponse.build(RetEnum.RET_SERVICE_MCH_NOT_EXIST);
简述:
项目使用的Mybatis + Mybatis Plus 进行数据层访问, 目前所有Service全部继承了Mybatis+ 的ServiceImpl类, 支持新函数的同时也对Mybatis历史函数做了兼容。
建议使用 LambdaQueryWrapper进行查询参数的构造, 避免直接传入列名称导致难以维护;
例如查询mchId为1001的商户信息:
LambdaQueryWrapper<MchInfo> queryWrapper = new LambdaQueryWrapper(); queryWrapper.eq(MchInfo::getMchId, 1001L); MchInfo mchInfo = mchInfoService.getOne(queryWrapper);
具体条件编写请参考: https://mybatis.plus/
场景一: 表结构有变动, 需对Mapper进行更改:
更改org.xxpay.service.test.generator.MybatisPlusCodeGenerator
文件中的数据库地址、用户名、待生成的表名等信息;
注意:
org.xxpay.service.test.generator.MybatisCodeGenerator