Skip to content

Commit

Permalink
1、docker-compose启动austin
Browse files Browse the repository at this point in the history
2、微信服务号登录 接入中
  • Loading branch information
ZhongFuCheng3y committed Dec 9, 2022
1 parent d9725f6 commit fac98a7
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 14 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ ENV PARAMS="--spring.profiles.active=docker"

# 设置工作目录
WORKDIR /build

# 将jar包复制到容器中
ADD ./austin-web/target/austin-web-0.0.1-SNAPSHOT.jar ./austin.jar
# 暴露8080端口
EXPOSE 8080

# 运行jar包
ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS austin.jar $PARAMS"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.java3y.austin.web.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* 健康检测
*
* @author 3y
*/
@Slf4j
@RestController
@Api("健康检测")
public class HealthController {
@GetMapping("/")
@ApiOperation("/健康检测")
public String health() {
return "success";
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.java3y.austin.web.controller;


import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.base.Throwables;
import com.java3y.austin.common.enums.RespStatusEnum;
import com.java3y.austin.common.vo.BasicResultVO;
Expand All @@ -11,12 +14,17 @@
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
import me.chanjar.weixin.mp.bean.template.WxMpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
* 微信服务号
Expand Down Expand Up @@ -79,4 +87,50 @@ public BasicResultVO queryDetailList(Long id, String wxTemplateId) {
}


/**
* 接收微信的事件消息
* https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Access_Overview.html
* 临时给微信服务号登录使用,正常消息推送平台不会有此接口
*
* @return
*/
@GetMapping("/receipt")
@ApiOperation("/接收微信的事件消息")
public String receiptMessage(String signature, String timestamp, String nonce, String echostr) {
log.info("get weixin signature:{},:{},nonce:{},echostr:{}", signature, timestamp, nonce, echostr);
if (StrUtil.isNotBlank(echostr)) {
return echostr;
}
return null;
}

/**
* 临时给微信服务号登录使用(生成二维码),正常消息推送平台不会有此接口
*
* @param accountId 消息推送平台体系内的Id
* @return
*/
@GetMapping("/qrCode")
@ApiOperation("/生成 服务号 二维码")
public BasicResultVO getQrCode(Long accountId) {
if (accountId == null) {
return BasicResultVO.fail(RespStatusEnum.CLIENT_BAD_PARAMETERS);
}
try {
// 生成随机值,获取服务号二维码 且 用于校验登录
String id = IdUtil.getSnowflake().nextIdStr();
WxMpService wxMpService = wxServiceUtils.getOfficialAccountServiceMap().get(accountId);
WxMpQrCodeTicket ticket = wxMpService.getQrcodeService().qrCodeCreateTmpTicket(id, 2592000);


String url = wxMpService.getQrcodeService().qrCodePictureUrl(ticket.getTicket());
Map<Object, Object> result = MapUtil.of(new String[][]{{"url", url}, {"id", id}});
return BasicResultVO.success(result);
} catch (Exception e) {
log.error("OfficialAccountController#getQrCode fail:{}", Throwables.getStackTraceAsString(e));
return BasicResultVO.fail(RespStatusEnum.SERVICE_ERROR);
}
}


}
3 changes: 1 addition & 2 deletions austin-web/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# TODO please replace 【must】 config value
# TODO please replace 【must】 config value
# TODO please replace 【must】 config value
server.port=8080

# todo [database] ip/port/username/password 【must】
austin.database.ip=austin.mysql
Expand Down Expand Up @@ -83,8 +84,6 @@ austin.rocketmq.recall.consumer.group=unique-recall-consumer-group
########################################## RabbitMq start ##########################################
spring.rabbitmq.host=${austin.rabbitmq.ip}
spring.rabbitmq.port=${austin.rabbitmq.port}
server.port=8080
spring.application.name=cl
spring.rabbitmq.username=root
spring.rabbitmq.password=123456
spring.rabbitmq.publisher-confirm-type=correlated
Expand Down
9 changes: 4 additions & 5 deletions austin-web/src/main/resources/application-docker.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# TODO please replace 【must】 config value
# TODO please replace 【must】 config value
# TODO please replace 【must】 config value
server.port=8080

# todo [database] ip/port/username/password 【must】
austin.database.ip=mysql
austin.database.ip=austin-mysql
austin.database.port=3306
austin.database.username=root
austin.database.password=root123_A

# todo [redis] ip/port/password【must】
austin.redis.ip=redis
austin.redis.ip=austin-redis
austin.redis.port=6379
austin.redis.password=austin

Expand Down Expand Up @@ -45,7 +46,7 @@ austin.business.upload.crowd.path=/Users/3y/temp

########################################## database start ##########################################
# notice:mysql version 5.7x !!!
spring.datasource.url=jdbc:mysql://${austin.database.ip}:${austin.database.port}/austin?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
spring.datasource.url=jdbc:mysql://${austin.database.ip}:${austin.database.port}/austin?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
spring.datasource.username=${austin.database.username}
spring.datasource.password=${austin.database.password}
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
Expand Down Expand Up @@ -83,8 +84,6 @@ austin.rocketmq.recall.consumer.group=unique-recall-consumer-group
########################################## RabbitMq start ##########################################
spring.rabbitmq.host=${austin.rabbitmq.ip}
spring.rabbitmq.port=${austin.rabbitmq.port}
server.port=8080
spring.application.name=cl
spring.rabbitmq.username=root
spring.rabbitmq.password=123456
spring.rabbitmq.publisher-confirm-type=correlated
Expand Down
3 changes: 2 additions & 1 deletion austin-web/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
spring.profiles.active=dev
spring.profiles.active=dev
spring.application.name=austin
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '3'
services:
mysql:
austin-mysql:
environment:
TZ: Asia/Shanghai
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
Expand All @@ -17,12 +17,12 @@ services:
- 23306:3306
networks:
- app
redis:
austin-redis:
image: redis:3.2
ports:
- 16379:6379
restart: always
container_name: redis
container_name: austin-redis
networks:
- app
austin:
Expand Down

0 comments on commit fac98a7

Please sign in to comment.