feat(ticket): 添加issue_type字段支持工单分类
在工单系统中新增issue_type字段用于区分工单类型(0-普通工单,1-提现工单) 修改相关API、模型和逻辑以支持该字段的创建、查询和筛选
This commit is contained in:
parent
2d4bfe0330
commit
ac3bbaf7bf
@ -16,11 +16,12 @@ type (
|
||||
Status *uint8 `json:"status" validate:"required"`
|
||||
}
|
||||
GetTicketListRequest {
|
||||
Page int64 `form:"page"`
|
||||
Size int64 `form:"size"`
|
||||
UserId int64 `form:"user_id,omitempty"`
|
||||
Status *uint8 `form:"status,omitempty"`
|
||||
Search string `form:"search,omitempty"`
|
||||
Page int64 `form:"page"`
|
||||
Size int64 `form:"size"`
|
||||
UserId int64 `form:"user_id,omitempty"`
|
||||
Status *uint8 `form:"status,omitempty"`
|
||||
IssueType *uint8 `form:"issue_type,omitempty"`
|
||||
Search string `form:"search,omitempty"`
|
||||
}
|
||||
GetTicketListResponse {
|
||||
Total int64 `json:"total"`
|
||||
|
||||
@ -18,12 +18,14 @@ type (
|
||||
CreateUserTicketRequest {
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
IssueType uint8 `json:"issue_type"`
|
||||
}
|
||||
GetUserTicketListRequest {
|
||||
Page int `form:"page"`
|
||||
Size int `form:"size"`
|
||||
Status *uint8 `form:"status,omitempty"`
|
||||
Search string `form:"search,omitempty"`
|
||||
Page int `form:"page"`
|
||||
Size int `form:"size"`
|
||||
Status *uint8 `form:"status,omitempty"`
|
||||
IssueType *uint8 `form:"issue_type,omitempty"`
|
||||
Search string `form:"search,omitempty"`
|
||||
}
|
||||
GetUserTicketDetailRequest {
|
||||
Id int64 `form:"id" validate:"required"`
|
||||
|
||||
@ -27,7 +27,7 @@ func NewGetTicketListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Get
|
||||
}
|
||||
|
||||
func (l *GetTicketListLogic) GetTicketList(req *types.GetTicketListRequest) (resp *types.GetTicketListResponse, err error) {
|
||||
total, list, err := l.svcCtx.TicketModel.QueryTicketList(l.ctx, int(req.Page), int(req.Size), req.UserId, req.Status, req.Search)
|
||||
total, list, err := l.svcCtx.TicketModel.QueryTicketList(l.ctx, int(req.Page), int(req.Size), req.UserId, req.Status, req.IssueType, req.Search)
|
||||
if err != nil {
|
||||
l.Errorw("[GetTicketList] Query Database Error: ", logger.Field("error", err.Error()))
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "QueryTicketList error: %v", err)
|
||||
|
||||
@ -41,6 +41,7 @@ func (l *CreateUserTicketLogic) CreateUserTicket(req *types.CreateUserTicketRequ
|
||||
Description: req.Description,
|
||||
UserId: u.Id,
|
||||
Status: ticket.Pending,
|
||||
IssueType: req.IssueType,
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DatabaseInsertError), "insert ticket error: %v", err.Error())
|
||||
|
||||
@ -36,7 +36,7 @@ func (l *GetUserTicketListLogic) GetUserTicketList(req *types.GetUserTicketListR
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.InvalidAccess), "Invalid Access")
|
||||
}
|
||||
l.Logger.Debugf("Current user: %v", u.Id)
|
||||
total, list, err := l.svcCtx.TicketModel.QueryTicketList(l.ctx, req.Page, req.Size, u.Id, req.Status, req.Search)
|
||||
total, list, err := l.svcCtx.TicketModel.QueryTicketList(l.ctx, req.Page, req.Size, u.Id, req.Status, req.IssueType, req.Search)
|
||||
if err != nil {
|
||||
l.Errorw("[GetUserTicketListLogic] Database Error", logger.Field("error", err.Error()))
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "QueryTicketList error: %v", err)
|
||||
|
||||
@ -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+"%")
|
||||
}
|
||||
|
||||
@ -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"`
|
||||
}
|
||||
|
||||
@ -529,6 +529,7 @@ type CreateUserTicketFollowRequest struct {
|
||||
type CreateUserTicketRequest struct {
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
IssueType uint8 `json:"issue_type"`
|
||||
}
|
||||
|
||||
type Currency struct {
|
||||
@ -905,11 +906,12 @@ type GetSubscriptionResponse struct {
|
||||
}
|
||||
|
||||
type GetTicketListRequest struct {
|
||||
Page int64 `form:"page"`
|
||||
Size int64 `form:"size"`
|
||||
UserId int64 `form:"user_id,omitempty"`
|
||||
Status *uint8 `form:"status,omitempty"`
|
||||
Search string `form:"search,omitempty"`
|
||||
Page int64 `form:"page"`
|
||||
Size int64 `form:"size"`
|
||||
UserId int64 `form:"user_id,omitempty"`
|
||||
Status *uint8 `form:"status,omitempty"`
|
||||
IssueType *uint8 `form:"issue_type,omitempty"`
|
||||
Search string `form:"search,omitempty"`
|
||||
}
|
||||
|
||||
type GetTicketListResponse struct {
|
||||
@ -1021,10 +1023,11 @@ type GetUserTicketDetailRequest struct {
|
||||
}
|
||||
|
||||
type GetUserTicketListRequest struct {
|
||||
Page int `form:"page"`
|
||||
Size int `form:"size"`
|
||||
Status *uint8 `form:"status,omitempty"`
|
||||
Search string `form:"search,omitempty"`
|
||||
Page int `form:"page"`
|
||||
Size int `form:"size"`
|
||||
Status *uint8 `form:"status,omitempty"`
|
||||
IssueType *uint8 `form:"issue_type,omitempty"`
|
||||
Search string `form:"search,omitempty"`
|
||||
}
|
||||
|
||||
type GetUserTicketListResponse struct {
|
||||
@ -1769,6 +1772,7 @@ type Ticket struct {
|
||||
UserId int64 `json:"user_id"`
|
||||
Follows []Follow `json:"follow,omitempty"`
|
||||
Status uint8 `json:"status"`
|
||||
IssueType uint8 `json:"issue_type"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at"`
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user