Commit 80eaacfa authored by ysongq's avatar ysongq

Merge branch 'dm_dev' of http://gitlab.ioubuy.cn/yaobenzhang/dm_project into dm_dev

parents 7f7bda24 f3e14f54
......@@ -3,6 +3,7 @@ package com.jz.dm;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
......@@ -16,7 +17,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
* @Description:
**/
@SpringBootApplication
//@ComponentScan(basePackages = {"com.jz"})
@ComponentScan(basePackages = {"com.jz"})
@MapperScan("com.jz.dm.mapper")
@EnableTransactionManagement
public class ApiGatewayApplication {
......
#数据源
spring:
security:
basic:
enabled: false
datasource:
url: jdbc:mysql://rm-wz9n399q2avsy3k6m4o.mysql.rds.aliyuncs.com:3306/wj-mkt-project?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
username: root
password: I%ou$buy!ok
driver-class-name: com.mysql.jdbc.Driver
druid:
# 初始化时建立物理连接的个数。初始化发生在显示调用init方法,或者第一次getConnection时
initialSize: 1
# 最小连接池数量
minIdle: 1
# 最大连接池数量
maxActive: 10
# 配置获取连接等待超时的时间
maxWait: 10000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 验证连接有效与否的SQL,不同的数据配置不同
validationQuery: select 1
# 建议配置为true,不影响性能,并且保证安全性。
# 申请连接的时候检测,如果空闲时间大于
# timeBetweenEvictionRunsMillis,
# 执行validationQuery检测连接是否有效。
testWhileIdle: true
# 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。
# 这里建议配置为TRUE,防止取到的连接不可用
testOnBorrow: true
# 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能
testOnReturn: false
# 是否缓存preparedStatement,也就是PSCache。
# PSCache对支持游标的数据库性能提升巨大,比如说oracle。
# 在mysql5.5以下的版本中没有PSCache功能,建议关闭掉。
# 作者在5.5版本中使用PSCache,通过监控界面发现PSCache有缓存命中率记录,
# 该应该是支持PSCache。
# 打开PSCache,并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
# 属性类型是字符串,通过别名的方式配置扩展插件,
# 常用的插件有:
# 监控统计用的filter:stat
# 日志用的filter:log4j
# 防御sql注入的filter:wall
filters: stat
# ====================MybatisPlus====================
......@@ -49,32 +49,3 @@ spring:
filters: stat
# ====================MybatisPlus====================
mybatis-plus:
# 如果是放在src/main/java目录下 classpath:/com/yourpackage/*/mapper/*Mapper.xml
# 如果是放在resource目录 classpath:/mapper/*Mapper.xml
mapper-locations: classpath*:com/frame/**/**.xml,classpath*:mapping/**/**.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.frame.**.entity,com.frame.**.dto
global-config:
#刷新mapper 调试神器
db-config:
#主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
id-type: UUID
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy: 2
#驼峰下划线转换
column-underline: false
#数据库大写下划线转换
# capital-mode: true
#逻辑删除配置
logic-delete-value: 1
logic-not-delete-value: 0
refresh: true
configuration:
#配置返回数据库(column下划线命名&&返回java实体是驼峰命名),自动匹配无需as(没开启这个,SQL需要写as: select user_id as userId)
map-underscore-to-camel-case: true
cache-enabled: false
#配置JdbcTypeForNull, oracle数据库必须配置
jdbc-type-for-null: 'null'
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
database-id: mysql
\ No newline at end of file
......@@ -19,19 +19,34 @@ spring:
active: test #默认使用的配置文件
#MyBatis
#mybatis-plus:
# mapper-locations: classpath:/mapper/**/*.xml
# typeAliasesPackage: com.jz.common.entity
# #type-handlers-package: com.btcpay.commons.typehandler
# global-config:
# id-type: 1
# field-strategy: 2
# db-column-underline: true
# refresh-mapper: true
# configuration:
# map-underscore-to-camel-case: true
# cache-enabled: false
# #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mybatis-plus:
# 如果是放在src/main/java目录下 classpath:/com/yourpackage/*/mapper/*Mapper.xml
# 如果是放在resource目录 classpath:/mapper/*Mapper.xml
mapper-locations: classpath*:com/frame/**/**.xml,classpath*:mapping/**/**.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.frame.**.entity,com.frame.**.dto
global-config:
#刷新mapper 调试神器
db-config:
#主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
id-type: UUID
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy: 2
#驼峰下划线转换
column-underline: false
#数据库大写下划线转换
# capital-mode: true
#逻辑删除配置
logic-delete-value: 1
logic-not-delete-value: 0
refresh: true
configuration:
#配置返回数据库(column下划线命名&&返回java实体是驼峰命名),自动匹配无需as(没开启这个,SQL需要写as: select user_id as userId)
map-underscore-to-camel-case: true
cache-enabled: false
#配置JdbcTypeForNull, oracle数据库必须配置
jdbc-type-for-null: 'null'
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
database-id: mysql
package com.jz.common.constant;
import com.alibaba.fastjson.JSON;
/**
* @author ZC
* @PACKAGE_NAME: com.fbpay.broker.common
* @PROJECT_NAME: fbp-parent
* @NAME: ResultCode
* @USER: Administrator
* @DATE: 2020/5/24/10:39
* @DAY_NAME_SHORT: 周日
* @Description: 返回状态吗枚举类
**/
public enum ResultCode {
/** 执行成功 */
SUCCESS(200, ResultMsg.SUCCESS),
/** 执行失败 */
FAILURE(300, ResultMsg.DATA_NOT_FOUND),
/** 未授权的访问 */
UNAUTHORIZED(401, ResultMsg.UNAUTHORIZED),
/** 授权过期 */
INVALID_TOKEN(402, ResultMsg.INVALID_TOKEN),
/** 禁止访问 */
FORBIDOM(403, ResultMsg.FORBIDOM);
private int code;
/**
* 提示信息
*/
private ResultMsg msg;
private ResultCode(int code, ResultMsg msg) {
this.code = code;
this.msg = msg;
}
/**
* 通过业务代码获取业务操作枚举
* @param code 业务代码
* @return 业务枚举
*/
public static ResultCode getResultStatusEnum(int code) {
for (ResultCode item : ResultCode.values()) {
if (item.code == code) {
return item;
}
}
return null;
}
@Override
public String toString() {
return JSON.toJSONString(this);
}
public int getCode() {
return code;
}
public ResultMsg getMsg() {
return this.msg;
}
public void setMsg(ResultMsg msg) {
this.msg = msg;
}
}
package com.jz.common.constant;
public enum ResultMsg {
/**
* 执行失败
*/
FAILURE("执行失败"),
/**
* 执行成功
*/
SUCCESS("执行成功"),
PAY_FAILURE("支付失败"),
PAY_SUCCESS("支付成功"),
IN_PROCESS("正在处理中"),
QUERY_FAIL("查询失败"),
SEND_SUCCESS("发送成功"),
SEND_FAIL("发送失败"),
ACCEPT_SUCCESS("受理成功"),
ACCEPT_FAIL("受理失败"),
TRANS_SUCCESS("转账成功"),
TRANS_FAIL("转账失败"),
RECHARGE_SUCCESS("充值成功"),
RECHARGE_FAIL("充值失败"),
/**
* 需审核
*/
NEED_AUDIT("已提交审核"),
/**
* 查询结果为空
*/
DATA_NOT_FOUND("查询结果为空"),
/**
* 重复请求
*/
REPEATED_REQUEST("重复请求"),
/**
* 邮箱格式错误
*/
EMAIL_FORMAT("邮箱格式错误"),
/**
* 邮箱格式已存在
*/
EMAIL_EXIST("邮箱已存在"),
/**
* 合伙人不存在
*/
BROKER_NO_EXIST("合伙人不存在"),
/**
* 上级合伙人不存在
*/
ON_BROKER_NO_EXIST("上级合伙人不存在"),
/**
* 验证码异常
*/
VALID_UNUSUAL("验证码错误"),
/**
* 验证码异常
*/
VALID_EMPTY("验证码不能为空"),
/**
* 邀请人不存在
*/
INVITE_UNUSUAL("邀请人信息不存在"),
/**
* 数据已存在
*/
DATA_EXIST("数据已存在"),
/**
* 用户名或者密码错误
*/
INVALID_LOGIN("用户名或者密码错误"),
/**
* 用户名不存在
*/
INVALID_USERNAME("用户名错误"),
/**
* 用户错误
*/
INVALID_USER("用户错误"),
/**
* 用户已报备
*/
USER_REPORTED("用户已报备"),
/**
* 用户名错误
*/
USER_NAME_ERROR("用户名错误"),
/**
* 用户名不符合规则
*/
USER_NAME_INVALIDE("用户名不符合规则"),
/**
* 用户是系统用户
*/
USER_IS_SYSTEM_USER("用户是系统用户"),
/**
* 用户名字重复
*/
USER_LOGIN_NAME_IS_EXIST("用户名字重复"),
/**
* 用户用户存在角色
*/
USER_HAVE_ROLE("用户用户存在角色"),
/**
* 用户需要定义角色
*/
USER_NEED_AT_LEASE_ONE_ROLE("用户自少需要定义一个角色"),
/**
* 用户在同一平台多个角色
*/
USER_ROLE_NOT_IN_SAME_PLATFORM("用户在同一平台多个角色"),
/**
* 用户不存在
*/
USER_NOT_EXIST("用户不存在"),
/**
* 发包方用户不存在
*/
USERBAG_NOT_EXIST("发包方用户不存在"),
/**
* 退出成功
*/
USER_LOGOUT_SUCCESS("退出成功"),
/**
* 用户状态异常
*/
USER_IN_UNABLE_STATUS("用户状态异常,请联系客服"),
/**
* 用户存在多个
*/
USER_EXIST_MANY("用户存在多个"),
/**
* 用户手机号已经注册
*/
USER_MOBILE_REGISTED("用户手机号已经注册"),
/**
* 用户在待审批状态
*/
USER_IN_UNAPPROVAL_STATUS("用户待审批,注意邮箱状态变更"),
/**
* 用户在驳回状态
*/
USER_IN_APPROVALNO_STATUS("用户审核驳回,请重新登陆"),
/**
* 原密码不正确
*/
OLDPASSWORD_NOT_RIGHT("原密码不正确"),
/**
* 用户错误
*/
INVALID_AUTHOR("不合法的权限"),
/**
* 用户错误
*/
MENU_URL_EXIST("菜单url已经存在了"),
/**
* 菜单不存在
*/
MENU_NO_EXIST("菜单不存在"),
/**
* 用户错误
*/
MENU_USE_IN_ROLE("菜单有角色在使用"),
/**
* 有权限在页面使用
*/
PERMISSION_USED("有权限在页面使用"),
/**
* 权限已经存在
*/
PERMISSION_EXIST("权限已经存在"),
/**
* 权限不存在
*/
PERMISSION_NO_EXIST("权限不存在"),
/**
* 系统权限不能删除
*/
PERMISSION_IS_SYSTEM("系统权限不能删除"),
/**
* 权限不存在
*/
PERMISSION_MEHTOD_INVALID("权限方法名称不合法"),
/**
* 请求参数错误
*/
INVALID_PARAM("请求参数错误"),
/**
* 找不到请求的资源
*/
NOT_FOUND("找不到请求的资源"),
/**
* 日期格式错误
*/
DATE_FORMAT_INVALIDE("日期格式错误"),
/**
* 操作数据不存在
*/
DATA_NOT_EXIST("操作数据不存在"),
/**
* 操作数据状态不正确
*/
DATA_STATUS_ERROR("操作数据状态不正确"),
/**
* 找不到请求的资源
*/
SHARE_UNUSUAL("分润异常"),
/**
* 商户信息不存在
*/
MERCHANT_EXIST("商户信息不存在"),
/**
* 商户状态异常
*/
MERCHANT_INVALID("商户状态异常"),
/**
* 商户状态异常
*/
SUPPLIER_INVALID("商户状态异常"),
/**
* 服务不可达
*/
SERVICE_UNAVILABLE("服务不可达,请稍后重试"),
/**
* 系统发生异常
*/
ERROR("系统发生异常"),
/**
* 验证失败
*/
VERIFICATION_FAILURE("验证失败"),
/**
* 未授权的访问
*/
UNAUTHORIZED("未授权的访问"),
/**
* token过期
*/
INVALID_TOKEN("token过期"),
/**
* 禁止访问
*/
FORBIDOM("禁止访问"),
/**
* 手机号已存在
*/
MOBILE_USEED("手机号已存在,请更换手机号!"),
/**
* 角色名字已经存在
*/
ADD_ROLE_NAME_ERROR("角色名字已经存在"),
/**
* 角色不存在
*/
ROLE_NOT_EXIST("角色不存在"),
/**
* 角色在页面中使用
*/
ROLE_USED_IN_MENU("角色在页面中使用"),
/**
* 角色还有用户在使用
*/
ROLE_USED_IN_USER("角色还有用户在使用,请去用户设置里删除用户或改变用户角色"),
/**
* 系统角色不能解绑
*/
ROLE_SYSTEM_NO_UNBIND("系统角色不能解绑"),
/**
* 系统角色不能接口添加
*/
ROLE_SYSTEM_CAN_NO_INSRT("系统角色不能接口添加"),
/**
* 权限在页面中使用
*/
MEHTOD_USE_IN_MENU("方法在页面中使用,请先解绑页面"),
/**
* 数据状态不允许操作
*/
DATE_STATUS_IN_ERROR_OPERATION("数据状态不允许操作"),
SHARE_STSTE_MESSAGR_NOT_EXIST("分润统计信息不存在!"),
/**
* 添加成功
*/
INSERT_SUCCESS("添加成功"),
/**
* 添加失败
*/
INSERT_FAIL("添加失败"),
/**
* 修改成功
*/
UPDATE_SUCCESS("修改成功"),
/**
* 修改失败
*/
UPDATE_FAIL("修改失败"),
/**
* 修改内容不存在
*/
UPDATA_DATA_UNABLE("修改数据不存在"),
/**
* 删除成功
*/
DELETE_SUCCESS("删除成功"),
/**
* 删除失败
*/
DELETE_FAIL("删除失败"),
/**
* 邮箱格式错误
*/
EMAIL_FORMAT_ERROR("邮箱格式错误"),
/**
* 手机号格式错误
*/
MOBILE_EXIST("手机号已存在"),
/**
* 手机号格式错误
*/
MOBILE_FORMAT_ERROR("手机号格式错误"),
/**
* 身份证格式错误
*/
IDCARD_FORMAT_ERROR("身份证格式错误"),
/**
* 身份证错误
*/
IDCARD_ERROR("身份证格式错误"),
/**
* 修改cron表达式成功
*/
CRON_CHNAGE_SUCCESS("修改cron表达式成功"),
ERROR_OPERATE("非法操作"),
EMPTY_PARAM("参数不能为空"),
INVALID_STATUS("订单已成功"),
ERROR_PAY_PASSWORD("支付密码错误"),
INVALID_ORDER("无效的代付订单"),
INVALID_ORDER_NO("无效的订单号"),
NOT_EXIST_ORDER("订单不存在"),
NOT_EXIST_COMPLETION("完工证明不存在"),
CLOSED_ORDER("订单已关闭"),
REPEAT_COMMIT("订单已提交"),
SIGNED_ORDER("订单已签约"),
NOT_SUBMIT_ORDER("订单未提交"),
NOT_EXIST_PAYMENT("明细不存在"),
NOT_EXIST_ACCOUNT("账户不存在"),
ERROR_ACCOUNT_NO("银行卡号错误"),
ERROR_ALI_ACCOUNT_NO("支付宝账号错误"),
ERROR_MOBILE("手机号格式不正确"),
ERROR_AGE("客户年龄受限"),
INVALID_MAX("单比人数已超限"),
INVALID_REQ("已创建清算明细"),
INVALID_EMPTY("参数不能为空"),
INVALID_BAL("账户余额不足"),
INVALID_ACC("无效的收款账号"),
LIMITED_AMOUNT("每月金额受限"),
INVALID_AMOUNT("金额格式不正确"),
NOT_EXIST_USER("操作人不存在"),
INVALID_ACC_STATUS("账户已经被锁定,不允许支付"),
DON_HAVA_BACK_ORDER("没有生成回单"),
/**
* 上传目录没有写权限
*/
UPLOAD_FAIL("文件上传失败"),
FILE_ANALYSIS_ERROR("文件解析出错,请重新确认再试"),
/**
* 上传目录没有写权限
*/
FILE_UPLOAD_PATH_NOT_WRITE("上传目录没有写权限"),
/**
* 文件格式错误
*/
FILE_UPLOAD_TYPE_ERROR("文件格式错误"),
/**
* 文件大小超过限制
*/
FILE_UPLOAD_SIZE_MAX("文件大小超过限制"),
/**
* 上传目录不存在
*/
FILE_UPLOAD_PATH_NOT_EXIST("上传目录不存在"),
/**
* 企业组织请先提交注册申请
*/
PERSON_NO_APPLY_DATA("请先提交注册申请"),
/**
* 该企业组织已经申请
*/
PERSON_MERCHANT_EXIST("该企业组织已经申请"),
/**
* 商户名字或者身份证重复
*/
PERSON_MERCHANT_NAME_OR_IDCARD_REPECT("商户名字或者身份证重复"),
/**
* 订单信息不存在
*/
ORDER_NO_EXIST("订单信息不存在"),
/**
* 分润金额小于指定值
*/
SHARE_AMOUNT_ERROR("分润金额小于指定值"),
/**
* 商户类型不能参与分润
*/
MERCHANT_TYPE_ERROR("商户类型不能参与分润"),
/**
* 可看合伙人等级信息不存在
*/
VISIBLE_LEVEL_ERROR("可看合伙人等级信息不存在"),
/**
* 合伙人费率信息不存在
*/
BROKER_RATE_NO_EXIST("合伙人费率信息不存在"),
/**
* 合伙人分润表里用户不存在
*/
BROKER_SHARE_STAT_NO_EXIST("合伙人分润表里用户不存在"),
/**
* 合伙人分润表里用户存在多条
*/
BROKER_SHARE_STAT_EXIST_MANY("合伙人分润表里用户存在多条"),
/**
* 商户费率信息不存在
*/
MERCHANT_RATE_NO_EXIST("商户费率信息不存在"),
ERROR_REPORT_INFO("报备商户名与营业执照信息不符,请检查后重新申请!"),
EXIST_REPORT_INFO("商户报备信息已存在,请查询确认!"),
NOT_EXIST_SUPPLIER("申请人信息不存在!"),
REPORTED_MERCHANT("该商户已报备!"),
REPORT_EXCEPTION("添加报备信息异常"),
VOUCHER_NOT_NULL("转账凭证不能为空"),
/**
* 银行开户提交成功
*/
ACCOUNT_INSERT_SUCCESS("银行开户提交成功"),
/**
* BPO项目相关
*/
APPLY_SUCCESS("申请成功"),
APPLY_FAILED("申请失败"),
PROJECT_ASSIGNED("项目已指派,请勿重复指派"),
NULL_RECEIVER("请选择接包方");
private String msg;
ResultMsg() {
}
public String getMsg() {
return msg;
}
ResultMsg(String msg) {
this.msg = msg;
}
}
package com.jz.common.exception;
import com.jz.common.constant.ResultCode;
import com.jz.common.constant.ResultMsg;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @date 业务异常 父类。在restful 接口层使用切面捕获,统一封装输出。
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class ResponseException extends RuntimeException {
private static final long serialVersionUID = -721489076559710085L;
/**
* 错误代码
*/
protected ResultCode code;
/**
* 错误信息
*/
protected String message;
private Throwable cause;
public static ResponseException of_error(ResultMsg errorMsg) {
return ResponseException.of(ResultCode.FAILURE,errorMsg.getMsg());
}
public static ResponseException of_error(String errorMsg) {
return ResponseException.of(ResultCode.FAILURE,errorMsg);
}
public static ResponseException of(ResultCode code) {
ResponseException ufaceException = new ResponseException();
ufaceException.setCode(code);
ufaceException.setMessage(code.getMsg().getMsg());
return ufaceException;
}
public static ResponseException of(ResultCode code, String message) {
ResponseException ufaceException = new ResponseException();
ufaceException.setCode(code);
ufaceException.setMessage(message);
return ufaceException;
}
public static ResponseException ofDetail(ResultCode code, Object... params) {
String message = String.format(code.getMsg().getMsg(), params);
ResponseException ufaceException = new ResponseException();
ufaceException.setCode(code);
ufaceException.setMessage(message);
return ufaceException;
}
public static ResponseException of(ResultCode code, Throwable cause) {
ResponseException ufaceException = new ResponseException();
ufaceException.setCode(code);
ufaceException.setCause(cause);
ufaceException.setMessage("todo need get from db/properties");
return ufaceException;
}
}
......@@ -74,10 +74,10 @@
</dependency>
<!-- spring boot 和mybatis -->
<!--<dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>-->
</dependency>
<!-- mybatis plus -->
<dependency>
......
//package com.jz.dm.mall.config;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//
//import javax.sql.DataSource;
//import java.sql.SQLException;
//
///**
// * @ProjectName zhaxinle
// * @Author: zeroJun
// * @Date: 2018/8/16 16:49
// * @Description: 主数据源配置类
// */
//@Configuration
//// 前缀为primary.datasource.druid的配置信息
//@ConfigurationProperties(prefix = "spring.datasource")
//@MapperScan(basePackages = DatabaseConfig.PACKAGE, sqlSessionFactoryRef = "sqlSessionFactory")
//public class DatabaseConfig {
//
// /**
// * dao层的包路径
// */
// static final String PACKAGE = "com.jz.dm.mall.moduls.mapper";
//
// /**
// * mapper文件的相对路径
// */
// private static final String MAPPER_LOCATION = "classpath:mapperconf/*.xml";
//
// private String filters;
// private String url;
// private String username;
// private String password;
// private String driverClassName;
// private int initialSize;
// private int minIdle;
// private int maxActive;
// private long maxWait;
// private long timeBetweenEvictionRunsMillis;
// private long minEvictableIdleTimeMillis;
// private String validationQuery;
// private boolean testWhileIdle;
// private boolean testOnBorrow;
// private boolean testOnReturn;
// private boolean poolPreparedStatements;
// private int maxPoolPreparedStatementPerConnectionSize;
//
// // 主数据源使用@Primary注解进行标识
// //@Primary
// @Bean(name = "dataSource")
// public DataSource dataSource() throws SQLException {
// DruidDataSource druid = new DruidDataSource();
// // 监控统计拦截的filters
// druid.setFilters(filters);
//
// // 配置基本属性
// druid.setDriverClassName(driverClassName);
// druid.setUsername(username);
// druid.setPassword(password);
// druid.setUrl(url);
//
// //初始化时建立物理连接的个数
// druid.setInitialSize(initialSize);
// //最大连接池数量
// druid.setMaxActive(maxActive);
// //最小连接池数量
// druid.setMinIdle(minIdle);
// //获取连接时最大等待时间,单位毫秒。
// druid.setMaxWait(maxWait);
// //间隔多久进行一次检测,检测需要关闭的空闲连接
// druid.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
// //一个连接在池中最小生存的时间
// druid.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
// //用来检测连接是否有效的sql
// druid.setValidationQuery(validationQuery);
// //建议配置为true,不影响性能,并且保证安全性。
// druid.setTestWhileIdle(testWhileIdle);
// //申请连接时执行validationQuery检测连接是否有效
// druid.setTestOnBorrow(testOnBorrow);
// druid.setTestOnReturn(testOnReturn);
// //是否缓存preparedStatement,也就是PSCache,oracle设为true,mysql设为false。分库分表较多推荐设置为false
// druid.setPoolPreparedStatements(poolPreparedStatements);
// // 打开PSCache时,指定每个连接上PSCache的大小
// druid.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
//
// return druid;
// }
//
// // 创建该数据源的事务管理
// @Primary
// @Bean(name = "transactionManager")
// public DataSourceTransactionManager transactionManager() throws SQLException {
// return new DataSourceTransactionManager(dataSource());
// }
//
// // 创建Mybatis的连接会话工厂实例
// @Primary
// @Bean(name = "sqlSessionFactory")
// public SqlSessionFactory sqlSessionFactory(@Qualifier("dataSource") DataSource dataSource) throws Exception {
// final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
// sessionFactory.setDataSource(dataSource); // 设置数据源bean
// sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
// .getResources(DatabaseConfig.MAPPER_LOCATION)); // 设置mapper文件路径
//
// return sessionFactory.getObject();
// }
//
// public String getFilters() {
// return filters;
// }
//
// public void setFilters(String filters) {
// this.filters = filters;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getDriverClassName() {
// return driverClassName;
// }
//
// public void setDriverClassName(String driverClassName) {
// this.driverClassName = driverClassName;
// }
//
// public int getInitialSize() {
// return initialSize;
// }
//
// public void setInitialSize(int initialSize) {
// this.initialSize = initialSize;
// }
//
// public int getMinIdle() {
// return minIdle;
// }
//
// public void setMinIdle(int minIdle) {
// this.minIdle = minIdle;
// }
//
// public int getMaxActive() {
// return maxActive;
// }
//
// public void setMaxActive(int maxActive) {
// this.maxActive = maxActive;
// }
//
// public long getMaxWait() {
// return maxWait;
// }
//
// public void setMaxWait(long maxWait) {
// this.maxWait = maxWait;
// }
//
// public long getTimeBetweenEvictionRunsMillis() {
// return timeBetweenEvictionRunsMillis;
// }
//
// public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
// this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
// }
//
// public long getMinEvictableIdleTimeMillis() {
// return minEvictableIdleTimeMillis;
// }
//
// public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
// this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
// }
//
// public String getValidationQuery() {
// return validationQuery;
// }
//
// public void setValidationQuery(String validationQuery) {
// this.validationQuery = validationQuery;
// }
//
// public boolean isTestWhileIdle() {
// return testWhileIdle;
// }
//
// public void setTestWhileIdle(boolean testWhileIdle) {
// this.testWhileIdle = testWhileIdle;
// }
//
// public boolean isTestOnBorrow() {
// return testOnBorrow;
// }
//
// public void setTestOnBorrow(boolean testOnBorrow) {
// this.testOnBorrow = testOnBorrow;
// }
//
// public boolean isTestOnReturn() {
// return testOnReturn;
// }
//
// public void setTestOnReturn(boolean testOnReturn) {
// this.testOnReturn = testOnReturn;
// }
//
// public boolean isPoolPreparedStatements() {
// return poolPreparedStatements;
// }
//
// public void setPoolPreparedStatements(boolean poolPreparedStatements) {
// this.poolPreparedStatements = poolPreparedStatements;
// }
//
// public int getMaxPoolPreparedStatementPerConnectionSize() {
// return maxPoolPreparedStatementPerConnectionSize;
// }
//
// public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize) {
// this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize;
// }
//
//}
\ No newline at end of file
package com.jz.dm.mall.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
import java.sql.SQLException;
/**
* @ProjectName zhaxinle
* @Author: zeroJun
* @Date: 2018/8/16 16:49
* @Description: 主数据源配置类
*/
@Configuration
// 前缀为primary.datasource.druid的配置信息
@ConfigurationProperties(prefix = "spring.datasource")
@MapperScan(basePackages = DatabaseConfig.PACKAGE, sqlSessionFactoryRef = "sqlSessionFactory")
public class DatabaseConfig {
/**
* dao层的包路径
*/
static final String PACKAGE = "com.jz.dm.mall.moduls.mapper";
/**
* mapper文件的相对路径
*/
private static final String MAPPER_LOCATION = "classpath:mapperconf/*.xml";
private String filters;
private String url;
private String username;
private String password;
private String driverClassName;
private int initialSize;
private int minIdle;
private int maxActive;
private long maxWait;
private long timeBetweenEvictionRunsMillis;
private long minEvictableIdleTimeMillis;
private String validationQuery;
private boolean testWhileIdle;
private boolean testOnBorrow;
private boolean testOnReturn;
private boolean poolPreparedStatements;
private int maxPoolPreparedStatementPerConnectionSize;
// 主数据源使用@Primary注解进行标识
//@Primary
@Bean(name = "dataSource")
public DataSource dataSource() throws SQLException {
DruidDataSource druid = new DruidDataSource();
// 监控统计拦截的filters
druid.setFilters(filters);
// 配置基本属性
druid.setDriverClassName(driverClassName);
druid.setUsername(username);
druid.setPassword(password);
druid.setUrl(url);
//初始化时建立物理连接的个数
druid.setInitialSize(initialSize);
//最大连接池数量
druid.setMaxActive(maxActive);
//最小连接池数量
druid.setMinIdle(minIdle);
//获取连接时最大等待时间,单位毫秒。
druid.setMaxWait(maxWait);
//间隔多久进行一次检测,检测需要关闭的空闲连接
druid.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
//一个连接在池中最小生存的时间
druid.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
//用来检测连接是否有效的sql
druid.setValidationQuery(validationQuery);
//建议配置为true,不影响性能,并且保证安全性。
druid.setTestWhileIdle(testWhileIdle);
//申请连接时执行validationQuery检测连接是否有效
druid.setTestOnBorrow(testOnBorrow);
druid.setTestOnReturn(testOnReturn);
//是否缓存preparedStatement,也就是PSCache,oracle设为true,mysql设为false。分库分表较多推荐设置为false
druid.setPoolPreparedStatements(poolPreparedStatements);
// 打开PSCache时,指定每个连接上PSCache的大小
druid.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
return druid;
}
// 创建该数据源的事务管理
@Primary
@Bean(name = "transactionManager")
public DataSourceTransactionManager transactionManager() throws SQLException {
return new DataSourceTransactionManager(dataSource());
}
// 创建Mybatis的连接会话工厂实例
@Primary
@Bean(name = "sqlSessionFactory")
public SqlSessionFactory sqlSessionFactory(@Qualifier("dataSource") DataSource dataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource); // 设置数据源bean
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(DatabaseConfig.MAPPER_LOCATION)); // 设置mapper文件路径
return sessionFactory.getObject();
}
public String getFilters() {
return filters;
}
public void setFilters(String filters) {
this.filters = filters;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDriverClassName() {
return driverClassName;
}
public void setDriverClassName(String driverClassName) {
this.driverClassName = driverClassName;
}
public int getInitialSize() {
return initialSize;
}
public void setInitialSize(int initialSize) {
this.initialSize = initialSize;
}
public int getMinIdle() {
return minIdle;
}
public void setMinIdle(int minIdle) {
this.minIdle = minIdle;
}
public int getMaxActive() {
return maxActive;
}
public void setMaxActive(int maxActive) {
this.maxActive = maxActive;
}
public long getMaxWait() {
return maxWait;
}
public void setMaxWait(long maxWait) {
this.maxWait = maxWait;
}
public long getTimeBetweenEvictionRunsMillis() {
return timeBetweenEvictionRunsMillis;
}
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
}
public long getMinEvictableIdleTimeMillis() {
return minEvictableIdleTimeMillis;
}
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
}
public String getValidationQuery() {
return validationQuery;
}
public void setValidationQuery(String validationQuery) {
this.validationQuery = validationQuery;
}
public boolean isTestWhileIdle() {
return testWhileIdle;
}
public void setTestWhileIdle(boolean testWhileIdle) {
this.testWhileIdle = testWhileIdle;
}
public boolean isTestOnBorrow() {
return testOnBorrow;
}
public void setTestOnBorrow(boolean testOnBorrow) {
this.testOnBorrow = testOnBorrow;
}
public boolean isTestOnReturn() {
return testOnReturn;
}
public void setTestOnReturn(boolean testOnReturn) {
this.testOnReturn = testOnReturn;
}
public boolean isPoolPreparedStatements() {
return poolPreparedStatements;
}
public void setPoolPreparedStatements(boolean poolPreparedStatements) {
this.poolPreparedStatements = poolPreparedStatements;
}
public int getMaxPoolPreparedStatementPerConnectionSize() {
return maxPoolPreparedStatementPerConnectionSize;
}
public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize) {
this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize;
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@ package com.jz.dm.mall.moduls.controller.finance;
import com.jz.common.base.BaseController;
import com.jz.common.utils.Result;
import com.jz.dm.mall.moduls.controller.order.bean.OrderDto;
import com.jz.dm.mall.moduls.controller.finance.bean.FinanceCustomerAssetsDto;
import com.jz.dm.mall.moduls.service.FinanceTradeFlowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
* 企业客户交易流水(TFinanceTradeFlow)表控制层
......@@ -33,11 +35,19 @@ public class FinanceTradeFlowController extends BaseController {
* 充值----获取企业账户余额
*
* @author Bellamy
* @since 2020-12-03
*/
@GetMapping(value = "/getAccountMoney")
@ApiOperation(value = "充值----获取账户余额", notes = "获取账户余额")
public Result<OrderDto> getAccountMoney(HttpServletRequest req) throws Exception {
return new Result<>();
@ApiOperation(value = "充值----获取账户余额", notes = "获取账户余额,只有已审核(认证)企业才可以充值")
public Result<FinanceCustomerAssetsDto> getAccountMoney(HttpServletRequest requset) throws Exception {
Result<FinanceCustomerAssetsDto> result = new Result<>();
//requset.getSession().getAttribute(""); //从session中获取商城用户的 id,和企业资产账户id
Map map = new HashMap();
map.put("assetsId", 1); //企业资产账户id
map.put("departmentId", 1); //企业ID
FinanceCustomerAssetsDto dto = financeTradeFlowService.queryAccountMoneyByMap(map);
result.setResult(dto);
return result;
}
}
\ No newline at end of file
package com.jz.dm.mall.moduls.controller.finance.bean;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 商城企业客户资产(TFinanceCustomerAssets)实体类
*
* @author Bellamy
* @since 2020-12-01 10:41:38
*/
@ApiModel
public class FinanceCustomerAssetsDto implements Serializable {
private static final long serialVersionUID = -86484762300825431L;
/**
* 资产id
*/
@TableId(value = "assets_id",type = IdType.AUTO)
@ApiModelProperty(value = "资产id")
private Long assetsId;
/**
* 企业id
*/
@ApiModelProperty(value = "企业id")
private Long departmentId;
/**
* 可用金额
*/
@ApiModelProperty(value = "可用金额")
private BigDecimal useMoney;
/**
* 冻结金额
*/
@ApiModelProperty(value = "冻结金额")
private BigDecimal frozenMoney;
/**
* 总金额
*/
@ApiModelProperty(value = "总金额")
private BigDecimal totalMoney;
public Long getAssetsId() {
return assetsId;
}
public void setAssetsId(Long assetsId) {
this.assetsId = assetsId;
}
public Long getDepartmentId() {
return departmentId;
}
public void setDepartmentId(Long departmentId) {
this.departmentId = departmentId;
}
public BigDecimal getUseMoney() {
return useMoney;
}
public void setUseMoney(BigDecimal useMoney) {
this.useMoney = useMoney;
}
public BigDecimal getFrozenMoney() {
return frozenMoney;
}
public void setFrozenMoney(BigDecimal frozenMoney) {
this.frozenMoney = frozenMoney;
}
public BigDecimal getTotalMoney() {
return totalMoney;
}
public void setTotalMoney(BigDecimal totalMoney) {
this.totalMoney = totalMoney;
}
}
\ No newline at end of file
package com.jz.dm.mall.moduls.mapper;
import com.jz.common.base.BaseMapper;
import com.jz.dm.mall.moduls.controller.finance.bean.FinanceCustomerAssetsDto;
import com.jz.dm.mall.moduls.entity.FinanceTradeFlow;
import java.util.Map;
/**
* 企业客户交易流水(TFinanceTradeFlow)表数据库访问层
*
......@@ -13,4 +16,5 @@ import com.jz.dm.mall.moduls.entity.FinanceTradeFlow;
public interface FinanceTradeFlowDao extends BaseMapper<FinanceTradeFlow> {
FinanceCustomerAssetsDto queryAccountMoneyByMap(Map map) throws Exception ;
}
\ No newline at end of file
package com.jz.dm.mall.moduls.service;
import com.jz.dm.mall.moduls.controller.finance.bean.FinanceCustomerAssetsDto;
import java.util.Map;
/**
* 企业客户交易流水(TFinanceTradeFlow)表服务接口
*
......@@ -9,4 +13,5 @@ package com.jz.dm.mall.moduls.service;
public interface FinanceTradeFlowService {
FinanceCustomerAssetsDto queryAccountMoneyByMap(Map map) throws Exception ;
}
\ No newline at end of file
package com.jz.dm.mall.moduls.service.impl;
import com.jz.common.entity.Department;
import com.jz.common.exception.ResponseException;
import com.jz.dm.mall.moduls.entity.FinanceCustomerAssets;
import com.jz.dm.mall.moduls.entity.MallCustomer;
import com.jz.common.utils.Result;
......@@ -104,7 +105,7 @@ public class CompanyAuthServiceImpl implements CompanyAuthService {
departmentInset.setCrePerson(req.getLoginName());
BeanUtils.copyProperties(req,departmentInset);
if (departmentDao.insert(departmentInset) != 1){
throw new RuntimeException("保存企业信息失败");
throw ResponseException.of_error("保存企业信息失败");
}
//初始化用户资产表
FinanceCustomerAssets finance = new FinanceCustomerAssets();
......@@ -112,7 +113,7 @@ public class CompanyAuthServiceImpl implements CompanyAuthService {
finance.setCreTime(new Date());
finance.setCrePerson(req.getLoginName());
if (financeCustomerAssetsDao.insert(finance) != 1){
throw new RuntimeException("初始化用户资产失败");
throw ResponseException.of_error("初始化用户资产失败");
}
//更新用户企业信息
MallCustomer mallCustomer = new MallCustomer();
......@@ -121,7 +122,7 @@ public class CompanyAuthServiceImpl implements CompanyAuthService {
mallCustomer.setUptTime(new Date());
// mallCustomer.setUptPerson(req.getLoginName());
if (mallCustomerDao.updateById(mallCustomer) != 1){
throw new RuntimeException("更新用户企业信息失败");
throw ResponseException.of_error("更新用户企业信息失败");
}
}
}
package com.jz.dm.mall.moduls.service.impl;
import com.jz.dm.mall.moduls.controller.finance.bean.FinanceCustomerAssetsDto;
import com.jz.dm.mall.moduls.mapper.FinanceTradeFlowDao;
import com.jz.dm.mall.moduls.service.FinanceTradeFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* 企业客户交易流水(TFinanceTradeFlow)表服务实现类
*
......@@ -13,7 +16,12 @@ import org.springframework.stereotype.Service;
*/
@Service("financeTradeFlowService")
public class FinanceTradeFlowServiceImpl implements FinanceTradeFlowService {
@Autowired
private FinanceTradeFlowDao tFinanceTradeFlowDao;
private FinanceTradeFlowDao financeTradeFlowDao;
@Override
public FinanceCustomerAssetsDto queryAccountMoneyByMap(Map map) throws Exception {
return financeTradeFlowDao.queryAccountMoneyByMap(map);
}
}
\ No newline at end of file
......@@ -2,18 +2,18 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jz.dm.mall.moduls.mapper.FinanceCustomerAssetsDao">
<!-- <resultMap type="com.jz.manage.moduls.entity.FinanceCustomerAssets" id="TFinanceCustomerAssetsMap">-->
<!-- <result property="assetsId" column="assets_id" jdbcType="INTEGER"/>-->
<!-- <result property="departmentId" column="department_id" jdbcType="INTEGER"/>-->
<!-- <result property="useMoney" column="use_money" jdbcType="NUMERIC"/>-->
<!-- <result property="frozenMoney" column="frozen_money" jdbcType="NUMERIC"/>-->
<!-- <result property="totalMoney" column="total_money" jdbcType="NUMERIC"/>-->
<!-- <result property="creTime" column="cre_time" jdbcType="TIMESTAMP"/>-->
<!-- <result property="crePerson" column="cre_person" jdbcType="VARCHAR"/>-->
<!-- <result property="uptTime" column="upt_time" jdbcType="TIMESTAMP"/>-->
<!-- <result property="uptPerson" column="upt_person" jdbcType="VARCHAR"/>-->
<!-- <result property="delFlag" column="del_flag" jdbcType="VARCHAR"/>-->
<!-- </resultMap>-->
<resultMap type="com.jz.dm.mall.moduls.entity.FinanceCustomerAssets" id="TFinanceCustomerAssetsMap">
<result property="assetsId" column="assets_id" jdbcType="INTEGER"/>
<result property="departmentId" column="department_id" jdbcType="INTEGER"/>
<result property="useMoney" column="use_money" jdbcType="NUMERIC"/>
<result property="frozenMoney" column="frozen_money" jdbcType="NUMERIC"/>
<result property="totalMoney" column="total_money" jdbcType="NUMERIC"/>
<result property="creTime" column="cre_time" jdbcType="TIMESTAMP"/>
<result property="crePerson" column="cre_person" jdbcType="VARCHAR"/>
<result property="uptTime" column="upt_time" jdbcType="TIMESTAMP"/>
<result property="uptPerson" column="upt_person" jdbcType="VARCHAR"/>
<result property="delFlag" column="del_flag" jdbcType="VARCHAR"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="TFinanceCustomerAssetsMap">
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jz.dm.mall.moduls.mapper.FinanceTradeFlowDao">
<!--商城 充值 只有已审核(认证)企业-->
<select id="queryAccountMoneyByMap" resultType="com.jz.dm.mall.moduls.controller.finance.bean.FinanceCustomerAssetsDto" parameterType="map">
select
assets_id as assetsId,
department_id as departmentId,
use_money as useMoney,
frozen_money as frozenMoney,
total_money as totalMoney
from t_finance_customer_assets t
left join t_department t1 on t.department_id=t1.department_id and t1.audit_status='02'
where 1=1
<if test="assetsId != null">and assets_id = #{assetsId}</if>
<if test="departmentId != null">and department_id = #{departmentId}</if>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment