refactor(工单/版本模块): 重构工单和版本模块代码结构

重构工单和版本模块的模型、服务层、控制器及CRUD操作
移除冗余代码,统一使用基础CRUD类实现
添加查询参数类用于工单和版本管理
优化模型字段定义和关系映射
This commit is contained in:
zhangtao
2025-09-16 00:42:11 +08:00
parent 046957654a
commit a42feeee30
14 changed files with 172 additions and 267 deletions
@@ -1,19 +1,16 @@
# -*- coding: utf-8 -*-
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from app.core.base_model import BaseModel
from app.api.v1.module_system.user.model import User
from datetime import datetime
from app.core.base_model import MappedBase, CreatorMixin
class Ticket(BaseModel):
class Ticket(CreatorMixin):
"""工单模型"""
__tablename__ = "ticket"
id = Column(Integer, primary_key=True, index=True, comment="工单ID")
title = Column(String(255), nullable=False, comment="工单标题")
status = Column(String(50), default="open", comment="工单状态(open, in_progress, resolved, closed)")
status = Column(String(50), default="1", comment="工单状态(1:待处理 2:处理中 3:已解决 4:已关闭)")
priority = Column(String(50), default="medium", comment="优先级(low, medium, high, urgent)")
type = Column(String(50), comment="工单类型(bug, feature, task)")
assignee_id = Column(Integer, ForeignKey("system_user.id"), comment="指派给用户ID")
@@ -21,10 +18,6 @@ class Ticket(BaseModel):
project = Column(String(100), comment="所属项目")
version = Column(String(50), comment="版本号")
description = Column(Text, comment="工单描述")
created_at = Column(DateTime, default=datetime.now, comment="创建时间")
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment="更新时间")
# 关系
assignee = relationship("User", foreign_keys=[assignee_id])
reporter = relationship("User", foreign_keys=[reporter_id])
assignee = relationship("UserModel", foreign_keys=[assignee_id])
reporter = relationship("UserModel", foreign_keys=[reporter_id])