├── .gitignore ├── Hodor-cgi ├── build.gradle └── src │ └── main │ ├── java │ └── com │ │ └── codido │ │ └── hodor │ │ └── api │ │ ├── HodorApiApplication.java │ │ ├── SwaggersConfig.java │ │ ├── common │ │ ├── annotation │ │ │ └── AreYouLogin.java │ │ ├── aop │ │ │ ├── LoginAspect.java │ │ │ └── RequestLogAspect.java │ │ ├── bean │ │ │ ├── req │ │ │ │ ├── BasePageReq.java │ │ │ │ └── BaseReq.java │ │ │ └── resp │ │ │ │ ├── BasePageResp.java │ │ │ │ └── BaseResp.java │ │ ├── config │ │ │ ├── DruidDBConfig.java │ │ │ └── EvnConfig.java │ │ ├── constans │ │ │ └── AppConstans.java │ │ ├── exception │ │ │ ├── LoginException.java │ │ │ └── WebException.java │ │ └── util │ │ │ ├── ChuangLanSmsSendUtil.java │ │ │ ├── ChuangLanSmsUtil.java │ │ │ ├── JsonUtils.java │ │ │ ├── LogUtil.java │ │ │ ├── request │ │ │ └── SmsSendRequest.java │ │ │ └── response │ │ │ └── SmsSendResponse.java │ │ ├── ord │ │ ├── bean │ │ │ ├── req │ │ │ │ └── ApplyOrderReq.java │ │ │ └── resp │ │ │ │ └── ApplyOrderResp.java │ │ └── controller │ │ │ └── OrdController.java │ │ ├── usr │ │ ├── bean │ │ │ └── vo │ │ │ │ ├── UserInfoVo.java │ │ │ │ └── WXSessionModelVo.java │ │ ├── controller │ │ │ └── UserController.java │ │ └── service │ │ │ └── UserServiceImpl.java │ │ └── weixin │ │ ├── bean │ │ ├── dto │ │ │ ├── AccessTokenVo.java │ │ │ ├── SNSUserInfo.java │ │ │ ├── Token.java │ │ │ ├── WeixinConfigVo.java │ │ │ ├── WeixinOauth2Token.java │ │ │ └── WeixinUserInfo.java │ │ ├── outbean │ │ │ └── WXSnsUserInfoRespBean.java │ │ ├── req │ │ │ ├── DealUserWxLoginReq.java │ │ │ └── QueryWechatJssdkInfoReq.java │ │ └── resp │ │ │ ├── DealUserWxLoginResp.java │ │ │ └── QueryWechatJssdkInfoResp.java │ │ ├── builder │ │ ├── AbstractBuilder.java │ │ ├── ImageBuilder.java │ │ └── TextBuilder.java │ │ ├── config │ │ ├── WxAccountEnum.java │ │ ├── WxAppConfig.java │ │ ├── WxConfig.java │ │ └── WxPayConfiguration.java │ │ ├── handler │ │ └── common │ │ │ ├── AbstractHandler.java │ │ │ ├── LogHandler.java │ │ │ └── NullHandler.java │ │ └── util │ │ ├── MyX509TrustManager.java │ │ └── WeixinServerRequestUtil.java │ └── resources │ ├── application-dev.yml │ ├── application-ptc.yml │ ├── application-uat.yml │ ├── application.yml │ └── logback-spring.xml ├── Hodor-core ├── build.gradle └── src │ └── main │ ├── java │ └── com │ │ └── codido │ │ └── hodor │ │ ├── cfg │ │ └── bo │ │ │ ├── CfgBo.java │ │ │ └── impl │ │ │ └── CfgBoImpl.java │ │ └── core │ │ ├── bo │ │ ├── BaseBo.java │ │ ├── RedisUtilBo.java │ │ ├── SendMpMessageBo.java │ │ └── dto │ │ │ ├── BaseDto.java │ │ │ ├── BaseParaDto.java │ │ │ ├── BaseReturnDto.java │ │ │ └── WxPushMsgReqDto.java │ │ ├── common │ │ ├── constans │ │ │ └── CommonConstans.java │ │ ├── dto │ │ │ ├── BaseParamDto.java │ │ │ ├── BaseRetDto.java │ │ │ ├── MessageXSendParaDto.java │ │ │ ├── MessageXSendRetDto.java │ │ │ └── TimestampRetDto.java │ │ └── util │ │ │ ├── AesCbcUtil.java │ │ │ ├── CaseComputUtils.java │ │ │ ├── Digests.java │ │ │ ├── Encodes.java │ │ │ ├── HttpClientUtil.java │ │ │ ├── JBDateUtil.java │ │ │ ├── JBFileUtil.java │ │ │ ├── JBPictureUtil.java │ │ │ ├── JBUtil.java │ │ │ ├── MD5Util.java │ │ │ ├── MessageXsendUtil.java │ │ │ ├── OrderNoGeneratorUtil.java │ │ │ ├── Password.java │ │ │ ├── PictureUtil.java │ │ │ ├── RequestEncoder.java │ │ │ ├── Sha1Util.java │ │ │ └── XMLUtil.java │ │ ├── mapper │ │ ├── CfgAgentMapper.java │ │ ├── CfgAgentSqlProvider.java │ │ ├── CfgChannelMapper.java │ │ ├── CfgChannelSqlProvider.java │ │ ├── CfgOfferMapper.java │ │ ├── CfgOfferSqlProvider.java │ │ ├── PubParamMapper.java │ │ └── PubParamSqlProvider.java │ │ └── model │ │ ├── CfgAgent.java │ │ ├── CfgAgentExample.java │ │ ├── CfgChannel.java │ │ ├── CfgChannelExample.java │ │ ├── CfgOffer.java │ │ ├── CfgOfferExample.java │ │ ├── PubParam.java │ │ └── PubParamExample.java │ └── resources │ ├── application.properties │ └── tools │ └── NeedleGeneratorConfig.xml ├── Hodor-job ├── build.gradle └── src │ └── main │ ├── java │ └── com │ │ └── codido │ │ └── hodor │ │ └── job │ │ ├── JobApplication.java │ │ ├── bean │ │ └── vo │ │ │ └── WxPushReq.java │ │ ├── job │ │ ├── bean │ │ │ └── dto │ │ │ │ ├── BaseRetDto.java │ │ │ │ ├── SendOrderChooseDto.java │ │ │ │ ├── SendOrderDetailDto.java │ │ │ │ ├── SendOrderToTerminalRequestDto.java │ │ │ │ ├── SendOrderToTerminalResponseDto.java │ │ │ │ └── SendOrderToTerminalRetDto.java │ │ ├── config │ │ │ ├── EvnConfig.java │ │ │ └── ScheduleConfig.java │ │ └── scheduling │ │ │ └── SubIntScheduling.java │ │ ├── scb │ │ └── service │ │ │ └── SendMessageService.java │ │ └── weixin │ │ ├── bean │ │ └── dto │ │ │ ├── AccessTokenVo.java │ │ │ ├── SNSUserInfo.java │ │ │ ├── Token.java │ │ │ ├── WeixinOauth2Token.java │ │ │ └── WeixinUserInfo.java │ │ ├── builder │ │ ├── AbstractBuilder.java │ │ ├── ImageBuilder.java │ │ └── TextBuilder.java │ │ ├── config │ │ ├── WxAccountEnum.java │ │ └── WxConfig.java │ │ ├── handler │ │ ├── AbstractHandler.java │ │ ├── LogHandler.java │ │ ├── MenuHandler.java │ │ └── MsgHandler.java │ │ ├── service │ │ ├── BaseWxService.java │ │ └── WxMpService.java │ │ └── util │ │ └── JsonUtils.java │ └── resources │ ├── application-dev.yml │ ├── application-ptc.yml │ ├── application-uat.yml │ ├── application.yml │ └── logback-spring.xml ├── README.md ├── build.gradle ├── gradle └── wrapper │ └── gradle-wrapper.properties └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Example user template template 3 | ### Example user template 4 | 5 | # IntelliJ project files 6 | .idea 7 | *.iml 8 | .gradle/ 9 | log/ 10 | out/ 11 | gen/ 12 | build/ 13 | /logPath_IS_UNDEFINED/ 14 | -------------------------------------------------------------------------------- /Hodor-cgi/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.2.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | 14 | group 'com.codido' 15 | version '1.0-SNAPSHOT' 16 | 17 | 18 | apply plugin: 'java' 19 | //apply plugin: 'war' 20 | apply plugin: 'org.springframework.boot' 21 | apply plugin: 'io.spring.dependency-management' 22 | 23 | sourceCompatibility = 1.8 24 | 25 | repositories { 26 | mavenCentral() 27 | } 28 | 29 | //排除tomcat配置 30 | configurations { 31 | compile.exclude module: "spring-boot-starter-tomcat" 32 | } 33 | 34 | dependencies { 35 | compile project(':Hodor-core') 36 | 37 | implementation('org.springframework.boot:spring-boot-starter-web') 38 | implementation("org.springframework.boot:spring-boot-starter-jetty:1.4.1.RELEASE") 39 | implementation('org.springframework.boot:spring-boot-configuration-processor') 40 | implementation('org.springframework.boot:spring-boot-starter-aop') 41 | implementation('org.springframework.boot:spring-boot-starter-data-redis') 42 | 43 | implementation('org.mybatis.spring.boot:mybatis-spring-boot-starter:2.0.0') 44 | implementation('com.github.pagehelper:pagehelper-spring-boot-starter:1.2.3') 45 | runtime('mysql:mysql-connector-java') 46 | implementation('com.alibaba:druid:1.1.10') 47 | 48 | implementation('com.alibaba:fastjson:1.2.12') 49 | implementation('org.codehaus.jackson:jackson-core-asl:1.9.13') 50 | implementation('com.google.code.gson:gson:2.8.2') 51 | 52 | compile('com.github.binarywang:weixin-java-mp:2.9.0') 53 | compile('com.github.binarywang:weixin-java-pay:2.9.0') 54 | //compile('com.github.binarywang:weixin-java-open:3.8.0') 55 | 56 | compile('org.dom4j:dom4j:2.1.1') 57 | 58 | compile('com.qiniu:qiniu-java-sdk:7.2.27') 59 | implementation('net.coobird:thumbnailator:0.4.8') 60 | 61 | compile('log4j:log4j:+') 62 | 63 | implementation("org.apache.commons:commons-lang3:3.4") 64 | implementation("commons-io:commons-io:2.5") 65 | implementation("org.apache.httpcomponents:httpcore:4.4.8") 66 | implementation("org.apache.httpcomponents:httpclient:4.5.4") 67 | implementation("org.apache.httpcomponents:httpmime:4.5.4") 68 | implementation("com.thoughtworks.xstream:xstream:1.4.9") 69 | 70 | //implementation ("org.projectlombok:lombok:1.16.20") 71 | annotationProcessor 'org.projectlombok:lombok:1.18.2' 72 | compileOnly 'org.projectlombok:lombok:1.18.2' 73 | 74 | implementation('io.springfox:springfox-swagger2:2.9.2') 75 | implementation('io.springfox:springfox-swagger-ui:2.9.2') 76 | implementation('com.github.xiaoymin:swagger-bootstrap-ui:1.9.6') 77 | implementation('com.github.caspar-chen:swagger-ui-layer:1.1.3') 78 | 79 | testImplementation('org.springframework.boot:spring-boot-starter-test') 80 | } -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/HodorApiApplication.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @MapperScan("com.codido.hodor.core.mapper") 9 | public class HodorApiApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(HodorApiApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/SwaggersConfig.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.Profile; 6 | import springfox.documentation.builders.ApiInfoBuilder; 7 | import springfox.documentation.builders.PathSelectors; 8 | import springfox.documentation.builders.RequestHandlerSelectors; 9 | import springfox.documentation.service.ApiInfo; 10 | import springfox.documentation.spi.DocumentationType; 11 | import springfox.documentation.spring.web.plugins.Docket; 12 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 13 | 14 | @Configuration 15 | @EnableSwagger2 16 | @Profile({"dev", "uat"}) 17 | public class SwaggersConfig { 18 | 19 | @Bean 20 | public Docket createRestApi() { 21 | return new Docket(DocumentationType.SWAGGER_2) 22 | .apiInfo(apiInfo()) 23 | .select() 24 | .apis(RequestHandlerSelectors.basePackage("com.codido.hodor.api")) 25 | .paths(PathSelectors.any()) 26 | .build(); 27 | } 28 | 29 | 30 | private ApiInfo apiInfo() { 31 | return new ApiInfoBuilder() 32 | .title("Needle接口文档") 33 | .description("Needle用于各种会员充值的服务") 34 | .termsOfServiceUrl("http://www.rivendell.top/CV.html") 35 | .contact("双例模式") 36 | .version("1.0") 37 | .build(); 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/annotation/AreYouLogin.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.annotation; 2 | 3 | 4 | import java.lang.annotation.*; 5 | 6 | @Target(ElementType.METHOD) 7 | @Retention(RetentionPolicy.RUNTIME) 8 | @Inherited 9 | public @interface AreYouLogin { 10 | 11 | String[] value() default {}; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/aop/LoginAspect.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.aop; 2 | 3 | import com.codido.hodor.api.common.bean.req.BaseReq; 4 | import com.codido.hodor.api.common.exception.LoginException; 5 | import com.codido.hodor.core.common.constans.CommonConstans; 6 | import com.codido.hodor.core.common.util.JBDateUtil; 7 | import com.codido.hodor.core.common.util.JBUtil; 8 | import com.github.pagehelper.PageHelper; 9 | import org.aspectj.lang.ProceedingJoinPoint; 10 | import org.aspectj.lang.annotation.*; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.core.annotation.Order; 15 | import org.springframework.stereotype.Component; 16 | 17 | /** 18 | * 登录处理Aspect 19 | * 根据请求类的tokenId查询用户对象,如果有用户对象,就添加到req里面,没有就返回未登录 20 | */ 21 | @Aspect 22 | @Order(1) 23 | @Component 24 | public class LoginAspect { 25 | 26 | /** 27 | * 日志工具 28 | */ 29 | private static final Logger logger = LoggerFactory.getLogger(LoginAspect.class); 30 | 31 | 32 | /** 33 | * 定义一个切入点. 34 | * 解释下: 35 | * ~ 第一个 * 代表任意修饰符及任意返回值. 36 | * ~ 第二个 * 任意包名 37 | * ~ 第三个 * 代表任意方法. 38 | * ~ 第四个 * 定义在web包或者子包 39 | * ~ 第五个 * 任意方法 40 | * ~ .. 匹配任意数量的参数. 41 | */ 42 | @Pointcut("@annotation(com.codido.hodor.api.common.annotation.AreYouLogin)") 43 | public void loginCheck() { 44 | 45 | } 46 | 47 | @Around("loginCheck()") 48 | public Object doAround(ProceedingJoinPoint pjp) throws Throwable { 49 | //做登录校验 50 | logger.info("做登录校验"); 51 | Object[] objects = pjp.getArgs(); 52 | if (objects != null) { 53 | int objectsSize = objects.length; 54 | for (int i = 0; i < objectsSize; i++) { 55 | if (objects[i] instanceof BaseReq) { 56 | BaseReq req = (BaseReq) objects[i]; 57 | if (!JBUtil.isStrEmpty(req.getTokenId())) { 58 | //通过用户的TOKEN编码获取到用户的身份信息 59 | // UsrUser usrUser = usrUserOPMapper.selectByTokenCode(req.getTokenId()); 60 | // if (usrUser != null) { 61 | // logger.info("数据库获取了登录参数:" + usrUser.toString()); 62 | // //判断token是否已经过期 63 | // req.setUsrUser(usrUser); 64 | // //更新TOKEN有效时间 65 | // UsrToken usrToken = new UsrToken(); 66 | // usrToken.setTokenCode(req.getTokenId()); 67 | // usrToken.setTokenSts(CommonConstans.COMMON_STS_VALID); 68 | // usrToken.setTokenEndTime(JBDateUtil.addDate(30));//在现有基础上增加30天 69 | // usrTokenOPMapper.updateByTokenCode(usrToken); 70 | // return pjp.proceed(); 71 | // } else { 72 | // logger.info("登录校验完成,未找到合适的token,不可登录\n\n"); 73 | // throw new LoginException(); 74 | // } 75 | } else { 76 | logger.info("登录校验完成,有入参问题,不可登录\n\n"); 77 | throw new LoginException(); 78 | } 79 | } 80 | } 81 | } 82 | return pjp.proceed(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/aop/RequestLogAspect.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.aop; 2 | 3 | 4 | import com.codido.hodor.api.common.util.JsonUtils; 5 | import com.codido.hodor.api.common.util.LogUtil; 6 | import com.codido.hodor.core.common.util.OrderNoGeneratorUtil; 7 | import org.aspectj.lang.JoinPoint; 8 | import org.aspectj.lang.annotation.*; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.core.annotation.Order; 12 | import org.springframework.stereotype.Component; 13 | import org.springframework.web.context.request.RequestContextHolder; 14 | import org.springframework.web.context.request.ServletRequestAttributes; 15 | 16 | import javax.servlet.http.HttpServletRequest; 17 | import java.util.*; 18 | 19 | /** 20 | * AOP处理日志 21 | */ 22 | @Aspect 23 | @Order(0) 24 | @Component 25 | public class RequestLogAspect { 26 | 27 | /** 28 | * 日志工具 29 | */ 30 | private static final Logger logger = LoggerFactory.getLogger(RequestLogAspect.class); 31 | 32 | /** 33 | * 定义一个切入点. 34 | * 解释下: 35 | * ~ 第一个 * 代表任意修饰符及任意返回值. 36 | * ~ 第二个 * 任意包名 37 | * ~ 第三个 * 代表任意方法. 38 | * ~ 第四个 * 定义在web包或者子包 39 | * ~ 第五个 * 任意方法 40 | * ~ .. 匹配任意数量的参数. 41 | */ 42 | @Pointcut("execution(public * com.codido.hodor.api.*.controller..*.*(..))") 43 | public void controllerLog() { 44 | } 45 | 46 | /** 47 | * 定义一个切入点 48 | * 49 | * @param joinPoint 50 | */ 51 | @Before("controllerLog()") //指定拦截器规则;也可以直接把“execution(* com.codido.........)”写进这里 52 | public void doBefore(JoinPoint joinPoint) { 53 | // 接收到请求,记录请求内容 54 | //整个请求最前面,把日志给记录一下 55 | 56 | LogUtil.setBizIdWithClear(OrderNoGeneratorUtil.generatorOrderNo(OrderNoGeneratorUtil.LOG_PRE_FLAG)); 57 | 58 | //开始记录基本日志 59 | logger.info("请求开始"); 60 | ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); 61 | HttpServletRequest request = attributes.getRequest(); 62 | 63 | // 记录下请求内容 64 | logger.info("请求URL : " + request.getRequestURL().toString()); 65 | logger.info("请求HTTP_METHOD : " + request.getMethod()); 66 | logger.info("请求IP : " + request.getRemoteAddr()); 67 | logger.info("请求的方法 : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName()); 68 | StringBuffer argsStr = new StringBuffer(); 69 | if(joinPoint.getArgs()!=null && joinPoint.getArgs().length>0){ 70 | int argsSize = joinPoint.getArgs().length; 71 | for(int i=0;i enu = request.getParameterNames(); 81 | while (enu.hasMoreElements()) { 82 | String paraName = enu.nextElement(); 83 | logger.info("请求参数:"+paraName + ": " + request.getParameter(paraName)); 84 | } 85 | } 86 | 87 | @AfterReturning(pointcut = "controllerLog()", returning = "ret") 88 | public void doAfterReturning(Object ret) { 89 | // 处理完请求,返回内容 90 | 91 | logger.info("响应内容:" + ((ret==null)?"": JsonUtils.toJsonString(ret))); 92 | logger.info("响应完成\n\n"); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/bean/req/BasePageReq.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.bean.req; 2 | 3 | 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | 9 | /** 10 | * 分页请求基类 11 | */ 12 | @Data 13 | @EqualsAndHashCode(callSuper = false) 14 | @ApiModel 15 | public class BasePageReq extends BaseReq { 16 | 17 | @ApiModelProperty("页码") 18 | private Integer pageNum; 19 | 20 | @ApiModelProperty("每页请求数量") 21 | private Integer prePageCount; 22 | } 23 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/bean/req/BaseReq.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.bean.req; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 整体请求基类 12 | */ 13 | @Data 14 | @EqualsAndHashCode(callSuper = false) 15 | @ApiModel 16 | public class BaseReq implements Serializable { 17 | 18 | @ApiModelProperty("用户TOKENID") 19 | private String tokenId; 20 | 21 | @ApiModelProperty("页面上传的渠道标识,从页面参数获取,可为空,空的情况下做小程序处理:APP_YOUSHU_ANDROID:android客户端,APP_YOUSHU_IOS:iOS客户端") 22 | private String channelFlag; 23 | 24 | @ApiModelProperty("APP版本号") 25 | private String versionNumber; 26 | 27 | @ApiModelProperty("APP渠道来源,即集成友盟后,客户端分发的版本") 28 | private String appChannelInfo; 29 | } 30 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/bean/resp/BasePageResp.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.bean.resp; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | /** 9 | * 分页响应基类 10 | */ 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | @ApiModel 14 | public class BasePageResp extends BaseResp { 15 | 16 | @ApiModelProperty("当前页码") 17 | private String currentPageNo; 18 | } 19 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/bean/resp/BaseResp.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.bean.resp; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 响应基类 10 | */ 11 | @Data 12 | public class BaseResp implements Serializable { 13 | 14 | @ApiModelProperty("响应编码,0000表示成功,其他有各自的定义") 15 | private String respCode; 16 | 17 | @ApiModelProperty("响应错误提示") 18 | private String respMsg; 19 | } 20 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/config/DruidDBConfig.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.config; 2 | 3 | 4 | import com.alibaba.druid.pool.DruidDataSource; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.context.annotation.Primary; 9 | 10 | import javax.sql.DataSource; 11 | import java.sql.SQLException; 12 | 13 | /** 14 | * 数据库连接池 15 | */ 16 | @Configuration 17 | public class DruidDBConfig { 18 | 19 | @Value("${spring.datasource.url}") 20 | private String dbUrl; 21 | 22 | @Value("${spring.datasource.username}") 23 | private String username; 24 | 25 | @Value("${spring.datasource.password}") 26 | private String password; 27 | 28 | @Value("${spring.datasource.driverClassName}") 29 | private String driverClassName; 30 | 31 | @Value("${spring.datasource.initialSize}") 32 | private int initialSize; 33 | 34 | @Value("${spring.datasource.minIdle}") 35 | private int minIdle; 36 | 37 | @Value("${spring.datasource.maxActive}") 38 | private int maxActive; 39 | 40 | @Value("${spring.datasource.maxWait}") 41 | private int maxWait; 42 | 43 | @Value("${spring.datasource.timeBetweenEvictionRunsMillis}") 44 | private int timeBetweenEvictionRunsMillis; 45 | 46 | @Value("${spring.datasource.minEvictableIdleTimeMillis}") 47 | private int minEvictableIdleTimeMillis; 48 | 49 | @Value("${spring.datasource.validationQuery}") 50 | private String validationQuery; 51 | 52 | @Value("${spring.datasource.testWhileIdle}") 53 | private boolean testWhileIdle; 54 | 55 | @Value("${spring.datasource.testOnBorrow}") 56 | private boolean testOnBorrow; 57 | 58 | @Value("${spring.datasource.testOnReturn}") 59 | private boolean testOnReturn; 60 | 61 | @Value("${spring.datasource.poolPreparedStatements}") 62 | private boolean poolPreparedStatements; 63 | 64 | @Value("${spring.datasource.maxPoolPreparedStatementPerConnectionSize}") 65 | private int maxPoolPreparedStatementPerConnectionSize; 66 | 67 | @Value("${spring.datasource.filters}") 68 | private String filters; 69 | 70 | @Value("{spring.datasource.connectionProperties}") 71 | private String connectionProperties; 72 | 73 | @Bean //声明其为Bean实例 74 | @Primary //在同样的DataSource中,首先使用被标注的DataSource 75 | public DataSource dataSource(){ 76 | DruidDataSource datasource = new DruidDataSource(); 77 | 78 | datasource.setUrl(this.dbUrl); 79 | datasource.setUsername(username); 80 | datasource.setPassword(password); 81 | datasource.setDriverClassName(driverClassName); 82 | 83 | //configuration 84 | datasource.setInitialSize(initialSize); 85 | datasource.setMinIdle(minIdle); 86 | datasource.setMaxActive(maxActive); 87 | datasource.setMaxWait(maxWait); 88 | datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); 89 | datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); 90 | datasource.setValidationQuery(validationQuery); 91 | datasource.setTestWhileIdle(testWhileIdle); 92 | datasource.setTestOnBorrow(testOnBorrow); 93 | datasource.setTestOnReturn(testOnReturn); 94 | datasource.setPoolPreparedStatements(poolPreparedStatements); 95 | datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); 96 | try { 97 | datasource.setFilters(filters); 98 | } catch (SQLException e) { 99 | //logger.error("druid configuration initialization filter", e); 100 | System.out.println("druid configuration initialization filter"); 101 | } 102 | datasource.setConnectionProperties(connectionProperties); 103 | 104 | return datasource; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/config/EvnConfig.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.config; 2 | 3 | 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | /** 10 | * 环境参数 11 | */ 12 | @Data 13 | @EqualsAndHashCode(callSuper = false) 14 | @Configuration 15 | public class EvnConfig { 16 | 17 | @Value("${spring.profiles.active}") 18 | private String evn; 19 | } 20 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/constans/AppConstans.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.constans; 2 | 3 | /** 4 | * APP工程静态常量 5 | */ 6 | public class AppConstans { 7 | 8 | /** 9 | * 用户来源标识 10 | */ 11 | //public static String USER_REGIST_SOURCE_LOTTOSTORE = "WX_LOTTOSTORE";//自有渠道来源标识-->LOTTO_STORE_MP 12 | 13 | 14 | /** 15 | * 错误码 16 | */ 17 | public static String RESP_CODE_SUCCESS = "0000"; 18 | public static String RESP_MSG_SUCCESS = "响应成功"; 19 | public static String RESP_CODE_WXLOGIN_ERROR = "0101"; 20 | public static String RESP_MSG_WXLOGIN_ERROR = "获取微信参数异常"; 21 | public static String RESP_CODE_WXJSTICKET_ERROR = "0102"; 22 | public static String RESP_MSG_WXJSTICKET_ERROR = "获取微信JSSDK参数异常"; 23 | public static String RESP_CODE_PAYORDER_ERROR = "0112"; 24 | public static String RESP_MSG_PAYORDER_ERROR = "调用微信获取支付参数异常"; 25 | //分类等配置信息相关 26 | public static String RESP_CODE_NOSERVICETYPES_ERROR = "0201"; 27 | public static String RESP_MSG_NOSERVICETYPES_ERROR = "无分类数据"; 28 | public static String RESP_CODE_DUAL_SERVICE_ERROR = "0204";//重复的服务 29 | public static String RESP_MSG_DUAL_SERVICE_ERROR = "重复的服务";//重复的服务 30 | public static String RESP_CODE_NOSHOP_ERROR = "0210"; 31 | public static String RESP_MSG_NOSHOP_ERROR = "当前用户未绑定店铺"; 32 | //登录用户相关 33 | public static String RESP_CODE_TOKEN_ERROR = "0203"; 34 | public static String RESP_MSG_TOKEN_ERROR = "无效的token"; 35 | public static String RESP_CODE_USERLOGIN_ERROR = "0301"; 36 | public static String RESP_MSG_USERLOGIN_ERROR = "用户登录失败"; 37 | public static String RESP_CODE_USERVIPINST_ERROR = "0302"; 38 | public static String RESP_MSG_USERVIPINST_ERROR = "获取用户已订阅信息列表出错"; 39 | public static String RESP_CODE_OTHERUSERINFO_ERROR = "0303"; 40 | public static String RESP_MSG_OTHERUSERINFO_ERROR = "获取其他用户信息失败"; 41 | public static String RESP_CODE_USERCOSTINFO_ERROR = "0304"; 42 | public static String RESP_MSG_USERCOSTINFO_ERROR = "获取用户消费信息失败"; 43 | public static String RESP_PRIVAVCY_UPDATE_ERROR = "0305"; 44 | public static String RESP_MSG_PRIVAVCY_UPDATE_ERROR = "通知状态或通知时间字段异常,只能输入0-7天"; 45 | public static String RESP_CODE_APPLYSMS_ERROR = "0306"; 46 | public static String RESP_MSG_APPLYSMS_ERROR = "获取短信验证码失败"; 47 | public static String RESP_CODE_BINDLING_WXBINDED_ERROR = "0307"; 48 | public static String RESP_MSG_BINDLING_WXBINDED_ERROR = "微信账号已绑定手机号,不可进行绑定"; 49 | public static String RESP_CODE_BINDLING_WXINUSE_ERROR = "0308"; 50 | public static String RESP_MSG_BINDLING_WXINUSE_ERROR = "微信账号已使用,请选择如何进行合并"; 51 | public static String RESP_CODE_BINDLING_MBLBINDED_ERROR = "0309"; 52 | public static String RESP_MSG_BINDLING_MBLBINDED_ERROR = "手机号已绑定微信号,不可进行绑定"; 53 | public static String RESP_CODE_BINDLING_MBLINUSE_ERROR = "0310"; 54 | public static String RESP_MSG_BINDLING_MBLINUSE_ERROR = "手机号已使用,请选择如何进行合并"; 55 | public static String RESP_CODE_BINDLING_DIST_WX_EMPTY_ERROR = "0311"; 56 | public static String RESP_MSG_BINDLING_DIST_WX_EMPTY_ERROR = "用户微信信息为空,请核实后重新选择"; 57 | public static String RESP_CODE_BINDLING_DIST_MBLNO_EMPTY_ERROR = "0312"; 58 | public static String RESP_MSG_BINDLING_DIST_MBLNO_EMPTY_ERROR = "用户微信信息为空,请核实后重新选择"; 59 | public static String RESP_CODE_MBLNO_PWD_ERROR = "0313"; 60 | public static String RESP_MSG_MBLNO_PWD_ERROR = "手机号不存在或密码错误"; 61 | 62 | //订单相关 63 | public static String RESP_CODE_PARAM_ERROR = "9000"; 64 | public static String RESP_MSG_PARAM_ERROR = "参数异常!!"; 65 | public static String RESP_CODE_OTHER_ERROR = "9999"; 66 | public static String RESP_MSG_OTHER_ERROR = "服务器开了点小差,攻城狮正在跟它商量......"; 67 | public static String RESP_CODE_UNKNOW_ERROR = "9998"; 68 | public static String RESP_MSG_UNKNOW_ERROR = "未知数据错误"; 69 | 70 | 71 | /** 72 | * token失效周期 73 | */ 74 | public static int TOKEN_EXP_DAYS = 60;//token失效周期 75 | 76 | /** 77 | * 定义常量,万能验证码 78 | */ 79 | public static String CONST_SMS_CODE ="696988"; 80 | public static String CONST_SMS_MBLNO ="15308408401"; 81 | 82 | } 83 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/exception/LoginException.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.exception; 2 | 3 | /** 4 | * 登录异常 5 | */ 6 | public class LoginException extends RuntimeException{ 7 | 8 | } 9 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/exception/WebException.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.exception; 2 | 3 | import com.codido.hodor.api.common.bean.resp.BaseResp; 4 | import com.codido.hodor.api.common.constans.AppConstans; 5 | import com.codido.hodor.core.common.util.JBUtil; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.validation.ObjectError; 9 | import org.springframework.web.bind.MethodArgumentNotValidException; 10 | import org.springframework.web.bind.annotation.ControllerAdvice; 11 | import org.springframework.web.bind.annotation.ExceptionHandler; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | import javax.servlet.http.HttpServletRequest; 15 | import java.util.List; 16 | 17 | /** 18 | * 统一异常处理接口 19 | */ 20 | @ControllerAdvice 21 | public class WebException { 22 | 23 | /** 24 | * 日志 25 | */ 26 | private static Logger logger = LoggerFactory.getLogger(WebException.class); 27 | 28 | 29 | @ExceptionHandler(MethodArgumentNotValidException.class) 30 | @ResponseBody 31 | public BaseResp exeMethodArgEcp(MethodArgumentNotValidException exception) { 32 | exception.printStackTrace(); 33 | String errorMsgStr = ""; 34 | List errors = exception.getBindingResult().getAllErrors(); 35 | if (!JBUtil.isListEmpty(errors)) { 36 | errorMsgStr = errors.get(0).getDefaultMessage(); 37 | } else { 38 | errorMsgStr = AppConstans.RESP_MSG_PARAM_ERROR; 39 | } 40 | BaseResp baseResp = new BaseResp(); 41 | baseResp.setRespCode(AppConstans.RESP_CODE_PARAM_ERROR); 42 | baseResp.setRespMsg(errorMsgStr); 43 | return baseResp; 44 | } 45 | 46 | @ExceptionHandler(value = LoginException.class) 47 | @ResponseBody 48 | public BaseResp jsonErrorHandler(HttpServletRequest req, LoginException e) throws Exception { 49 | BaseResp resp = new BaseResp(); 50 | resp.setRespCode(AppConstans.RESP_CODE_TOKEN_ERROR); 51 | resp.setRespMsg(AppConstans.RESP_MSG_TOKEN_ERROR); 52 | return resp; 53 | } 54 | 55 | @ExceptionHandler(Exception.class) 56 | @ResponseBody 57 | public BaseResp execp(Exception exception) { 58 | exception.printStackTrace(); 59 | logger.error("发生异常:" + exception.getLocalizedMessage()); 60 | BaseResp baseResp = new BaseResp(); 61 | baseResp.setRespCode(AppConstans.RESP_CODE_OTHER_ERROR); 62 | baseResp.setRespMsg(AppConstans.RESP_MSG_OTHER_ERROR); 63 | return baseResp; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/util/ChuangLanSmsSendUtil.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.util; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.codido.hodor.api.common.util.request.SmsSendRequest; 5 | import com.codido.hodor.api.common.util.response.SmsSendResponse; 6 | 7 | /** 8 | * 短信验证码 9 | * 10 | * @author tianyh 11 | * @Description:普通短信发送 12 | */ 13 | public class ChuangLanSmsSendUtil { 14 | 15 | private static final String charset = "utf-8"; 16 | // 用户平台API账号(非登录账号,示例:N1234567) 17 | private static String account = "N7267512"; 18 | // 用户平台API密码(非登录密码) 19 | private static String pswd = "Clnjce2017"; 20 | 21 | /** 22 | * 发送短信验证码方法 23 | * 24 | * @param mblNo 25 | * @param content 26 | * @return 27 | */ 28 | public static SmsSendResponse sendSmsCode(String mblNo, String content) { 29 | //请求地址请登录253云通讯自助通平台查看或者询问您的商务负责人获取 30 | String smsSingleRequestServerUrl = "http://smssh1.253.com/msg/send/json"; 31 | // 短信内容 32 | //String msg = "【253云通讯】你好,你的验证码是123456"; 33 | String msg = content; 34 | //手机号码 35 | String phone = mblNo; 36 | //状态报告 37 | String report = "true"; 38 | 39 | SmsSendRequest smsSingleRequest = new SmsSendRequest(account, pswd, msg, phone, report); 40 | 41 | String requestJson = JSON.toJSONString(smsSingleRequest); 42 | 43 | System.out.println("before request string is: " + requestJson); 44 | 45 | String response = ChuangLanSmsUtil.sendSmsByPost(smsSingleRequestServerUrl, requestJson); 46 | 47 | System.out.println("response after request result is :" + response); 48 | 49 | SmsSendResponse smsSingleResponse = JSON.parseObject(response, SmsSendResponse.class); 50 | 51 | System.out.println("response toString is :" + smsSingleResponse); 52 | 53 | return smsSingleResponse; 54 | } 55 | 56 | 57 | } -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/util/ChuangLanSmsUtil.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.util; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.InputStreamReader; 5 | import java.io.OutputStream; 6 | //import java.io.PrintWriter; 7 | import java.net.HttpURLConnection; 8 | import java.net.URL; 9 | 10 | /** 11 | * 短信验证码发送类 12 | * 13 | * @author tianyh 14 | * @Description:HTTP 请求 15 | */ 16 | public class ChuangLanSmsUtil { 17 | 18 | /** 19 | * @param path 20 | * @param postContent 21 | * @return String 22 | * @throws 23 | * @author tianyh 24 | * @Description 25 | */ 26 | public static String sendSmsByPost(String path, String postContent) { 27 | URL url = null; 28 | try { 29 | url = new URL(path); 30 | HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); 31 | httpURLConnection.setRequestMethod("POST");// 提交模式 32 | httpURLConnection.setConnectTimeout(10000);//连接超时 单位毫秒 33 | httpURLConnection.setReadTimeout(10000);//读取超时 单位毫秒 34 | // 发送POST请求必须设置如下两行 35 | httpURLConnection.setDoOutput(true); 36 | httpURLConnection.setDoInput(true); 37 | httpURLConnection.setRequestProperty("Charset", "UTF-8"); 38 | httpURLConnection.setRequestProperty("Content-Type", "application/json"); 39 | 40 | // PrintWriter printWriter = new PrintWriter(httpURLConnection.getOutputStream()); 41 | // printWriter.write(postContent); 42 | // printWriter.flush(); 43 | 44 | httpURLConnection.connect(); 45 | OutputStream os = httpURLConnection.getOutputStream(); 46 | os.write(postContent.getBytes("UTF-8")); 47 | os.flush(); 48 | 49 | StringBuilder sb = new StringBuilder(); 50 | int httpRspCode = httpURLConnection.getResponseCode(); 51 | if (httpRspCode == HttpURLConnection.HTTP_OK) { 52 | // 开始获取数据 53 | BufferedReader br = new BufferedReader( 54 | new InputStreamReader(httpURLConnection.getInputStream(), "utf-8")); 55 | String line = null; 56 | while ((line = br.readLine()) != null) { 57 | sb.append(line); 58 | } 59 | br.close(); 60 | return sb.toString(); 61 | 62 | } 63 | 64 | } catch (Exception e) { 65 | e.printStackTrace(); 66 | } 67 | return null; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/util/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.util; 2 | 3 | 4 | import com.alibaba.fastjson.JSON; 5 | 6 | /** 7 | * @author Binary Wang(https://github.com/binarywang) 8 | */ 9 | public class JsonUtils { 10 | public static String toJsonString(Object obj) { 11 | return JSON.toJSONString(obj); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/util/LogUtil.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.util; 2 | 3 | import com.google.common.base.Joiner; 4 | import org.apache.commons.lang3.StringUtils; 5 | import org.slf4j.MDC; 6 | 7 | /** 8 | * 日志工具 9 | */ 10 | public class LogUtil { 11 | 12 | private static final String BIZPARAM = "bizParam"; 13 | 14 | /** 15 | * 设置日志中的业务参数 16 | * 17 | * @param bizId 业务ID 18 | */ 19 | public static void setBizId(String... bizId) { 20 | String bizParam = MDC.get(BIZPARAM); 21 | if (StringUtils.isBlank(bizParam)) { 22 | bizParam = Joiner.on(",").skipNulls().join(bizId); 23 | MDC.put(BIZPARAM, bizParam); 24 | } else { 25 | StringBuilder sbd = new StringBuilder().append(bizParam).append(",").append(Joiner.on(",").skipNulls().join(bizId)); 26 | MDC.put(BIZPARAM, sbd.toString()); 27 | } 28 | } 29 | 30 | /** 31 | * 日志打点,加入清除原有数据的代码 32 | * 33 | * @param bizId 业务ID 34 | */ 35 | public static void setBizIdWithClear(String... bizId) { 36 | MDC.clear(); 37 | setBizId(bizId); 38 | } 39 | 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/util/request/SmsSendRequest.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.util.request; 2 | /** 3 | * 4 | * @author tianyh 5 | * @Description:普通短信发送实体类 6 | */ 7 | public class SmsSendRequest { 8 | /** 9 | * 用户账号,必填 10 | */ 11 | private String account; 12 | /** 13 | * 用户密码,必填 14 | */ 15 | private String password; 16 | /** 17 | * 短信内容。长度不能超过536个字符,必填 18 | */ 19 | private String msg; 20 | /** 21 | * 机号码。多个手机号码使用英文逗号分隔,必填 22 | */ 23 | private String phone; 24 | 25 | 26 | /** 27 | * 定时发送短信时间。格式为yyyyMMddHHmm,值小于或等于当前时间则立即发送,默认立即发送,选填 28 | */ 29 | private String sendtime; 30 | /** 31 | * 是否需要状态报告(默认false),选填 32 | */ 33 | private String report; 34 | /** 35 | * 下发短信号码扩展码,纯数字,建议1-3位,选填 36 | */ 37 | private String extend; 38 | /** 39 | * 该条短信在您业务系统内的ID,如订单号或者短信发送记录流水号,选填 40 | */ 41 | private String uid; 42 | 43 | public SmsSendRequest() { 44 | 45 | } 46 | public SmsSendRequest(String account, String password, String msg, String phone) { 47 | super(); 48 | this.account = account; 49 | this.password = password; 50 | this.msg = msg; 51 | this.phone = phone; 52 | } 53 | public SmsSendRequest(String account, String password, String msg, String phone, String report) { 54 | super(); 55 | this.account = account; 56 | this.password = password; 57 | this.msg = msg; 58 | this.phone = phone; 59 | this.report=report; 60 | } 61 | 62 | public SmsSendRequest(String account, String password, String msg, String phone, String report,String sendtime) { 63 | super(); 64 | this.account = account; 65 | this.password = password; 66 | this.msg = msg; 67 | this.phone = phone; 68 | this.sendtime=sendtime; 69 | this.report=report; 70 | } 71 | public SmsSendRequest(String account, String password, String msg, String phone, String sendtime,String report,String uid) { 72 | super(); 73 | this.account = account; 74 | this.password = password; 75 | this.msg = msg; 76 | this.phone = phone; 77 | this.sendtime=sendtime; 78 | this.report=report; 79 | this.uid=uid; 80 | } 81 | public String getAccount() { 82 | return account; 83 | } 84 | public void setAccount(String account) { 85 | this.account = account; 86 | } 87 | public String getPassword() { 88 | return password; 89 | } 90 | public void setPassword(String password) { 91 | this.password = password; 92 | } 93 | public String getMsg() { 94 | return msg; 95 | } 96 | public void setMsg(String msg) { 97 | this.msg = msg; 98 | } 99 | public String getPhone() { 100 | return phone; 101 | } 102 | public void setPhone(String phone) { 103 | this.phone = phone; 104 | } 105 | public String getSendtime() { 106 | return sendtime; 107 | } 108 | public void setSendtime(String sendtime) { 109 | this.sendtime = sendtime; 110 | } 111 | public String getReport() { 112 | return report; 113 | } 114 | public void setReport(String report) { 115 | this.report = report; 116 | } 117 | public String getExtend() { 118 | return extend; 119 | } 120 | public void setExtend(String extend) { 121 | this.extend = extend; 122 | } 123 | public String getUid() { 124 | return uid; 125 | } 126 | public void setUid(String uid) { 127 | this.uid = uid; 128 | } 129 | 130 | 131 | } 132 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/common/util/response/SmsSendResponse.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.common.util.response; 2 | /** 3 | * 4 | * @author tianyh 5 | * @Description:普通短信发送响应实体类 6 | */ 7 | public class SmsSendResponse { 8 | /** 9 | * 响应时间 10 | */ 11 | private String time; 12 | /** 13 | * 消息id 14 | */ 15 | private String msgId; 16 | /** 17 | * 状态码说明(成功返回空) 18 | */ 19 | private String errorMsg; 20 | /** 21 | * 状态码(详细参考提交响应状态码) 22 | */ 23 | private String code; 24 | public String getTime() { 25 | return time; 26 | } 27 | public void setTime(String time) { 28 | this.time = time; 29 | } 30 | public String getMsgId() { 31 | return msgId; 32 | } 33 | public void setMsgId(String msgId) { 34 | this.msgId = msgId; 35 | } 36 | public String getErrorMsg() { 37 | return errorMsg; 38 | } 39 | public void setErrorMsg(String errorMsg) { 40 | this.errorMsg = errorMsg; 41 | } 42 | public String getCode() { 43 | return code; 44 | } 45 | public void setCode(String code) { 46 | this.code = code; 47 | } 48 | @Override 49 | public String toString() { 50 | return "SmsSingleResponse [time=" + time + ", msgId=" + msgId + ", errorMsg=" + errorMsg + ", code=" + code 51 | + "]"; 52 | } 53 | 54 | 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/ord/bean/req/ApplyOrderReq.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.ord.bean.req; 2 | 3 | import com.codido.hodor.api.common.bean.req.BaseReq; 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | 9 | @Data 10 | @ApiModel("下单订购请求对象") 11 | @EqualsAndHashCode(callSuper=false) 12 | public class ApplyOrderReq extends BaseReq { 13 | 14 | @ApiModelProperty("币种Id") 15 | private String currencyId; 16 | 17 | @ApiModelProperty("会员费用") 18 | private String currencyTypeValue; 19 | 20 | @ApiModelProperty("周期Id") 21 | private String cycleId; 22 | } 23 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/ord/bean/resp/ApplyOrderResp.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.ord.bean.resp; 2 | 3 | import com.codido.hodor.api.common.bean.resp.BaseResp; 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | 9 | @Data 10 | @ApiModel("下单订购响应对象") 11 | @EqualsAndHashCode(callSuper = false) 12 | public class ApplyOrderResp extends BaseResp { 13 | 14 | @ApiModelProperty("币种Id") 15 | private String currencyId; 16 | 17 | @ApiModelProperty("会员费用") 18 | private String currencyTypeValue; 19 | 20 | @ApiModelProperty("周期Id") 21 | private String cycleId; 22 | } 23 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/ord/controller/OrdController.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.ord.controller; 2 | 3 | import com.codido.hodor.api.common.annotation.AreYouLogin; 4 | import com.codido.hodor.api.ord.bean.resp.ApplyOrderResp; 5 | import com.codido.hodor.api.ord.bean.req.ApplyOrderReq; 6 | import io.swagger.annotations.Api; 7 | import io.swagger.annotations.ApiOperation; 8 | import io.swagger.annotations.ApiParam; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.springframework.web.bind.annotation.RequestBody; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | @RestController 16 | @RequestMapping("/order") 17 | @Api(value = "订单申请", description = "订单申请请求") 18 | @Slf4j 19 | public class OrdController { 20 | 21 | @ApiOperation(value = "申请订单", notes = "申请订单请求") 22 | @RequestMapping(value = "/applyForOrder", method = RequestMethod.POST) 23 | @AreYouLogin 24 | public ApplyOrderResp applyForOrder(@RequestBody @ApiParam(value = "用户添加订阅请求对象", required = true) ApplyOrderReq req) throws Exception { 25 | // 用户添加自定义订阅 26 | ApplyOrderResp resp = new ApplyOrderResp(); 27 | return resp; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/usr/bean/vo/UserInfoVo.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.usr.bean.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 微信登录 用户信息对象 12 | */ 13 | @ApiModel 14 | @Data 15 | @EqualsAndHashCode(callSuper = false) 16 | public class UserInfoVo implements Serializable { 17 | 18 | @ApiModelProperty("用户昵称") 19 | private String nickName; 20 | 21 | @ApiModelProperty("用户头像图片的 URL") 22 | private String avatarUrl; 23 | 24 | @ApiModelProperty("用户性别") 25 | private String gender; 26 | 27 | @ApiModelProperty("用户所在国家") 28 | private String country; 29 | 30 | @ApiModelProperty("用户所在省份") 31 | private String province; 32 | 33 | @ApiModelProperty("用户所在城市") 34 | private String city; 35 | 36 | @ApiModelProperty("显示 country,province,city 所用的语言") 37 | private String language; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/usr/bean/vo/WXSessionModelVo.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.usr.bean.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 微信 code2Session接口返回的POJO 10 | */ 11 | @ApiModel 12 | @Data 13 | public class WXSessionModelVo implements Serializable { 14 | 15 | /** 16 | * 用户唯一标识 17 | */ 18 | private String openid; 19 | 20 | /** 21 | * 会话密钥 22 | */ 23 | private String session_key; 24 | 25 | /** 26 | * 用户在开放平台的唯一标识符 27 | */ 28 | private String unionid; 29 | 30 | /** 31 | * 错误码 32 | */ 33 | private String errcode; 34 | 35 | /** 36 | * 错误信息 37 | */ 38 | private String errmsg; 39 | } 40 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/usr/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.usr.controller; 2 | 3 | import com.codido.hodor.api.usr.service.UserServiceImpl; 4 | import io.swagger.annotations.Api; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | /** 13 | * 用户controller 14 | */ 15 | @Slf4j 16 | @RestController 17 | @RequestMapping("/usr") 18 | @Api(value = "用户信息", description = "获取用户信息的相关请求") 19 | public class UserController { 20 | /** 21 | * 用户service 22 | */ 23 | @Autowired 24 | private UserServiceImpl userServiceImpl; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/usr/service/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.usr.service; 2 | 3 | import com.codido.hodor.api.weixin.config.WxAppConfig; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * 用户相关service 10 | */ 11 | @Slf4j 12 | @Service 13 | public class UserServiceImpl { 14 | 15 | /** 16 | * 微信配置信息 17 | */ 18 | @Autowired 19 | private WxAppConfig wxAppConfig; 20 | } 21 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/bean/dto/AccessTokenVo.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.bean.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * accesstoken的信息 7 | * Created by bpascal on 2017/6/19. 8 | */ 9 | public class AccessTokenVo implements Serializable { 10 | 11 | // 接口访问凭证 12 | private String accessToken; 13 | // 凭证有效期,单位:秒 14 | private int expiresIn; 15 | 16 | public String getAccessToken() { 17 | return accessToken; 18 | } 19 | 20 | public void setAccessToken(String accessToken) { 21 | this.accessToken = accessToken; 22 | } 23 | 24 | public int getExpiresIn() { 25 | return expiresIn; 26 | } 27 | 28 | public void setExpiresIn(int expiresIn) { 29 | this.expiresIn = expiresIn; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "AccessTokenVo{" + 35 | "accessToken='" + accessToken + '\'' + 36 | ", expiresIn=" + expiresIn + 37 | '}'; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/bean/dto/SNSUserInfo.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.bean.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** 7 | * 通过网页授权获取的用户信息 8 | * Created by bpascal on 2017/4/28. 9 | */ 10 | public class SNSUserInfo implements Serializable { 11 | 12 | // 用户标识 13 | private String openId; 14 | // 用户昵称 15 | private String nickname; 16 | // 性别(1是男性,2是女性,0是未知) 17 | private int sex; 18 | // 国家 19 | private String country; 20 | // 省份 21 | private String province; 22 | // 城市 23 | private String city; 24 | // 用户头像链接 25 | private String headImgUrl; 26 | 27 | //绑定公众号的unionid 28 | private String unionid; 29 | // 用户特权信息 30 | private List privilegeList; 31 | 32 | public String getOpenId() { 33 | return openId; 34 | } 35 | 36 | public void setOpenId(String openId) { 37 | this.openId = openId; 38 | } 39 | 40 | public String getNickname() { 41 | return nickname; 42 | } 43 | 44 | public void setNickname(String nickname) { 45 | this.nickname = nickname; 46 | } 47 | 48 | public int getSex() { 49 | return sex; 50 | } 51 | 52 | public void setSex(int sex) { 53 | this.sex = sex; 54 | } 55 | 56 | public String getCountry() { 57 | return country; 58 | } 59 | 60 | public void setCountry(String country) { 61 | this.country = country; 62 | } 63 | 64 | public String getProvince() { 65 | return province; 66 | } 67 | 68 | public void setProvince(String province) { 69 | this.province = province; 70 | } 71 | 72 | public String getCity() { 73 | return city; 74 | } 75 | 76 | public void setCity(String city) { 77 | this.city = city; 78 | } 79 | 80 | public String getHeadImgUrl() { 81 | return headImgUrl; 82 | } 83 | 84 | public void setHeadImgUrl(String headImgUrl) { 85 | this.headImgUrl = headImgUrl; 86 | } 87 | 88 | public String getUnionid() { 89 | return unionid; 90 | } 91 | 92 | public void setUnionid(String unionid) { 93 | this.unionid = unionid; 94 | } 95 | 96 | public List getPrivilegeList() { 97 | return privilegeList; 98 | } 99 | 100 | public void setPrivilegeList(List privilegeList) { 101 | this.privilegeList = privilegeList; 102 | } 103 | 104 | @Override 105 | public String toString() { 106 | return "SNSUserInfo{" + 107 | "openId='" + openId + '\'' + 108 | ", nickname='" + nickname + '\'' + 109 | ", sex=" + sex + 110 | ", country='" + country + '\'' + 111 | ", province='" + province + '\'' + 112 | ", city='" + city + '\'' + 113 | ", headImgUrl='" + headImgUrl + '\'' + 114 | ", unionid='" + unionid + '\'' + 115 | ", privilegeList=" + privilegeList + 116 | '}'; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/bean/dto/Token.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.bean.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 凭证实体类 7 | * Created by bpascal on 2017/4/28. 8 | */ 9 | public class Token implements Serializable { 10 | 11 | // 接口访问凭证 12 | private String accessToken; 13 | // 凭证有效期,单位:秒 14 | private int expiresIn; 15 | 16 | public String getAccessToken() { 17 | return accessToken; 18 | } 19 | 20 | public void setAccessToken(String accessToken) { 21 | this.accessToken = accessToken; 22 | } 23 | 24 | public int getExpiresIn() { 25 | return expiresIn; 26 | } 27 | 28 | public void setExpiresIn(int expiresIn) { 29 | this.expiresIn = expiresIn; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "Token{" + 35 | "accessToken='" + accessToken + '\'' + 36 | ", expiresIn=" + expiresIn + 37 | '}'; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/bean/dto/WeixinConfigVo.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.bean.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | import java.io.Serializable; 9 | import java.util.List; 10 | 11 | @ApiModel("微信参数信息对象") 12 | @Data 13 | @EqualsAndHashCode(callSuper = false) 14 | public class WeixinConfigVo implements Serializable { 15 | 16 | @ApiModelProperty("appId") 17 | private String appId; 18 | 19 | @ApiModelProperty("时间戳") 20 | private String timestamp; 21 | 22 | @ApiModelProperty("生成签名的随机串") 23 | private String nonceStr; 24 | 25 | @ApiModelProperty("签名") 26 | private String signature; 27 | 28 | @ApiModelProperty("js的API列表") 29 | private List jsApiList; 30 | } 31 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/bean/dto/WeixinOauth2Token.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.bean.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 网页授权信息 7 | * Created by bpascal on 2017/4/28. 8 | */ 9 | public class WeixinOauth2Token implements Serializable { 10 | 11 | // 网页授权接口调用凭证 12 | private String accessToken; 13 | // 凭证有效时长 14 | private int expiresIn; 15 | // 用于刷新凭证 16 | private String refreshToken; 17 | // 用户标识 18 | private String openId; 19 | // 用户授权作用域 20 | private String scope; 21 | 22 | public String getAccessToken() { 23 | return accessToken; 24 | } 25 | 26 | public void setAccessToken(String accessToken) { 27 | this.accessToken = accessToken; 28 | } 29 | 30 | public int getExpiresIn() { 31 | return expiresIn; 32 | } 33 | 34 | public void setExpiresIn(int expiresIn) { 35 | this.expiresIn = expiresIn; 36 | } 37 | 38 | public String getRefreshToken() { 39 | return refreshToken; 40 | } 41 | 42 | public void setRefreshToken(String refreshToken) { 43 | this.refreshToken = refreshToken; 44 | } 45 | 46 | public String getOpenId() { 47 | return openId; 48 | } 49 | 50 | public void setOpenId(String openId) { 51 | this.openId = openId; 52 | } 53 | 54 | public String getScope() { 55 | return scope; 56 | } 57 | 58 | public void setScope(String scope) { 59 | this.scope = scope; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return "WeixinOauth2Token{" + 65 | "accessToken='" + accessToken + '\'' + 66 | ", expiresIn=" + expiresIn + 67 | ", refreshToken='" + refreshToken + '\'' + 68 | ", openId='" + openId + '\'' + 69 | ", scope='" + scope + '\'' + 70 | '}'; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/bean/dto/WeixinUserInfo.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.bean.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 微信用户的基本信息 7 | * Created by bpascal on 2017/4/28. 8 | */ 9 | public class WeixinUserInfo implements Serializable { 10 | 11 | // 用户的标识 12 | private String openId; 13 | // 关注状态(1是关注,0是未关注),未关注时获取不到其余信息 14 | private int subscribe; 15 | // 用户关注时间,为时间戳。如果用户曾多次关注,则取最后关注时间 16 | private String subscribeTime; 17 | // 昵称 18 | private String nickname; 19 | // 用户的性别(1是男性,2是女性,0是未知) 20 | private int sex; 21 | // 用户所在国家 22 | private String country; 23 | // 用户所在省份 24 | private String province; 25 | // 用户所在城市 26 | private String city; 27 | // 用户的语言,简体中文为zh_CN 28 | private String language; 29 | // 用户头像 30 | private String headImgUrl; 31 | 32 | public String getOpenId() { 33 | return openId; 34 | } 35 | 36 | public void setOpenId(String openId) { 37 | this.openId = openId; 38 | } 39 | 40 | public int getSubscribe() { 41 | return subscribe; 42 | } 43 | 44 | public void setSubscribe(int subscribe) { 45 | this.subscribe = subscribe; 46 | } 47 | 48 | public String getSubscribeTime() { 49 | return subscribeTime; 50 | } 51 | 52 | public void setSubscribeTime(String subscribeTime) { 53 | this.subscribeTime = subscribeTime; 54 | } 55 | 56 | public String getNickname() { 57 | return nickname; 58 | } 59 | 60 | public void setNickname(String nickname) { 61 | this.nickname = nickname; 62 | } 63 | 64 | public int getSex() { 65 | return sex; 66 | } 67 | 68 | public void setSex(int sex) { 69 | this.sex = sex; 70 | } 71 | 72 | public String getCountry() { 73 | return country; 74 | } 75 | 76 | public void setCountry(String country) { 77 | this.country = country; 78 | } 79 | 80 | public String getProvince() { 81 | return province; 82 | } 83 | 84 | public void setProvince(String province) { 85 | this.province = province; 86 | } 87 | 88 | public String getCity() { 89 | return city; 90 | } 91 | 92 | public void setCity(String city) { 93 | this.city = city; 94 | } 95 | 96 | public String getLanguage() { 97 | return language; 98 | } 99 | 100 | public void setLanguage(String language) { 101 | this.language = language; 102 | } 103 | 104 | public String getHeadImgUrl() { 105 | return headImgUrl; 106 | } 107 | 108 | public void setHeadImgUrl(String headImgUrl) { 109 | this.headImgUrl = headImgUrl; 110 | } 111 | 112 | @Override 113 | public String toString() { 114 | return "WeixinUserInfo{" + 115 | "openId='" + openId + '\'' + 116 | ", subscribe=" + subscribe + 117 | ", subscribeTime='" + subscribeTime + '\'' + 118 | ", nickname='" + nickname + '\'' + 119 | ", sex=" + sex + 120 | ", country='" + country + '\'' + 121 | ", province='" + province + '\'' + 122 | ", city='" + city + '\'' + 123 | ", language='" + language + '\'' + 124 | ", headImgUrl='" + headImgUrl + '\'' + 125 | '}'; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/bean/outbean/WXSnsUserInfoRespBean.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.bean.outbean; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** 7 | * 微信接口返回的用户信息bean 8 | * Created by bpascal on 2017/4/28. 9 | */ 10 | public class WXSnsUserInfoRespBean implements Serializable { 11 | 12 | /** 13 | * 用户的标识 14 | */ 15 | private String openid; 16 | 17 | /** 18 | * 昵称 19 | */ 20 | private String nickname; 21 | 22 | /** 23 | * 性别(1是男性,2是女性,0是未知) 24 | */ 25 | private String sex; 26 | 27 | /** 28 | * 用户所在国家 29 | */ 30 | private String country; 31 | 32 | /** 33 | * 用户所在省份 34 | */ 35 | private String province; 36 | 37 | /** 38 | * 用户所在城市 39 | */ 40 | private String city; 41 | 42 | /** 43 | * 用户头像 44 | */ 45 | private String headimgurl; 46 | 47 | /** 48 | * 用户UNIONID信息 49 | */ 50 | private String unionid; 51 | 52 | /** 53 | * 用户特权信息 54 | */ 55 | private List privilege; 56 | 57 | /** 58 | * 错误code 59 | */ 60 | private String errcode; 61 | 62 | /** 63 | * 错误 msg 64 | */ 65 | private String errmsg; 66 | 67 | public String getOpenid() { 68 | return openid; 69 | } 70 | 71 | public void setOpenid(String openid) { 72 | this.openid = openid; 73 | } 74 | 75 | public String getNickname() { 76 | return nickname; 77 | } 78 | 79 | public void setNickname(String nickname) { 80 | this.nickname = nickname; 81 | } 82 | 83 | public String getSex() { 84 | return sex; 85 | } 86 | 87 | public void setSex(String sex) { 88 | this.sex = sex; 89 | } 90 | 91 | public String getCountry() { 92 | return country; 93 | } 94 | 95 | public void setCountry(String country) { 96 | this.country = country; 97 | } 98 | 99 | public String getProvince() { 100 | return province; 101 | } 102 | 103 | public void setProvince(String province) { 104 | this.province = province; 105 | } 106 | 107 | public String getCity() { 108 | return city; 109 | } 110 | 111 | public void setCity(String city) { 112 | this.city = city; 113 | } 114 | 115 | public String getHeadimgurl() { 116 | return headimgurl; 117 | } 118 | 119 | public void setHeadimgurl(String headimgurl) { 120 | this.headimgurl = headimgurl; 121 | } 122 | 123 | public List getPrivilege() { 124 | return privilege; 125 | } 126 | 127 | public void setPrivilege(List privilege) { 128 | this.privilege = privilege; 129 | } 130 | 131 | public String getErrcode() { 132 | return errcode; 133 | } 134 | 135 | public void setErrcode(String errcode) { 136 | this.errcode = errcode; 137 | } 138 | 139 | public String getErrmsg() { 140 | return errmsg; 141 | } 142 | 143 | public void setErrmsg(String errmsg) { 144 | this.errmsg = errmsg; 145 | } 146 | 147 | 148 | @Override 149 | public String toString() { 150 | return "WXSnsUserInfoRespBean{" + 151 | "openid='" + openid + '\'' + 152 | ", nickname='" + nickname + '\'' + 153 | ", sex='" + sex + '\'' + 154 | ", country='" + country + '\'' + 155 | ", province='" + province + '\'' + 156 | ", city='" + city + '\'' + 157 | ", headimgurl='" + headimgurl + '\'' + 158 | ", unionid='" + unionid + '\'' + 159 | ", privilege=" + privilege + 160 | ", errcode='" + errcode + '\'' + 161 | ", errmsg='" + errmsg + '\'' + 162 | '}'; 163 | } 164 | 165 | public String getUnionid() { 166 | return unionid; 167 | } 168 | 169 | public void setUnionid(String unionid) { 170 | this.unionid = unionid; 171 | } 172 | 173 | } 174 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/bean/req/DealUserWxLoginReq.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.bean.req; 2 | 3 | 4 | import com.codido.hodor.api.common.bean.req.BaseReq; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | 10 | /** 11 | * 用户通过微信页面登录请求对象 12 | */ 13 | @Data 14 | @EqualsAndHashCode(callSuper = false) 15 | @ApiModel 16 | public class DealUserWxLoginReq extends BaseReq { 17 | 18 | @ApiModelProperty("调用微信返回的code") 19 | private String wxCode; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/bean/req/QueryWechatJssdkInfoReq.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.bean.req; 2 | 3 | import com.codido.hodor.api.common.bean.req.BaseReq; 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | 9 | /** 10 | * 查询微信jssdk需要的信息的请求对象 11 | */ 12 | @Data 13 | @EqualsAndHashCode(callSuper = false) 14 | @ApiModel 15 | public class QueryWechatJssdkInfoReq extends BaseReq { 16 | 17 | @ApiModelProperty("需要使用的url地址") 18 | private String url; 19 | } 20 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/bean/resp/DealUserWxLoginResp.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.bean.resp; 2 | 3 | import com.codido.hodor.api.common.bean.resp.BaseResp; 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | 9 | /** 10 | * 用户通过微信页面登录响应对象 11 | */ 12 | @Data 13 | @EqualsAndHashCode(callSuper = false) 14 | @ApiModel 15 | public class DealUserWxLoginResp extends BaseResp { 16 | 17 | @ApiModelProperty("登录后后台生成的token") 18 | private String tokenId; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/bean/resp/QueryWechatJssdkInfoResp.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.bean.resp; 2 | 3 | import com.codido.hodor.api.common.bean.resp.BaseResp; 4 | import com.codido.hodor.job.weixin.bean.dto.WeixinConfigVo; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | 10 | /** 11 | * 查询微信jssdk需要的信息的响应对象 12 | */ 13 | @Data 14 | @EqualsAndHashCode(callSuper = false) 15 | @ApiModel 16 | public class QueryWechatJssdkInfoResp extends BaseResp { 17 | 18 | @ApiModelProperty("微信参数信息对象") 19 | private WeixinConfigVo weixinConfigVo; 20 | } 21 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/builder/AbstractBuilder.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.builder; 2 | 3 | import me.chanjar.weixin.mp.api.WxMpService; 4 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 5 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | /** 10 | * @author Binary Wang(https://github.com/binarywang) 11 | */ 12 | public abstract class AbstractBuilder { 13 | protected final Logger logger = LoggerFactory.getLogger(getClass()); 14 | 15 | public abstract WxMpXmlOutMessage build(String content, 16 | WxMpXmlMessage wxMessage, WxMpService service); 17 | } 18 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/builder/ImageBuilder.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.builder; 2 | 3 | import me.chanjar.weixin.mp.api.WxMpService; 4 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 5 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutImageMessage; 6 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 7 | 8 | /** 9 | * @author Binary Wang(https://github.com/binarywang) 10 | */ 11 | public class ImageBuilder extends AbstractBuilder { 12 | 13 | @Override 14 | public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, 15 | WxMpService service) { 16 | 17 | WxMpXmlOutImageMessage m = WxMpXmlOutMessage.IMAGE().mediaId(content) 18 | .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) 19 | .build(); 20 | 21 | return m; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/builder/TextBuilder.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.builder; 2 | 3 | import me.chanjar.weixin.mp.api.WxMpService; 4 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 5 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 6 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutTextMessage; 7 | 8 | /** 9 | * @author Binary Wang(https://github.com/binarywang) 10 | */ 11 | public class TextBuilder extends AbstractBuilder { 12 | 13 | @Override 14 | public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, 15 | WxMpService service) { 16 | WxMpXmlOutTextMessage m = WxMpXmlOutMessage.TEXT().content(content) 17 | .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) 18 | .build(); 19 | return m; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/config/WxAccountEnum.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.config; 2 | 3 | /** 4 | * 公众号标识的枚举类 5 | * 6 | * @author Binary Wang 7 | */ 8 | public enum WxAccountEnum { 9 | APP(1, "APP"); 10 | 11 | private int pubid; 12 | private String name; 13 | 14 | private WxAccountEnum(int pubid, String name) { 15 | this.name = name; 16 | this.pubid = pubid; 17 | } 18 | 19 | public static int queryPubid(String wxCode) { 20 | return WxAccountEnum.valueOf(wxCode.toUpperCase()).getPubid(); 21 | } 22 | 23 | public static String queryWxCode(int pubid) { 24 | for (WxAccountEnum e : values()) { 25 | if (e.getPubid() == pubid) { 26 | return e.name().toLowerCase(); 27 | } 28 | } 29 | 30 | return null; 31 | } 32 | 33 | public int getPubid() { 34 | return this.pubid; 35 | } 36 | 37 | public String getName() { 38 | return this.name; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/config/WxAppConfig.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.config; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * APP参数配置文件 8 | */ 9 | @Configuration 10 | public class WxAppConfig extends WxConfig { 11 | 12 | @Value("${wechat.app.appId}") 13 | private String appid; 14 | 15 | @Value("${wechat.app.secret}") 16 | private String appsecret; 17 | 18 | @Value("${wechat.app.token}") 19 | private String token; 20 | 21 | @Value("${wechat.app.aesKey}") 22 | private String aesKey; 23 | 24 | @Override 25 | public String getAppid() { 26 | return this.appid; 27 | } 28 | 29 | @Override 30 | public String getAppsecret() { 31 | return this.appsecret; 32 | } 33 | 34 | @Override 35 | public String getToken() { 36 | return this.token; 37 | } 38 | 39 | @Override 40 | public String getAesKey() { 41 | return this.aesKey; 42 | } 43 | 44 | @Override 45 | public WxAccountEnum getWxAccountEnum() { 46 | return WxAccountEnum.APP; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/config/WxConfig.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.config; 2 | 3 | /** 4 | * 微信配置的抽象实现类 5 | * 6 | * @author Binary Wang 7 | */ 8 | public abstract class WxConfig { 9 | public abstract String getToken(); 10 | 11 | public abstract String getAppid(); 12 | 13 | public abstract String getAppsecret(); 14 | 15 | public abstract String getAesKey(); 16 | 17 | public abstract WxAccountEnum getWxAccountEnum(); 18 | 19 | public int getPubId() { 20 | return getWxAccountEnum().getPubid(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/config/WxPayConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.config; 2 | 3 | import com.github.binarywang.wxpay.config.WxPayConfig; 4 | import com.github.binarywang.wxpay.service.WxPayService; 5 | import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | /** 11 | * 微信支付相关配置 12 | *

