diff --git a/design/fix-enumeration.md b/design/fix-enumeration.md
new file mode 100644
index 00000000..b3b74cd6
--- /dev/null
+++ b/design/fix-enumeration.md
@@ -0,0 +1,7 @@
+# 需求
+
+后端将所有枚举修改为中文, 前端对应调整
+
+## 涉及枚举
+
+## 任务列表
\ No newline at end of file
diff --git a/docs/swagger.json b/docs/swagger.json
index 625d67a8..33fb77b7 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -993,6 +993,7 @@
},
{
"enum": [
+ 7,
-1,
0,
1,
@@ -1002,12 +1003,12 @@
5,
-1,
5,
- 6,
- 7
+ 6
],
"type": "integer",
"format": "int32",
"x-enum-varnames": [
+ "_numLevels",
"DebugLevel",
"InfoLevel",
"WarnLevel",
@@ -1017,8 +1018,7 @@
"FatalLevel",
"_minLevel",
"_maxLevel",
- "InvalidLevel",
- "_numLevels"
+ "InvalidLevel"
],
"name": "level",
"in": "query"
@@ -4055,6 +4055,46 @@
}
}
}
+ },
+ "/healthz": {
+ "get": {
+ "description": "检查服务进程是否运行正常,只要服务能响应就返回 200 OK。",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "健康检查"
+ ],
+ "summary": "服务存活检查",
+ "responses": {
+ "200": {
+ "description": "服务存活",
+ "schema": {
+ "$ref": "#/definitions/controller.Response"
+ }
+ }
+ }
+ }
+ },
+ "/readyz": {
+ "get": {
+ "description": "检查服务是否已准备好接收流量。当前实现为只要服务能响应即代表就绪。",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "健康检查"
+ ],
+ "summary": "服务就绪检查",
+ "responses": {
+ "200": {
+ "description": "服务已就绪",
+ "schema": {
+ "$ref": "#/definitions/controller.Response"
+ }
+ }
+ }
+ }
}
},
"definitions": {
@@ -6854,6 +6894,7 @@
"type": "integer",
"format": "int32",
"enum": [
+ 7,
-1,
0,
1,
@@ -6863,10 +6904,10 @@
5,
-1,
5,
- 6,
- 7
+ 6
],
"x-enum-varnames": [
+ "_numLevels",
"DebugLevel",
"InfoLevel",
"WarnLevel",
@@ -6876,8 +6917,7 @@
"FatalLevel",
"_minLevel",
"_maxLevel",
- "InvalidLevel",
- "_numLevels"
+ "InvalidLevel"
]
}
},
diff --git a/src/components/DeviceTemplateForm.vue b/src/components/DeviceTemplateForm.vue
index 75633689..15633fa8 100644
--- a/src/components/DeviceTemplateForm.vue
+++ b/src/components/DeviceTemplateForm.vue
@@ -27,8 +27,8 @@
-
-
+
+
@@ -42,7 +42,7 @@
@@ -68,6 +68,7 @@
import { ref, reactive, computed, watch, nextTick } from 'vue';
import { ElMessage } from 'element-plus';
import deviceTemplateService from '../services/deviceTemplateService.js';
+import { DeviceCategory } from '../enums.js';
// 默认的JSON模板
const DEFAULT_ACTUATOR_COMMANDS = JSON.stringify({
@@ -115,7 +116,7 @@ export default {
name: '',
manufacturer: '',
description: '',
- category: '执行器', // 默认执行器
+ category: DeviceCategory.ACTUATOR, // 默认执行器
commands: DEFAULT_ACTUATOR_COMMANDS, // 预填充执行器指令
values: '',
});
@@ -143,7 +144,7 @@ export default {
{ validator: validateJson, message: '指令参数必须是有效的 JSON 格式', trigger: 'blur' },
],
values: [
- { required: formData.category === '传感器', message: '请输入值描述', trigger: 'blur' },
+ { required: formData.category === DeviceCategory.SENSOR, message: '请输入值描述', trigger: 'blur' },
{ validator: validateJson, message: '值描述必须是有效的 JSON 格式', trigger: 'blur' },
],
}));
@@ -153,10 +154,10 @@ export default {
});
const handleCategoryChange = (newCategory) => {
- if (newCategory === '执行器') {
+ if (newCategory === DeviceCategory.ACTUATOR) {
formData.commands = DEFAULT_ACTUATOR_COMMANDS;
formData.values = ''; // 执行器没有values
- } else if (newCategory === '传感器') {
+ } else if (newCategory === DeviceCategory.SENSOR) {
formData.commands = DEFAULT_SENSOR_COMMANDS;
formData.values = DEFAULT_SENSOR_VALUES; // 传感器预填充values
}
@@ -193,7 +194,7 @@ export default {
commands: JSON.parse(formData.commands),
};
- if (formData.category === '传感器' && formData.values) {
+ if (formData.category === DeviceCategory.SENSOR && formData.values) {
submitData.values = JSON.parse(formData.values);
}
@@ -227,9 +228,9 @@ export default {
formData.manufacturer = newVal.manufacturer;
formData.description = newVal.description;
if (newVal.category === 'sensor') {
- formData.category = '传感器';
+ formData.category = DeviceCategory.SENSOR;
} else if (newVal.category === 'actuator') {
- formData.category = '执行器';
+ formData.category = DeviceCategory.ACTUATOR;
} else {
formData.category = newVal.category;
}
@@ -274,6 +275,7 @@ export default {
handleCategoryChange,
handleClose,
handleSubmit,
+ DeviceCategory,
};
},
};
diff --git a/src/components/PenForm.vue b/src/components/PenForm.vue
index 2a6bab5a..952e1996 100644
--- a/src/components/PenForm.vue
+++ b/src/components/PenForm.vue
@@ -39,6 +39,7 @@
import { ref, reactive, watch, computed, nextTick } from 'vue';
import { ElMessage } from 'element-plus';
import { createPen, updatePen } from '@/api/pen.js';
+import { PenStatus } from '@/enums.js';
export default {
name: 'PenForm',
@@ -60,13 +61,13 @@ export default {
setup(props, { emit }) {
const formRef = ref(null);
const loading = ref(false);
- const penStatusOptions = ["空闲", "使用中", "病猪栏", "康复栏", "清洗消毒", "维修中"];
+ const penStatusOptions = Object.values(PenStatus);
const initialFormData = () => ({
id: null,
pen_number: '',
capacity: 10,
- status: '空闲',
+ status: PenStatus.EMPTY,
house_id: null
});
diff --git a/src/components/PigBatchForm.vue b/src/components/PigBatchForm.vue
index 3061445f..55083cd2 100644
--- a/src/components/PigBatchForm.vue
+++ b/src/components/PigBatchForm.vue
@@ -53,6 +53,7 @@
import {ref, reactive, watch, computed, nextTick} from 'vue';
import {ElMessage} from 'element-plus';
import {createPigBatch, updatePigBatch} from '@/api/pigBatch.js';
+import { PigBatchOriginType, PigBatchStatus } from '@/enums.js';
export default {
name: 'PigBatchForm',
@@ -75,16 +76,16 @@ export default {
const formRef = ref(null);
const loading = ref(false);
- const originTypeOptions = ["自繁", "外购"];
- const batchStatusOptions = ["保育", "生长", "育肥", "待售", "已出售", "已归档"];
+ const originTypeOptions = Object.values(PigBatchOriginType);
+ const batchStatusOptions = Object.values(PigBatchStatus);
const initialFormData = () => ({
id: null,
batch_number: '',
initial_count: 1,
- origin_type: '自繁',
+ origin_type: PigBatchOriginType.SELF_FARROWED,
start_date: '',
- status: '保育',
+ status: PigBatchStatus.WEANING,
});
const formData = reactive(initialFormData());
@@ -182,8 +183,8 @@ export default {
formData.id = props.batchData.id;
formData.batch_number = props.batchData.batch_number || '';
formData.initial_count = props.batchData.initial_count || 1;
- formData.origin_type = props.batchData.origin_type || '自繁';
- formData.status = props.batchData.status || '保育';
+ formData.origin_type = props.batchData.origin_type || PigBatchOriginType.SELF_FARROWED;
+ formData.status = props.batchData.status || PigBatchStatus.WEANING;
formData.start_date = fromRFC3339(props.batchData.start_date);
}
nextTick(() => {
diff --git a/src/components/PigBatchPenCard.vue b/src/components/PigBatchPenCard.vue
index 7057eeea..d65ec219 100644
--- a/src/components/PigBatchPenCard.vue
+++ b/src/components/PigBatchPenCard.vue
@@ -18,6 +18,7 @@