Pārlūkot izejas kodu

公共广播系统-报错修复

sixian 2 gadi atpakaļ
vecāks
revīzija
ad21778f10

+ 1 - 1
Makefile

@@ -1,9 +1,9 @@
 BINARY="build/iot_service"
 VERSION=1.0.0
 BASH_PATH=D:\Programs\Git\bin\bash.exe
-
 export GOARCH=amd64
 export GOOS=linux
+
 clear:
 	$(RM) ${BINARY}
 

+ 0 - 2
README.md

@@ -1,5 +1,3 @@
 ## go 平江智慧路灯大数据平台
 
 ### 常见问题
-* 1. 2022-12-15 `github.com/tosone/minimp`报gcc不存在
-    参考这个方法在本地安装gcc ![https://www.cnblogs.com/lonecloud/p/15468154.html](https://www.cnblogs.com/lonecloud/p/15468154.html)

+ 2 - 0
app/multimedia/controller/programController.go

@@ -171,4 +171,6 @@ func (c *programCtl) Audit(ctx *gin.Context) {
 		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
 		return
 	}
+
+	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, nil))
 }

+ 46 - 0
app/multimedia/controller/publishLibrariesController.go

@@ -0,0 +1,46 @@
+package controller
+
+import (
+	"github.com/gin-gonic/gin"
+	"iot_manager_service/app/middleware"
+	"iot_manager_service/app/multimedia/model"
+	"iot_manager_service/app/multimedia/service"
+	"iot_manager_service/util/common"
+	"math"
+	"net/http"
+	"strconv"
+)
+
+var PublishLibraries = new(PublishLibrariesCtl)
+
+type PublishLibrariesCtl struct{}
+
+func (c *PublishLibrariesCtl) List(ctx *gin.Context) {
+	searchValue := ctx.Query("searchValue")
+	current, _ := strconv.Atoi(ctx.Query("current"))
+	size, _ := strconv.Atoi(ctx.Query("size"))
+
+	if current == 0 {
+		current = 1
+	}
+	if size <= 0 || size > 100 {
+		size = 10
+	}
+
+	value, _ := ctx.Get(middleware.Authorization)
+	claims := value.(*middleware.Claims)
+	libraries, err := service.PublishLibrariesService.List(claims.TenantId, searchValue, current, size)
+	if err != nil {
+		ctx.JSON(http.StatusOK, err)
+		return
+	}
+	pages := math.Ceil(float64(len(libraries)) / float64(size))
+	rsp := model.RsqPublishLibrariesList{
+		Current: current,
+		Size:    size,
+		Total:   len(libraries),
+		Pages:   int(pages),
+		Records: libraries,
+	}
+	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
+}

+ 13 - 7
app/multimedia/dao/common.go

