From 8adde93b8f2af29fb8a6405efaa49a41a1c22f8d Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 15 五月 2024 20:15:31 +0800
Subject: [PATCH] 上传音频时保存车站号,车次,车站到火车信息表,提供火车信息查询接口
---
constvar/const.go | 8
request/audio.go | 12
models/train.go | 266 ++++++++++++++++++++
models/db.go | 1
models/audio.go | 12
docs/swagger.yaml | 87 ++++++
controllers/audio.go | 62 ++++
docs/docs.go | 130 +++++++++
docs/swagger.json | 130 +++++++++
router/router.go | 15
10 files changed, 700 insertions(+), 23 deletions(-)
diff --git a/constvar/const.go b/constvar/const.go
index 5d5daca..ce63823 100644
--- a/constvar/const.go
+++ b/constvar/const.go
@@ -25,3 +25,11 @@
func (slf BoolType) Bool() bool {
return slf == BoolTypeTrue
}
+
+type Class int
+
+const (
+ ClassLocomotive Class = 1 //鏈鸿溅
+ ClassTrain Class = 2 //杞︽
+ ClassStation Class = 3 //杞︾珯
+)
diff --git a/controllers/audio.go b/controllers/audio.go
index 94b0117..1326952 100644
--- a/controllers/audio.go
+++ b/controllers/audio.go
@@ -73,7 +73,7 @@
LocomotiveNumber: arr[0],
TrainNumber: arr[1],
DriverNumber: arr[2],
- StationNumber: arr[3],
+ Station: arr[3],
OccurrenceAt: t,
IsFollowed: 0,
}
@@ -82,6 +82,31 @@
util.ResponseFormat(c, code.SaveFail, "涓婁紶澶辫触")
return
}
+ go func() {
+
+ var trainInfoNames = []string{arr[0], arr[1], arr[3]}
+
+ var (
+ info *models.TrainInfo
+ err error
+ parent models.TrainInfo
+ )
+ for i := 0; i < 3; i++ {
+ name := trainInfoNames[i]
+ class := constvar.Class(i + 1)
+ info, err = models.NewTrainInfoSearch().SetName(name).SetClass(class).First()
+ if err == gorm.ErrRecordNotFound {
+ info = &models.TrainInfo{
+ Name: name,
+ Class: class,
+ ParentID: parent.ID,
+ }
+ _ = models.NewTrainInfoSearch().Create(info)
+ }
+ parent = *info
+ }
+
+ }()
util.ResponseFormat(c, code.Success, "娣诲姞鎴愬姛")
}
@@ -92,6 +117,39 @@
return errors.New("鏂囦欢鏍煎紡閿欒")
}
return nil
+}
+
+// TrainInfoList
+// @Tags 闊抽
+// @Summary 鑾峰彇鐏溅淇℃伅
+// @Produce application/json
+// @Param object query request.GetTrainInfoList true "鍙傛暟"
+// @Success 200 {object} util.ResponseList{data=[]models.TrainInfo} "鎴愬姛"
+// @Router /api-sa/v1/audio/trainInfoList [get]
+func (slf AudioCtl) TrainInfoList(c *gin.Context) {
+ var params request.GetTrainInfoList
+ if err := c.ShouldBindQuery(¶ms); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, err.Error())
+ return
+ }
+
+ if !params.PageInfo.Check() {
+ util.ResponseFormat(c, code.RequestParamError, "鍒嗛〉鍙傛暟閿欒")
+ return
+ }
+
+ list, total, err := models.NewTrainInfoSearch().
+ SetPage(params.Page, params.PageSize).
+ SetClass(params.Class).
+ SetParentId(params.ParentID).
+ Find()
+
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触")
+ return
+ }
+
+ util.ResponseFormatList(c, code.Success, list, total)
}
// List
@@ -119,7 +177,7 @@
SetLocomotiveNumber(params.LocomotiveNumber).
SetTrainNumber(params.TrainNumber).
SetDriverNumber(params.DriverNumber).
- SetStationNumber(params.StationNumber).
+ SetStation(params.StationNumber).
Find()
if err != nil {
diff --git a/docs/docs.go b/docs/docs.go
index c21ad56..64c129c 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -256,6 +256,81 @@
}
}
},
+ "/api-sa/v1/audio/trainInfoList": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "闊抽"
+ ],
+ "summary": "鑾峰彇鐏溅淇℃伅",
+ "parameters": [
+ {
+ "enum": [
+ 1,
+ 2,
+ 3
+ ],
+ "type": "integer",
+ "x-enum-comments": {
+ "ClassLocomotive": "鏈鸿溅",
+ "ClassStation": "杞︾珯",
+ "ClassTrain": "杞︽"
+ },
+ "x-enum-varnames": [
+ "ClassLocomotive",
+ "ClassTrain",
+ "ClassStation"
+ ],
+ "description": "淇℃伅鍒嗙被 1鏈鸿溅2杞︽3杞︾珯",
+ "name": "class",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "椤电爜",
+ "name": "page",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "姣忛〉澶у皬",
+ "name": "pageSize",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "涓婄骇id",
+ "name": "parentID",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.ResponseList"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/models.TrainInfo"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
"/api-sa/v1/audio/upload": {
"post": {
"produces": [
@@ -409,6 +484,24 @@
"BoolTypeFalse"
]
},
+ "constvar.Class": {
+ "type": "integer",
+ "enum": [
+ 1,
+ 2,
+ 3
+ ],
+ "x-enum-comments": {
+ "ClassLocomotive": "鏈鸿溅",
+ "ClassStation": "杞︾珯",
+ "ClassTrain": "杞︽"
+ },
+ "x-enum-varnames": [
+ "ClassLocomotive",
+ "ClassTrain",
+ "ClassStation"
+ ]
+ },
"gorm.DeletedAt": {
"type": "object",
"properties": {
@@ -472,8 +565,8 @@
"description": "闊抽澶у皬",
"type": "integer"
},
- "stationNumber": {
- "description": "杞︾珯鍙�",
+ "station": {
+ "description": "杞︾珯",
"type": "string"
},
"trainNumber": {
@@ -510,6 +603,39 @@
}
}
},
+ "models.TrainInfo": {
+ "type": "object",
+ "properties": {
+ "class": {
+ "description": "鍒嗙被",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.Class"
+ }
+ ]
+ },
+ "createdAt": {
+ "type": "string"
+ },
+ "deletedAt": {
+ "$ref": "#/definitions/gorm.DeletedAt"
+ },
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "description": "鍚嶇О",
+ "type": "string"
+ },
+ "parentID": {
+ "description": "涓婄骇id",
+ "type": "integer"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
"request.AddTextReq": {
"type": "object",
"required": [
diff --git a/docs/swagger.json b/docs/swagger.json
index fd84112..f946de2 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -244,6 +244,81 @@
}
}
},
+ "/api-sa/v1/audio/trainInfoList": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "闊抽"
+ ],
+ "summary": "鑾峰彇鐏溅淇℃伅",
+ "parameters": [
+ {
+ "enum": [
+ 1,
+ 2,
+ 3
+ ],
+ "type": "integer",
+ "x-enum-comments": {
+ "ClassLocomotive": "鏈鸿溅",
+ "ClassStation": "杞︾珯",
+ "ClassTrain": "杞︽"
+ },
+ "x-enum-varnames": [
+ "ClassLocomotive",
+ "ClassTrain",
+ "ClassStation"
+ ],
+ "description": "淇℃伅鍒嗙被 1鏈鸿溅2杞︽3杞︾珯",
+ "name": "class",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "椤电爜",
+ "name": "page",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "姣忛〉澶у皬",
+ "name": "pageSize",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "涓婄骇id",
+ "name": "parentID",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.ResponseList"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/models.TrainInfo"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
"/api-sa/v1/audio/upload": {
"post": {
"produces": [
@@ -397,6 +472,24 @@
"BoolTypeFalse"
]
},
+ "constvar.Class": {
+ "type": "integer",
+ "enum": [
+ 1,
+ 2,
+ 3
+ ],
+ "x-enum-comments": {
+ "ClassLocomotive": "鏈鸿溅",
+ "ClassStation": "杞︾珯",
+ "ClassTrain": "杞︽"
+ },
+ "x-enum-varnames": [
+ "ClassLocomotive",
+ "ClassTrain",
+ "ClassStation"
+ ]
+ },
"gorm.DeletedAt": {
"type": "object",
"properties": {
@@ -460,8 +553,8 @@
"description": "闊抽澶у皬",
"type": "integer"
},
- "stationNumber": {
- "description": "杞︾珯鍙�",
+ "station": {
+ "description": "杞︾珯",
"type": "string"
},
"trainNumber": {
@@ -498,6 +591,39 @@
}
}
},
+ "models.TrainInfo": {
+ "type": "object",
+ "properties": {
+ "class": {
+ "description": "鍒嗙被",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.Class"
+ }
+ ]
+ },
+ "createdAt": {
+ "type": "string"
+ },
+ "deletedAt": {
+ "$ref": "#/definitions/gorm.DeletedAt"
+ },
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "description": "鍚嶇О",
+ "type": "string"
+ },
+ "parentID": {
+ "description": "涓婄骇id",
+ "type": "integer"
+ },
+ "updatedAt": {
+ "type": "string"
+ }
+ }
+ },
"request.AddTextReq": {
"type": "object",
"required": [
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 53b00ca..fc611f7 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -30,6 +30,20 @@
x-enum-varnames:
- BoolTypeTrue
- BoolTypeFalse
+ constvar.Class:
+ enum:
+ - 1
+ - 2
+ - 3
+ type: integer
+ x-enum-comments:
+ ClassLocomotive: 鏈鸿溅
+ ClassStation: 杞︾珯
+ ClassTrain: 杞︽
+ x-enum-varnames:
+ - ClassLocomotive
+ - ClassTrain
+ - ClassStation
gorm.DeletedAt:
properties:
time:
@@ -71,8 +85,8 @@
size:
description: 闊抽澶у皬
type: integer
- stationNumber:
- description: 杞︾珯鍙�
+ station:
+ description: 杞︾珯
type: string
trainNumber:
description: 杞︽
@@ -94,6 +108,27 @@
locomotiveNumber:
description: 鏈鸿溅鍙�
type: string
+ updatedAt:
+ type: string
+ type: object
+ models.TrainInfo:
+ properties:
+ class:
+ allOf:
+ - $ref: '#/definitions/constvar.Class'
+ description: 鍒嗙被
+ createdAt:
+ type: string
+ deletedAt:
+ $ref: '#/definitions/gorm.DeletedAt'
+ id:
+ type: integer
+ name:
+ description: 鍚嶇О
+ type: string
+ parentID:
+ description: 涓婄骇id
+ type: integer
updatedAt:
type: string
type: object
@@ -310,6 +345,54 @@
summary: 澶勭悊闊抽
tags:
- 闊抽
+ /api-sa/v1/audio/trainInfoList:
+ get:
+ parameters:
+ - description: 淇℃伅鍒嗙被 1鏈鸿溅2杞︽3杞︾珯
+ enum:
+ - 1
+ - 2
+ - 3
+ in: query
+ name: class
+ type: integer
+ x-enum-comments:
+ ClassLocomotive: 鏈鸿溅
+ ClassStation: 杞︾珯
+ ClassTrain: 杞︽
+ x-enum-varnames:
+ - ClassLocomotive
+ - ClassTrain
+ - ClassStation
+ - description: 椤电爜
+ in: query
+ name: page
+ type: integer
+ - description: 姣忛〉澶у皬
+ in: query
+ name: pageSize
+ type: integer
+ - description: 涓婄骇id
+ in: query
+ name: parentID
+ type: integer
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ allOf:
+ - $ref: '#/definitions/util.ResponseList'
+ - properties:
+ data:
+ items:
+ $ref: '#/definitions/models.TrainInfo'
+ type: array
+ type: object
+ summary: 鑾峰彇鐏溅淇℃伅
+ tags:
+ - 闊抽
/api-sa/v1/audio/upload:
post:
parameters:
diff --git a/models/audio.go b/models/audio.go
index 747d2d9..45331be 100644
--- a/models/audio.go
+++ b/models/audio.go
@@ -19,7 +19,7 @@
LocomotiveNumber string `gorm:"index;type:varchar(255);not null;default:'';comment:鏈鸿溅鍙�" json:"locomotiveNumber"` // 鏈鸿溅鍙�
TrainNumber string `gorm:"index;type:varchar(255);not null;default:'';comment:杞︽" json:"trainNumber"` // 杞︽
DriverNumber string `gorm:"index;type:varchar(255);not null;default:'';comment:鍙告満鍙�" json:"driverNumber"` // 鍙告満鍙�
- StationNumber string `gorm:"index;type:varchar(255);not null;default:'';comment:杞︾珯鍙�" json:"stationNumber"` // 杞︾珯鍙�
+ Station string `gorm:"index;type:varchar(255);not null;default:'';comment:杞︾珯鍙�" json:"station"` // 杞︾珯
OccurrenceAt time.Time `json:"-"`
OccurrenceTime string `json:"occurrenceTime" gorm:"-"`
IsFollowed constvar.BoolType `gorm:"type:tinyint;not null;default:2;comment:鏄惁鍏虫敞"` //鏄惁鍏虫敞 1鍏虫敞 2鏈叧娉�
@@ -100,8 +100,8 @@
slf.DriverNumber = name
return slf
}
-func (slf *AudioSearch) SetStationNumber(name string) *AudioSearch {
- slf.StationNumber = name
+func (slf *AudioSearch) SetStation(name string) *AudioSearch {
+ slf.Station = name
return slf
}
@@ -118,7 +118,7 @@
if slf.Keyword != "" {
kw := "%" + slf.Keyword + "%"
- db = db.Where("name like ? or locomotive_number like ? or train_number like ? or driver_number like ? or station_number like ?", kw, kw, kw, kw, kw)
+ db = db.Where("name like ? or locomotive_number like ? or train_number like ? or driver_number like ? or station like ?", kw, kw, kw, kw, kw)
}
if slf.Name != "" {
@@ -137,8 +137,8 @@
db = db.Where("driver_number like ?", slf.DriverNumber)
}
- if slf.StationNumber != "" {
- db = db.Where("station_number like ?", slf.StationNumber)
+ if slf.Station != "" {
+ db = db.Where("station like ?", slf.Station)
}
if len(slf.IDs) > 0 {
diff --git a/models/db.go b/models/db.go
index 0459d6a..e19e158 100644
--- a/models/db.go
+++ b/models/db.go
@@ -76,6 +76,7 @@
Audio{},
AudioText{},
Text{},
+ TrainInfo{},
)
return err
}
diff --git a/models/train.go b/models/train.go
new file mode 100644
index 0000000..025dc96
--- /dev/null
+++ b/models/train.go
@@ -0,0 +1,266 @@
+package models
+
+import (
+ "fmt"
+ "gorm.io/gorm"
+ "speechAnalysis/constvar"
+ "speechAnalysis/pkg/mysqlx"
+)
+
+type (
+ // TrainInfo 鐏溅淇℃伅
+ TrainInfo struct {
+ gorm.Model
+ Name string `gorm:"type:varchar(255);not null;default:'';comment:鍚嶇О" json:"name"` //鍚嶇О
+ Class constvar.Class `gorm:"type:tinyint;not null;default:0;comment:鍒嗙被" json:"class"` //鍒嗙被
+ ParentID uint `gorm:"type:int;not null;default 0; comment:涓婄骇id" json:"parentID"` //涓婄骇id
+ }
+
+ TrainInfoSearch struct {
+ TrainInfo
+ Order string
+ PageNum int
+ PageSize int
+ Orm *gorm.DB
+ Keyword string
+ IDs []uint
+ }
+)
+
+func (slf *TrainInfo) TableName() string {
+ return "train_info"
+}
+
+func NewTrainInfoSearch() *TrainInfoSearch {
+ return &TrainInfoSearch{Orm: mysqlx.GetDB()}
+}
+
+func (slf *TrainInfoSearch) SetOrm(tx *gorm.DB) *TrainInfoSearch {
+ slf.Orm = tx
+ return slf
+}
+
+func (slf *TrainInfoSearch) SetPage(page, size int) *TrainInfoSearch {
+ slf.PageNum, slf.PageSize = page, size
+ return slf
+}
+
+func (slf *TrainInfoSearch) SetOrder(order string) *TrainInfoSearch {
+ slf.Order = order
+ return slf
+}
+
+func (slf *TrainInfoSearch) SetID(id uint) *TrainInfoSearch {
+ slf.ID = id
+ return slf
+}
+
+func (slf *TrainInfoSearch) SetIDs(ids []uint) *TrainInfoSearch {
+ slf.IDs = ids
+ return slf
+}
+
+func (slf *TrainInfoSearch) SetKeyword(kw string) *TrainInfoSearch {
+ slf.Keyword = kw
+ return slf
+}
+
+func (slf *TrainInfoSearch) SetName(name string) *TrainInfoSearch {
+ slf.Name = name
+ return slf
+}
+
+func (slf *TrainInfoSearch) SetClass(class constvar.Class) *TrainInfoSearch {
+ slf.Class = class
+ return slf
+}
+
+func (slf *TrainInfoSearch) SetParentId(id uint) *TrainInfoSearch {
+ slf.ParentID = id
+ return slf
+}
+
+func (slf *TrainInfoSearch) build() *gorm.DB {
+ var db = slf.Orm.Table(slf.TableName())
+
+ if slf.ID != 0 {
+ db = db.Where("id = ?", slf.ID)
+ }
+
+ if slf.Order != "" {
+ db = db.Order(slf.Order)
+ }
+
+ if slf.Keyword != "" {
+ kw := "%" + slf.Keyword + "%"
+ db = db.Where("name like ? ", kw)
+ }
+
+ if len(slf.IDs) > 0 {
+ db = db.Where("id in ?", slf.IDs)
+ }
+
+ if slf.Name != "" {
+ db = db.Where("name = ?", slf.Name)
+ }
+
+ if slf.Class != 0 {
+ db = db.Where("class = ?", slf.Class)
+ }
+
+ if slf.ParentID != 0 {
+ db = db.Where("parent_id = ?", slf.ParentID)
+ }
+
+ return db
+}
+
+// Create 鍗曟潯鎻掑叆
+func (slf *TrainInfoSearch) Create(record *TrainInfo) error {
+ var db = slf.build()
+
+ if err := db.Create(record).Error; err != nil {
+ return fmt.Errorf("create err: %v, record: %+v", err, record)
+ }
+
+ return nil
+}
+
+// CreateBatch 鎵归噺鎻掑叆
+func (slf *TrainInfoSearch) CreateBatch(records []*TrainInfo) error {
+ var db = slf.build()
+
+ if err := db.Create(&records).Error; err != nil {
+ return fmt.Errorf("create batch err: %v, records: %+v", err, records)
+ }
+
+ return nil
+}
+
+func (slf *TrainInfoSearch) Save(record *TrainInfo) error {
+ var db = slf.build()
+
+ if err := db.Omit("CreatedAt").Save(record).Error; err != nil {
+ return fmt.Errorf("save err: %v, record: %+v", err, record)
+ }
+
+ return nil
+}
+
+func (slf *TrainInfoSearch) UpdateByMap(upMap map[string]interface{}) error {
+ var (
+ db = slf.build()
+ )
+
+ if err := db.Updates(upMap).Error; err != nil {
+ return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap)
+ }
+
+ return nil
+}
+
+func (slf *TrainInfoSearch) UpdateByQuery(query string, args []interface{}, upMap map[string]interface{}) error {
+ var (
+ db = slf.Orm.Table(slf.TableName()).Where(query, args...)
+ )
+
+ if err := db.Updates(upMap).Error; err != nil {
+ return fmt.Errorf("update by query err: %v, query: %s, args: %+v, upMap: %+v", err, query, args, upMap)
+ }
+
+ return nil
+}
+
+func (slf *TrainInfoSearch) Delete() error {
+ var db = slf.build()
+
+ if err := db.Delete(&TrainInfo{}).Error; err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (slf *TrainInfoSearch) First() (*TrainInfo, error) {
+ var (
+ record = new(TrainInfo)
+ db = slf.build()
+ )
+
+ if err := db.First(record).Error; err != nil {
+ return record, err
+ }
+
+ return record, nil
+}
+
+func (slf *TrainInfoSearch) Find() ([]*TrainInfo, int, error) {
+ var (
+ records = make([]*TrainInfo, 0)
+ total int64
+ db = slf.build()
+ )
+
+ if err := db.Count(&total).Error; err != nil {
+ return records, int(total), fmt.Errorf("find count err: %v", err)
+ }
+ if slf.PageNum*slf.PageSize > 0 {
+ db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
+ }
+ if err := db.Find(&records).Error; err != nil {
+ return records, int(total), fmt.Errorf("find records err: %v", err)
+ }
+
+ return records, int(total), nil
+}
+
+func (slf *TrainInfoSearch) FindNotTotal() ([]*TrainInfo, error) {
+ var (
+ records = make([]*TrainInfo, 0)
+ db = slf.build()
+ )
+
+ if slf.PageNum*slf.PageSize > 0 {
+ db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
+ }
+ if err := db.Find(&records).Error; err != nil {
+ return records, fmt.Errorf("find records err: %v", err)
+ }
+
+ return records, nil
+}
+
+// FindByQuery 鎸囧畾鏉′欢鏌ヨ.
+func (slf *TrainInfoSearch) FindByQuery(query string, args []interface{}) ([]*TrainInfo, int64, error) {
+ var (
+ records = make([]*TrainInfo, 0)
+ total int64
+ db = slf.Orm.Table(slf.TableName()).Where(query, args...)
+ )
+
+ if err := db.Count(&total).Error; err != nil {
+ return records, total, fmt.Errorf("find by query count err: %v", err)
+ }
+ if slf.PageNum*slf.PageSize > 0 {
+ db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
+ }
+ if err := db.Find(&records).Error; err != nil {
+ return records, total, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args)
+ }
+
+ return records, total, nil
+}
+
+// FindAll 鎸囧畾鏉′欢鏌ヨ&涓嶅垎椤�.
+func (slf *TrainInfoSearch) FindAll(query string, args []interface{}) ([]*TrainInfo, error) {
+ var (
+ records = make([]*TrainInfo, 0)
+ db = slf.Orm.Table(slf.TableName()).Where(query, args...)
+ )
+
+ if err := db.Find(&records).Error; err != nil {
+ return records, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args)
+ }
+
+ return records, nil
+}
diff --git a/request/audio.go b/request/audio.go
index 1e5512a..bfbeb50 100644
--- a/request/audio.go
+++ b/request/audio.go
@@ -1,10 +1,12 @@
package request
+import "speechAnalysis/constvar"
+
type GetAudioList struct {
PageInfo
- Keyword string `form:"keyword"` // 鍏抽敭瀛�
+ Keyword string `form:"keyword"` // 鍏抽敭瀛�
LocomotiveNumber string `gorm:"index;type:varchar(255);not null;default:'';comment:鏈鸿溅鍙�" form:"locomotiveNumber"` // 鏈鸿溅鍙�
- TrainNumber string `gorm:"index;type:varchar(255);not null;default:'';comment:杞︽" form:"trainNumber"` // 杞︽
+ TrainNumber string `gorm:"index;type:varchar(255);not null;default:'';comment:杞︽" form:"trainNumber"` // 杞︽
DriverNumber string `gorm:"index;type:varchar(255);not null;default:'';comment:鍙告満鍙�" form:"driverNumber"` // 鍙告満鍙�
StationNumber string `gorm:"index;type:varchar(255);not null;default:'';comment:杞︾珯鍙�" form:"stationNumber"` // 杞︾珯鍙�
}
@@ -20,3 +22,9 @@
type FollowReq struct {
ID uint `json:"id" binding:"required"`
}
+
+type GetTrainInfoList struct {
+ PageInfo
+ Class constvar.Class `form:"class" json:"class"` //淇℃伅鍒嗙被 1鏈鸿溅2杞︽3杞︾珯
+ ParentID uint `form:"parentID" json:"parentID"` //涓婄骇id
+}
diff --git a/router/router.go b/router/router.go
index 86b1549..1a4ad18 100644
--- a/router/router.go
+++ b/router/router.go
@@ -25,13 +25,14 @@
audioCtl := new(controllers.AudioCtl)
audioAPi := r.Group(urlPrefix + "/audio")
{
- audioAPi.POST("upload", audioCtl.Upload) // 涓婁紶闊抽
- audioAPi.GET("list", audioCtl.List) // 闊抽妫�绱�
- audioAPi.POST("process", audioCtl.Process) // 闊抽澶勭悊
- audioAPi.POST("batchProcess", audioCtl.BatchProcess) // 闊抽鎵归噺澶勭悊
- audioAPi.DELETE("delete", audioCtl.Delete) // 闊抽鍒犻櫎
- audioAPi.DELETE("batchDelete", audioCtl.BatchDelete) // 闊抽鎵归噺鍒犻櫎
- audioAPi.POST("follow", audioCtl.Follow) // 鍏虫敞/鍙栨秷鍏虫敞
+ audioAPi.POST("upload", audioCtl.Upload) // 涓婁紶闊抽
+ audioAPi.GET("list", audioCtl.List) // 闊抽妫�绱�
+ audioAPi.GET("trainInfoList", audioCtl.TrainInfoList) // 鐏溅淇℃伅鍒楄〃
+ audioAPi.POST("process", audioCtl.Process) // 闊抽澶勭悊
+ audioAPi.POST("batchProcess", audioCtl.BatchProcess) // 闊抽鎵归噺澶勭悊
+ audioAPi.DELETE("delete", audioCtl.Delete) // 闊抽鍒犻櫎
+ audioAPi.DELETE("batchDelete", audioCtl.BatchDelete) // 闊抽鎵归噺鍒犻櫎
+ audioAPi.POST("follow", audioCtl.Follow) // 鍏虫敞/鍙栨秷鍏虫敞
}
--
Gitblit v1.8.0