feat(ticket): 添加issue_type字段支持工单分类

在工单系统中新增issue_type字段用于区分工单类型(0-普通工单,1-提现工单)
修改相关API、模型和逻辑以支持该字段的创建、查询和筛选
This commit is contained in:
2025-09-15 01:42:44 -07:00
parent 2d4bfe0330
commit ac3bbaf7bf
8 changed files with 36 additions and 23 deletions
+6 -2
View File
@@ -17,6 +17,7 @@ type Details struct {
Description string `gorm:"type:text;comment:Description"`
UserId int64 `gorm:"type:bigint;not null;default:0;comment:UserId"`
Status uint8 `gorm:"type:tinyint(1);not null;default:1;comment:Status"`
IssueType uint8 `gorm:"type:tinyint(1);not null;default:0;comment:Issue Type: 0 ticket, 1 withdraw"`
Follows []Follow `gorm:"foreignKey:TicketId;references:Id"`
CreatedAt time.Time `gorm:"<-:create;comment:Create Time"`
UpdatedAt time.Time `gorm:"comment:Update Time"`
@@ -24,7 +25,7 @@ type Details struct {
type customTicketLogicModel interface {
QueryTicketDetail(ctx context.Context, id int64) (*Details, error)
InsertTicketFollow(ctx context.Context, data *Follow) error
QueryTicketList(ctx context.Context, page, size int, userId int64, status *uint8, search string) (int64, []*Ticket, error)
QueryTicketList(ctx context.Context, page, size int, userId int64, status *uint8, issueType *uint8, search string) (int64, []*Ticket, error)
UpdateTicketStatus(ctx context.Context, id, userId int64, status uint8) error
QueryWaitReplyTotal(ctx context.Context) (int64, error)
}
@@ -55,7 +56,7 @@ func (m *customTicketModel) InsertTicketFollow(ctx context.Context, data *Follow
}
// QueryTicketList returns the ticket list.
func (m *customTicketModel) QueryTicketList(ctx context.Context, page, size int, userId int64, status *uint8, search string) (int64, []*Ticket, error) {
func (m *customTicketModel) QueryTicketList(ctx context.Context, page, size int, userId int64, status *uint8, issueType *uint8, search string) (int64, []*Ticket, error) {
var data []*Ticket
var total int64
err := m.QueryNoCacheCtx(ctx, &data, func(conn *gorm.DB, v interface{}) error {
@@ -68,6 +69,9 @@ func (m *customTicketModel) QueryTicketList(ctx context.Context, page, size int,
} else {
query = query.Where("status != ?", 4)
}
if issueType != nil {
query = query.Where("issue_type = ?", issueType)
}
if search != "" {
query = query.Where("title like ? or description like ?", "%"+search+"%", "%"+search+"%")
}
+2 -1
View File
@@ -12,9 +12,10 @@ const (
type Ticket struct {
Id int64 `gorm:"primaryKey"`
Title string `gorm:"type:varchar(255);not null;default:'';comment:Title"`
Description string `gorm:"type:text;comment:Description"`
Description string `gorm:"type:longtext;comment:Description"`
UserId int64 `gorm:"type:bigint;not null;default:0;comment:UserId"`
Status uint8 `gorm:"type:tinyint(1);not null;default:1;comment:Status"`
IssueType uint8 `gorm:"type:tinyint(1);not null;default:0;comment:Issue Type: 0 ticket, 1 withdraw"`
CreatedAt time.Time `gorm:"<-:create;comment:Create Time"`
UpdatedAt time.Time `gorm:"comment:Update Time"`
}