@@ -3,18 +3,24 @@ package dao
 import (
 	"fmt"
 	"gorm.io/gorm"
+	"iot_manager_service/util/common"
 )
 
 var Db *gorm.DB
 
 func InitDB(db *gorm.DB) {
 	Db = db
-	err := Db.AutoMigrate(
-		&Library{},
-		&Program{},
-		&ProgramRelation{},
-	)
-	if err != nil {
-		panic(fmt.Sprintf("AutoMigrate err : %v", err))
+	models := []common.TableModelAuto{
+		{&Library{}, "素材表"},
+		{&Program{}, "节目表"},
+		{&ProgramRelation{}, "节目排期表"},
+		{&PublishLibraries{}, "已发布节目单库"},
+	}
+	for _, val := range models {
+		//fmt.Println(val.Model)
+		err := Db.Set("gorm:table_options", "comment '"+val.Comment+"'").AutoMigrate(val.Model)
+		if err != nil {
+			panic(fmt.Sprintf("AutoMigrate err : %v", err))
+		}
 	}
 }

+ 44 - 0
app/multimedia/dao/publishLibrariesDao.go

@@ -0,0 +1,44 @@
+package dao
+
+import (
+	"time"
+)
+
+type PublishLibraries struct {
+	Id               uint      `gorm:"column:id;type:int(10) unsigned;primary_key;AUTO_INCREMENT;" json:"id"` // 编号
+	Name             string    `gorm:"column:name;type:varchar(64)" json:"name"`                              // 名称
+	Resolution       int       `gorm:"column:resolution;type:int(11)" json:"resolution"`                      // 分辨率
+	Duration         int64     `gorm:"column:duration;type:bigint(20);default:0" json:"duration"`             // 统计文件时长
+	FileSize         int64     `gorm:"column:file_size;type:bigint(20);default:0" json:"file_size"`           // 统计文件大小
+	InfoId           string    `gorm:"column:info_id;type:varchar(4000)" json:"info_id"`                      // 信息屏ID 组合
+	ImgDuration      int       `gorm:"column:img_duration;type:int(11);default:0" json:"img_duration"`        // 图片播放时长(毫秒)
+	StartTime        time.Time `gorm:"column:start_time;type:date" json:"start_time"`                         // 播放开始时间
+	EndTime          time.Time `gorm:"column:end_time;type:date" json:"end_time"`                             // 播放结束时间
+	NotificationType string    `gorm:"column:notification_type;type:varchar(60)" json:"notification_type"`    // 通知类型 组合1短信2邮件3电话4微信
+	CreateTime       time.Time `gorm:"column:create_time;type:datetime" json:"create_time"`                   // 新增时间
+	CreateUser       string    `gorm:"column:create_user;type:varchar(60)" json:"create_user"`                // 新增记录操作用户ID
+	CreateName       string    `gorm:"column:create_name;type:varchar(64)" json:"create_name"`                // 新增用户姓名
+	UpdateTime       time.Time `gorm:"column:update_time;type:datetime" json:"update_time"`                   // 修改时间
+	UpdateUser       string    `gorm:"column:update_user;type:varchar(60)" json:"update_user"`                // 修改用户
+	IsDeleted        int       `gorm:"column:is_deleted;type:int(11);default:0" json:"is_deleted"`            // 是否删除 0=未删除,1=删除
+	Status           int       `gorm:"column:status;type:int(11)" json:"status"`                              // 状态 0审核1播放2暂停3取消4过期5审核不通过
+	TenantId         int       `gorm:"column:tenant_id;type:int(11)" json:"tenant_id"`                        // 租户ID
+	Remarks          string    `gorm:"column:remarks;type:varchar(4000)" json:"remarks"`                      // 备注
+	SysType          int       `gorm:"column:sys_type;type:int(11);default:0" json:"sys_type"`                // 系统类型:0-多媒体系统,1-广播系统
+	KsTime           time.Time `gorm:"column:ks_time;type:bigint(20)" json:"ks_time"`                         // 播放开始时间
+	JsTime           time.Time `gorm:"column:js_time;type:bigint(20)" json:"js_time"`                         // 播放结束时间
+	FileId           int       `gorm:"column:file_id;type:int(11)" json:"file_id"`                            // 文件ID,系统类型为广播系统时使用
+	TaskId           int       `gorm:"column:task_id;type:int(11)" json:"task_id"`                            // 任务ID,发布后才有用于控制启动与停止
+	PlayTime         int       `gorm:"column:play_time;type:int(11);default:1" json:"play_time"`              // 播放次数(1-100)
+	PlayInterval     int       `gorm:"column:play_interval;type:int(11);default:0" json:"play_interval"`      // 播放间隔(0-360秒)
+}
+
+func (PublishLibraries) TableName() string {
+	return "media_publish_libraries"
+}
+
+func (c *PublishLibraries) GetList(offset int, limit int) ([]PublishLibraries, error) {
+	var list []PublishLibraries
+	err := Db.Debug().Model(&c).Where("tenant_id = ? and is_deleted = 0", c.TenantId).Find(&list).Error
+	return list, err
+}

+ 11 - 0
app/multimedia/model/publishLibrary.go

@@ -0,0 +1,11 @@
+package model
+
+import "iot_manager_service/app/multimedia/dao"
+
+type RsqPublishLibrariesList struct {
+	Records []dao.PublishLibraries `json:"records"` //记录列表
+	Current int                    `json:"current"` //当前分页
+	Size    int                    `json:"size"`    //每页数量
+	Pages   int                    `json:"pages"`   //总页数
+	Total   int                    `json:"total"`   //总数
+}

+ 27 - 0
app/multimedia/service/publishLibrariesService.go

@@ -0,0 +1,27 @@
+package service
+
+import (
+	"iot_manager_service/app/multimedia/dao"
+	"iot_manager_service/util/common"
+)
+
+var PublishLibrariesService = new(publishLibrariesService)
+
+type publishLibrariesService struct{}
+
+func (s *publishLibrariesService) List(tenantId int, searchValue string, current, size int) ([]dao.PublishLibraries,
+	*common.Errors) {
+	program := &dao.PublishLibraries{
+		TenantId: tenantId,
+	}
+	offset := (current - 1) * size
+	limit := size
+	if searchValue != "" {
+		program.Name = searchValue
+	}
+	list, err := program.GetList(offset, limit)
+	if err != nil {
+		return nil, common.FailResponse(err.Error(), nil)
+	}
+	return list, nil
+}

+ 7 - 0
router/router.go

@@ -467,6 +467,7 @@ func InitRouter(engine *gin.Engine) {
 		multimediaGroup.POST("/remove", multimedia.Library.Remove)
 		multimediaGroup.GET("/getList", multimedia.Library.GetList)
 		multimediaGroup.POST("/putFile", multimedia.Library.UploadFile)
+		multimediaGroup.POST("/putMp3File", multimedia.Library.UploadFile)
 		multimediaGroup.POST("/submit", multimedia.Library.Submit)
 	}
 
@@ -491,6 +492,12 @@ func InitRouter(engine *gin.Engine) {
 		programGroup.POST("/audit", multimedia.Program.Audit)
 	}
 
+	//节目播放
+	publishLibraries := engine.Group("/api/longchi/multimedia/publishlibraries")
+	{
+		publishLibraries.GET("/list", multimedia.PublishLibraries.List)
+	}
+
 	operationGroup := engine.Group("/api/longchi/operation")
 	environment := operationGroup.Group("/em/environmentMonitor")
 	{

+ 5 - 0
util/common/common.go

@@ -148,3 +148,8 @@ func MlParseTime(strTime string) (time.Time, error) {
 func IsAdmin(roleId int64) bool {
 	return roleId == 1
 }
+
+type TableModelAuto struct {
+	Model   interface{}
+	Comment string
+}