zhangqian
2024-05-17 dc962c6426829f6c843bb57fb89627974667470c
音频检索增加时间范围和是否关注的搜索条件
6个文件已修改
121 ■■■■■ 已修改文件
controllers/audio.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/audio.go 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/audio.go 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/audio.go
@@ -178,6 +178,9 @@
        SetTrainNumber(params.TrainNumber).
        SetDriverNumber(params.DriverNumber).
        SetStation(params.StationNumber).
        SetBeginTime(params.BeginTime).
        SetEndTime(params.EndTime).
        SetIsFollowed(params.IsFollowed).
        Find()
    if err != nil {
docs/docs.go
@@ -199,12 +199,42 @@
                "parameters": [
                    {
                        "type": "string",
                        "description": "开始时间",
                        "name": "beginTime",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "司机号",
                        "name": "driverNumber",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "结束时间",
                        "name": "endTime",
                        "in": "query"
                    },
                    {
                        "enum": [
                            1,
                            2
                        ],
                        "type": "integer",
                        "x-enum-comments": {
                            "BoolTypeFalse": "false",
                            "BoolTypeTrue": "true"
                        },
                        "x-enum-varnames": [
                            "BoolTypeTrue",
                            "BoolTypeFalse"
                        ],
                        "description": "是否关注 1关注 2未关注",
                        "name": "isFollowed",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "关键字",
                        "name": "keyword",
                        "in": "query"
docs/swagger.json
@@ -187,12 +187,42 @@
                "parameters": [
                    {
                        "type": "string",
                        "description": "开始时间",
                        "name": "beginTime",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "司机号",
                        "name": "driverNumber",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "结束时间",
                        "name": "endTime",
                        "in": "query"
                    },
                    {
                        "enum": [
                            1,
                            2
                        ],
                        "type": "integer",
                        "x-enum-comments": {
                            "BoolTypeFalse": "false",
                            "BoolTypeTrue": "true"
                        },
                        "x-enum-varnames": [
                            "BoolTypeTrue",
                            "BoolTypeFalse"
                        ],
                        "description": "是否关注 1关注 2未关注",
                        "name": "isFollowed",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "关键字",
                        "name": "keyword",
                        "in": "query"
docs/swagger.yaml
@@ -313,10 +313,31 @@
  /api-sa/v1/audio/list:
    get:
      parameters:
      - description: 开始时间
        in: query
        name: beginTime
        type: string
      - description: 司机号
        in: query
        name: driverNumber
        type: string
      - description: 结束时间
        in: query
        name: endTime
        type: string
      - description: 是否关注 1关注 2未关注
        enum:
        - 1
        - 2
        in: query
        name: isFollowed
        type: integer
        x-enum-comments:
          BoolTypeFalse: "false"
          BoolTypeTrue: "true"
        x-enum-varnames:
        - BoolTypeTrue
        - BoolTypeFalse
      - description: 关键字
        in: query
        name: keyword
models/audio.go
@@ -38,6 +38,8 @@
        Orm      *gorm.DB
        Keyword  string
        IDs      []uint
        BeginTime time.Time
        EndTime   time.Time
    }
)
@@ -113,6 +115,21 @@
    return slf
}
func (slf *AudioSearch) SetBeginTime(time time.Time) *AudioSearch {
    slf.BeginTime = time
    return slf
}
func (slf *AudioSearch) SetEndTime(time time.Time) *AudioSearch {
    slf.EndTime = time
    return slf
}
func (slf *AudioSearch) SetIsFollowed(isFollowed constvar.BoolType) *AudioSearch {
    slf.IsFollowed = isFollowed
    return slf
}
func (slf *AudioSearch) build() *gorm.DB {
    var db = slf.Orm.Table(slf.TableName())
@@ -153,6 +170,18 @@
        db = db.Where("id in ?", slf.IDs)
    }
    if !slf.BeginTime.IsZero() {
        db = db.Where("occurrence_at >= ?", slf.BeginTime)
    }
    if !slf.EndTime.IsZero() {
        db = db.Where("occurrence_at <= ?", slf.EndTime)
    }
    if slf.IsFollowed != 0 {
        db = db.Where("is_followed = ?", slf.IsFollowed)
    }
    return db
}
request/audio.go
@@ -1,6 +1,9 @@
package request
import "speechAnalysis/constvar"
import (
    "speechAnalysis/constvar"
    "time"
)
type GetAudioList struct {
    PageInfo
@@ -9,6 +12,9 @@
    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"`    // 车站号
    BeginTime        time.Time         `json:"beginTime"`                                                                          //开始时间
    EndTime          time.Time         `json:"endTime"`                                                                            //结束时间
    IsFollowed       constvar.BoolType `json:"isFollowed"`                                                                         //是否关注 1关注 2未关注
}
type ProcessAudio struct {