13 | * Created by laijj on 2017/5/12. 14 | */ 15 | @Configuration 16 | public class WxPayConfiguration { 17 | @Value("${wechat.pay.appId}") 18 | private String appId; 19 | 20 | @Value("${wechat.pay.mchId}") 21 | private String mchId; 22 | 23 | @Value("${wechat.pay.mchKey}") 24 | private String mchKey; 25 | 26 | // @Value("#{wxPayProperties.subAppId}") 27 | // private String subAppId; 28 | // 29 | // @Value("#{wxPayProperties.subMchId}") 30 | // private String subMchId; 31 | // 32 | @Value("${wechat.pay.keyPath}") 33 | private String keyPath; 34 | 35 | @Bean 36 | public WxPayConfig payConfig() { 37 | WxPayConfig payConfig = new WxPayConfig(); 38 | payConfig.setAppId(this.appId); 39 | payConfig.setMchId(this.mchId); 40 | payConfig.setMchKey(this.mchKey); 41 | //payConfig.setSubAppId(this.subAppId); 42 | //payConfig.setSubMchId(this.subMchId); 43 | payConfig.setKeyPath(this.keyPath); 44 | 45 | return payConfig; 46 | } 47 | 48 | @Bean 49 | public WxPayService payService() { 50 | WxPayService payService = new WxPayServiceImpl(); 51 | payService.setConfig(payConfig()); 52 | return payService; 53 | } 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/handler/common/AbstractHandler.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.handler.common; 2 | 3 | import me.chanjar.weixin.mp.api.WxMpMessageHandler; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | /** 8 | * @author Binary Wang(https://github.com/binarywang) 9 | */ 10 | public abstract class AbstractHandler implements WxMpMessageHandler { 11 | protected Logger logger = LoggerFactory.getLogger(getClass()); 12 | } 13 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/handler/common/LogHandler.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.handler.common; 2 | 3 | import com.codido.hodor.api.common.util.JsonUtils; 4 | import me.chanjar.weixin.common.session.WxSessionManager; 5 | import me.chanjar.weixin.mp.api.WxMpService; 6 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 7 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * @author Binary Wang(https://github.com/binarywang) 14 | */ 15 | @Component 16 | public class LogHandler extends AbstractHandler { 17 | @Override 18 | public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, 19 | Map context, WxMpService wxMpService, 20 | WxSessionManager sessionManager) { 21 | this.logger.info("\n接收到请求消息,内容:{}", JsonUtils.toJsonString(wxMessage)); 22 | return null; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/handler/common/NullHandler.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.handler.common; 2 | 3 | import me.chanjar.weixin.common.session.WxSessionManager; 4 | import me.chanjar.weixin.mp.api.WxMpService; 5 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 6 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.Map; 10 | 11 | /** 12 | * @author Binary Wang(https://github.com/binarywang) 13 | */ 14 | @Component 15 | public class NullHandler extends AbstractHandler { 16 | 17 | @Override 18 | public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, 19 | Map context, WxMpService wxMpService, 20 | WxSessionManager sessionManager) { 21 | return null; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/java/com/codido/hodor/api/weixin/util/MyX509TrustManager.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.api.weixin.util; 2 | 3 | import javax.net.ssl.X509TrustManager; 4 | import java.security.cert.CertificateException; 5 | import java.security.cert.X509Certificate; 6 | 7 | /** 8 | * 信任管理器 9 | * Created by bpascal on 2017/4/28. 10 | */ 11 | public class MyX509TrustManager implements X509TrustManager { 12 | 13 | // 检查客户端证书 14 | public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { 15 | } 16 | 17 | // 检查服务器端证书 18 | public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { 19 | } 20 | 21 | // 返回受信任的X509证书数组 22 | public X509Certificate[] getAcceptedIssuers() { 23 | return null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Hodor-cgi/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #数据源基础信息 2 | spring: 3 | datasource: 4 | type: com.alibaba.druid.pool.DruidDataSource 5 | url: jdbc:mysql://111.111.111.111:3306/hodor?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false 6 | username: hodor_adm 7 | password: 888888888 8 | driverClassName: com.mysql.jdbc.Driver 9 | initialSize: 5 10 | minIdle: 5 11 | maxActive: 20 12 | maxWait: 60000 13 | timeBetweenEvictionRunsMillis: 60000 14 | minEvictableIdleTimeMillis: 300000 15 | validationQuery: SELECT 1 FROM t_pub_param 16 | testWhileIdle: true 17 | testOnBorrow: false 18 | testOnReturn: false 19 | poolPreparedStatements: true 20 | maxPoolPreparedStatementPerConnectionSize: 20 21 | filters: stat,wall,log4j 22 | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000\ 23 | redis: 24 | host: xxx.xxx.xxx.xxx 25 | port: 8998 26 | database: 0 27 | password: 11111111 28 | timeout: 3000 29 | 30 | #mybatis基础配置 31 | mybatis: 32 | configuration: 33 | mapUnderscoreToCamelCase: true 34 | 35 | #mybatis分页相关配置 36 | pagehelper: 37 | helperDialect: mysql 38 | reasonable: true 39 | supportMethodsArguments: true 40 | params: count=countSql;pageSize=0 41 | pageSizeZero: true 42 | 43 | #服务相关参数 44 | server: 45 | port: 8848 46 | 47 | #日志参数 48 | log: 49 | # path: /Users/bpascal/Downloads/log 50 | logging: 51 | level: 52 | root: INFO 53 | com.codido.hodor.core.mapper: debug 54 | 55 | #微信参数 56 | wechat: 57 | app: 58 | appId: wx209e789aebc1fd6e 59 | secret: 111111111111111111111111111111 60 | token: 111111 61 | aesKey: 111111 62 | pay: 63 | appId: wxb0df5ef1b490a8b1 64 | mchId: 1111111111 65 | mchKey: 111111111111111111111111111111 66 | keyPath: /home/serveradm/apiclient_cert.p12 67 | 68 | #服务路径相关 69 | basecontext: 70 | urlpath: 71 | requestpath: http://www.rivendell.top 72 | 73 | #七牛云存储参数 74 | qiniu: 75 | userparams: 76 | accesskey: yAC2iK-zdCfoo-4RttvC9rmKi98TwVXtfvu6EQHl 77 | secretkey: 1111111111111111111111111111111111111111 78 | imagebucket: bpascal 79 | filecontext: http://images.rivendell.top/ -------------------------------------------------------------------------------- /Hodor-cgi/src/main/resources/application-ptc.yml: -------------------------------------------------------------------------------- 1 | #数据源基础信息 2 | spring: 3 | datasource: 4 | type: com.alibaba.druid.pool.DruidDataSource 5 | url: jdbc:mysql://111.111.111.111:3306/hodor?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false 6 | username: hodor_adm 7 | password: 888888888 8 | driverClassName: com.mysql.jdbc.Driver 9 | initialSize: 5 10 | minIdle: 5 11 | maxActive: 100 12 | maxWait: 60000 13 | timeBetweenEvictionRunsMillis: 60000 14 | minEvictableIdleTimeMillis: 300000 15 | validationQuery: SELECT 1 FROM t_pub_param 16 | testWhileIdle: true 17 | testOnBorrow: false 18 | testOnReturn: false 19 | poolPreparedStatements: true 20 | maxPoolPreparedStatementPerConnectionSize: 20 21 | filters: stat,wall,log4j 22 | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000\ 23 | redis: 24 | host: xxx.xxx.xxx.xxx 25 | port: 8998 26 | database: 0 27 | password: 11111111 28 | timeout: 3000 29 | 30 | #mybatis基础配置 31 | mybatis: 32 | configuration: 33 | mapUnderscoreToCamelCase: true 34 | 35 | #mybatis分页相关配置 36 | pagehelper: 37 | helperDialect: mysql 38 | reasonable: true 39 | supportMethodsArguments: true 40 | params: count=countSql;pageSize=0 41 | pageSizeZero: true 42 | 43 | #服务参数 44 | server: 45 | port: 9011 46 | 47 | #日志参数 48 | log: 49 | path: /home/serveradm/logs 50 | 51 | logging: 52 | level: 53 | root: INFO 54 | com.codido.hodor.core.mapper: info 55 | 56 | #微信参数 57 | wechat: 58 | app: 59 | appId: wx209e789aebc1fd6e 60 | secret: 111111111111111111111111111111 61 | token: 111111 62 | aesKey: 111111 63 | pay: 64 | appId: wxb0df5ef1b490a8b1 65 | mchId: 1111111111 66 | mchKey: 111111111111111111111111111111 67 | keyPath: /home/serveradm/apiclient_cert.p12 68 | 69 | #服务路径相关 70 | basecontext: 71 | urlpath: 72 | requestpath: http://www.rivendell.top 73 | 74 | #七牛云存储参数 75 | qiniu: 76 | userparams: 77 | accesskey: yAC2iK-zdCfoo-4RttvC9rmKi98TwVXtfvu6EQHl 78 | secretkey: 1111111111111111111111111111111111111111 79 | imagebucket: bpascal 80 | filecontext: http://images.rivendell.top/ -------------------------------------------------------------------------------- /Hodor-cgi/src/main/resources/application-uat.yml: -------------------------------------------------------------------------------- 1 | #数据源基础信息 2 | spring: 3 | datasource: 4 | type: com.alibaba.druid.pool.DruidDataSource 5 | url: jdbc:mysql://111.111.111.111:3306/hodor?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false 6 | username: hodor_adm 7 | password: 888888888 8 | driverClassName: com.mysql.jdbc.Driver 9 | initialSize: 5 10 | minIdle: 5 11 | maxActive: 20 12 | maxWait: 60000 13 | timeBetweenEvictionRunsMillis: 60000 14 | minEvictableIdleTimeMillis: 300000 15 | validationQuery: SELECT 1 FROM t_pub_param 16 | testWhileIdle: true 17 | testOnBorrow: false 18 | testOnReturn: false 19 | poolPreparedStatements: true 20 | maxPoolPreparedStatementPerConnectionSize: 20 21 | filters: stat,wall,log4j 22 | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000\ 23 | redis: 24 | host: xxx.xxx.xxx.xxx 25 | port: 8998 26 | database: 0 27 | password: 11111111 28 | timeout: 3000 29 | 30 | #mybatis基础配置 31 | mybatis: 32 | configuration: 33 | mapUnderscoreToCamelCase: true 34 | 35 | #mybatis分页相关配置 36 | pagehelper: 37 | helperDialect: mysql 38 | reasonable: true 39 | supportMethodsArguments: true 40 | params: count=countSql;pageSize=0 41 | pageSizeZero: true 42 | 43 | #服务参数 44 | server: 45 | port: 8090 46 | 47 | #日志参数 48 | log: 49 | path: /home/serveradm/logs 50 | 51 | logging: 52 | level: 53 | root: INFO 54 | com.codido.hodor.core.mapper: debug 55 | 56 | #微信参数 57 | wechat: 58 | app: 59 | appId: wx209e789aebc1fd6e 60 | secret: 111111111111111111111111111111 61 | token: 111111 62 | aesKey: 111111 63 | pay: 64 | appId: wxb0df5ef1b490a8b1 65 | mchId: 1111111111 66 | mchKey: 111111111111111111111111111111 67 | keyPath: /home/serveradm/apiclient_cert.p12 68 | 69 | #服务路径相关 70 | basecontext: 71 | urlpath: 72 | requestpath: http://www.rivendell.top 73 | 74 | #七牛云存储参数 75 | qiniu: 76 | userparams: 77 | accesskey: yAC2iK-zdCfoo-4RttvC9rmKi98TwVXtfvu6EQHl 78 | secretkey: 1111111111111111111111111111111111111111 79 | imagebucket: bpascal 80 | filecontext: http://images.rivendell.top/ 81 | 82 | #swagger配置,只有测试环境需要 83 | springfox: 84 | documentation: 85 | swagger: 86 | v2: 87 | host: www.rivendell.top/hodor -------------------------------------------------------------------------------- /Hodor-cgi/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev -------------------------------------------------------------------------------- /Hodor-cgi/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | [%X{bizParam}][%-5level][%d{HH:mm:ss.SSS}][%logger{36}]:%msg%n 12 | 13 | 14 | 15 | 16 | 17 | 18 | ${logPath}/hodor-api-server.log 19 | 20 | ${logPath}/hodor-api-server-%d{yyyy-MM-dd}.%i.log 21 | 22 | 10 23 | 24 | 5MB 25 | 26 | 27 | 28 | 29 | [%X{bizParam}][%-5level][%d{HH:mm:ss.SSS}][%logger{36}]:%msg%n 30 | 31 | 32 | 33 | 34 | 35 | 36 | 0 37 | 38 | 512 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /Hodor-core/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.2.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | 14 | group 'com.codido' 15 | version '1.0-SNAPSHOT' 16 | 17 | apply plugin: 'java' 18 | apply plugin: 'org.springframework.boot' 19 | apply plugin: 'io.spring.dependency-management' 20 | 21 | sourceCompatibility = 1.8 22 | 23 | bootJar { 24 | enabled = false 25 | } 26 | 27 | jar { 28 | enabled = true 29 | } 30 | 31 | repositories { 32 | mavenCentral() 33 | } 34 | 35 | dependencies { 36 | implementation("org.apache.commons:commons-lang3:3.4") 37 | implementation("org.apache.httpcomponents:httpcore:4.4.8") 38 | implementation("org.apache.httpcomponents:httpclient:4.5.4") 39 | implementation("org.apache.httpcomponents:httpmime:4.5.4") 40 | implementation("commons-codec:commons-codec:1.9") 41 | implementation("commons-io:commons-io:2.5") 42 | runtime('javax.servlet:javax.servlet-api') 43 | 44 | compile("com.thoughtworks.xstream:xstream:1.4.9") 45 | compile('org.dom4j:dom4j:2.1.1') 46 | 47 | implementation('com.google.code.gson:gson:2.8.2') 48 | implementation("com.alibaba:fastjson:1.2.15") 49 | compileOnly "org.projectlombok:lombok:1.16.10" 50 | implementation("org.slf4j:slf4j-api:1.7.21") 51 | implementation("ch.qos.logback:logback-classic:1.1.7") 52 | 53 | compile('com.qiniu:qiniu-java-sdk:7.2.27') 54 | implementation('net.coobird:thumbnailator:0.4.8') 55 | 56 | implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.0.0' 57 | implementation('com.github.pagehelper:pagehelper-spring-boot-starter:1.2.3') 58 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 59 | implementation('org.springframework.boot:spring-boot-starter-data-redis') 60 | 61 | implementation 'org.springframework.boot:spring-boot-starter-web' 62 | implementation "org.dom4j:dom4j:2.0.0" 63 | runtimeOnly 'mysql:mysql-connector-java' 64 | //implementation "org.projectlombok:lombok:1.16.20" 65 | annotationProcessor 'org.projectlombok:lombok:1.18.2' 66 | // compileOnly 'org.projectlombok:lombok:1.18.8' 67 | 68 | implementation 'org.bouncycastle:bcprov-jdk15on:1.60' 69 | 70 | } 71 | 72 | sourceSets { 73 | main { 74 | java { 75 | srcDir 'src/main/java' 76 | } 77 | resources { 78 | srcDir 'src/main/resources' 79 | } 80 | } 81 | } 82 | 83 | //mybatis generator plugin ------ start 84 | buildscript { 85 | repositories { 86 | maven { 87 | url "https://plugins.gradle.org/m2/" 88 | } 89 | } 90 | dependencies { 91 | classpath "gradle.plugin.com.arenagod.gradle:mybatis-generator-plugin:1.4" 92 | } 93 | } 94 | 95 | apply plugin: "com.arenagod.gradle.MybatisGenerator" 96 | 97 | configurations { 98 | mybatisGenerator 99 | } 100 | 101 | mybatisGenerator { 102 | verbose = true 103 | configFile = 'src/main/resources/tools/NeedleGeneratorConfig.xml' 104 | } 105 | //mybatis generator plugin ------ end -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/cfg/bo/CfgBo.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.cfg.bo; 2 | 3 | /** 4 | * 控制参数Bo对象 5 | */ 6 | public interface CfgBo { 7 | } 8 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/cfg/bo/impl/CfgBoImpl.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.cfg.bo.impl; 2 | 3 | import com.codido.hodor.cfg.bo.CfgBo; 4 | import org.springframework.stereotype.Component; 5 | 6 | /** 7 | * 配置信息BO实现对象 8 | */ 9 | @Component 10 | public class CfgBoImpl implements CfgBo { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/bo/BaseBo.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.bo; 2 | 3 | /** 4 | * bo基类 5 | */ 6 | public abstract class BaseBo { 7 | } 8 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/bo/SendMpMessageBo.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.bo; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | /** 6 | * 发送公众号通知消息BO 7 | */ 8 | @Component 9 | public class SendMpMessageBo extends BaseBo{ 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/bo/dto/BaseDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.bo.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 基础DTO对象 7 | */ 8 | public class BaseDto implements Serializable { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/bo/dto/BaseParaDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.bo.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | /** 7 | * 入参dto对象 8 | */ 9 | @Data 10 | @EqualsAndHashCode(callSuper = false) 11 | public class BaseParaDto extends BaseDto { 12 | 13 | /** 14 | * 页码 15 | */ 16 | private Integer pageNum; 17 | 18 | /** 19 | * 每页请求数量 20 | */ 21 | private Integer prePageCount; 22 | } 23 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/bo/dto/BaseReturnDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.bo.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | /** 7 | * 返回参数DTO 8 | */ 9 | @Data 10 | @EqualsAndHashCode(callSuper = false) 11 | public class BaseReturnDto extends BaseDto { 12 | 13 | /** 14 | * 处理结果 15 | */ 16 | private Boolean retResult; 17 | 18 | /** 19 | * 处理错误数据 20 | */ 21 | private String retMessage; 22 | 23 | /** 24 | * 处理错误码 25 | */ 26 | private String retCode; 27 | } 28 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/bo/dto/WxPushMsgReqDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.bo.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.LinkedList; 6 | 7 | /** 8 | * @ProjectName: mall 9 | * @ClassName: WxPushMsgReqDto 10 | * @Description: 11 | * @Author: gongtao 12 | * @CreateDate: 2020/2/22 16:06 13 | */ 14 | @Data 15 | public class WxPushMsgReqDto { 16 | /** 17 | * 模版编号 18 | */ 19 | private String tmId; 20 | /** 21 | * 用户OPEN_ID 22 | */ 23 | private String openId; 24 | /** 25 | * 跳转H5链接 26 | */ 27 | private String url; 28 | /** 29 | * 必须按顺序存储,依次为first,keyword1...keywordn,remark 30 | */ 31 | private LinkedList parmList; 32 | /** 33 | * 小程序APPID 34 | */ 35 | private String appid; 36 | /** 37 | * 小程序路径 38 | */ 39 | private String pagepath; 40 | } 41 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/dto/BaseParamDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 返回DTO基类 10 | */ 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | public class BaseParamDto implements Serializable{ 14 | 15 | /** 16 | * 页码 17 | */ 18 | private Integer pageNum; 19 | 20 | /** 21 | * 每页请求数量 22 | */ 23 | private Integer prePageCount; 24 | } 25 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/dto/BaseRetDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 返回DTO基类 10 | */ 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | public class BaseRetDto implements Serializable { 14 | 15 | /** 16 | * 处理结果 17 | */ 18 | private boolean handlerResult; 19 | 20 | /** 21 | * 处理结果消息 22 | */ 23 | private String handlerMsg; 24 | 25 | /** 26 | * 处理错误码 27 | */ 28 | private String handlerCode; 29 | } 30 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/dto/MessageXSendParaDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 发送xsend短信的请求对象 10 | */ 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | public class MessageXSendParaDto implements Serializable{ 14 | 15 | /** 16 | * 发送的验证码字段 17 | */ 18 | private String code; 19 | } 20 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/dto/MessageXSendRetDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 发送xsend响应dto 10 | */ 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | public class MessageXSendRetDto implements Serializable{ 14 | 15 | /** 16 | * 状态:success表示成功 17 | */ 18 | private String status; 19 | 20 | /** 21 | * 短信ID 22 | */ 23 | private String send_id; 24 | 25 | /** 26 | * 所耗条数 27 | */ 28 | private String fee; 29 | 30 | /** 31 | * 剩余条数 32 | */ 33 | private String sms_credits; 34 | } 35 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/dto/TimestampRetDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 取时间戳返回对象 10 | */ 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | public class TimestampRetDto implements Serializable{ 14 | 15 | /** 16 | * 时间戳 17 | */ 18 | private String timestamp; 19 | } 20 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/util/AesCbcUtil.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.util; 2 | 3 | import org.apache.commons.codec.binary.Base64; 4 | import org.bouncycastle.jce.provider.BouncyCastleProvider; 5 | 6 | import javax.crypto.BadPaddingException; 7 | import javax.crypto.Cipher; 8 | import javax.crypto.IllegalBlockSizeException; 9 | import javax.crypto.NoSuchPaddingException; 10 | import javax.crypto.spec.IvParameterSpec; 11 | import javax.crypto.spec.SecretKeySpec; 12 | import java.io.UnsupportedEncodingException; 13 | import java.security.*; 14 | import java.security.spec.InvalidParameterSpecException; 15 | 16 | /** 17 | * 解密方法类 18 | */ 19 | public class AesCbcUtil { 20 | 21 | static { 22 | //BouncyCastle是一个开源的加解密解决方案,主页在http://www.bouncycastle.org/ 23 | Security.addProvider(new BouncyCastleProvider()); 24 | } 25 | 26 | /** 27 | * AES解密 28 | * 29 | * @param data //密文,被加密的数据 30 | * @param key //秘钥 31 | * @param iv //偏移量 32 | * @param encodingFormat //解密后的结果需要进行的编码 33 | * @return 34 | * @throws Exception 35 | */ 36 | public static String decrypt(String data, String key, String iv, String encodingFormat) throws Exception { 37 | // initialize(); 38 | 39 | //被加密的数据 40 | byte[] dataByte = Base64.decodeBase64(data); 41 | //加密秘钥 42 | byte[] keyByte = Base64.decodeBase64(key); 43 | //偏移量 44 | byte[] ivByte = Base64.decodeBase64(iv); 45 | 46 | 47 | try { 48 | Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding","BC"); 49 | 50 | SecretKeySpec spec = new SecretKeySpec(keyByte, "AES"); 51 | 52 | AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES"); 53 | parameters.init(new IvParameterSpec(ivByte)); 54 | 55 | cipher.init(Cipher.DECRYPT_MODE, spec, parameters);// 初始化 56 | 57 | byte[] resultByte = cipher.doFinal(dataByte); 58 | if (null != resultByte && resultByte.length > 0) { 59 | String result = new String(resultByte, encodingFormat); 60 | return result; 61 | } 62 | return null; 63 | } catch (NoSuchAlgorithmException e) { 64 | e.printStackTrace(); 65 | } catch (NoSuchPaddingException e) { 66 | e.printStackTrace(); 67 | } catch (InvalidParameterSpecException e) { 68 | e.printStackTrace(); 69 | } catch (InvalidKeyException e) { 70 | e.printStackTrace(); 71 | } catch (InvalidAlgorithmParameterException e) { 72 | e.printStackTrace(); 73 | } catch (IllegalBlockSizeException e) { 74 | e.printStackTrace(); 75 | } catch (BadPaddingException e) { 76 | e.printStackTrace(); 77 | } catch (UnsupportedEncodingException e) { 78 | e.printStackTrace(); 79 | } 80 | 81 | return null; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/util/Digests.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2005-2012 springside.org.cn 3 | */ 4 | package com.codido.hodor.core.common.util; 5 | 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.security.GeneralSecurityException; 9 | import java.security.MessageDigest; 10 | import java.security.SecureRandom; 11 | 12 | import org.apache.commons.lang3.Validate; 13 | 14 | /** 15 | * 支持SHA-1/MD5消息摘要的工具类. 16 | * 17 | * 返回ByteSource,可进一步被编码为Hex, Base64或UrlSafeBase64 18 | * 19 | * @author calvin 20 | */ 21 | public class Digests { 22 | 23 | private static final String SHA1 = "SHA-1"; 24 | private static final String MD5 = "MD5"; 25 | 26 | private static SecureRandom random = new SecureRandom(); 27 | 28 | /** 29 | * 对输入字符串进行md5散列. 30 | */ 31 | public static byte[] md5(byte[] input) { 32 | return digest(input, MD5, null, 1); 33 | } 34 | public static byte[] md5(byte[] input, int iterations) { 35 | return digest(input, MD5, null, iterations); 36 | } 37 | 38 | /** 39 | * 对输入字符串进行sha1散列. 40 | */ 41 | public static byte[] sha1(byte[] input) { 42 | return digest(input, SHA1, null, 1); 43 | } 44 | 45 | public static byte[] sha1(byte[] input, byte[] salt) { 46 | return digest(input, SHA1, salt, 1); 47 | } 48 | 49 | public static byte[] sha1(byte[] input, byte[] salt, int iterations) { 50 | return digest(input, SHA1, salt, iterations); 51 | } 52 | 53 | /** 54 | * 对字符串进行散列, 支持md5与sha1算法. 55 | */ 56 | private static byte[] digest(byte[] input, String algorithm, byte[] salt, int iterations) { 57 | try { 58 | MessageDigest digest = MessageDigest.getInstance(algorithm); 59 | 60 | if (salt != null) { 61 | digest.update(salt); 62 | } 63 | 64 | byte[] result = digest.digest(input); 65 | 66 | for (int i = 1; i < iterations; i++) { 67 | digest.reset(); 68 | result = digest.digest(result); 69 | } 70 | return result; 71 | } catch (GeneralSecurityException e) { 72 | throw new RuntimeException(e); 73 | } 74 | } 75 | 76 | /** 77 | * 生成随机的Byte[]作为salt. 78 | * 79 | * @param numBytes byte数组的大小 80 | */ 81 | public static byte[] generateSalt(int numBytes) { 82 | Validate.isTrue(numBytes > 0, "numBytes argument must be a positive integer (1 or larger)", numBytes); 83 | 84 | byte[] bytes = new byte[numBytes]; 85 | random.nextBytes(bytes); 86 | return bytes; 87 | } 88 | 89 | /** 90 | * 对文件进行md5散列. 91 | */ 92 | public static byte[] md5(InputStream input) throws IOException { 93 | return digest(input, MD5); 94 | } 95 | 96 | /** 97 | * 对文件进行sha1散列. 98 | */ 99 | public static byte[] sha1(InputStream input) throws IOException { 100 | return digest(input, SHA1); 101 | } 102 | 103 | private static byte[] digest(InputStream input, String algorithm) throws IOException { 104 | try { 105 | MessageDigest messageDigest = MessageDigest.getInstance(algorithm); 106 | int bufferLength = 8 * 1024; 107 | byte[] buffer = new byte[bufferLength]; 108 | int read = input.read(buffer, 0, bufferLength); 109 | 110 | while (read > -1) { 111 | messageDigest.update(buffer, 0, read); 112 | read = input.read(buffer, 0, bufferLength); 113 | } 114 | 115 | return messageDigest.digest(); 116 | } catch (GeneralSecurityException e) { 117 | throw new RuntimeException(e); 118 | } 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/util/Encodes.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2005-2012 springside.org.cn 3 | */ 4 | package com.codido.hodor.core.common.util; 5 | 6 | import java.io.UnsupportedEncodingException; 7 | import java.net.URLDecoder; 8 | import java.net.URLEncoder; 9 | 10 | import org.apache.commons.codec.DecoderException; 11 | import org.apache.commons.codec.binary.Base64; 12 | import org.apache.commons.codec.binary.Hex; 13 | import org.apache.commons.lang3.StringEscapeUtils; 14 | 15 | /** 16 | * 封装各种格式的编码解码工具类. 17 | * 1.Commons-Codec的 hex/base64 编码 18 | * 2.自制的base62 编码 19 | * 3.Commons-Lang的xml/html escape 20 | * 4.JDK提供的URLEncoder 21 | * @author calvin 22 | * @version 2013-01-15 23 | */ 24 | public class Encodes { 25 | 26 | private static final String DEFAULT_URL_ENCODING = "UTF-8"; 27 | private static final char[] BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray(); 28 | 29 | /** 30 | * Hex编码. 31 | */ 32 | public static String encodeHex(byte[] input) { 33 | return new String(Hex.encodeHex(input)); 34 | } 35 | 36 | /** 37 | * Hex解码. 38 | */ 39 | public static byte[] decodeHex(String input) { 40 | try { 41 | return Hex.decodeHex(input.toCharArray()); 42 | } catch (DecoderException e) { 43 | throw new RuntimeException(e); 44 | } 45 | } 46 | 47 | /** 48 | * Base64编码. 49 | */ 50 | public static String encodeBase64(byte[] input) { 51 | return new String(Base64.encodeBase64(input)); 52 | } 53 | 54 | /** 55 | * Base64编码. 56 | */ 57 | public static String encodeBase64(String input) { 58 | try { 59 | return new String(Base64.encodeBase64(input.getBytes(DEFAULT_URL_ENCODING))); 60 | } catch (UnsupportedEncodingException e) { 61 | return ""; 62 | } 63 | } 64 | 65 | // /** 66 | // * Base64编码, URL安全(将Base64中的URL非法字符'+'和'/'转为'-'和'_', 见RFC3548). 67 | // */ 68 | // public static String encodeUrlSafeBase64(byte[] input) { 69 | // return Base64.encodeBase64URLSafe(input); 70 | // } 71 | 72 | /** 73 | * Base64解码. 74 | */ 75 | public static byte[] decodeBase64(String input) { 76 | return Base64.decodeBase64(input.getBytes()); 77 | } 78 | 79 | /** 80 | * Base64解码. 81 | */ 82 | public static String decodeBase64String(String input) { 83 | try { 84 | return new String(Base64.decodeBase64(input.getBytes()), DEFAULT_URL_ENCODING); 85 | } catch (UnsupportedEncodingException e) { 86 | return ""; 87 | } 88 | } 89 | 90 | /** 91 | * Base62编码。 92 | */ 93 | public static String encodeBase62(byte[] input) { 94 | char[] chars = new char[input.length]; 95 | for (int i = 0; i < input.length; i++) { 96 | chars[i] = BASE62[((input[i] & 0xFF) % BASE62.length)]; 97 | } 98 | return new String(chars); 99 | } 100 | 101 | /** 102 | * Html 转码. 103 | */ 104 | public static String escapeHtml(String html) { 105 | return StringEscapeUtils.escapeHtml4(html); 106 | } 107 | 108 | /** 109 | * Html 解码. 110 | */ 111 | public static String unescapeHtml(String htmlEscaped) { 112 | return StringEscapeUtils.unescapeHtml4(htmlEscaped); 113 | } 114 | 115 | /** 116 | * Xml 转码. 117 | */ 118 | public static String escapeXml(String xml) { 119 | return StringEscapeUtils.escapeXml10(xml); 120 | } 121 | 122 | /** 123 | * Xml 解码. 124 | */ 125 | public static String unescapeXml(String xmlEscaped) { 126 | return StringEscapeUtils.unescapeXml(xmlEscaped); 127 | } 128 | 129 | /** 130 | * URL 编码, Encode默认为UTF-8. 131 | */ 132 | public static String urlEncode(String part) { 133 | try { 134 | return URLEncoder.encode(part, DEFAULT_URL_ENCODING); 135 | } catch (UnsupportedEncodingException e) { 136 | throw new RuntimeException(e); 137 | } 138 | } 139 | 140 | /** 141 | * URL 解码, Encode默认为UTF-8. 142 | */ 143 | public static String urlDecode(String part) { 144 | 145 | try { 146 | return URLDecoder.decode(part, DEFAULT_URL_ENCODING); 147 | } catch (UnsupportedEncodingException e) { 148 | throw new RuntimeException(e); 149 | } 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/util/JBFileUtil.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.util; 2 | 3 | import java.io.*; 4 | 5 | /** 6 | * 文件处理工具 7 | * Created by bpascal on 2017/6/14. 8 | */ 9 | public class JBFileUtil { 10 | 11 | /** 12 | * 创建文件 13 | * 14 | * @param fileName 15 | * @return 16 | */ 17 | public static boolean createFile(File fileName) throws Exception { 18 | boolean flag = false; 19 | try { 20 | if (!fileName.exists()) { 21 | fileName.createNewFile(); 22 | flag = true; 23 | } 24 | } catch (Exception e) { 25 | e.printStackTrace(); 26 | } 27 | return flag; 28 | } 29 | 30 | /** 31 | * 读TXT文件内容 32 | * 33 | * @param filePath 34 | * @return 35 | */ 36 | public static String readTxtFile(String filePath) throws Exception { 37 | String result = null; 38 | FileReader fileReader = null; 39 | BufferedReader bufferedReader = null; 40 | try { 41 | File f = new File(filePath); 42 | fileReader = new FileReader(f); 43 | bufferedReader = new BufferedReader(fileReader); 44 | try { 45 | String read = null; 46 | while ((read = bufferedReader.readLine()) != null) { 47 | result = result + read + "\r\n"; 48 | } 49 | } catch (Exception e) { 50 | e.printStackTrace(); 51 | } 52 | } catch (Exception e) { 53 | e.printStackTrace(); 54 | } finally { 55 | if (bufferedReader != null) { 56 | bufferedReader.close(); 57 | } 58 | if (fileReader != null) { 59 | fileReader.close(); 60 | } 61 | } 62 | System.out.println("读取出来的文件内容是:" + "\r\n" + result); 63 | return result; 64 | } 65 | 66 | /** 67 | * 写入文件 68 | * 69 | * @param content 70 | * @param filePath 71 | * @return 72 | * @throws Exception 73 | */ 74 | public static boolean writeTxtFile(String content, String filePath) throws Exception { 75 | RandomAccessFile mm = null; 76 | boolean flag = false; 77 | FileOutputStream o = null; 78 | try { 79 | File file = new File(filePath); 80 | if (!file.exists()) { 81 | file.createNewFile(); 82 | } 83 | o = new FileOutputStream(file); 84 | o.write(content.getBytes("UTF-8")); 85 | o.close(); 86 | flag = true; 87 | } catch (Exception e) { 88 | e.printStackTrace(); 89 | } finally { 90 | if (mm != null) { 91 | mm.close(); 92 | } 93 | } 94 | return flag; 95 | } 96 | 97 | 98 | /** 99 | * 追加文件内容 100 | * 101 | * @param filePath 102 | * @param content 103 | */ 104 | public static void contentAddToTxt(String filePath, String content) { 105 | String str = new String(); //原有txt内容 106 | String s1 = new String();//内容更新 107 | try { 108 | File f = new File(filePath); 109 | if (!f.exists()) { 110 | // 不存在则创建 111 | f.createNewFile(); 112 | } 113 | BufferedReader input = new BufferedReader(new FileReader(f)); 114 | 115 | while ((str = input.readLine()) != null) { 116 | s1 += str + "\n"; 117 | } 118 | input.close(); 119 | s1 += content; 120 | 121 | BufferedWriter output = new BufferedWriter(new FileWriter(f)); 122 | output.write(s1); 123 | output.close(); 124 | } catch (Exception e) { 125 | e.printStackTrace(); 126 | } 127 | } 128 | 129 | /** 130 | * 保存文件到本地路径 131 | * @param file 132 | * @param filePath 133 | */ 134 | public static String saveFileToDisk(File file,String filePath){ 135 | String retUrl; 136 | String path = "/data/www/resources/images/"; 137 | // String oldFileName = file.getFileName(); 138 | // String extension = 139 | // oldFileName.substring(oldFileName.lastIndexOf(".")); 140 | //String extension = file.getSuffix(); 141 | //String fileName = String.valueOf(System.currentTimeMillis()) + "." + extension; 142 | try { 143 | BufferedInputStream fis = null;//file.getFileStream(); 144 | File targetDir = new File(path); 145 | if (!targetDir.exists()) { 146 | targetDir.mkdirs(); 147 | } 148 | //File target = new File(targetDir, fileName); 149 | File target = new File(targetDir, ""); 150 | if (!target.exists()) { 151 | target.createNewFile(); 152 | target.setExecutable(true, false); 153 | target.setReadable(true, false); 154 | } 155 | FileOutputStream fos = new FileOutputStream(target); 156 | byte[] bts = new byte[300]; 157 | while (fis.read(bts, 0, 300) != -1) { 158 | fos.write(bts, 0, 300); 159 | } 160 | fos.close(); 161 | fis.close(); 162 | String fileRenderContextPath = "http://www.xiangzhixiangyu.com/resources/images/"; 163 | //retUrl = fileRenderContextPath + fileName; 164 | retUrl = fileRenderContextPath + ""; 165 | System.out.println("保存成功,文件路径为:" + retUrl); 166 | } catch (FileNotFoundException e) { 167 | System.out.println("FileNotFoundException:" + e.getLocalizedMessage()); 168 | e.printStackTrace(); 169 | retUrl = null; 170 | } catch (IOException e) { 171 | System.out.println("IOException:" + e.getLocalizedMessage()); 172 | e.printStackTrace(); 173 | retUrl = null; 174 | } 175 | return retUrl; 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/util/JBPictureUtil.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.util; 2 | 3 | import com.google.gson.Gson; 4 | import com.qiniu.common.QiniuException; 5 | import com.qiniu.common.Zone; 6 | import com.qiniu.http.Response; 7 | import com.qiniu.storage.Configuration; 8 | import com.qiniu.storage.UploadManager; 9 | import com.qiniu.storage.model.DefaultPutRet; 10 | import com.qiniu.util.Auth; 11 | import lombok.extern.slf4j.Slf4j; 12 | 13 | import javax.imageio.ImageIO; 14 | import java.awt.*; 15 | import java.awt.image.BufferedImage; 16 | import java.io.ByteArrayOutputStream; 17 | import java.io.File; 18 | import java.io.FileInputStream; 19 | import java.io.FileNotFoundException; 20 | import java.util.Date; 21 | 22 | /** 23 | * @Author: BigStrong 24 | * @Date: 2019/6/13 下午9:41 25 | * 生成图片工具类 26 | */ 27 | @Slf4j 28 | public class JBPictureUtil { 29 | 30 | /** 31 | * 生成图片方法 32 | * 33 | * @param str 34 | * @param outFile 35 | * @return 36 | * @throws Exception 37 | */ 38 | public static byte[] createImage(String str, File outFile) throws Exception { 39 | //创造一个文字 40 | Font font = new Font("PingFangSC-Thin", Font.BOLD, 128); 41 | //获取font的样式应用在str上的整个矩形 42 | //Rectangle2D r = font.getStringBounds(str, new FontRenderContext(AffineTransform.getScaleInstance(1, 1), false, false)); 43 | //获取单个字符的高度 44 | //int unitHeight = (int) Math.floor(r.getHeight()); 45 | //获取整个str用了font样式的宽度这里用四舍五入后+1保证宽度绝对能容纳这个字符串作为图片的宽度 46 | //int width=(int)Math.round(r.getWidth())+1; 47 | int width = 128; 48 | //把单个字符的高度+3保证高度绝对能容纳字符串作为图片的高度 49 | //int height=unitHeight+3; 50 | int height = 128; 51 | //创建图片 52 | BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); 53 | Graphics2D graphics2D = image.createGraphics(); 54 | 55 | // 增加下面代码使得背景透明 56 | image = graphics2D.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); 57 | graphics2D.dispose(); 58 | graphics2D = image.createGraphics(); 59 | // 背景透明代码结束 60 | 61 | //下面写字 62 | //颜色设置为白色 63 | graphics2D.setColor(Color.white); 64 | //设置画笔字体 65 | graphics2D.setFont(font); 66 | //开启文字抗锯齿 67 | graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 68 | //在图片中间画文字 69 | if(str.getBytes().length==str.length()){ 70 | //半角 71 | graphics2D.drawString(str, 32, 112); 72 | }else{ 73 | //全角 74 | graphics2D.drawString(str, 0, 112); 75 | } 76 | 77 | graphics2D.dispose(); 78 | 79 | if (outFile != null) { 80 | //输出png图片到指定目录 81 | ImageIO.write(image, "png", outFile); 82 | } 83 | //返回数据流 84 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 85 | boolean flag = ImageIO.write(image, "png", out); 86 | byte[] b = out.toByteArray(); 87 | return b; 88 | } 89 | 90 | 91 | /** 92 | * 图片上传到七牛到方法 93 | */ 94 | public static String picUploadQiNiu(File picFile,String accessKey,String secretKey,String bucket,String urlDomainContext,String fileName) throws QiniuException, FileNotFoundException { 95 | String retImgUrl = null; 96 | log.info("图片传到七牛开始"); 97 | String imgUrl = null;//返回的url 98 | //String suffix = picFile.getName().substring(picFile.getName().lastIndexOf(".") + 1); 99 | 100 | //文件输入流 101 | FileInputStream fileInputStream = new FileInputStream(picFile); 102 | //构造一个带指定Zone对象的配置类 103 | Configuration cfg = new Configuration(Zone.zone2());//华南二区 104 | //...其他参数参考类注释 105 | UploadManager uploadManager = new UploadManager(cfg); 106 | //默认不指定key的情况下,以文件内容的hash值作为文件名 107 | String key = JBDateUtil.convertDateToString(new Date(), JBDateUtil.dateFormat_yyyy_MM_dd) + "/" +fileName; 108 | Auth auth = Auth.create(accessKey, secretKey); 109 | String upToken = auth.uploadToken(bucket); 110 | try { 111 | Response response = uploadManager.put(fileInputStream, key, upToken, null, null); 112 | //解析上传成功的结果 113 | DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class); 114 | //log.info("七牛传图返回对象:" + putRet.toString()); 115 | imgUrl = urlDomainContext + putRet.key + "?imageslim"; 116 | log.info("图片传到七牛完成,文件路径是:" + imgUrl); 117 | retImgUrl = imgUrl; 118 | } catch (QiniuException ex) { 119 | Response r = ex.response; 120 | log.info("七牛传图异常:" + r.toString() + ",错误内容:" + r.bodyString()); 121 | } 122 | return retImgUrl; 123 | } 124 | 125 | 126 | public static void main(String[] arg) { 127 | // GraphicsEnvironment eq=GraphicsEnvironment.getLocalGraphicsEnvironment(); 128 | // Font[] list=eq.getAllFonts(); 129 | // for (int i=0;i 0) { 28 | retBool = false; 29 | } else { 30 | retBool = true; 31 | } 32 | return retBool; 33 | } 34 | 35 | /** 36 | * 判断字符串是否为空 37 | * 38 | * @param str 39 | * @return 40 | */ 41 | public static final boolean isStrEmpty(String str) { 42 | boolean retBool = false; 43 | if (str != null && !"".equals(str.trim())) { 44 | retBool = false; 45 | } else { 46 | retBool = true; 47 | } 48 | return retBool; 49 | } 50 | 51 | /** 52 | * URL编码(utf-8) 53 | * 54 | * @param source 55 | * @return 56 | */ 57 | public static String urlEncodeUTF8(String source) { 58 | String result = source; 59 | try { 60 | result = java.net.URLEncoder.encode(source, "utf-8"); 61 | } catch (UnsupportedEncodingException e) { 62 | e.printStackTrace(); 63 | } 64 | return result; 65 | } 66 | 67 | /** 68 | * 方法名:byteToHex
69 | * 详述:字符串加密辅助方法
70 | * 开发人员:laijj
71 | * 创建时间:2016-1-5
72 | * 73 | * @param hash 74 | * @return 说明返回值含义 75 | */ 76 | public static String byteToHex(final byte[] hash) { 77 | Formatter formatter = new Formatter(); 78 | for (byte b : hash) { 79 | formatter.format("%02x", b); 80 | } 81 | String result = formatter.toString(); 82 | formatter.close(); 83 | return result; 84 | 85 | } 86 | 87 | /** 88 | * double型字符转int 89 | * 90 | * @param string 91 | * @return 92 | */ 93 | public static int stringToInt(String string) { 94 | String str = string.substring(0, string.indexOf(".")) + string.substring(string.indexOf(".") + 1); 95 | int intgeo = Integer.parseInt(str) / 100; 96 | return intgeo; 97 | } 98 | 99 | 100 | /** 101 | * 实际替换动作 102 | * 103 | * @param userName userName 104 | * @return 105 | */ 106 | public static String replaceAction(String userName) { 107 | String userNameAfterReplaced = ""; 108 | int nameLength = userName.length(); 109 | if (nameLength < 3 && nameLength > 0) { 110 | if (nameLength == 1) { 111 | userNameAfterReplaced = "*"; 112 | } else { 113 | userNameAfterReplaced = userName.replaceAll(userName, "^.{1,2}"); 114 | } 115 | } else { 116 | Integer num1, num2, num3; 117 | num2 = (new Double(Math.ceil(new Double(nameLength) / 3))).intValue(); 118 | num1 = (new Double(Math.floor(new Double(nameLength) / 3))).intValue(); 119 | num3 = nameLength - num1 - num2; 120 | String star = StringUtils.repeat("*", num2); 121 | userNameAfterReplaced = userName.replaceAll("(.{" + num1 + "})(.{" + num2 + "})(.{" + num3 + "})", "$1" + star + "$3"); 122 | } 123 | return userNameAfterReplaced; 124 | } 125 | 126 | /** 127 | * 获取IP地址 128 | * 129 | * @param request 130 | * @return 131 | */ 132 | public static String getIpAddr(HttpServletRequest request) { 133 | String ipAddress = null; 134 | try { 135 | ipAddress = request.getHeader("x-forwarded-for"); 136 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { 137 | ipAddress = request.getHeader("Proxy-Client-IP"); 138 | } 139 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { 140 | ipAddress = request.getHeader("WL-Proxy-Client-IP"); 141 | } 142 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { 143 | ipAddress = request.getRemoteAddr(); 144 | if (ipAddress.equals("127.0.0.1")) { 145 | // 根据网卡取本机配置的IP 146 | InetAddress inet = null; 147 | try { 148 | inet = InetAddress.getLocalHost(); 149 | } catch (UnknownHostException e) { 150 | e.printStackTrace(); 151 | } 152 | ipAddress = inet.getHostAddress(); 153 | } 154 | } 155 | // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割 156 | if (ipAddress != null && ipAddress.length() > 15) { // "***.***.***.***".length() 157 | // = 15 158 | if (ipAddress.indexOf(",") > 0) { 159 | ipAddress = ipAddress.substring(0, ipAddress.indexOf(",")); 160 | } 161 | } 162 | } catch (Exception e) { 163 | ipAddress = ""; 164 | } 165 | // ipAddress = this.getRequest().getRemoteAddr(); 166 | 167 | return ipAddress; 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/util/MD5Util.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.util; 2 | 3 | import java.security.MessageDigest; 4 | 5 | import static java.nio.charset.StandardCharsets.UTF_8; 6 | 7 | /** 8 | * MD5处理工具类 9 | */ 10 | public class MD5Util { 11 | 12 | private static final String HEX_DIGITS[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"}; 13 | 14 | /** 15 | * 进行MD5编码 16 | * 17 | * @param origin 需要加密的字符 18 | * @param charsetname 字符集,可为空,如果为空,默认为UTF-8 19 | * @return 20 | */ 21 | public static String md5Encode(String origin, String charsetname) { 22 | String resultString = null; 23 | try { 24 | resultString = origin; 25 | MessageDigest md = MessageDigest.getInstance("MD5"); 26 | if (charsetname == null || "".equals(charsetname)) 27 | resultString = byteArrayToHexString(md.digest(resultString.getBytes(UTF_8))); 28 | else 29 | resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname))); 30 | } catch (Exception e) { 31 | e.printStackTrace(); 32 | } 33 | return resultString; 34 | } 35 | 36 | /** 37 | * byte数组转十六进制字符串 38 | * 39 | * @param b 40 | * @return 41 | */ 42 | private static String byteArrayToHexString(byte b[]) { 43 | StringBuffer resultSb = new StringBuffer(); 44 | for (int i = 0; i < b.length; i++) 45 | resultSb.append(byteToHexString(b[i])); 46 | 47 | return resultSb.toString(); 48 | } 49 | 50 | /** 51 | * byte字符转十六进制字符串 52 | * 53 | * @param b 54 | * @return 55 | */ 56 | private static String byteToHexString(byte b) { 57 | int n = b; 58 | if (n < 0) 59 | n += 256; 60 | int d1 = n / 16; 61 | int d2 = n % 16; 62 | return HEX_DIGITS[d1] + HEX_DIGITS[d2]; 63 | } 64 | 65 | /** 66 | * 测试方法 67 | * 68 | * @param args 69 | */ 70 | public static void main(String[] args) { 71 | System.out.println(md5Encode("jiqibaba2020", null)); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/util/MessageXsendUtil.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.util; 2 | 3 | import java.io.IOException; 4 | import java.util.Map; 5 | import java.util.TreeMap; 6 | 7 | 8 | import com.alibaba.fastjson.JSON; 9 | import com.codido.hodor.core.common.dto.MessageXSendParaDto; 10 | import com.codido.hodor.core.common.dto.TimestampRetDto; 11 | import org.apache.http.HttpEntity; 12 | import org.apache.http.HttpResponse; 13 | import org.apache.http.client.ClientProtocolException; 14 | import org.apache.http.client.methods.HttpGet; 15 | import org.apache.http.client.methods.HttpPost; 16 | import org.apache.http.entity.ContentType; 17 | 18 | import org.apache.http.entity.mime.MultipartEntityBuilder; 19 | import org.apache.http.impl.client.CloseableHttpClient; 20 | import org.apache.http.impl.client.HttpClientBuilder; 21 | import org.apache.http.protocol.HTTP; 22 | import org.apache.http.util.EntityUtils; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * 发送submail的验证码工具类 28 | */ 29 | public class MessageXsendUtil { 30 | 31 | private static Logger logger = LoggerFactory.getLogger(MessageXsendUtil.class); 32 | 33 | /** 34 | * 时间戳接口配置 35 | */ 36 | public static final String TIMESTAMP = "https://api.mysubmail.com/service/timestamp"; 37 | /** 38 | * 备用接口 39 | * http://api.mysubmail.com/service/timestamp 40 | * https://api.submail.cn/service/timestamp 41 | * http://api.submail.cn/service/timestamp 42 | */ 43 | 44 | public static final String TYPE_MD5 = "md5"; 45 | public static final String TYPE_SHA1 = "sha1"; 46 | /** 47 | * API 请求接口配置 48 | */ 49 | private static final String URL = "https://api.mysubmail.com/message/xsend"; 50 | 51 | /** 52 | * 备用接口 53 | * http://api.mysubmail.com/message/xsend 54 | * https://api.submail.cn/message/xsend 55 | * http://api.submail.cn/message/xsend 56 | */ 57 | public static String sendSubMailSms(String projectId,String mblNo, String code) { 58 | String jsonStr = null; 59 | TreeMap requestData = new TreeMap(); 60 | MessageXSendParaDto sendDto = new MessageXSendParaDto(); 61 | /** 62 | * --------------------------------参数配置------------------------------------ 63 | * 请仔细阅读参数配置说明 64 | * 65 | * 配置参数包括 appid, appkey ,to ,project, signtype, vars 66 | * appid, appkey, to, project 为必须参数 67 | * 请访问 submail 官网创建并获取 appid 和 appkey,链接:https://www.mysubmail.com/chs/sms/apps 68 | * 请访问 submail 官网创建获取项目标识 project_id,链接:https://www.mysubmail.com/chs/sms/templates 69 | * 如何获取项目标识 project 参数,链接:https://www.mysubmail.com/chs/documents/developer/MmSw12 70 | * vars参数 71 | * 例: vars.put("code", "123456"), 其中 code 对应短信模板中的 @var(code) 变量 72 | * signtype 为可选参数: normal | md5 | sha1 73 | * 当 signtype 参数为空时,默认为 normal 74 | * -------------------------------------------------------------------------- 75 | */ 76 | String appid = "50024"; 77 | String appkey = "b80ccca1d466c07ae5735add96cc9a82"; 78 | String signtype = ""; 79 | sendDto.setCode(code); 80 | 81 | /** 82 | * 签名验证方式 83 | * 详细说明可参考 SUBMAIL 官网,开发文档 → 开始 → API 授权与验证机制 84 | */ 85 | requestData.put("appid", appid); 86 | requestData.put("project", projectId); 87 | requestData.put("to", mblNo); 88 | requestData.put("vars", JSON.toJSONString(sendDto)); 89 | MultipartEntityBuilder builder = MultipartEntityBuilder.create(); 90 | @SuppressWarnings("deprecation") 91 | ContentType contentType = ContentType.create(HTTP.PLAIN_TEXT_TYPE, HTTP.UTF_8); 92 | for (Map.Entry entry : requestData.entrySet()) { 93 | String key = entry.getKey(); 94 | Object value = entry.getValue(); 95 | if (value instanceof String) { 96 | builder.addTextBody(key, String.valueOf(value), contentType); 97 | } 98 | } 99 | if (signtype.equals(TYPE_MD5) || signtype.equals(TYPE_SHA1)) { 100 | String timestamp = getTimestamp(); 101 | requestData.put("timestamp", timestamp); 102 | requestData.put("sign_type", signtype); 103 | String signStr = appid + appkey + RequestEncoder.formatRequest(requestData) + appid + appkey; 104 | 105 | builder.addTextBody("timestamp", timestamp); 106 | builder.addTextBody("sign_type", signtype); 107 | builder.addTextBody("signature", RequestEncoder.encode(signtype, signStr), contentType); 108 | } else { 109 | builder.addTextBody("signature", appkey, contentType); 110 | } 111 | /** 112 | * http post 请求接口 113 | * 成功返回 status: success,其中 fee 参数为短信费用 ,credits 参数为剩余短信余额 114 | * 详细的 API 错误日志请访问 SUBMAIL 官网 → 开发文档 → DEBUG → API 错误代码 115 | */ 116 | HttpPost httpPost = new HttpPost(URL); 117 | httpPost.addHeader("charset", "UTF-8"); 118 | httpPost.setEntity(builder.build()); 119 | try { 120 | CloseableHttpClient closeableHttpClient = HttpClientBuilder.create().build(); 121 | HttpResponse response = closeableHttpClient.execute(httpPost); 122 | HttpEntity httpEntity = response.getEntity(); 123 | if (httpEntity != null) { 124 | jsonStr = EntityUtils.toString(httpEntity, "UTF-8"); 125 | logger.info("submail短信发送完成:" + jsonStr); 126 | } 127 | } catch (ClientProtocolException e) { 128 | e.printStackTrace(); 129 | } catch (IOException e) { 130 | e.printStackTrace(); 131 | } 132 | return jsonStr; 133 | } 134 | 135 | /** 136 | * 获取时间戳 137 | * 138 | * @return 139 | */ 140 | private static String getTimestamp() { 141 | CloseableHttpClient closeableHttpClient = HttpClientBuilder.create().build(); 142 | HttpGet httpget = new HttpGet(TIMESTAMP); 143 | try { 144 | HttpResponse response = closeableHttpClient.execute(httpget); 145 | HttpEntity httpEntity = response.getEntity(); 146 | String jsonStr = EntityUtils.toString(httpEntity, "UTF-8"); 147 | if (jsonStr != null) { 148 | TimestampRetDto timestampRetDto = JSON.parseObject(jsonStr,TimestampRetDto.class); 149 | return timestampRetDto.getTimestamp(); 150 | } 151 | closeableHttpClient.close(); 152 | } catch (ClientProtocolException e) { 153 | e.printStackTrace(); 154 | } catch (IOException e) { 155 | e.printStackTrace(); 156 | } 157 | 158 | return null; 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/util/OrderNoGeneratorUtil.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.util; 2 | 3 | import org.apache.commons.lang3.RandomStringUtils; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 订单号工具类 9 | */ 10 | public class OrderNoGeneratorUtil { 11 | 12 | /** 13 | * 订单号统一前缀 14 | */ 15 | public static String ORDER_PRE_FLAG = "11";//普通订单 16 | public static String CHASE_PRE_FLAG = "12";//追号订单 17 | public static String BONUS_PRE_FLAG = "21";//派奖订单 18 | public static String WITHDRAWORDER_PRE_FLAG = "31";//提现订单 19 | public static String TXNO_PRE_FLAG = "81";//交易流水 20 | public static String LOG_PRE_FLAG = "91";//日志订单 21 | public static String PICNAME_PRE_FLAG = "61";//图片文件名 22 | public static String REFUND_PRE_FLAG = "71";//退款订单 23 | 24 | 25 | /** 26 | * 生成订单号 27 | * @param orderNoPre 28 | * @return 29 | */ 30 | public static String generatorOrderNo(String orderNoPre) { 31 | //订单号后缀取时间戳+4随机码 32 | String orderNo = JBDateUtil.transDate2String(new Date(),"",JBDateUtil.dateFormat_yyyyMMddHHmmssSSS) + RandomStringUtils.randomNumeric(4); 33 | return orderNoPre+orderNo; 34 | } 35 | 36 | /** 37 | * 测试方法 38 | * @param args 39 | */ 40 | public static void main(String [] args) { 41 | System.out.println("生成了订单号:"+generatorOrderNo("12")); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/util/Password.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.util; 2 | 3 | 4 | /** 5 | * 密码工具类 6 | * @author janjan, xujian_jason@163.com 7 | * 8 | */ 9 | public class Password { 10 | 11 | public static final String HASH_ALGORITHM = "SHA-1"; 12 | public static final String MD5_ALGORITHM = "MD5"; 13 | public static final int HASH_INTERATIONS = 1024; 14 | public static final int SALT_SIZE = 8; 15 | 16 | /** 17 | * 生成安全的密码,生成随机的16位salt并经过1024次 sha-1 hash 18 | */ 19 | public static String entryptPassword(String plainPassword) { 20 | String plain = Encodes.unescapeHtml(plainPassword); 21 | byte[] salt = Digests.generateSalt(SALT_SIZE); 22 | byte[] hashPassword = Digests.sha1(plain.getBytes(), salt, HASH_INTERATIONS); 23 | return Encodes.encodeHex(salt)+Encodes.encodeHex(hashPassword); 24 | } 25 | 26 | /** 27 | * 验证密码 28 | * @param plainPassword 明文密码 29 | * @param password 密文密码 30 | * @return 验证成功返回true 31 | */ 32 | public static boolean validatePassword(String plainPassword, String password) { 33 | String plain = Encodes.unescapeHtml(plainPassword); 34 | byte[] salt = Encodes.decodeHex(password.substring(0,16)); 35 | byte[] hashPassword = Digests.sha1(plain.getBytes(), salt, HASH_INTERATIONS); 36 | return password.equals(Encodes.encodeHex(salt)+Encodes.encodeHex(hashPassword)); 37 | } 38 | 39 | /* ================= test ================= */ 40 | public static void main(String[] args) { 41 | System.out.println(entryptPassword("e10adc3949ba59abbe56e057f20f883e")); 42 | System.out.println(validatePassword("e10adc3949ba59abbe56e057f20f883e", "cf8974c09eec3d95dd352641f0aefc1dced342eb0fdc466fcfd97f55")); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/util/PictureUtil.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.util; 2 | 3 | import java.awt.*; 4 | import java.awt.image.BufferedImage; 5 | import java.io.File; 6 | 7 | import javax.imageio.ImageIO; 8 | 9 | public class PictureUtil { 10 | 11 | public static void main(String[] args) { 12 | int imageWidth = 1920;//图片的宽度 13 | int imageHeight = 1080;//图片的高度 14 | BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB); 15 | Graphics graphics = image.getGraphics(); 16 | try 17 | { 18 | Font font=new Font("新宋体",Font.PLAIN,32); 19 | graphics.setFont(font); 20 | //graphics.drawImage(); 21 | graphics.fillRect(0, 0, imageWidth, imageHeight); 22 | graphics.setColor(new Color(0,0,0)); 23 | graphics.drawString("天天骑牛", 10, 100); 24 | graphics.drawString("www.rivendell.top", 10, 136); 25 | ImageIO.write(image, "PNG", new File("/Users/bpascal/Desktop/abc.png"));//生成图片方法一 26 | //ImageIO,可以生成不同格式的图片,比如JPG,PNG,GIF..... 27 | } 28 | catch(Exception ex) 29 | { 30 | ex.printStackTrace(); 31 | } 32 | graphics.dispose();//释放资源 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/util/RequestEncoder.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.util; 2 | 3 | import java.security.MessageDigest; 4 | import java.util.Iterator; 5 | import java.util.Map; 6 | import java.util.Set; 7 | 8 | public class RequestEncoder { 9 | 10 | 11 | private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', 12 | '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; 13 | public static final String MD5 = "MD5"; 14 | public static final String SHA1 = "SHA1"; 15 | /** 16 | * encode string 17 | * 18 | * @param algorithm 19 | * @param str 20 | * @return String 21 | */ 22 | public static String encode(String algorithm, String str) { 23 | if (str == null) { 24 | return null; 25 | } 26 | try { 27 | MessageDigest messageDigest = MessageDigest.getInstance(algorithm); 28 | messageDigest.update(str.getBytes()); 29 | return getFormattedText(messageDigest.digest()); 30 | } catch (Exception e) { 31 | throw new RuntimeException(e); 32 | } 33 | 34 | } 35 | 36 | /** 37 | * Takes the raw bytes from the digest and formats them correct. 38 | * 39 | * @param bytes 40 | * the raw bytes from the digest. 41 | * @return the formatted bytes. 42 | */ 43 | private static String getFormattedText(byte[] bytes) { 44 | int len = bytes.length; 45 | StringBuilder buf = new StringBuilder(len * 2); 46 | for (int j = 0; j < len; j++) {buf.append(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]); 47 | buf.append(HEX_DIGITS[bytes[j] & 0x0f]); 48 | } 49 | return buf.toString(); 50 | } 51 | 52 | public static String formatRequest(Map data){ 53 | Set keySet = data.keySet(); 54 | Iterator it = keySet.iterator(); 55 | StringBuffer sb = new StringBuffer(); 56 | while(it.hasNext()){ 57 | String key = it.next(); 58 | Object value = data.get(key); 59 | if(value instanceof String){ 60 | sb.append(key + "=" + value + "&"); 61 | } 62 | } 63 | if(sb.length() != 0){ 64 | return sb.substring(0, sb.length() - 1); 65 | } 66 | return null; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/util/Sha1Util.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.util; 2 | 3 | import java.security.MessageDigest; 4 | import java.util.Iterator; 5 | import java.util.Map; 6 | import java.util.Random; 7 | import java.util.Set; 8 | import java.util.SortedMap; 9 | 10 | /** 11 | * createSHA1Sign创建签名SHA1 12 | * getSha1()Sha1签名 13 | */ 14 | public class Sha1Util { 15 | 16 | public static String getNonceStr() { 17 | Random random = new Random(); 18 | return MD5Util.md5Encode(String.valueOf(random.nextInt(10000)), "UTF-8"); 19 | } 20 | 21 | public static String getTimeStamp() { 22 | return String.valueOf(System.currentTimeMillis() / 1000); 23 | } 24 | 25 | //创建签名SHA1 26 | public static String createSHA1Sign(SortedMap signParams) throws Exception { 27 | StringBuffer sb = new StringBuffer(); 28 | Set es = signParams.entrySet(); 29 | Iterator it = es.iterator(); 30 | while (it.hasNext()) { 31 | Map.Entry entry = (Map.Entry) it.next(); 32 | String k = (String) entry.getKey(); 33 | String v = (String) entry.getValue(); 34 | sb.append(k + "=" + v + "&"); 35 | //要采用URLENCODER的原始值! 36 | } 37 | String params = sb.substring(0, sb.lastIndexOf("&")); 38 | System.out.println("sha1 sb:" + params); 39 | return getSha1(params); 40 | } 41 | 42 | //Sha1签名 43 | public static String getSha1(String str) { 44 | if (str == null || str.length() == 0) { 45 | return null; 46 | } 47 | char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 48 | 'a', 'b', 'c', 'd', 'e', 'f'}; 49 | 50 | try { 51 | MessageDigest mdTemp = MessageDigest.getInstance("SHA1"); 52 | mdTemp.update(str.getBytes("GBK")); 53 | 54 | byte[] md = mdTemp.digest(); 55 | int j = md.length; 56 | char buf[] = new char[j * 2]; 57 | int k = 0; 58 | for (int i = 0; i < j; i++) { 59 | byte byte0 = md[i]; 60 | buf[k++] = hexDigits[byte0 >>> 4 & 0xf]; 61 | buf[k++] = hexDigits[byte0 & 0xf]; 62 | } 63 | return new String(buf); 64 | } catch (Exception e) { 65 | e.printStackTrace(); 66 | return null; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/common/util/XMLUtil.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.common.util; 2 | 3 | import org.dom4j.Document; 4 | import org.dom4j.DocumentException; 5 | import org.dom4j.Element; 6 | import org.dom4j.io.SAXReader; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import java.io.ByteArrayInputStream; 10 | import java.io.IOException; 11 | import java.io.InputStream; 12 | import java.util.HashMap; 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | /** 17 | * Created by FirenzesEagle on 2016/7/7 0007. 18 | * Email:liumingbo2008@gmail.com 19 | */ 20 | public class XMLUtil { 21 | 22 | /** 23 | * 将微信服务器发送的Request请求中Body的XML解析为Map 24 | * 25 | * @param request 26 | * @return 27 | * @throws Exception 28 | */ 29 | public static Map parseRequestXmlToMap(HttpServletRequest request) throws Exception { 30 | // 解析结果存储在HashMap中 31 | Map resultMap; 32 | InputStream inputStream = request.getInputStream(); 33 | resultMap = parseInputStreamToMap(inputStream); 34 | return resultMap; 35 | } 36 | 37 | /** 38 | * 将输入流中的XML解析为Map 39 | * 40 | * @param inputStream 41 | * @return 42 | * @throws DocumentException 43 | * @throws IOException 44 | */ 45 | public static Map parseInputStreamToMap(InputStream inputStream) throws DocumentException, IOException { 46 | // 解析结果存储在HashMap中 47 | Map map = new HashMap(); 48 | // 读取输入流 49 | SAXReader reader = new SAXReader(); 50 | Document document = reader.read(inputStream); 51 | //得到xml根元素 52 | Element root = document.getRootElement(); 53 | // 得到根元素的所有子节点 54 | List elementList = root.elements(); 55 | //遍历所有子节点 56 | for (Element e : elementList) { 57 | map.put(e.getName(), e.getText()); 58 | } 59 | //释放资源 60 | inputStream.close(); 61 | return map; 62 | } 63 | 64 | /** 65 | * 将String类型的XML解析为Map 66 | * 67 | * @param str 68 | * @return 69 | * @throws Exception 70 | */ 71 | public static Map parseXmlStringToMap(String str) throws Exception { 72 | Map resultMap; 73 | InputStream inputStream = new ByteArrayInputStream(str.getBytes("UTF-8")); 74 | resultMap = parseInputStreamToMap(inputStream); 75 | return resultMap; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/mapper/CfgAgentMapper.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.mapper; 2 | 3 | import com.codido.hodor.core.model.CfgAgent; 4 | import com.codido.hodor.core.model.CfgAgentExample; 5 | import java.math.BigDecimal; 6 | import java.util.List; 7 | import org.apache.ibatis.annotations.Arg; 8 | import org.apache.ibatis.annotations.ConstructorArgs; 9 | import org.apache.ibatis.annotations.Delete; 10 | import org.apache.ibatis.annotations.DeleteProvider; 11 | import org.apache.ibatis.annotations.Insert; 12 | import org.apache.ibatis.annotations.InsertProvider; 13 | import org.apache.ibatis.annotations.Options; 14 | import org.apache.ibatis.annotations.Param; 15 | import org.apache.ibatis.annotations.Select; 16 | import org.apache.ibatis.annotations.SelectProvider; 17 | import org.apache.ibatis.annotations.Update; 18 | import org.apache.ibatis.annotations.UpdateProvider; 19 | import org.apache.ibatis.type.JdbcType; 20 | 21 | public interface CfgAgentMapper { 22 | @SelectProvider(type=CfgAgentSqlProvider.class, method="countByExample") 23 | long countByExample(CfgAgentExample example); 24 | 25 | @DeleteProvider(type=CfgAgentSqlProvider.class, method="deleteByExample") 26 | int deleteByExample(CfgAgentExample example); 27 | 28 | @Delete({ 29 | "delete from t_cfg_agent", 30 | "where AGENT_ID = #{agentId,jdbcType=BIGINT}" 31 | }) 32 | int deleteByPrimaryKey(Long agentId); 33 | 34 | @Insert({ 35 | "insert into t_cfg_agent (AGENT_NAME, AGENT_TICKET_TYPE, ", 36 | "AGENT_STS, AGENT_CREATE_TIME, ", 37 | "PAY_TYPE, TOTAL_CHARGE_AMOUNT, ", 38 | "TOTAL_PAY_AMOUNT, CURRENT_BALANCE, ", 39 | "AGENT_IP_ADDRESS)", 40 | "values (#{agentName,jdbcType=VARCHAR}, #{agentTicketType,jdbcType=CHAR}, ", 41 | "#{agentSts,jdbcType=CHAR}, #{agentCreateTime,jdbcType=VARCHAR}, ", 42 | "#{payType,jdbcType=VARCHAR}, #{totalChargeAmount,jdbcType=DECIMAL}, ", 43 | "#{totalPayAmount,jdbcType=DECIMAL}, #{currentBalance,jdbcType=DECIMAL}, ", 44 | "#{agentIpAddress,jdbcType=VARCHAR})" 45 | }) 46 | @Options(useGeneratedKeys=true,keyProperty="agentId") 47 | int insert(CfgAgent record); 48 | 49 | @InsertProvider(type=CfgAgentSqlProvider.class, method="insertSelective") 50 | @Options(useGeneratedKeys=true,keyProperty="agentId") 51 | int insertSelective(CfgAgent record); 52 | 53 | @SelectProvider(type=CfgAgentSqlProvider.class, method="selectByExample") 54 | @ConstructorArgs({ 55 | @Arg(column="AGENT_ID", javaType=Long.class, jdbcType=JdbcType.BIGINT, id=true), 56 | @Arg(column="AGENT_NAME", javaType=String.class, jdbcType=JdbcType.VARCHAR), 57 | @Arg(column="AGENT_TICKET_TYPE", javaType=String.class, jdbcType=JdbcType.CHAR), 58 | @Arg(column="AGENT_STS", javaType=String.class, jdbcType=JdbcType.CHAR), 59 | @Arg(column="AGENT_CREATE_TIME", javaType=String.class, jdbcType=JdbcType.VARCHAR), 60 | @Arg(column="PAY_TYPE", javaType=String.class, jdbcType=JdbcType.VARCHAR), 61 | @Arg(column="TOTAL_CHARGE_AMOUNT", javaType=BigDecimal.class, jdbcType=JdbcType.DECIMAL), 62 | @Arg(column="TOTAL_PAY_AMOUNT", javaType=BigDecimal.class, jdbcType=JdbcType.DECIMAL), 63 | @Arg(column="CURRENT_BALANCE", javaType=BigDecimal.class, jdbcType=JdbcType.DECIMAL), 64 | @Arg(column="AGENT_IP_ADDRESS", javaType=String.class, jdbcType=JdbcType.VARCHAR) 65 | }) 66 | List selectByExample(CfgAgentExample example); 67 | 68 | @Select({ 69 | "select", 70 | "AGENT_ID, AGENT_NAME, AGENT_TICKET_TYPE, AGENT_STS, AGENT_CREATE_TIME, PAY_TYPE, ", 71 | "TOTAL_CHARGE_AMOUNT, TOTAL_PAY_AMOUNT, CURRENT_BALANCE, AGENT_IP_ADDRESS", 72 | "from t_cfg_agent", 73 | "where AGENT_ID = #{agentId,jdbcType=BIGINT}" 74 | }) 75 | @ConstructorArgs({ 76 | @Arg(column="AGENT_ID", javaType=Long.class, jdbcType=JdbcType.BIGINT, id=true), 77 | @Arg(column="AGENT_NAME", javaType=String.class, jdbcType=JdbcType.VARCHAR), 78 | @Arg(column="AGENT_TICKET_TYPE", javaType=String.class, jdbcType=JdbcType.CHAR), 79 | @Arg(column="AGENT_STS", javaType=String.class, jdbcType=JdbcType.CHAR), 80 | @Arg(column="AGENT_CREATE_TIME", javaType=String.class, jdbcType=JdbcType.VARCHAR), 81 | @Arg(column="PAY_TYPE", javaType=String.class, jdbcType=JdbcType.VARCHAR), 82 | @Arg(column="TOTAL_CHARGE_AMOUNT", javaType=BigDecimal.class, jdbcType=JdbcType.DECIMAL), 83 | @Arg(column="TOTAL_PAY_AMOUNT", javaType=BigDecimal.class, jdbcType=JdbcType.DECIMAL), 84 | @Arg(column="CURRENT_BALANCE", javaType=BigDecimal.class, jdbcType=JdbcType.DECIMAL), 85 | @Arg(column="AGENT_IP_ADDRESS", javaType=String.class, jdbcType=JdbcType.VARCHAR) 86 | }) 87 | CfgAgent selectByPrimaryKey(Long agentId); 88 | 89 | @UpdateProvider(type=CfgAgentSqlProvider.class, method="updateByExampleSelective") 90 | int updateByExampleSelective(@Param("record") CfgAgent record, @Param("example") CfgAgentExample example); 91 | 92 | @UpdateProvider(type=CfgAgentSqlProvider.class, method="updateByExample") 93 | int updateByExample(@Param("record") CfgAgent record, @Param("example") CfgAgentExample example); 94 | 95 | @UpdateProvider(type=CfgAgentSqlProvider.class, method="updateByPrimaryKeySelective") 96 | int updateByPrimaryKeySelective(CfgAgent record); 97 | 98 | @Update({ 99 | "update t_cfg_agent", 100 | "set AGENT_NAME = #{agentName,jdbcType=VARCHAR},", 101 | "AGENT_TICKET_TYPE = #{agentTicketType,jdbcType=CHAR},", 102 | "AGENT_STS = #{agentSts,jdbcType=CHAR},", 103 | "AGENT_CREATE_TIME = #{agentCreateTime,jdbcType=VARCHAR},", 104 | "PAY_TYPE = #{payType,jdbcType=VARCHAR},", 105 | "TOTAL_CHARGE_AMOUNT = #{totalChargeAmount,jdbcType=DECIMAL},", 106 | "TOTAL_PAY_AMOUNT = #{totalPayAmount,jdbcType=DECIMAL},", 107 | "CURRENT_BALANCE = #{currentBalance,jdbcType=DECIMAL},", 108 | "AGENT_IP_ADDRESS = #{agentIpAddress,jdbcType=VARCHAR}", 109 | "where AGENT_ID = #{agentId,jdbcType=BIGINT}" 110 | }) 111 | int updateByPrimaryKey(CfgAgent record); 112 | } -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/mapper/CfgOfferMapper.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.mapper; 2 | 3 | import com.codido.hodor.core.model.CfgOffer; 4 | import com.codido.hodor.core.model.CfgOfferExample; 5 | import java.util.List; 6 | import org.apache.ibatis.annotations.Arg; 7 | import org.apache.ibatis.annotations.ConstructorArgs; 8 | import org.apache.ibatis.annotations.Delete; 9 | import org.apache.ibatis.annotations.DeleteProvider; 10 | import org.apache.ibatis.annotations.Insert; 11 | import org.apache.ibatis.annotations.InsertProvider; 12 | import org.apache.ibatis.annotations.Options; 13 | import org.apache.ibatis.annotations.Param; 14 | import org.apache.ibatis.annotations.SelectProvider; 15 | import org.apache.ibatis.annotations.UpdateProvider; 16 | import org.apache.ibatis.type.JdbcType; 17 | 18 | public interface CfgOfferMapper { 19 | @SelectProvider(type=CfgOfferSqlProvider.class, method="countByExample") 20 | long countByExample(CfgOfferExample example); 21 | 22 | @DeleteProvider(type=CfgOfferSqlProvider.class, method="deleteByExample") 23 | int deleteByExample(CfgOfferExample example); 24 | 25 | @Delete({ 26 | "delete from t_cfg_offer", 27 | "where OFFER_ID = #{offerId,jdbcType=BIGINT}" 28 | }) 29 | int deleteByPrimaryKey(Long offerId); 30 | 31 | @Insert({ 32 | }) 33 | @Options(useGeneratedKeys=true,keyProperty="offerId") 34 | int insert(CfgOffer record); 35 | 36 | @InsertProvider(type=CfgOfferSqlProvider.class, method="insertSelective") 37 | @Options(useGeneratedKeys=true,keyProperty="offerId") 38 | int insertSelective(CfgOffer record); 39 | 40 | @SelectProvider(type=CfgOfferSqlProvider.class, method="selectByExample") 41 | @ConstructorArgs({ 42 | @Arg(column="OFFER_ID", javaType=Long.class, jdbcType=JdbcType.BIGINT, id=true) 43 | }) 44 | List selectByExample(CfgOfferExample example); 45 | 46 | @UpdateProvider(type=CfgOfferSqlProvider.class, method="updateByExampleSelective") 47 | int updateByExampleSelective(@Param("record") CfgOffer record, @Param("example") CfgOfferExample example); 48 | 49 | @UpdateProvider(type=CfgOfferSqlProvider.class, method="updateByExample") 50 | int updateByExample(@Param("record") CfgOffer record, @Param("example") CfgOfferExample example); 51 | } -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/mapper/PubParamMapper.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.mapper; 2 | 3 | import com.codido.hodor.core.model.PubParam; 4 | import com.codido.hodor.core.model.PubParamExample; 5 | import java.util.List; 6 | import org.apache.ibatis.annotations.Arg; 7 | import org.apache.ibatis.annotations.ConstructorArgs; 8 | import org.apache.ibatis.annotations.Delete; 9 | import org.apache.ibatis.annotations.DeleteProvider; 10 | import org.apache.ibatis.annotations.Insert; 11 | import org.apache.ibatis.annotations.InsertProvider; 12 | import org.apache.ibatis.annotations.Options; 13 | import org.apache.ibatis.annotations.Param; 14 | import org.apache.ibatis.annotations.Select; 15 | import org.apache.ibatis.annotations.SelectProvider; 16 | import org.apache.ibatis.annotations.Update; 17 | import org.apache.ibatis.annotations.UpdateProvider; 18 | import org.apache.ibatis.type.JdbcType; 19 | 20 | public interface PubParamMapper { 21 | @SelectProvider(type=PubParamSqlProvider.class, method="countByExample") 22 | long countByExample(PubParamExample example); 23 | 24 | @DeleteProvider(type=PubParamSqlProvider.class, method="deleteByExample") 25 | int deleteByExample(PubParamExample example); 26 | 27 | @Delete({ 28 | "delete from t_pub_param", 29 | "where PARAM_ID = #{paramId,jdbcType=BIGINT}" 30 | }) 31 | int deleteByPrimaryKey(Long paramId); 32 | 33 | @Insert({ 34 | "insert into t_pub_param (PARAM_NAME, PARAM_KEY, ", 35 | "PARAM_VALUE)", 36 | "values (#{paramName,jdbcType=VARCHAR}, #{paramKey,jdbcType=VARCHAR}, ", 37 | "#{paramValue,jdbcType=VARCHAR})" 38 | }) 39 | @Options(useGeneratedKeys=true,keyProperty="paramId") 40 | int insert(PubParam record); 41 | 42 | @InsertProvider(type=PubParamSqlProvider.class, method="insertSelective") 43 | @Options(useGeneratedKeys=true,keyProperty="paramId") 44 | int insertSelective(PubParam record); 45 | 46 | @SelectProvider(type=PubParamSqlProvider.class, method="selectByExample") 47 | @ConstructorArgs({ 48 | @Arg(column="PARAM_ID", javaType=Long.class, jdbcType=JdbcType.BIGINT, id=true), 49 | @Arg(column="PARAM_NAME", javaType=String.class, jdbcType=JdbcType.VARCHAR), 50 | @Arg(column="PARAM_KEY", javaType=String.class, jdbcType=JdbcType.VARCHAR), 51 | @Arg(column="PARAM_VALUE", javaType=String.class, jdbcType=JdbcType.VARCHAR) 52 | }) 53 | List selectByExample(PubParamExample example); 54 | 55 | @Select({ 56 | "select", 57 | "PARAM_ID, PARAM_NAME, PARAM_KEY, PARAM_VALUE", 58 | "from t_pub_param", 59 | "where PARAM_ID = #{paramId,jdbcType=BIGINT}" 60 | }) 61 | @ConstructorArgs({ 62 | @Arg(column="PARAM_ID", javaType=Long.class, jdbcType=JdbcType.BIGINT, id=true), 63 | @Arg(column="PARAM_NAME", javaType=String.class, jdbcType=JdbcType.VARCHAR), 64 | @Arg(column="PARAM_KEY", javaType=String.class, jdbcType=JdbcType.VARCHAR), 65 | @Arg(column="PARAM_VALUE", javaType=String.class, jdbcType=JdbcType.VARCHAR) 66 | }) 67 | PubParam selectByPrimaryKey(Long paramId); 68 | 69 | @UpdateProvider(type=PubParamSqlProvider.class, method="updateByExampleSelective") 70 | int updateByExampleSelective(@Param("record") PubParam record, @Param("example") PubParamExample example); 71 | 72 | @UpdateProvider(type=PubParamSqlProvider.class, method="updateByExample") 73 | int updateByExample(@Param("record") PubParam record, @Param("example") PubParamExample example); 74 | 75 | @UpdateProvider(type=PubParamSqlProvider.class, method="updateByPrimaryKeySelective") 76 | int updateByPrimaryKeySelective(PubParam record); 77 | 78 | @Update({ 79 | "update t_pub_param", 80 | "set PARAM_NAME = #{paramName,jdbcType=VARCHAR},", 81 | "PARAM_KEY = #{paramKey,jdbcType=VARCHAR},", 82 | "PARAM_VALUE = #{paramValue,jdbcType=VARCHAR}", 83 | "where PARAM_ID = #{paramId,jdbcType=BIGINT}" 84 | }) 85 | int updateByPrimaryKey(PubParam record); 86 | } -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/model/CfgAgent.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.model; 2 | 3 | import java.math.BigDecimal; 4 | 5 | public class CfgAgent { 6 | private Long agentId; 7 | 8 | private String agentName; 9 | 10 | private String agentTicketType; 11 | 12 | private String agentSts; 13 | 14 | private String agentCreateTime; 15 | 16 | private String payType; 17 | 18 | private BigDecimal totalChargeAmount; 19 | 20 | private BigDecimal totalPayAmount; 21 | 22 | private BigDecimal currentBalance; 23 | 24 | private String agentIpAddress; 25 | 26 | public CfgAgent(Long agentId, String agentName, String agentTicketType, String agentSts, String agentCreateTime, String payType, BigDecimal totalChargeAmount, BigDecimal totalPayAmount, BigDecimal currentBalance, String agentIpAddress) { 27 | this.agentId = agentId; 28 | this.agentName = agentName; 29 | this.agentTicketType = agentTicketType; 30 | this.agentSts = agentSts; 31 | this.agentCreateTime = agentCreateTime; 32 | this.payType = payType; 33 | this.totalChargeAmount = totalChargeAmount; 34 | this.totalPayAmount = totalPayAmount; 35 | this.currentBalance = currentBalance; 36 | this.agentIpAddress = agentIpAddress; 37 | } 38 | 39 | public CfgAgent() { 40 | super(); 41 | } 42 | 43 | public Long getAgentId() { 44 | return agentId; 45 | } 46 | 47 | public void setAgentId(Long agentId) { 48 | this.agentId = agentId; 49 | } 50 | 51 | public String getAgentName() { 52 | return agentName; 53 | } 54 | 55 | public void setAgentName(String agentName) { 56 | this.agentName = agentName == null ? null : agentName.trim(); 57 | } 58 | 59 | public String getAgentTicketType() { 60 | return agentTicketType; 61 | } 62 | 63 | public void setAgentTicketType(String agentTicketType) { 64 | this.agentTicketType = agentTicketType == null ? null : agentTicketType.trim(); 65 | } 66 | 67 | public String getAgentSts() { 68 | return agentSts; 69 | } 70 | 71 | public void setAgentSts(String agentSts) { 72 | this.agentSts = agentSts == null ? null : agentSts.trim(); 73 | } 74 | 75 | public String getAgentCreateTime() { 76 | return agentCreateTime; 77 | } 78 | 79 | public void setAgentCreateTime(String agentCreateTime) { 80 | this.agentCreateTime = agentCreateTime == null ? null : agentCreateTime.trim(); 81 | } 82 | 83 | public String getPayType() { 84 | return payType; 85 | } 86 | 87 | public void setPayType(String payType) { 88 | this.payType = payType == null ? null : payType.trim(); 89 | } 90 | 91 | public BigDecimal getTotalChargeAmount() { 92 | return totalChargeAmount; 93 | } 94 | 95 | public void setTotalChargeAmount(BigDecimal totalChargeAmount) { 96 | this.totalChargeAmount = totalChargeAmount; 97 | } 98 | 99 | public BigDecimal getTotalPayAmount() { 100 | return totalPayAmount; 101 | } 102 | 103 | public void setTotalPayAmount(BigDecimal totalPayAmount) { 104 | this.totalPayAmount = totalPayAmount; 105 | } 106 | 107 | public BigDecimal getCurrentBalance() { 108 | return currentBalance; 109 | } 110 | 111 | public void setCurrentBalance(BigDecimal currentBalance) { 112 | this.currentBalance = currentBalance; 113 | } 114 | 115 | public String getAgentIpAddress() { 116 | return agentIpAddress; 117 | } 118 | 119 | public void setAgentIpAddress(String agentIpAddress) { 120 | this.agentIpAddress = agentIpAddress == null ? null : agentIpAddress.trim(); 121 | } 122 | } -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/model/CfgChannel.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.model; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | 6 | public class CfgChannel { 7 | private Long channelId; 8 | 9 | private String channelName; 10 | 11 | private String channelSts; 12 | 13 | private String channelType; 14 | 15 | private Date channelCreateTime; 16 | 17 | private BigDecimal channelRechargeAmount; 18 | 19 | private BigDecimal channelPayAmount; 20 | 21 | private BigDecimal channelCurrentBalance; 22 | 23 | private String channelInterfaceStyle; 24 | 25 | private String orderActionUrl; 26 | 27 | private String orderQueryUrl; 28 | 29 | public CfgChannel(Long channelId, String channelName, String channelSts, String channelType, Date channelCreateTime, BigDecimal channelRechargeAmount, BigDecimal channelPayAmount, BigDecimal channelCurrentBalance, String channelInterfaceStyle, String orderActionUrl, String orderQueryUrl) { 30 | this.channelId = channelId; 31 | this.channelName = channelName; 32 | this.channelSts = channelSts; 33 | this.channelType = channelType; 34 | this.channelCreateTime = channelCreateTime; 35 | this.channelRechargeAmount = channelRechargeAmount; 36 | this.channelPayAmount = channelPayAmount; 37 | this.channelCurrentBalance = channelCurrentBalance; 38 | this.channelInterfaceStyle = channelInterfaceStyle; 39 | this.orderActionUrl = orderActionUrl; 40 | this.orderQueryUrl = orderQueryUrl; 41 | } 42 | 43 | public CfgChannel() { 44 | super(); 45 | } 46 | 47 | public Long getChannelId() { 48 | return channelId; 49 | } 50 | 51 | public void setChannelId(Long channelId) { 52 | this.channelId = channelId; 53 | } 54 | 55 | public String getChannelName() { 56 | return channelName; 57 | } 58 | 59 | public void setChannelName(String channelName) { 60 | this.channelName = channelName == null ? null : channelName.trim(); 61 | } 62 | 63 | public String getChannelSts() { 64 | return channelSts; 65 | } 66 | 67 | public void setChannelSts(String channelSts) { 68 | this.channelSts = channelSts == null ? null : channelSts.trim(); 69 | } 70 | 71 | public String getChannelType() { 72 | return channelType; 73 | } 74 | 75 | public void setChannelType(String channelType) { 76 | this.channelType = channelType == null ? null : channelType.trim(); 77 | } 78 | 79 | public Date getChannelCreateTime() { 80 | return channelCreateTime; 81 | } 82 | 83 | public void setChannelCreateTime(Date channelCreateTime) { 84 | this.channelCreateTime = channelCreateTime; 85 | } 86 | 87 | public BigDecimal getChannelRechargeAmount() { 88 | return channelRechargeAmount; 89 | } 90 | 91 | public void setChannelRechargeAmount(BigDecimal channelRechargeAmount) { 92 | this.channelRechargeAmount = channelRechargeAmount; 93 | } 94 | 95 | public BigDecimal getChannelPayAmount() { 96 | return channelPayAmount; 97 | } 98 | 99 | public void setChannelPayAmount(BigDecimal channelPayAmount) { 100 | this.channelPayAmount = channelPayAmount; 101 | } 102 | 103 | public BigDecimal getChannelCurrentBalance() { 104 | return channelCurrentBalance; 105 | } 106 | 107 | public void setChannelCurrentBalance(BigDecimal channelCurrentBalance) { 108 | this.channelCurrentBalance = channelCurrentBalance; 109 | } 110 | 111 | public String getChannelInterfaceStyle() { 112 | return channelInterfaceStyle; 113 | } 114 | 115 | public void setChannelInterfaceStyle(String channelInterfaceStyle) { 116 | this.channelInterfaceStyle = channelInterfaceStyle == null ? null : channelInterfaceStyle.trim(); 117 | } 118 | 119 | public String getOrderActionUrl() { 120 | return orderActionUrl; 121 | } 122 | 123 | public void setOrderActionUrl(String orderActionUrl) { 124 | this.orderActionUrl = orderActionUrl == null ? null : orderActionUrl.trim(); 125 | } 126 | 127 | public String getOrderQueryUrl() { 128 | return orderQueryUrl; 129 | } 130 | 131 | public void setOrderQueryUrl(String orderQueryUrl) { 132 | this.orderQueryUrl = orderQueryUrl == null ? null : orderQueryUrl.trim(); 133 | } 134 | } -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/model/CfgOffer.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.model; 2 | 3 | public class CfgOffer { 4 | private Long offerId; 5 | 6 | public CfgOffer(Long offerId) { 7 | this.offerId = offerId; 8 | } 9 | 10 | public CfgOffer() { 11 | super(); 12 | } 13 | 14 | public Long getOfferId() { 15 | return offerId; 16 | } 17 | 18 | public void setOfferId(Long offerId) { 19 | this.offerId = offerId; 20 | } 21 | } -------------------------------------------------------------------------------- /Hodor-core/src/main/java/com/codido/hodor/core/model/PubParam.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.core.model; 2 | 3 | public class PubParam { 4 | private Long paramId; 5 | 6 | private String paramName; 7 | 8 | private String paramKey; 9 | 10 | private String paramValue; 11 | 12 | public PubParam(Long paramId, String paramName, String paramKey, String paramValue) { 13 | this.paramId = paramId; 14 | this.paramName = paramName; 15 | this.paramKey = paramKey; 16 | this.paramValue = paramValue; 17 | } 18 | 19 | public PubParam() { 20 | super(); 21 | } 22 | 23 | public Long getParamId() { 24 | return paramId; 25 | } 26 | 27 | public void setParamId(Long paramId) { 28 | this.paramId = paramId; 29 | } 30 | 31 | public String getParamName() { 32 | return paramName; 33 | } 34 | 35 | public void setParamName(String paramName) { 36 | this.paramName = paramName == null ? null : paramName.trim(); 37 | } 38 | 39 | public String getParamKey() { 40 | return paramKey; 41 | } 42 | 43 | public void setParamKey(String paramKey) { 44 | this.paramKey = paramKey == null ? null : paramKey.trim(); 45 | } 46 | 47 | public String getParamValue() { 48 | return paramValue; 49 | } 50 | 51 | public void setParamValue(String paramValue) { 52 | this.paramValue = paramValue == null ? null : paramValue.trim(); 53 | } 54 | } -------------------------------------------------------------------------------- /Hodor-core/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | mybatis.type-aliases-package=com.codido.hodor.core.model 2 | 3 | spring.datasource.url=jdbc:mysql://111.111.111.111:3306/hodor?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false 4 | spring.datasource.username=hodor_adm 5 | spring.datasource.password=888888888 6 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver -------------------------------------------------------------------------------- /Hodor-core/src/main/resources/tools/NeedleGeneratorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 | 30 | 34 | 35 | 43 | 44 | 45 | 46 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 81 | 83 | 84 | 85 | 86 | 87 | 92 | 93 | 94 | 95 | 96 |
97 | 98 | 99 | 100 | 101 |
102 | 103 | 104 | 105 | 106 |
107 | 108 | 109 | 110 | 111 |
112 |
113 | 114 |
-------------------------------------------------------------------------------- /Hodor-job/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.2.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | group 'com.codido' 14 | version '1.0-SNAPSHOT' 15 | 16 | 17 | apply plugin: 'java' 18 | //apply plugin: 'war' 19 | apply plugin: 'org.springframework.boot' 20 | apply plugin: 'io.spring.dependency-management' 21 | 22 | sourceCompatibility = 1.8 23 | 24 | repositories { 25 | mavenCentral() 26 | } 27 | 28 | //排除tomcat配置 29 | configurations { 30 | compile.exclude module: "spring-boot-starter-tomcat" 31 | } 32 | 33 | dependencies { 34 | implementation project(':Hodor-core') 35 | 36 | implementation('org.springframework.boot:spring-boot-starter-web') 37 | implementation("org.springframework.boot:spring-boot-starter-jetty:1.4.1.RELEASE") 38 | implementation('org.springframework.boot:spring-boot-configuration-processor') 39 | implementation('org.springframework.boot:spring-boot-starter-aop') 40 | implementation('org.springframework.boot:spring-boot-starter-data-redis') 41 | 42 | implementation('org.mybatis.spring.boot:mybatis-spring-boot-starter:2.0.0') 43 | runtimeOnly('mysql:mysql-connector-java') 44 | implementation('com.alibaba:druid:1.1.10') 45 | 46 | implementation('com.alibaba:fastjson:1.2.12') 47 | implementation('org.codehaus.jackson:jackson-core-asl:1.9.13') 48 | implementation('com.google.code.gson:gson:2.8.2') 49 | 50 | //implementation('com.github.binarywang:weixin-java-mp:2.9.0') 51 | //implementation('com.github.binarywang:weixin-java-pay:2.9.0') 52 | implementation('com.github.binarywang:wx-java-mp-spring-boot-starter:3.7.0') 53 | implementation('com.github.binarywang:weixin-java-mp:3.7.0') 54 | 55 | implementation("org.apache.commons:commons-lang3:3.4") 56 | implementation("org.apache.httpcomponents:httpcore:4.4.8") 57 | implementation("org.apache.httpcomponents:httpclient:4.5.4") 58 | implementation("org.apache.httpcomponents:httpmime:4.5.4") 59 | implementation("com.thoughtworks.xstream:xstream:1.4.9") 60 | 61 | annotationProcessor 'org.projectlombok:lombok:1.18.2' 62 | compileOnly 'org.projectlombok:lombok:1.18.2' 63 | 64 | testImplementation('org.springframework.boot:spring-boot-starter-test') 65 | } 66 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/JobApplication.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.scheduling.annotation.EnableScheduling; 7 | 8 | @SpringBootApplication 9 | @EnableScheduling 10 | @MapperScan("com.codido.hodor.core.mapper") 11 | public class JobApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(JobApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/bean/vo/WxPushReq.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.bean.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.LinkedList; 7 | 8 | /** 9 | * @Author: BigStrong 10 | * @Date: 2020/3/1 下午8:02 11 | * 微信推送请求对象 12 | */ 13 | @Data 14 | public class WxPushReq implements Serializable { 15 | /** 16 | * 模版编号 17 | */ 18 | private String tmId; 19 | /** 20 | * 用户OPEN_ID 21 | */ 22 | private String openId; 23 | /** 24 | * 跳转H5链接 25 | */ 26 | private String url; 27 | /** 28 | * 必须按顺序存储,依次为first,keyword1...keywordn,remark 29 | */ 30 | private LinkedList parmList; 31 | /** 32 | * 小程序APPID 33 | */ 34 | private String appid; 35 | /** 36 | * 小程序路径 37 | */ 38 | private String pagepath; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/job/bean/dto/BaseRetDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.job.bean.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 返回DTO基类 10 | */ 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | public class BaseRetDto implements Serializable { 14 | 15 | /** 16 | * 处理结果 17 | */ 18 | private boolean handlerResult; 19 | 20 | /** 21 | * 处理结果消息 22 | */ 23 | private String handlerMsg; 24 | } 25 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/job/bean/dto/SendOrderChooseDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.job.bean.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 传送给终端后台的选号对象 10 | */ 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | public class SendOrderChooseDto implements Serializable { 14 | 15 | /** 16 | * 选择的号码字串,同区号码已空格分隔,不同区之间以:分隔 17 | */ 18 | private String chooseNumberStr; 19 | } 20 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/job/bean/dto/SendOrderDetailDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.job.bean.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | import java.io.Serializable; 7 | import java.util.List; 8 | 9 | /** 10 | * 传送给终端后台的订单对象 11 | */ 12 | @Data 13 | @EqualsAndHashCode(callSuper = false) 14 | public class SendOrderDetailDto implements Serializable { 15 | 16 | private String betTimes; 17 | 18 | private String lotteryId; 19 | 20 | private String lotteryPeriod; 21 | 22 | private List chooseList; 23 | } 24 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/job/bean/dto/SendOrderToTerminalRequestDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.job.bean.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 传送订单信息到终端后台的通讯接口请求对象 10 | */ 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | public class SendOrderToTerminalRequestDto implements Serializable { 14 | 15 | /** 16 | * 订单号 17 | */ 18 | private String orderNo; 19 | 20 | /** 21 | * 订单对象 22 | */ 23 | private SendOrderDetailDto orderDetail; 24 | } 25 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/job/bean/dto/SendOrderToTerminalResponseDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.job.bean.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 传送订单信息到终端后台的通讯接口响应对象 10 | */ 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | public class SendOrderToTerminalResponseDto implements Serializable { 14 | 15 | 16 | /** 17 | * 响应编码 18 | */ 19 | private Integer resultCode; 20 | 21 | /** 22 | * 错误码 23 | */ 24 | private String errMsg; 25 | 26 | 27 | /** 28 | * 二维码url 29 | */ 30 | private String content; 31 | } 32 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/job/bean/dto/SendOrderToTerminalRetDto.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.job.bean.dto; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | 7 | /** 8 | * 传送订单信息到终端后台的响应对象 9 | */ 10 | @Data 11 | @EqualsAndHashCode(callSuper = false) 12 | public class SendOrderToTerminalRetDto extends BaseRetDto { 13 | 14 | /** 15 | * 图片地址 16 | */ 17 | private String orderTicketUrl; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/job/config/EvnConfig.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.job.config; 2 | 3 | 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | /** 10 | * 环境参数 11 | */ 12 | @Data 13 | @EqualsAndHashCode(callSuper = false) 14 | @Configuration 15 | public class EvnConfig { 16 | 17 | @Value("${spring.profiles.active}") 18 | private String evn; 19 | 20 | @Value("${basecontext.urlpath.requestpath}") 21 | private String urlRequestContext; 22 | } 23 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/job/config/ScheduleConfig.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.job.config; 2 | 3 | import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; 4 | import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.scheduling.TaskScheduler; 8 | import org.springframework.scheduling.annotation.AsyncConfigurer; 9 | import org.springframework.scheduling.annotation.EnableScheduling; 10 | import org.springframework.scheduling.annotation.SchedulingConfigurer; 11 | import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; 12 | import org.springframework.scheduling.config.ScheduledTaskRegistrar; 13 | 14 | import java.util.concurrent.Executor; 15 | 16 | /** 17 | * 任务配置文件 18 | */ 19 | @Configuration 20 | @EnableScheduling 21 | public class ScheduleConfig implements SchedulingConfigurer, AsyncConfigurer { 22 | 23 | /** 24 | * 并行任务 25 | */ 26 | public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { 27 | TaskScheduler taskScheduler = taskScheduler(); 28 | taskRegistrar.setTaskScheduler(taskScheduler); 29 | } 30 | 31 | /** 32 | * 并行任务使用策略:多线程处理 33 | * 34 | * @return ThreadPoolTaskScheduler 线程池 35 | */ 36 | @Bean(destroyMethod = "shutdown") 37 | public ThreadPoolTaskScheduler taskScheduler() { 38 | ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); 39 | scheduler.setPoolSize(20); 40 | scheduler.setThreadNamePrefix("task-"); 41 | scheduler.setAwaitTerminationSeconds(60); 42 | scheduler.setWaitForTasksToCompleteOnShutdown(true); 43 | return scheduler; 44 | } 45 | 46 | /** 47 | * 异步任务 48 | */ 49 | public Executor getAsyncExecutor() { 50 | Executor executor = taskScheduler(); 51 | return executor; 52 | } 53 | 54 | /** 55 | * 异步任务 异常处理 56 | */ 57 | public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { 58 | return new SimpleAsyncUncaughtExceptionHandler(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/job/scheduling/SubIntScheduling.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.job.scheduling; 2 | 3 | import com.codido.hodor.job.job.bean.dto.BaseRetDto; 4 | import com.codido.hodor.core.common.util.JBDateUtil; 5 | import com.codido.hodor.core.common.util.JBUtil; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.scheduling.annotation.Scheduled; 10 | import org.springframework.stereotype.Component; 11 | import org.springframework.util.CollectionUtils; 12 | 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | /** 17 | * 处理用户的订阅实例的定时任务 18 | * cron表达式格式: 19 | * 1.Seconds Minutes Hours DayofMonth Month DayofWeek Year 20 | * 2.Seconds Minutes Hours DayofMonth Month DayofWeek 21 | * 顺序: 22 | * 秒(0~59) 23 | * 分钟(0~59) 24 | * 小时(0~23) 25 | * 天(月)(0~31,但是你需要考虑你月的天数) 26 | * 月(0~11) 27 | * 天(星期)(1~7 1=SUN 或 SUN,MON,TUE,WED,THU,FRI,SAT) 28 | * 年份(1970-2099) 29 | *

30 | * 注:其中每个元素可以是一个值(如6),一个连续区间(9-12),一个间隔时间(8-18/4)(/表示每隔4小时),一个列表(1,3,5),通配符。 31 | * 由于"月份中的日期"和"星期中的日期"这两个元素互斥的,必须要对其中一个设置?. 32 | */ 33 | @Component 34 | public class SubIntScheduling { 35 | 36 | /** 37 | * 日志 38 | */ 39 | private static Logger logger = LoggerFactory.getLogger(SubIntScheduling.class); 40 | 41 | 42 | 43 | /** 44 | * 生成自动续费订单轮训 45 | * 每天0点0分30秒执行 46 | */ 47 | @Scheduled(cron = "30 0 0 * * ?") 48 | public void dealUserSubInstScheduling() { 49 | logger.info("生成自动续费订单轮训启动"); 50 | 51 | logger.info("生成自动续费订单轮训结束"); 52 | } 53 | 54 | /** 55 | * 用户即将过期推送 56 | * 推送时间:每天 12 点进行 57 | * 推送前提:3天后要到期的订阅 58 | * t_user_openid -> MICROAPP_YOUSHU 59 | */ 60 | @Scheduled(cron = "0 0 12 * * ?") 61 | public void experidSubListMpPush() { 62 | logger.info("用户即将过期推送开始"); 63 | 64 | logger.info("用户即将过期推送结束"); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/scb/service/SendMessageService.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.scb.service; 2 | 3 | import com.codido.hodor.job.job.config.EvnConfig; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * 发送微信消息的service 10 | */ 11 | @Slf4j 12 | @Service 13 | public class SendMessageService { 14 | 15 | /** 16 | * 环境信息 17 | */ 18 | @Autowired 19 | private EvnConfig evnConfig; 20 | 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/bean/dto/AccessTokenVo.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.bean.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * accesstoken的信息 7 | * Created by bpascal on 2017/6/19. 8 | */ 9 | public class AccessTokenVo implements Serializable { 10 | 11 | // 接口访问凭证 12 | private String accessToken; 13 | // 凭证有效期,单位:秒 14 | private int expiresIn; 15 | 16 | public String getAccessToken() { 17 | return accessToken; 18 | } 19 | 20 | public void setAccessToken(String accessToken) { 21 | this.accessToken = accessToken; 22 | } 23 | 24 | public int getExpiresIn() { 25 | return expiresIn; 26 | } 27 | 28 | public void setExpiresIn(int expiresIn) { 29 | this.expiresIn = expiresIn; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "AccessTokenVo{" + 35 | "accessToken='" + accessToken + '\'' + 36 | ", expiresIn=" + expiresIn + 37 | '}'; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/bean/dto/SNSUserInfo.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.bean.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** 7 | * 通过网页授权获取的用户信息 8 | * Created by bpascal on 2017/4/28. 9 | */ 10 | public class SNSUserInfo implements Serializable { 11 | 12 | // 用户标识 13 | private String openId; 14 | // 用户昵称 15 | private String nickname; 16 | // 性别(1是男性,2是女性,0是未知) 17 | private int sex; 18 | // 国家 19 | private String country; 20 | // 省份 21 | private String province; 22 | // 城市 23 | private String city; 24 | // 用户头像链接 25 | private String headImgUrl; 26 | 27 | //绑定公众号的unionid 28 | private String unionid; 29 | // 用户特权信息 30 | private List privilegeList; 31 | 32 | public String getOpenId() { 33 | return openId; 34 | } 35 | 36 | public void setOpenId(String openId) { 37 | this.openId = openId; 38 | } 39 | 40 | public String getNickname() { 41 | return nickname; 42 | } 43 | 44 | public void setNickname(String nickname) { 45 | this.nickname = nickname; 46 | } 47 | 48 | public int getSex() { 49 | return sex; 50 | } 51 | 52 | public void setSex(int sex) { 53 | this.sex = sex; 54 | } 55 | 56 | public String getCountry() { 57 | return country; 58 | } 59 | 60 | public void setCountry(String country) { 61 | this.country = country; 62 | } 63 | 64 | public String getProvince() { 65 | return province; 66 | } 67 | 68 | public void setProvince(String province) { 69 | this.province = province; 70 | } 71 | 72 | public String getCity() { 73 | return city; 74 | } 75 | 76 | public void setCity(String city) { 77 | this.city = city; 78 | } 79 | 80 | public String getHeadImgUrl() { 81 | return headImgUrl; 82 | } 83 | 84 | public void setHeadImgUrl(String headImgUrl) { 85 | this.headImgUrl = headImgUrl; 86 | } 87 | 88 | public String getUnionid() { 89 | return unionid; 90 | } 91 | 92 | public void setUnionid(String unionid) { 93 | this.unionid = unionid; 94 | } 95 | 96 | public List getPrivilegeList() { 97 | return privilegeList; 98 | } 99 | 100 | public void setPrivilegeList(List privilegeList) { 101 | this.privilegeList = privilegeList; 102 | } 103 | 104 | @Override 105 | public String toString() { 106 | return "SNSUserInfo{" + 107 | "openId='" + openId + '\'' + 108 | ", nickname='" + nickname + '\'' + 109 | ", sex=" + sex + 110 | ", country='" + country + '\'' + 111 | ", province='" + province + '\'' + 112 | ", city='" + city + '\'' + 113 | ", headImgUrl='" + headImgUrl + '\'' + 114 | ", unionid='" + unionid + '\'' + 115 | ", privilegeList=" + privilegeList + 116 | '}'; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/bean/dto/Token.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.bean.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 凭证实体类 7 | * Created by bpascal on 2017/4/28. 8 | */ 9 | public class Token implements Serializable { 10 | 11 | // 接口访问凭证 12 | private String accessToken; 13 | // 凭证有效期,单位:秒 14 | private int expiresIn; 15 | 16 | public String getAccessToken() { 17 | return accessToken; 18 | } 19 | 20 | public void setAccessToken(String accessToken) { 21 | this.accessToken = accessToken; 22 | } 23 | 24 | public int getExpiresIn() { 25 | return expiresIn; 26 | } 27 | 28 | public void setExpiresIn(int expiresIn) { 29 | this.expiresIn = expiresIn; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "Token{" + 35 | "accessToken='" + accessToken + '\'' + 36 | ", expiresIn=" + expiresIn + 37 | '}'; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/bean/dto/WeixinOauth2Token.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.bean.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 网页授权信息 7 | * Created by bpascal on 2017/4/28. 8 | */ 9 | public class WeixinOauth2Token implements Serializable { 10 | 11 | // 网页授权接口调用凭证 12 | private String accessToken; 13 | // 凭证有效时长 14 | private int expiresIn; 15 | // 用于刷新凭证 16 | private String refreshToken; 17 | // 用户标识 18 | private String openId; 19 | // 用户授权作用域 20 | private String scope; 21 | 22 | public String getAccessToken() { 23 | return accessToken; 24 | } 25 | 26 | public void setAccessToken(String accessToken) { 27 | this.accessToken = accessToken; 28 | } 29 | 30 | public int getExpiresIn() { 31 | return expiresIn; 32 | } 33 | 34 | public void setExpiresIn(int expiresIn) { 35 | this.expiresIn = expiresIn; 36 | } 37 | 38 | public String getRefreshToken() { 39 | return refreshToken; 40 | } 41 | 42 | public void setRefreshToken(String refreshToken) { 43 | this.refreshToken = refreshToken; 44 | } 45 | 46 | public String getOpenId() { 47 | return openId; 48 | } 49 | 50 | public void setOpenId(String openId) { 51 | this.openId = openId; 52 | } 53 | 54 | public String getScope() { 55 | return scope; 56 | } 57 | 58 | public void setScope(String scope) { 59 | this.scope = scope; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return "WeixinOauth2Token{" + 65 | "accessToken='" + accessToken + '\'' + 66 | ", expiresIn=" + expiresIn + 67 | ", refreshToken='" + refreshToken + '\'' + 68 | ", openId='" + openId + '\'' + 69 | ", scope='" + scope + '\'' + 70 | '}'; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/bean/dto/WeixinUserInfo.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.bean.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 微信用户的基本信息 7 | * Created by bpascal on 2017/4/28. 8 | */ 9 | public class WeixinUserInfo implements Serializable { 10 | 11 | // 用户的标识 12 | private String openId; 13 | // 关注状态(1是关注,0是未关注),未关注时获取不到其余信息 14 | private int subscribe; 15 | // 用户关注时间,为时间戳。如果用户曾多次关注,则取最后关注时间 16 | private String subscribeTime; 17 | // 昵称 18 | private String nickname; 19 | // 用户的性别(1是男性,2是女性,0是未知) 20 | private int sex; 21 | // 用户所在国家 22 | private String country; 23 | // 用户所在省份 24 | private String province; 25 | // 用户所在城市 26 | private String city; 27 | // 用户的语言,简体中文为zh_CN 28 | private String language; 29 | // 用户头像 30 | private String headImgUrl; 31 | 32 | public String getOpenId() { 33 | return openId; 34 | } 35 | 36 | public void setOpenId(String openId) { 37 | this.openId = openId; 38 | } 39 | 40 | public int getSubscribe() { 41 | return subscribe; 42 | } 43 | 44 | public void setSubscribe(int subscribe) { 45 | this.subscribe = subscribe; 46 | } 47 | 48 | public String getSubscribeTime() { 49 | return subscribeTime; 50 | } 51 | 52 | public void setSubscribeTime(String subscribeTime) { 53 | this.subscribeTime = subscribeTime; 54 | } 55 | 56 | public String getNickname() { 57 | return nickname; 58 | } 59 | 60 | public void setNickname(String nickname) { 61 | this.nickname = nickname; 62 | } 63 | 64 | public int getSex() { 65 | return sex; 66 | } 67 | 68 | public void setSex(int sex) { 69 | this.sex = sex; 70 | } 71 | 72 | public String getCountry() { 73 | return country; 74 | } 75 | 76 | public void setCountry(String country) { 77 | this.country = country; 78 | } 79 | 80 | public String getProvince() { 81 | return province; 82 | } 83 | 84 | public void setProvince(String province) { 85 | this.province = province; 86 | } 87 | 88 | public String getCity() { 89 | return city; 90 | } 91 | 92 | public void setCity(String city) { 93 | this.city = city; 94 | } 95 | 96 | public String getLanguage() { 97 | return language; 98 | } 99 | 100 | public void setLanguage(String language) { 101 | this.language = language; 102 | } 103 | 104 | public String getHeadImgUrl() { 105 | return headImgUrl; 106 | } 107 | 108 | public void setHeadImgUrl(String headImgUrl) { 109 | this.headImgUrl = headImgUrl; 110 | } 111 | 112 | @Override 113 | public String toString() { 114 | return "WeixinUserInfo{" + 115 | "openId='" + openId + '\'' + 116 | ", subscribe=" + subscribe + 117 | ", subscribeTime='" + subscribeTime + '\'' + 118 | ", nickname='" + nickname + '\'' + 119 | ", sex=" + sex + 120 | ", country='" + country + '\'' + 121 | ", province='" + province + '\'' + 122 | ", city='" + city + '\'' + 123 | ", language='" + language + '\'' + 124 | ", headImgUrl='" + headImgUrl + '\'' + 125 | '}'; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/builder/AbstractBuilder.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.builder; 2 | 3 | import me.chanjar.weixin.mp.api.WxMpService; 4 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 5 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | /** 10 | * @author Binary Wang(https://github.com/binarywang) 11 | */ 12 | public abstract class AbstractBuilder { 13 | protected final Logger logger = LoggerFactory.getLogger(getClass()); 14 | 15 | public abstract WxMpXmlOutMessage build(String content, 16 | WxMpXmlMessage wxMessage, WxMpService service); 17 | } 18 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/builder/ImageBuilder.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.builder; 2 | 3 | import me.chanjar.weixin.mp.api.WxMpService; 4 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 5 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutImageMessage; 6 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 7 | 8 | /** 9 | * @author Binary Wang(https://github.com/binarywang) 10 | */ 11 | public class ImageBuilder extends AbstractBuilder { 12 | 13 | @Override 14 | public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, 15 | WxMpService service) { 16 | 17 | WxMpXmlOutImageMessage m = WxMpXmlOutMessage.IMAGE().mediaId(content) 18 | .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) 19 | .build(); 20 | 21 | return m; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/builder/TextBuilder.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.builder; 2 | 3 | import me.chanjar.weixin.mp.api.WxMpService; 4 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 5 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 6 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutTextMessage; 7 | 8 | /** 9 | * @author Binary Wang(https://github.com/binarywang) 10 | */ 11 | public class TextBuilder extends AbstractBuilder { 12 | 13 | @Override 14 | public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, 15 | WxMpService service) { 16 | WxMpXmlOutTextMessage m = WxMpXmlOutMessage.TEXT().content(content) 17 | .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) 18 | .build(); 19 | return m; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/config/WxAccountEnum.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.config; 2 | 3 | /** 4 | * 公众号标识的枚举类 5 | * 6 | * @author Binary Wang 7 | */ 8 | public enum WxAccountEnum { 9 | CSD(1, "彩士多"), 10 | ZDJL(2, "中大奖了"); 11 | 12 | private int pubid; 13 | private String name; 14 | 15 | private WxAccountEnum(int pubid, String name) { 16 | this.name = name; 17 | this.pubid = pubid; 18 | } 19 | 20 | public static int queryPubid(String wxCode) { 21 | return WxAccountEnum.valueOf(wxCode.toUpperCase()).getPubid(); 22 | } 23 | 24 | public static String queryWxCode(int pubid) { 25 | for (WxAccountEnum e : values()) { 26 | if (e.getPubid() == pubid) { 27 | return e.name().toLowerCase(); 28 | } 29 | } 30 | 31 | return null; 32 | } 33 | 34 | public int getPubid() { 35 | return this.pubid; 36 | } 37 | 38 | public String getName() { 39 | return this.name; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/config/WxConfig.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.config; 2 | 3 | /** 4 | * 微信配置的抽象实现类 5 | * 6 | * @author Binary Wang 7 | */ 8 | public abstract class WxConfig { 9 | public abstract String getToken(); 10 | 11 | public abstract String getAppid(); 12 | 13 | public abstract String getAppsecret(); 14 | 15 | public abstract String getAesKey(); 16 | 17 | public abstract WxAccountEnum getWxAccountEnum(); 18 | 19 | public int getPubId() { 20 | return getWxAccountEnum().getPubid(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/handler/AbstractHandler.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.handler; 2 | 3 | import me.chanjar.weixin.mp.api.WxMpMessageHandler; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | /** 8 | * @author Binary Wang(https://github.com/binarywang) 9 | */ 10 | public abstract class AbstractHandler implements WxMpMessageHandler { 11 | protected Logger logger = LoggerFactory.getLogger(getClass()); 12 | } 13 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/handler/LogHandler.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.handler; 2 | 3 | import com.codido.hodor.job.weixin.util.JsonUtils; 4 | import me.chanjar.weixin.common.session.WxSessionManager; 5 | import me.chanjar.weixin.mp.api.WxMpService; 6 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 7 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * @author Binary Wang(https://github.com/binarywang) 14 | */ 15 | @Component 16 | public class LogHandler extends AbstractHandler { 17 | @Override 18 | public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, 19 | Map context, WxMpService wxMpService, 20 | WxSessionManager sessionManager) { 21 | this.logger.info("\n接收到请求消息,内容:{}", JsonUtils.toJson(wxMessage)); 22 | return null; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/handler/MenuHandler.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.handler; 2 | 3 | import me.chanjar.weixin.common.session.WxSessionManager; 4 | import me.chanjar.weixin.mp.api.WxMpService; 5 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 6 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.Map; 10 | 11 | import static me.chanjar.weixin.common.api.WxConsts.MenuButtonType; 12 | 13 | /** 14 | * @author Binary Wang(https://github.com/binarywang) 15 | */ 16 | @Component 17 | public class MenuHandler extends AbstractHandler { 18 | 19 | @Override 20 | public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, WxMpService weixinService, WxSessionManager sessionManager) { 21 | String msg = null; 22 | if ("KEY_CUSTOMER_SERVICE".equals(wxMessage.getEventKey())) { 23 | msg ="有问题想咨询?您只需要点击屏幕最下方左侧的“小键盘图标”,在对话框中直接输入文字或表情就可以和客服聊天了~"; 24 | }else{ 25 | msg = String.format("type:%s, event:%s, key:%s", wxMessage.getMsgType(), wxMessage.getEvent(), wxMessage.getEventKey()); 26 | } 27 | if (MenuButtonType.VIEW.equals(wxMessage.getEvent())) { 28 | return null; 29 | } 30 | 31 | logger.info("菜单消息:" + wxMessage.toString()); 32 | return WxMpXmlOutMessage.TEXT().content(msg).fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).build(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/handler/MsgHandler.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.handler; 2 | 3 | import com.codido.hodor.job.weixin.util.JsonUtils; 4 | import me.chanjar.weixin.common.session.WxSessionManager; 5 | import me.chanjar.weixin.mp.api.WxMpService; 6 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 7 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * @author Binary Wang(https://github.com/binarywang) 14 | */ 15 | @Component 16 | public class MsgHandler extends AbstractHandler { 17 | 18 | 19 | @Override 20 | public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, WxMpService weixinService, WxSessionManager sessionManager) { 21 | logger.info("收到信息内容:" + JsonUtils.toJson(wxMessage)); 22 | //当用户输入关键词如“你好”,“客服”等,并且有客服在线时,把消息转发给在线客服 23 | // try { 24 | // if (weixinService.getKefuService().kfOnlineList().getKfOnlineList().size() > 0) { 25 | // return WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).build(); 26 | // } 27 | // } catch (WxErrorException e) { 28 | // e.printStackTrace(); 29 | // } 30 | return WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).build(); 31 | //String content = "收到信息内容:" + JsonUtils.toJson(wxMessage); 32 | //return new TextBuilder().build(content, wxMessage, weixinService); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/service/BaseWxService.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.service; 2 | 3 | import com.codido.hodor.job.weixin.config.WxConfig; 4 | import com.codido.hodor.job.weixin.handler.LogHandler; 5 | import me.chanjar.weixin.mp.api.WxMpMessageRouter; 6 | import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; 7 | import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfOnlineList; 8 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 9 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 10 | import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; 11 | import me.chanjar.weixin.mp.constant.WxMpEventConstants; 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | 16 | import javax.annotation.PostConstruct; 17 | 18 | import static me.chanjar.weixin.common.api.WxConsts.*; 19 | 20 | /** 21 | * @author Binary Wang 22 | */ 23 | public abstract class BaseWxService extends WxMpServiceImpl { 24 | private final Logger logger = LoggerFactory.getLogger(this.getClass()); 25 | 26 | @Autowired 27 | protected LogHandler logHandler; 28 | 29 | 30 | private WxMpMessageRouter router; 31 | 32 | protected abstract WxConfig getServerConfig(); 33 | 34 | @PostConstruct 35 | public void init() { 36 | 37 | final WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl(); 38 | config.setAppId(this.getServerConfig().getAppid());// 设置微信公众号的appid 39 | config.setSecret(this.getServerConfig().getAppsecret());// 设置微信公众号的app corpSecret 40 | config.setToken(this.getServerConfig().getToken());// 设置微信公众号的token 41 | config.setAesKey(this.getServerConfig().getAesKey());// 设置消息加解密密钥 42 | super.setWxMpConfigStorage(config); 43 | 44 | this.refreshRouter(); 45 | } 46 | 47 | 48 | /** 49 | * 路由信息 50 | */ 51 | private void refreshRouter() { 52 | 53 | final WxMpMessageRouter newRouter = new WxMpMessageRouter(this); 54 | 55 | // 记录所有事件的日志 56 | newRouter.rule().handler(this.logHandler).next(); 57 | 58 | // 接收客服会话管理事件 59 | newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(WxMpEventConstants.CustomerService.KF_CLOSE_SESSION).handler(null).end(); 60 | newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(WxMpEventConstants.CustomerService.KF_CREATE_SESSION).handler(null).end(); 61 | newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(WxMpEventConstants.CustomerService.KF_SWITCH_SESSION).handler(null).end(); 62 | 63 | // 门店审核事件 64 | newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(WxMpEventConstants.POI_CHECK_NOTIFY).handler(null).end(); 65 | 66 | // 自定义菜单事件 67 | newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(MenuButtonType.CLICK).handler(null).end(); 68 | 69 | // 点击菜单连接事件 70 | newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(MenuButtonType.VIEW).handler(null).end(); 71 | 72 | // 关注事件 73 | newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(EventType.SUBSCRIBE).handler(null).end(); 74 | 75 | // 取消关注事件 76 | newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(EventType.UNSUBSCRIBE).handler(null).end(); 77 | 78 | // 上报地理位置事件 79 | newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(EventType.LOCATION).handler(null).end(); 80 | 81 | // 接收地理位置消息 82 | newRouter.rule().async(false).msgType(XmlMsgType.LOCATION).handler(null).end(); 83 | 84 | // 扫码事件 85 | newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(EventType.SCAN).handler(null).end(); 86 | 87 | // 默认 88 | newRouter.rule().async(false).handler(null).end(); 89 | 90 | this.router = newRouter; 91 | } 92 | 93 | /** 94 | * 路由处理消息 95 | * 96 | * @param message 97 | * @return 98 | */ 99 | public WxMpXmlOutMessage route(WxMpXmlMessage message) { 100 | try { 101 | return this.router.route(message); 102 | } catch (Exception e) { 103 | this.logger.error(e.getMessage(), e); 104 | } 105 | 106 | return null; 107 | } 108 | 109 | public boolean hasKefuOnline() { 110 | try { 111 | WxMpKfOnlineList kfOnlineList = this.getKefuService().kfOnlineList(); 112 | return kfOnlineList != null && kfOnlineList.getKfOnlineList().size() > 0; 113 | } catch (Exception e) { 114 | this.logger.error("获取客服在线状态异常: " + e.getMessage(), e); 115 | } 116 | 117 | return false; 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/service/WxMpService.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.service; 2 | 3 | import com.codido.hodor.job.weixin.config.WxConfig; 4 | import com.codido.hodor.job.weixin.handler.LogHandler; 5 | import lombok.extern.slf4j.Slf4j; 6 | import me.chanjar.weixin.mp.api.WxMpMessageRouter; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.stereotype.Service; 10 | 11 | /** 12 | * 微信消息处理 13 | * 14 | * @author laijj 15 | */ 16 | @Slf4j 17 | @Service 18 | public class WxMpService extends BaseWxService { 19 | 20 | @Autowired 21 | protected LogHandler logHandler; 22 | 23 | @Autowired 24 | private WxConfig wxConfig; 25 | 26 | @Override 27 | protected WxConfig getServerConfig() { 28 | return this.wxConfig; 29 | } 30 | 31 | 32 | @Bean 33 | public WxMpMessageRouter router(WxMpService wxMpService) { 34 | final WxMpMessageRouter newRouter = new WxMpMessageRouter(wxMpService); 35 | 36 | // 记录所有事件的日志 (异步执行) 37 | newRouter.rule().handler(this.logHandler).next(); 38 | 39 | return newRouter; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Hodor-job/src/main/java/com/codido/hodor/job/weixin/util/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.codido.hodor.job.weixin.util; 2 | 3 | 4 | import com.alibaba.fastjson.JSON; 5 | 6 | /** 7 | * @author Binary Wang(https://github.com/binarywang) 8 | */ 9 | public class JsonUtils { 10 | public static String toJson(Object obj) { 11 | return JSON.toJSONString(obj); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Hodor-job/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | #数据源基础信息 2 | spring: 3 | datasource: 4 | type: com.alibaba.druid.pool.DruidDataSource 5 | url: jdbc:mysql://111.111.111.111:3306/hodor?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false 6 | username: hodor_adm 7 | password: 888888888 8 | driverClassName: com.mysql.jdbc.Driver 9 | initialSize: 5 10 | minIdle: 5 11 | maxActive: 20 12 | maxWait: 60000 13 | timeBetweenEvictionRunsMillis: 60000 14 | minEvictableIdleTimeMillis: 300000 15 | validationQuery: SELECT 1 FROM t_pub_param 16 | testWhileIdle: true 17 | testOnBorrow: false 18 | testOnReturn: false 19 | poolPreparedStatements: true 20 | maxPoolPreparedStatementPerConnectionSize: 20 21 | filters: stat,wall,log4j 22 | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000\ 23 | redis: 24 | host: xxx.xxx.xxx.xxx 25 | port: 8998 26 | database: 0 27 | password: 11111111 28 | timeout: 3000 29 | 30 | 31 | #服务相关参数 32 | server: 33 | port: 8089 34 | 35 | #日志参数 36 | log: 37 | $path: /Users/bpascal/Documents/workspaces/ideaworkspace/lottostore/log 38 | 39 | #mybatis基础配置 40 | mybatis: 41 | configuration: 42 | mapUnderscoreToCamelCase: true 43 | 44 | #微信参数 45 | wechat: 46 | app: 47 | appId: wx209e789aebc1fd6e 48 | secret: 111111111111111111111111111111 49 | token: 111111 50 | aesKey: 111111 51 | pay: 52 | appId: wxb0df5ef1b490a8b1 53 | mchId: 1111111111 54 | mchKey: 111111111111111111111111111111 55 | keyPath: /home/serveradm/apiclient_cert.p12 56 | 57 | #服务路径相关 58 | basecontext: 59 | urlpath: 60 | requestpath: http://www.rivendell.top 61 | 62 | #七牛云存储参数 63 | qiniu: 64 | userparams: 65 | accesskey: yAC2iK-zdCfoo-4RttvC9rmKi98TwVXtfvu6EQHl 66 | secretkey: 1111111111111111111111111111111111111111 67 | imagebucket: bpascal 68 | filecontext: http://images.rivendell.top/ -------------------------------------------------------------------------------- /Hodor-job/src/main/resources/application-ptc.yml: -------------------------------------------------------------------------------- 1 | #数据源基础信息 2 | spring: 3 | datasource: 4 | type: com.alibaba.druid.pool.DruidDataSource 5 | url: jdbc:mysql://111.111.111.111:3306/hodor?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false 6 | username: hodor_adm 7 | password: 888888888 8 | driverClassName: com.mysql.jdbc.Driver 9 | initialSize: 5 10 | minIdle: 5 11 | maxActive: 20 12 | maxWait: 60000 13 | timeBetweenEvictionRunsMillis: 60000 14 | minEvictableIdleTimeMillis: 300000 15 | validationQuery: SELECT 1 FROM t_pub_param 16 | testWhileIdle: true 17 | testOnBorrow: false 18 | testOnReturn: false 19 | poolPreparedStatements: true 20 | maxPoolPreparedStatementPerConnectionSize: 20 21 | filters: stat,wall,log4j 22 | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000\ 23 | redis: 24 | host: xxx.xxx.xxx.xxx 25 | port: 8998 26 | database: 0 27 | password: 11111111 28 | timeout: 3000 29 | 30 | #服务参数 31 | server: 32 | port: 9012 33 | 34 | #日志参数 35 | log: 36 | path: /home/serveradm/logs 37 | 38 | #mybatis基础配置 39 | mybatis: 40 | configuration: 41 | mapUnderscoreToCamelCase: true 42 | 43 | #微信参数 44 | wechat: 45 | app: 46 | appId: wx209e789aebc1fd6e 47 | secret: 111111111111111111111111111111 48 | token: 111111 49 | aesKey: 111111 50 | pay: 51 | appId: wxb0df5ef1b490a8b1 52 | mchId: 1111111111 53 | mchKey: 111111111111111111111111111111 54 | keyPath: /home/serveradm/apiclient_cert.p12 55 | 56 | #服务路径相关 57 | basecontext: 58 | urlpath: 59 | requestpath: http://www.rivendell.top 60 | 61 | #七牛云存储参数 62 | qiniu: 63 | userparams: 64 | accesskey: yAC2iK-zdCfoo-4RttvC9rmKi98TwVXtfvu6EQHl 65 | secretkey: 1111111111111111111111111111111111111111 66 | imagebucket: bpascal 67 | filecontext: http://images.rivendell.top/ -------------------------------------------------------------------------------- /Hodor-job/src/main/resources/application-uat.yml: -------------------------------------------------------------------------------- 1 | #数据源基础信息 2 | spring: 3 | datasource: 4 | type: com.alibaba.druid.pool.DruidDataSource 5 | url: jdbc:mysql://111.111.111.111:3306/hodor?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false 6 | username: hodor_adm 7 | password: 888888888 8 | driverClassName: com.mysql.jdbc.Driver 9 | initialSize: 5 10 | minIdle: 5 11 | maxActive: 20 12 | maxWait: 60000 13 | timeBetweenEvictionRunsMillis: 60000 14 | minEvictableIdleTimeMillis: 300000 15 | validationQuery: SELECT 1 FROM t_pub_param 16 | testWhileIdle: true 17 | testOnBorrow: false 18 | testOnReturn: false 19 | poolPreparedStatements: true 20 | maxPoolPreparedStatementPerConnectionSize: 20 21 | filters: stat,wall,log4j 22 | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000\ 23 | redis: 24 | host: xxx.xxx.xxx.xxx 25 | port: 8998 26 | database: 0 27 | password: 11111111 28 | timeout: 3000 29 | 30 | #服务参数 31 | server: 32 | port: 8089 33 | 34 | #日志参数 35 | log: 36 | path: /home/serveradm/logs 37 | 38 | #mybatis基础配置 39 | mybatis: 40 | configuration: 41 | mapUnderscoreToCamelCase: true 42 | 43 | #微信参数 44 | wechat: 45 | app: 46 | appId: wx209e789aebc1fd6e 47 | secret: 111111111111111111111111111111 48 | token: 111111 49 | aesKey: 111111 50 | pay: 51 | appId: wxb0df5ef1b490a8b1 52 | mchId: 1111111111 53 | mchKey: 111111111111111111111111111111 54 | keyPath: /home/serveradm/apiclient_cert.p12 55 | 56 | #服务路径相关 57 | basecontext: 58 | urlpath: 59 | requestpath: http://www.rivendell.top 60 | 61 | #七牛云存储参数 62 | qiniu: 63 | userparams: 64 | accesskey: yAC2iK-zdCfoo-4RttvC9rmKi98TwVXtfvu6EQHl 65 | secretkey: 1111111111111111111111111111111111111111 66 | imagebucket: bpascal 67 | filecontext: http://images.rivendell.top/ -------------------------------------------------------------------------------- /Hodor-job/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: uat -------------------------------------------------------------------------------- /Hodor-job/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | [%X{bizParam}][%-5level][%d{HH:mm:ss.SSS}][%logger{36}]:%msg%n 12 | 13 | 14 | 15 | 16 | 17 | 18 | ${logPath}/hodor-job.log 19 | 20 | ${logPath}/hodor-job-%d{yyyy-MM-dd}.%i.log 21 | 22 | 10 23 | 24 | 5MB 25 | 26 | 27 | 28 | 29 | [%X{bizParam}][%-5level][%d{HH:mm:ss.SSS}][%logger{36}]:%msg%n 30 | 31 | 32 | 33 | 34 | 35 | 36 | 0 37 | 38 | 512 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Hodor后端工程 2 | 3 | #### 0.技术栈 4 | 5 | 整体框架:spring boot 6 | 数据库连接池:Druid 7 | DAO层:MyBatis 8 | 缓存:redis 9 | 日志:logback 10 | 接口文档:swagger2生成 11 | 12 | #### 1.工程目录介绍 13 | 14 | 15 | 16 | 17 | #### 2.开发规范 18 | 19 | 20 | 21 | #### 3.参考资料 22 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.codido' 2 | version '1.0-SNAPSHOT' 3 | 4 | apply plugin: 'java' 5 | 6 | sourceCompatibility = 1.8 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | 14 | testCompile group: 'junit', name: 'junit', version: '4.12' 15 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-bin.zip 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStorePath=wrapper/dists 5 | zipStoreBase=GRADLE_USER_HOME 6 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Hodor' 2 | include 'Hodor-core' 3 | include 'Hodor-cgi' 4 | include 'Hodor-job' 5 | --------------------------------------------------------------------------------