This commit is contained in:
oneao committed 2025-11-26 17:31:56 +08:00
1 parent a57070f860
commit b9f728812d
22 files changed
+2892 -391

No files matched your search

+715 -33
View File
@@ -1,34 +1,716 @@
<!-- <Drawer
isOpen={dateSelected}
anchor="bottom"
onClose={() => {
setDateSelected(false)
}}
size="md"
>
<DrawerBackdrop />
<DrawerContent style={{ padding: 12 }}>
<DrawerBody style={{ padding: 0, marginTop: 0, marginBottom: 0 }}>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
<Text>This is the basic drawer component.</Text>
</DrawerBody>
</DrawerContent>
</Drawer> -->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>船司跟踪查询系统</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}
body {
background: linear-gradient(135deg, #1a2980, #26d0ce);
color: #333;
min-height: 100vh;
padding: 20px;
display: flex;
justify-content: center;
align-items: center;
}
.container {
width: 100%;
max-width: 900px;
background: white;
border-radius: 12px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
overflow: hidden;
}
header {
background: #1a2980;
color: white;
padding: 20px;
text-align: center;
}
h1 {
font-size: 28px;
margin-bottom: 5px;
}
.subtitle {
font-size: 16px;
opacity: 0.8;
}
.content {
padding: 30px;
}
.simulation-controls {
display: flex;
gap: 15px;
margin-bottom: 20px;
background: #f8f9fa;
padding: 15px;
border-radius: 8px;
}
.simulation-controls label {
display: flex;
align-items: center;
gap: 8px;
font-weight: 600;
color: #1a2980;
}
.search-form {
display: flex;
flex-wrap: wrap;
gap: 15px;
margin-bottom: 30px;
}
.form-group {
flex: 1;
min-width: 200px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #1a2980;
}
input, select {
width: 100%;
padding: 12px 15px;
border: 1px solid #ddd;
border-radius: 6px;
font-size: 16px;
transition: all 0.3s;
}
input:focus, select:focus {
outline: none;
border-color: #1a2980;
box-shadow: 0 0 0 3px rgba(26, 41, 128, 0.1);
}
.btn {
background: #1a2980;
color: white;
border: none;
padding: 12px 25px;
border-radius: 6px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s;
display: flex;
align-items: center;
justify-content: center;
}
.btn:hover {
background: #152066;
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}
.btn:active {
transform: translateY(0);
}
.btn:disabled {
background: #cccccc;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
.btn-success {
background: #4CAF50;
}
.btn-failure {
background: #f44336;
}
.placeholder {
background: #f8f9fa;
border-radius: 8px;
padding: 40px 20px;
margin-bottom: 30px;
text-align: center;
color: #666;
border: 2px dashed #ddd;
}
.placeholder-icon {
font-size: 48px;
margin-bottom: 15px;
color: #ccc;
}
.placeholder-text {
font-size: 16px;
}
.status-indicator {
background: #f8f9fa;
border-radius: 8px;
padding: 20px;
margin-bottom: 30px;
display: none;
}
.status-title {
font-size: 18px;
font-weight: 600;
margin-bottom: 15px;
color: #1a2980;
}
/* 垂直布局样式 */
.steps-vertical {
display: flex;
flex-direction: column;
position: relative;
margin-bottom: 30px;
}
.steps-vertical::before {
content: '';
position: absolute;
left: 15px;
top: 0;
bottom: 0;
width: 3px;
background: #e0e0e0;
z-index: 1;
}
.step-vertical {
display: flex;
align-items: center;
margin-bottom: 20px;
position: relative;
z-index: 2;
}
.step-circle-vertical {
width: 30px;
height: 30px;
border-radius: 50%;
background: #e0e0e0;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
margin-right: 15px;
flex-shrink: 0;
transition: all 0.3s;
}
.step-vertical.active .step-circle-vertical {
background: #1a2980;
animation: pulse 1.5s infinite;
}
.step-vertical.completed .step-circle-vertical {
background: #4CAF50;
}
.step-vertical.failed .step-circle-vertical {
background: #f44336;
}
.step-text-vertical {
font-size: 14px;
}
.status-message {
padding: 15px;
border-radius: 6px;
margin-top: 10px;
display: none;
}
.status-message.info {
background: #e3f2fd;
color: #0d47a1;
}
.status-message.success {
background: #e8f5e9;
color: #2e7d32;
}
.status-message.warning {
background: #fff3e0;
color: #ef6c00;
}
.result {
display: none;
background: #f8f9fa;
border-radius: 8px;
padding: 20px;
margin-top: 20px;
}
.result-title {
font-size: 20px;
font-weight: 600;
margin-bottom: 15px;
color: #1a2980;
border-bottom: 2px solid #1a2980;
padding-bottom: 10px;
}
.tracking-info {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
}
.info-item {
background: white;
padding: 15px;
border-radius: 6px;
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.info-label {
font-size: 14px;
color: #666;
margin-bottom: 5px;
}
.info-value {
font-size: 16px;
font-weight: 600;
color: #333;
}
.spinner {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid rgba(255,255,255,.3);
border-radius: 50%;
border-top-color: #fff;
animation: spin 1s ease-in-out infinite;
margin-right: 10px;
}
.success-animation {
animation: successPulse 2s ease-in-out;
}
.warning-animation {
animation: warningPulse 2s ease-in-out;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
@keyframes successPulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
@keyframes warningPulse {
0% { transform: scale(1); }
50% { transform: scale(1.02); }
100% { transform: scale(1); }
}
.test-buttons {
display: flex;
gap: 10px;
margin-top: 15px;
}
@media (max-width: 768px) {
.step-vertical {
flex-direction: column;
align-items: flex-start;
}
.step-circle-vertical {
margin-bottom: 8px;
margin-right: 0;
}
.steps-vertical::before {
left: 15px;
}
.test-buttons {
flex-direction: column;
}
.simulation-controls {
flex-direction: column;
gap: 10px;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>船司跟踪查询系统</h1>
<div class="subtitle">实时追踪您的船舶位置与状态</div>
</header>
<div class="content">
<div class="simulation-controls">
<label>
<input type="radio" name="simulationMode" value="random" checked> 随机模式 (80%成功, 20%暂时无法获取)
</label>
<label>
<input type="radio" name="simulationMode" value="success"> 模拟可获取数据
</label>
<label>
<input type="radio" name="simulationMode" value="failure"> 模拟暂时无法获取数据
</label>
</div>
<form class="search-form" id="trackingForm">
<div class="form-group">
<label for="company">船运公司</label>
<select id="company" required>
<option value="">请选择船运公司</option>
<option value="maersk">马士基航运 (Maersk)</option>
<option value="msc">地中海航运 (MSC)</option>
<option value="cosco">中远海运 (COSCO)</option>
<option value="cma-cgm">达飞轮船 (CMA CGM)</option>
<option value="evergreen">长荣海运 (Evergreen)</option>
</select>
</div>
<div class="form-group">
<label for="trackingNumber">提单号/集装箱号</label>
<input type="text" id="trackingNumber" placeholder="请输入提单号或集装箱号" required>
</div>
<div class="form-group" style="display: flex; align-items: flex-end;">
<button type="submit" class="btn" id="searchBtn">
<span id="btnText">查询</span>
</button>
</div>
</form>
<div class="test-buttons">
<button class="btn btn-success" id="testSuccessBtn">测试可获取数据案例</button>
<button class="btn btn-failure" id="testFailureBtn">测试暂时无法获取数据案例</button>
</div>
<!-- 初始占位符 -->
<div class="placeholder" id="placeholder">
<div class="placeholder-icon">🚢</div>
<div class="placeholder-text">请输入查询条件并点击"查询"按钮开始跟踪</div>
</div>
<!-- 状态指示器(初始隐藏) -->
<div class="status-indicator" id="statusIndicator">
<div class="status-title">查询状态</div>
<div class="steps-vertical" id="stepsVertical">
<div class="step-vertical" id="step1">
<div class="step-circle-vertical">1</div>
<div class="step-text-vertical">发出请求</div>
</div>
<div class="step-vertical" id="step2">
<div class="step-circle-vertical">2</div>
<div class="step-text-vertical">等待响应</div>
</div>
<div class="step-vertical" id="step3">
<div class="step-circle-vertical">3</div>
<div class="step-text-vertical">处理数据</div>
</div>
<div class="step-vertical" id="step4">
<div class="step-circle-vertical">4</div>
<div class="step-text-vertical">查询完成</div>
</div>
</div>
<div class="status-message info" id="statusMessage"></div>
</div>
<!-- 查询结果(初始隐藏) -->
<div class="result" id="result">
<div class="result-title">查询结果</div>
<div class="tracking-info">
<div class="info-item">
<div class="info-label">船运公司</div>
<div class="info-value" id="result-company">-</div>
</div>
<div class="info-item">
<div class="info-label">提单号</div>
<div class="info-value" id="result-bill">-</div>
</div>
<div class="info-item">
<div class="info-label">集装箱号</div>
<div class="info-value" id="result-container">-</div>
</div>
<div class="info-item">
<div class="info-label">当前位置</div>
<div class="info-value" id="result-location">-</div>
</div>
<div class="info-item">
<div class="info-label">状态</div>
<div class="info-value" id="result-status">-</div>
</div>
<div class="info-item">
<div class="info-label">预计到达</div>
<div class="info-value" id="result-eta">-</div>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
console.log('DOM已加载,正在初始化船司跟踪查询系统...');
const trackingForm = document.getElementById('trackingForm');
const searchBtn = document.getElementById('searchBtn');
const testSuccessBtn = document.getElementById('testSuccessBtn');
const testFailureBtn = document.getElementById('testFailureBtn');
const placeholder = document.getElementById('placeholder');
const statusIndicator = document.getElementById('statusIndicator');
const result = document.getElementById('result');
if (!trackingForm) {
console.error('错误:未找到ID为"trackingForm"的表单元素');
return;
}
if (!searchBtn) {
console.error('错误:未找到ID为"searchBtn"的按钮元素');
return;
}
// 绑定表单提交事件
trackingForm.addEventListener('submit', function(e) {
e.preventDefault();
console.log('表单提交事件触发');
const company = document.getElementById('company').value;
const trackingNumber = document.getElementById('trackingNumber').value;
const simulationMode = document.querySelector('input[name="simulationMode"]:checked').value;
console.log('公司:', company, '跟踪号:', trackingNumber, '模拟模式:', simulationMode);
if (!company || !trackingNumber) {
alert('请填写完整的查询信息');
return;
}
startTracking(company, trackingNumber, simulationMode);
});
// 测试成功按钮
testSuccessBtn.addEventListener('click', function() {
document.getElementById('company').value = 'maersk';
document.getElementById('trackingNumber').value = 'MAE123456789';
document.querySelector('input[name="simulationMode"][value="success"]').checked = true;
startTracking('maersk', 'MAE123456789', 'success');
});
// 测试失败按钮
testFailureBtn.addEventListener('click', function() {
document.getElementById('company').value = 'msc';
document.getElementById('trackingNumber').value = 'MSC987654321';
document.querySelector('input[name="simulationMode"][value="failure"]').checked = true;
startTracking('msc', 'MSC987654321', 'failure');
});
console.log('船司跟踪查询系统初始化完成');
});
function startTracking(company, trackingNumber, simulationMode) {
console.log('开始跟踪流程,模式:', simulationMode);
// 隐藏占位符,显示状态指示器
document.getElementById('placeholder').style.display = 'none';
document.getElementById('statusIndicator').style.display = 'block';
document.getElementById('result').style.display = 'none';
resetStatus();
const searchBtn = document.getElementById('searchBtn');
searchBtn.disabled = true;
document.getElementById('btnText').innerHTML = '<span class="spinner"></span>查询中...';
updateStep(1, 'active', '正在向船运公司发送查询请求...');
console.log('步骤1: 发出请求');
setTimeout(() => {
updateStep(1, 'completed');
updateStep(2, 'active', '已发送请求,等待船运公司响应...');
console.log('步骤2: 等待响应');
setTimeout(() => {
updateStep(2, 'completed');
updateStep(3, 'active', '收到响应,正在处理数据...');
console.log('步骤3: 处理数据');
setTimeout(() => {
updateStep(3, 'completed');
updateStep(4, 'active', '数据解析完成,生成查询结果...');
console.log('步骤4: 查询完成');
setTimeout(() => {
let isSuccess;
// 根据选择的模拟模式决定结果
if (simulationMode === 'success') {
isSuccess = true;
} else if (simulationMode === 'failure') {
isSuccess = false;
} else {
// 随机模式:80%成功,20%失败
isSuccess = Math.random() > 0.2;
}
if (isSuccess) {
updateStep(4, 'completed', '查询成功!已找到相关船舶信息。');
console.log('查询成功');
document.getElementById('statusIndicator').classList.add('success-animation');
showResult(company, trackingNumber);
} else {
// 使用更友好的提示信息
updateStep(4, 'failed', '目前无法获取该船舶的实时信息,请稍后再试。');
console.log('查询暂时无法获取数据');
document.getElementById('statusIndicator').classList.add('warning-animation');
// 暂时无法获取数据时显示占位符
setTimeout(() => {
document.getElementById('placeholder').style.display = 'block';
document.getElementById('placeholder').innerHTML = `
<div class="placeholder-icon">⏳</div>
<div class="placeholder-text">当前无法获取该船舶的实时信息,请稍后再试</div>
`;
document.getElementById('statusIndicator').style.display = 'none';
}, 2000);
}
searchBtn.disabled = false;
document.getElementById('btnText').textContent = '查询';
}, 1500);
}, 2000);
}, 1500);
}, 1000);
}
function updateStep(stepNumber, status, message) {
console.log(`更新步骤 ${stepNumber} 状态为: ${status}`);
const stepElement = document.getElementById('step' + stepNumber);
const messageElement = document.getElementById('statusMessage');
if (!stepElement) {
console.error(`错误:未找到ID为"step${stepNumber}"的步骤元素`);
return;
}
stepElement.classList.remove('active', 'completed', 'failed');
if (status) {
stepElement.classList.add(status);
}
if (message && messageElement) {
messageElement.textContent = message;
messageElement.className = 'status-message';
if (status === 'active') {
messageElement.classList.add('info');
} else if (status === 'completed') {
messageElement.classList.add('success');
} else if (status === 'failed') {
messageElement.classList.add('warning');
}
messageElement.style.display = 'block';
}
}
function resetStatus() {
console.log('重置状态指示器');
for (let i = 1; i <= 4; i++) {
const stepElement = document.getElementById('step' + i);
if (stepElement) {
stepElement.classList.remove('active', 'completed', 'failed');
}
}
const messageElement = document.getElementById('statusMessage');
if (messageElement) {
messageElement.style.display = 'none';
}
document.getElementById('statusIndicator').classList.remove('success-animation', 'warning-animation');
}
function showResult(company, trackingNumber) {
console.log('显示查询结果');
const companies = {
'maersk': '马士基航运',
'msc': '地中海航运',
'cosco': '中远海运',
'cma-cgm': '达飞轮船',
'evergreen': '长荣海运'
};
const locations = [
'上海港', '新加坡港', '鹿特丹港', '汉堡港', '洛杉矶港',
'釜山港', '深圳港', '迪拜港', '纽约港', '安特卫普港'
];
const statuses = [
'在港装货', '海上航行', '在港卸货', '等待泊位', '海关检查'
];
const randomLocation = locations[Math.floor(Math.random() * locations.length)];
const randomStatus = statuses[Math.floor(Math.random() * statuses.length)];
const etaDate = new Date();
etaDate.setDate(etaDate.getDate() + Math.floor(Math.random() * 13) + 3);
const etaString = etaDate.toLocaleDateString('zh-CN');
document.getElementById('result-company').textContent = companies[company] || company;
document.getElementById('result-bill').textContent = trackingNumber;
document.getElementById('result-container').textContent = 'CCLU' + Math.floor(Math.random() * 1000000);
document.getElementById('result-location').textContent = randomLocation;
document.getElementById('result-status').textContent = randomStatus;
document.getElementById('result-eta').textContent = etaString;
document.getElementById('result').style.display = 'block';
}
</script>
</body>
</html>
+19 -15
View File
@@ -33,7 +33,8 @@
pageSize:30,
onClickRow:onClickRow,
showPageInfo:false,
showRefresh:false
showRefresh:false,
data: createMockData(100)
">
<thead>
<tr>
@@ -57,20 +58,23 @@ let editIndex = undefined;
// 初始化 Datagrid 数据
$('#dg').datagrid({
data: createMockData(100),
onLoadSuccess: function(){
let pager = $('#dg').datagrid('getPager');
pager.pagination({
showRefresh: true, // 隐藏刷新按钮
showPageInfo: true, // 隐藏页信息
onRefresh: function(pageNumber, pageSize){
let newData = createMockData(300);
$('#dg').datagrid('loadData', newData);
$('#dg').datagrid('clearSelections');
$('#dg').datagrid('clearChecked');
}
});
data: createMockData(100)
});
// 2. 获取分页控件并绑定事件
var pager = $('#dg').datagrid('getPager');
pager.pagination({
showRefresh: false,
showPageList: false,
onBeforeRefresh: function(){
console.log('onBeforeRefresh triggered');
},
onRefresh: function(pageNumber, pageSize){
console.log('onRefresh triggered', pageNumber, pageSize);
// 刷新数据
var newData = createMockData(300);
$('#dg').datagrid('loadData', newData);
$('#dg').datagrid('clearSelections');
$('#dg').datagrid('clearChecked');
}
});
Binary file not shown.
File diff suppressed because it is too large. Load diff
Binary file not shown.
@@ -1,7 +1,3 @@
/**
保证多routine共用同一数据
*/
package routinex
import (
-2
View File
@@ -11,8 +11,6 @@ _cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.exe~
*.test
*.prof
*.rar
@@ -7,8 +7,9 @@ import (
"cn/oneao/base-go/ent/userinfo"
"cn/oneao/base-go/utils/jwtx"
"cn/oneao/base-go/utils/response"
"cn/oneao/base-go/utils/routinex"
"context"
"fmt"
"github.com/cloudwego/hertz/pkg/common/hlog"
"time"
auth "cn/oneao/base-go/biz/model/auth"
@@ -27,23 +28,32 @@ func LoginDefault(ctx context.Context, c *app.RequestContext) {
c.String(consts.StatusBadRequest, err.Error())
return
}
// 假设 ctx 已有,req.Account / req.Password 已有
start := time.Now()
// 查询登录用户
loginUser, err := db.Client.UserInfo.
Query().
Where(userinfo.AccountEQ(req.Account),
userinfo.PasswordEQ(req.Password)).
Only(ctx)
duration := time.Since(start) // 耗时
fmt.Printf("登录查询: (耗时: %v)\n", duration)
if err != nil {
c.String(consts.StatusInternalServerError, "账号或密码错误")
response.Fail(c).Message("账号或密码错误").Send()
return
}
// 异步更新登录事件
routinex.Go(func() {
err := db.Client.UserInfo.
Update().
SetLastLoginTime(time.Now()).
Where(userinfo.IDEQ(loginUser.ID)).
Exec(ctx)
if err != nil {
hlog.Errorf("更新用户登录时间失败,UserID=%d, err=%v", loginUser.ID, err)
}
})
// 包装数据
token, err := jwtx.CreateAccessToken(loginUser.ID)
refreshToken, err := jwtx.CreateRefreshToken(loginUser.ID)
@@ -1,27 +0,0 @@
// Code generated by hertz generator.
package hello
import (
"context"
hello "cn/oneao/base-go/biz/model/hertz/hello"
"github.com/cloudwego/hertz/pkg/app"
"github.com/cloudwego/hertz/pkg/protocol/consts"
)
// Method1 .
// @router /hello [GET]
func Method1(ctx context.Context, c *app.RequestContext) {
var err error
var req hello.HelloReq
err = c.BindAndValidate(&req)
if err != nil {
c.String(consts.StatusBadRequest, err.Error())
return
}
resp := new(hello.HelloResp)
c.JSON(consts.StatusOK, resp)
}
@@ -1,216 +0,0 @@
// idl/hello/hello.proto
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v6.33.1
// source: hello.proto
package hello
import (
_ "cn/oneao/base-go/biz/model/api"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type HelloReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name" query:"name"`
}
func (x *HelloReq) Reset() {
*x = HelloReq{}
if protoimpl.UnsafeEnabled {
mi := &file_hello_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *HelloReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HelloReq) ProtoMessage() {}
func (x *HelloReq) ProtoReflect() protoreflect.Message {
mi := &file_hello_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HelloReq.ProtoReflect.Descriptor instead.
func (*HelloReq) Descriptor() ([]byte, []int) {
return file_hello_proto_rawDescGZIP(), []int{0}
}
func (x *HelloReq) GetName() string {
if x != nil {
return x.Name
}
return ""
}
type HelloResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RespBody string `protobuf:"bytes,1,opt,name=RespBody,proto3" form:"RespBody" json:"RespBody" query:"RespBody"`
}
func (x *HelloResp) Reset() {
*x = HelloResp{}
if protoimpl.UnsafeEnabled {
mi := &file_hello_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *HelloResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HelloResp) ProtoMessage() {}
func (x *HelloResp) ProtoReflect() protoreflect.Message {
mi := &file_hello_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HelloResp.ProtoReflect.Descriptor instead.
func (*HelloResp) Descriptor() ([]byte, []int) {
return file_hello_proto_rawDescGZIP(), []int{1}
}
func (x *HelloResp) GetRespBody() string {
if x != nil {
return x.RespBody
}
return ""
}
var File_hello_proto protoreflect.FileDescriptor
var file_hello_proto_rawDesc = []byte{
0x0a, 0x0b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x68,
0x65, 0x6c, 0x6c, 0x6f, 0x1a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
0x28, 0x0a, 0x08, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x04, 0x4e,
0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, 0xb2, 0xbb, 0x18, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x27, 0x0a, 0x09, 0x48, 0x65, 0x6c,
0x6c, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x42, 0x6f,
0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x52, 0x65, 0x73, 0x70, 0x42, 0x6f,
0x64, 0x79, 0x32, 0x48, 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x12, 0x38, 0x0a, 0x07, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x31, 0x12, 0x0f, 0x2e,
0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x10,
0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x73, 0x70,
0x22, 0x0a, 0xca, 0xc1, 0x18, 0x06, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x42, 0x28, 0x5a, 0x26,
0x63, 0x6e, 0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2d, 0x67, 0x6f,
0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x68, 0x65, 0x72, 0x74, 0x7a,
0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_hello_proto_rawDescOnce sync.Once
file_hello_proto_rawDescData = file_hello_proto_rawDesc
)
func file_hello_proto_rawDescGZIP() []byte {
file_hello_proto_rawDescOnce.Do(func() {
file_hello_proto_rawDescData = protoimpl.X.CompressGZIP(file_hello_proto_rawDescData)
})
return file_hello_proto_rawDescData
}
var file_hello_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_hello_proto_goTypes = []interface{}{
(*HelloReq)(nil), // 0: hello.HelloReq
(*HelloResp)(nil), // 1: hello.HelloResp
}
var file_hello_proto_depIdxs = []int32{
0, // 0: hello.HelloService.Method1:input_type -> hello.HelloReq
1, // 1: hello.HelloService.Method1:output_type -> hello.HelloResp
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_hello_proto_init() }
func file_hello_proto_init() {
if File_hello_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_hello_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*HelloReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_hello_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*HelloResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_hello_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_hello_proto_goTypes,
DependencyIndexes: file_hello_proto_depIdxs,
MessageInfos: file_hello_proto_msgTypes,
}.Build()
File_hello_proto = out.File
file_hello_proto_rawDesc = nil
file_hello_proto_goTypes = nil
file_hello_proto_depIdxs = nil
}
@@ -1,21 +0,0 @@
// Code generated by hertz generator. DO NOT EDIT.
package hello
import (
hello "cn/oneao/base-go/biz/handler/hello"
"github.com/cloudwego/hertz/pkg/app/server"
)
/*
This file will register all the routes of the services in the master idl.
And it will update automatically when you use the "update" command for the idl.
So don't modify the contents of the file, or your code will be deleted when it is updated.
*/
// Register register routes based on the IDL 'api.${HTTP Method}' annotation.
func Register(r *server.Hertz) {
root := r.Group("/", rootMw()...)
root.GET("/hello", append(_method1Mw(), hello.Method1)...)
}
@@ -1,17 +0,0 @@
// Code generated by hertz generator.
package hello
import (
"github.com/cloudwego/hertz/pkg/app"
)
func rootMw() []app.HandlerFunc {
// your code...
return nil
}
func _method1Mw() []app.HandlerFunc {
// your code...
return nil
}
@@ -4,14 +4,12 @@ package router
import (
auth "cn/oneao/base-go/biz/router/auth"
hello "cn/oneao/base-go/biz/router/hello"
"github.com/cloudwego/hertz/pkg/app/server"
)
// GeneratedRegister registers routers generated by IDL.
func GeneratedRegister(r *server.Hertz) {
//INSERT_POINT: DO NOT DELETE THIS LINE!
hello.Register(r)
auth.Register(r)
}
@@ -60,8 +60,6 @@ func init() {
userinfoDescUpdateTime := userinfoFields[8].Descriptor()
// userinfo.DefaultUpdateTime holds the default value on creation for the update_time field.
userinfo.DefaultUpdateTime = userinfoDescUpdateTime.Default.(func() time.Time)
// userinfo.UpdateDefaultUpdateTime holds the default value on update for the update_time field.
userinfo.UpdateDefaultUpdateTime = userinfoDescUpdateTime.UpdateDefault.(func() time.Time)
// userinfoDescID is the schema descriptor for id field.
userinfoDescID := userinfoFields[0].Descriptor()
// userinfo.DefaultID holds the default value on creation for the id field.
@@ -71,7 +71,6 @@ func (UserInfo) Fields() []ent.Field {
// 自动更新时间
field.Time("update_time").
Default(time.Now).
UpdateDefault(time.Now).
Comment("更新时间"),
field.Time("last_login_time").
@@ -76,8 +76,6 @@ var (
DefaultCreateTime func() time.Time
// DefaultUpdateTime holds the default value on creation for the "update_time" field.
DefaultUpdateTime func() time.Time
// UpdateDefaultUpdateTime holds the default value on update for the "update_time" field.
UpdateDefaultUpdateTime func() time.Time
// DefaultID holds the default value on creation for the "id" field.
DefaultID func() int64
)
@@ -132,6 +132,14 @@ func (_u *UserInfoUpdate) SetUpdateTime(v time.Time) *UserInfoUpdate {
return _u
}
// SetNillableUpdateTime sets the "update_time" field if the given value is not nil.
func (_u *UserInfoUpdate) SetNillableUpdateTime(v *time.Time) *UserInfoUpdate {
if v != nil {
_u.SetUpdateTime(*v)
}
return _u
}
// SetLastLoginTime sets the "last_login_time" field.
func (_u *UserInfoUpdate) SetLastLoginTime(v time.Time) *UserInfoUpdate {
_u.mutation.SetLastLoginTime(v)
@@ -159,7 +167,6 @@ func (_u *UserInfoUpdate) Mutation() *UserInfoMutation {
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *UserInfoUpdate) Save(ctx context.Context) (int, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
@@ -185,14 +192,6 @@ func (_u *UserInfoUpdate) ExecX(ctx context.Context) {
}
}
// defaults sets the default values of the builder before save.
func (_u *UserInfoUpdate) defaults() {
if _, ok := _u.mutation.UpdateTime(); !ok {
v := userinfo.UpdateDefaultUpdateTime()
_u.mutation.SetUpdateTime(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *UserInfoUpdate) check() error {
if v, ok := _u.mutation.Email(); ok {
@@ -387,6 +386,14 @@ func (_u *UserInfoUpdateOne) SetUpdateTime(v time.Time) *UserInfoUpdateOne {
return _u
}
// SetNillableUpdateTime sets the "update_time" field if the given value is not nil.
func (_u *UserInfoUpdateOne) SetNillableUpdateTime(v *time.Time) *UserInfoUpdateOne {
if v != nil {
_u.SetUpdateTime(*v)
}
return _u
}
// SetLastLoginTime sets the "last_login_time" field.
func (_u *UserInfoUpdateOne) SetLastLoginTime(v time.Time) *UserInfoUpdateOne {
_u.mutation.SetLastLoginTime(v)
@@ -427,7 +434,6 @@ func (_u *UserInfoUpdateOne) Select(field string, fields ...string) *UserInfoUpd
// Save executes the query and returns the updated UserInfo entity.
func (_u *UserInfoUpdateOne) Save(ctx context.Context) (*UserInfo, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
@@ -453,14 +459,6 @@ func (_u *UserInfoUpdateOne) ExecX(ctx context.Context) {
}
}
// defaults sets the default values of the builder before save.
func (_u *UserInfoUpdateOne) defaults() {
if _, ok := _u.mutation.UpdateTime(); !ok {
v := userinfo.UpdateDefaultUpdateTime()
_u.mutation.SetUpdateTime(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *UserInfoUpdateOne) check() error {
if v, ok := _u.mutation.Email(); ok {
Binary file not shown.
+8 -2
View File
@@ -7,7 +7,6 @@ require (
github.com/cloudwego/hertz v0.10.3
github.com/golang-jwt/jwt/v4 v4.5.2
github.com/hertz-contrib/jwt v1.0.4
github.com/hertz-contrib/logger/zap v1.1.0
github.com/hertz-contrib/requestid v1.1.0
github.com/lib/pq v1.10.9
go.uber.org/zap v1.27.1
@@ -29,12 +28,17 @@ require (
github.com/elastic/pkcs8 v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/go-openapi/inflect v0.21.3 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/hcl/v2 v2.24.0 // indirect
github.com/hertz-contrib/logger/zap v1.1.0 // indirect
github.com/jmoiron/sqlx v1.4.0 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/nyaruka/phonenumbers v1.6.7 // indirect
github.com/syndtr/goleveldb v1.0.0 // indirect
github.com/tidwall/gjson v1.18.0 // indirect
github.com/tidwall/match v1.2.0 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
@@ -44,11 +48,13 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.23.0 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6 // indirect
golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 // indirect
golang.org/x/mod v0.30.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/tools v0.39.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
xorm.io/builder v0.3.13 // indirect
xorm.io/xorm v1.3.11 // indirect
)
+43
View File
@@ -2,6 +2,8 @@ ariga.io/atlas v0.38.0 h1:MwbtwVtDWJFq+ECyeTAz2ArvewDnpeiw/t/sgNdDsdo=
ariga.io/atlas v0.38.0/go.mod h1:D7XMK6ei3GvfDqvzk+2VId78j77LdqHrqPOWamn51/s=
entgo.io/ent v0.14.5 h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=
entgo.io/ent v0.14.5/go.mod h1:zTzLmWtPvGpmSwtkaayM2cm5m819NdM7z7tYPq3vN0U=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
@@ -38,17 +40,25 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/elastic/pkcs8 v1.0.0 h1:HhitlUKxhN288kcNcYkjW6/ouvuwJWd9ioxpjnD9jVA=
github.com/elastic/pkcs8 v1.0.0/go.mod h1:ipsZToJfq1MxclVTwpG7U/bgeDtf+0HkUiOxebk95+0=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/go-openapi/inflect v0.21.3 h1:TmQvw+9eLrsNp4X0BBQacEZZtAnzk2z1FaLdQQJsDiU=
github.com/go-openapi/inflect v0.21.3/go.mod h1:INezMuUu7SJQc2AyR3WO0DqqYUJSj8Kb4hBd7WtjlAw=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI=
github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
@@ -66,6 +76,11 @@ github.com/hertz-contrib/logger/zap v1.1.0 h1:4efINiIDJrXEtAFeEdDJvc3Hye0VFxp+0X
github.com/hertz-contrib/logger/zap v1.1.0/go.mod h1:D/rJJgsYn+SGaHVfVqWS3vHTbbc7ODAlJO+6smWgTeE=
github.com/hertz-contrib/requestid v1.1.0 h1:+y1cuNlNX2KUoEC1SnBJ6M55/TlMTx3M9yxkqi0oTkk=
github.com/hertz-contrib/requestid v1.1.0/go.mod h1:+l5CbZl//cSUoos421fnDFKQ6YYlVHcYc3Ri7AS8DUA=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
@@ -76,8 +91,12 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A=
github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
@@ -85,13 +104,23 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
github.com/nyaruka/phonenumbers v1.0.55/go.mod h1:sDaTZ/KPX5f8qyV9qN+hIm+4ZBARJrupC6LuhshJq1U=
github.com/nyaruka/phonenumbers v1.6.7 h1:WmebT8TNEzNaui5QlrGqbccRC6dZkEkYc+MGQoILSSo=
github.com/nyaruka/phonenumbers v1.6.7/go.mod h1:7gjs+Lchqm49adhAKB5cdcng5ZXgt6x7Jgvi0ZorUtU=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@@ -102,6 +131,8 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/tidwall/gjson v1.9.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.13.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
@@ -138,10 +169,13 @@ golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6 h1:zfMcR1Cs4KNuomFFgGefv5N0czO2XZpUbxGUy8i8ug0=
golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6/go.mod h1:46edojNIoXTNOhySWIWdix628clX9ODXwPsQuG6hsK0=
golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 h1:DHNhtq3sNNzrvduZZIiFyXWOL9IWaDPHqTnLJp+rCBY=
golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39/go.mod h1:46edojNIoXTNOhySWIWdix628clX9ODXwPsQuG6hsK0=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk=
golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
@@ -149,6 +183,7 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -156,6 +191,7 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -199,10 +235,17 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo=
xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
xorm.io/xorm v1.3.11 h1:i4tlVUASogb0ZZFJHA7dZqoRU2pUpUsutnNdaOlFyMI=
xorm.io/xorm v1.3.11/go.mod h1:cs0ePc8O4a0jD78cNvD+0VFwhqotTvLQZv372QsDw7Q=
@@ -1,22 +0,0 @@
// idl/hello/hello.proto
syntax = "proto3";
package hello;
option go_package = "hertz/hello";
import "api.proto";
message HelloReq {
string Name = 1[(api.query)="name"];
}
message HelloResp {
string RespBody = 1;
}
service HelloService {
rpc Method1(HelloReq) returns(HelloResp) {
option (api.get) = "/hello";
}
}
@@ -0,0 +1,73 @@
package routinex
import (
"runtime"
"strconv"
"strings"
"sync"
)
// CurGID 获取 routine 的id
func CurGID() uint64 {
var buf [64]byte
n := runtime.Stack(buf[:], false)
line := strings.Fields(strings.TrimPrefix(string(buf[:n]), "goroutine "))[0]
gid, _ := strconv.ParseUint(line, 10, 64)
return gid
}
type RoutineLocal struct {
data sync.Map // gid -> map[key]any
}
var (
instance *RoutineLocal
instanceOnce sync.Once
)
// GetInstance 获取当前示例
func GetInstance() *RoutineLocal {
instanceOnce.Do(func() {
instance = &RoutineLocal{}
})
return instance
}
// Set 存储单条数据
func Set(key string, value any) {
gid := CurGID()
v, _ := GetInstance().data.LoadOrStore(gid, &sync.Map{})
m := v.(*sync.Map)
m.Store(key, value)
}
// Get 获取单条数据
func Get(key string) any {
gid := CurGID()
if v, ok := GetInstance().data.Load(gid); ok {
m := v.(*sync.Map)
if val, ok := m.Load(key); ok {
return val
}
}
return nil
}
// Clear 删除当前 goroutine 所有数据
func Clear() {
GetInstance().data.Delete(CurGID())
}
// Go 自动继承父 goroutine 数据,多 routine 的时候需要使用
func Go(f func()) {
parentGID := CurGID()
parentData, _ := GetInstance().data.Load(parentGID)
go func() {
if parentData != nil {
GetInstance().data.Store(CurGID(), parentData)
defer Clear()
}
f()
}()
}