gitea + docker + drone 实现CI/CD
parent
25113aba37
commit
a3e36cba7e
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# 定义应用组名
|
||||||
|
group_name='nnzmr'
|
||||||
|
# 定义应用名称
|
||||||
|
app_name='venue_reservation_service'
|
||||||
|
# 定义应用版本
|
||||||
|
app_version='latest'
|
||||||
|
echo '----copy jar----'
|
||||||
|
docker stop ${app_name}
|
||||||
|
echo '----stop container----'
|
||||||
|
docker rm ${app_name}
|
||||||
|
echo '----rm container----'
|
||||||
|
docker rmi ${group_name}/${app_name}:${app_version}
|
||||||
|
echo '----rm image----'
|
||||||
|
# 打包编译docker镜像
|
||||||
|
docker build -t ${group_name}/${app_name}:${app_version} .
|
||||||
|
echo '----build image----'
|
||||||
|
docker run -p 9020:9020 --name ${app_name} \
|
||||||
|
-e TZ="Asia/Shanghai" \
|
||||||
|
-v /etc/localtime:/etc/localtime \
|
||||||
|
-d ${group_name}/${app_name}:${app_version}
|
||||||
|
echo '----start container----'
|
@ -0,0 +1,65 @@
|
|||||||
|
package com.example.venue_reservation_service.config;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.info.Contact;
|
||||||
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
|
import io.swagger.v3.oas.models.info.License;
|
||||||
|
import org.springdoc.core.models.GroupedOpenApi;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Knife4j配置类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Patrick
|
||||||
|
* @since 2025-1-1
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class Knife4jConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建系统分组api
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public GroupedOpenApi systemApi() {
|
||||||
|
return createRestApi("系统管理", "com.example.venue_reservation_service.controller");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建api
|
||||||
|
*
|
||||||
|
* @param groupName 分组名称
|
||||||
|
* @param basePackage 包路径
|
||||||
|
* @return GroupedOpenApi
|
||||||
|
*/
|
||||||
|
public GroupedOpenApi createRestApi(String groupName, String basePackage) {
|
||||||
|
return GroupedOpenApi.builder()
|
||||||
|
.group(groupName) // 分组名称
|
||||||
|
.packagesToScan(basePackage) // 扫描的包路径
|
||||||
|
.pathsToMatch("/**") // 匹配所有路径
|
||||||
|
.addOpenApiCustomizer(openApi -> openApi.info(apiInfo())) // 设置api信息
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* api简介信息
|
||||||
|
*
|
||||||
|
* @return ApiInfo
|
||||||
|
*/
|
||||||
|
private Info apiInfo() {
|
||||||
|
return new Info()
|
||||||
|
.title("华交场馆管控一体化平台API") // 标题
|
||||||
|
.description("校园 e 站通・华交场馆管控一体化平台 -- 接口文档") // 描述
|
||||||
|
.version("1.0.0") // 版本号
|
||||||
|
.termsOfService("http://doc.xiaominfo.com") // 服务条款
|
||||||
|
.contact(new Contact().name("实训小组1")
|
||||||
|
.url("https://github.com/Patrick-Luo-THR")
|
||||||
|
.email("patrick.luo@163.com")) // 联系人信息
|
||||||
|
.license(new License().name("Apache 2.0")
|
||||||
|
.url("http://www.apache.org/licenses/LICENSE-2.0.html")); // 许可证信息
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,13 +1,18 @@
|
|||||||
package com.example.venue_reservation_service.dto;
|
package com.example.venue_reservation_service.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@Schema(description = "积分添加对象")
|
||||||
public class PointDTO {
|
public class PointDTO {
|
||||||
|
|
||||||
|
@Schema(description = "管理员编号")
|
||||||
Integer adminId;
|
Integer adminId;
|
||||||
|
|
||||||
|
@Schema(description = "用户编号")
|
||||||
Integer userId;
|
Integer userId;
|
||||||
|
|
||||||
|
@Schema(description = "充值金额")
|
||||||
Double money;
|
Double money;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.example.venue_reservation_service.mq;
|
||||||
|
|
||||||
|
import com.example.venue_reservation_service.service.ReservationService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DelayMessageConsumer {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ReservationService reservationService;
|
||||||
|
|
||||||
|
// 处理预约检查消息
|
||||||
|
@RabbitListener(queues = "delayed.queue")
|
||||||
|
public void handleReservationCheck(Integer reservationId) {
|
||||||
|
reservationService.dealReservation(reservationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理测试消息
|
||||||
|
@RabbitListener(queues = "delayed.queue")
|
||||||
|
public void handleTestMessage(String message) {
|
||||||
|
System.out.println("[" + LocalTime.now() + "] 收到延迟消息: " + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue