Pārlūkot izejas kodu

节目、日志优化

terry 2 gadi atpakaļ
vecāks
revīzija
8ced89b1bd

+ 7 - 0
app/device/dao/infoBoardDao.go

@@ -109,3 +109,10 @@ func (c InfoBoard) GetDevicesByLampPole() []InfoBoard {
 		c.LampPoleId).Find(&devices)
 	return devices
 }
+
+func (c InfoBoard) GetDevicesByResolution() []InfoBoard {
+	var devices []InfoBoard
+	Db.Debug().Model(&c).Where("resolution = ? and tenant_id = ? and is_deleted = 0",
+		c.Resolution, c.TenantId).Find(&devices)
+	return devices
+}

+ 7 - 0
app/device/dao/ipBroadcastDao.go

@@ -101,3 +101,10 @@ func (c IpBroadcast) GetDevicesByLampPole() []IpBroadcast {
 		c.LampPoleId).Find(&devices)
 	return devices
 }
+
+func (c IpBroadcast) GetAll() []IpBroadcast {
+	var devices []IpBroadcast
+	Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId,
+		c.IsDeleted).Scan(&devices)
+	return devices
+}

+ 7 - 0
app/device/dao/lampPoleGroupDao.go

@@ -76,3 +76,10 @@ func (c LampPoleGroup) GetAllDevices() ([]*LampPoleGroup, error) {
 	err := Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
 	return devices, err
 }
+
+func (c LampPoleGroup) BatchGet(ids []int) []*LampPoleGroup {
+	var devices []*LampPoleGroup
+	Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? and id in (?)", c.TenantId,
+		c.IsDeleted, ids).Scan(&devices)
+	return devices
+}

+ 1 - 0
app/device/model/infoBoard.go

@@ -22,4 +22,5 @@ type InfoBoardDetail struct {
 	EndLineTime  time.Time `json:"endLineTime"`  //最后上线时间
 	NetworkState string    `json:"networkState"` //网络状态
 	RunState     string    `json:"runState"`     //运行状态
+	PublicName   string    `json:"publicName"`   //节目发布时使用
 }

+ 12 - 6
app/device/service/infoBoardService.go

@@ -109,18 +109,24 @@ func (s *infoBoardService) Remove(userId int64, tenantId int, id int) *common.Er
 	return nil
 }
 
-func (s *infoBoardService) GetByGateway(id int) []dao.InfoBoard {
-	// 创建查询实例
+func (s *infoBoardService) GetByGateway(gatewayId int) []dao.InfoBoard {
 	device := &dao.InfoBoard{
-		GatewayId: id,
+		GatewayId: gatewayId,
 	}
 	return device.GetDevicesByGateway()
 }
 
-func (s *infoBoardService) GetByLampPole(id int) []dao.InfoBoard {
-	// 创建查询实例
+func (s *infoBoardService) GetByLampPole(lampPoleId int) []dao.InfoBoard {
 	device := &dao.InfoBoard{
-		LampPoleId: id,
+		LampPoleId: lampPoleId,
 	}
 	return device.GetDevicesByLampPole()
 }
+
+func (s *infoBoardService) GetByResolution(tenantId, resolution int) []dao.InfoBoard {
+	device := &dao.InfoBoard{
+		Resolution: resolution,
+		TenantId:   tenantId,
+	}
+	return device.GetDevicesByResolution()
+}

+ 8 - 0
app/device/service/ipBroadcastService.go

@@ -138,3 +138,11 @@ func (s *ipBroadcastService) GetByLampPole(id int) []dao.IpBroadcast {
 	}
 	return device.GetDevicesByLampPole()
 }
+
+func (s *ipBroadcastService) GetAll(tenantId int) []dao.IpBroadcast {
+	device := &dao.IpBroadcast{
+		TenantId:  tenantId,
+		IsDeleted: 0,
+	}
+	return device.GetAll()
+}

+ 8 - 0
app/device/service/lampPoleGroupService.go

@@ -169,3 +169,11 @@ func (s *lampPoleGroupService) GetTree(tenantId int) ([]*dao.LampPoleGroup, *com
 
 	return devices, nil
 }
+
+func (s *lampPoleGroupService) GetByIds(tenantId int, ids []int) []*dao.LampPoleGroup {
+	device := &dao.LampPoleGroup{
+		TenantId:  tenantId,
+		IsDeleted: 0,
+	}
+	return device.BatchGet(ids)
+}

+ 32 - 7
app/multimedia/controller/programController.go

@@ -40,7 +40,7 @@ func (c *programCtl) List(ctx *gin.Context) {
 	if size <= 0 || size > 100 {
 		size = 10
 	}
-	sysType := -1
+	sysType := 0
 	if s != "" {
 		sysType, _ = strconv.Atoi(s)
 	}
@@ -132,18 +132,43 @@ func (c *programCtl) GetLibraryList(ctx *gin.Context) {
 
 func (c *programCtl) RelationDeviceList(ctx *gin.Context) {
 	resolutionStr := ctx.Query("resolution")
-	resolution, e := strconv.Atoi(resolutionStr)
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
+	sysTypeStr := ctx.Query("sysType")
+	resolution := 0
+	if resolutionStr != "" {
+		resolution, _ = strconv.Atoi(resolutionStr)
+	}
+	sysType := 0
+	if sysTypeStr != "" {
+		sysType, _ = strconv.Atoi(sysTypeStr)
+	}
+
+	value, _ := ctx.Get(middleware.Authorization)
+	claims := value.(*middleware.Claims)
+
+	devices, err := service.ProgramService.RelationDeviceList(claims.TenantId, sysType, resolution)
+	if err != nil {
+		ctx.JSON(http.StatusOK, err)
 		return
 	}
+	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, devices))
+}
+
+func (c *programCtl) RelationIpBroadcastList(ctx *gin.Context) {
 	value, _ := ctx.Get(middleware.Authorization)
 	claims := value.(*middleware.Claims)
 
-	libraries, err := service.ProgramService.RelationDeviceList(claims.TenantId, resolution)
+	devices, err := service.ProgramService.RelationDeviceList(claims.TenantId, 1, 0)
 	if err != nil {
-		ctx.JSON(http.StatusOK, e)
+		ctx.JSON(http.StatusOK, err)
+		return
+	}
+	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, devices))
+}
+
+func (c *programCtl) Audit(ctx *gin.Context) {
+	var req model.ReqProgramAudit
+	if err := ctx.ShouldBindJSON(&req); err != nil {
+		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
 		return
 	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, libraries))
 }

+ 27 - 0
app/multimedia/model/program.go

@@ -4,6 +4,11 @@ import (
 	"iot_manager_service/app/multimedia/dao"
 )
 
+const (
+	SysTypeInfoBar   = 0
+	SysTypeBroadcast = 1
+)
+
 type ProgramDetail struct {
 	dao.Program
 	LibraryIds     string `json:"libraryIds"`     //组合素材ID 逗号分割
@@ -29,3 +34,25 @@ type ReqProgramSubmit struct {
 	LibraryIds     string `json:"libraryIds"`     //组合素材ID 逗号分割
 	ResolutionName string `json:"resolutionName"` //分辨率
 }
+
+type ProgramDeviceDetail struct {
+	PublicName    string          `json:"publicName"`    //灯杆分组名
+	InfoBoardList []ProgramDevice `json:"infoBoardList"` //信息屏或ip音柱信息
+}
+
+type ProgramDevice struct {
+	Id         int    `json:"id"`         //设备id
+	PublicName string `json:"publicName"` //设备名
+}
+
+type ReqProgramAudit struct {
+	Duration           int64  `json:"duration"`           //统计文件时长
+	ProgramLibrariesId int    `json:"programLibrariesId"` //节目制作ID
+	ImgDuration        int    `json:"imgDuration"`        //图片时长
+	NotificationType   string `json:"notificationType"`   //通知类型 组合1短信2邮件3电话4微信
+	StartTime          string `json:"startTime"`          //播放开始日期
+	EndTime            string `json:"endTime"`            //播放结束日期
+	InfoId             string `json:"infoId"`             //设备id组合(原信息屏ID组合),使用,隔开
+	Resolution         int    `json:"resolution"`         //分辨率
+	SysType            int    `json:"sysType"`            //系统类型:0-多媒体系统,1-广播系统
+}

+ 49 - 3
app/multimedia/service/programService.go

@@ -1,7 +1,7 @@
 package service
 
 import (
-	deviceModel "iot_manager_service/app/device/model"
+	deviceService "iot_manager_service/app/device/service"
 	"iot_manager_service/app/multimedia/dao"
 	"iot_manager_service/app/multimedia/model"
 	"iot_manager_service/app/system/service"
@@ -103,6 +103,7 @@ func (s *programService) Submit(tenantId int, userId int64, req model.ReqProgram
 		FileSize:    req.FileSize,
 		ImgDuration: req.ImgDuration,
 		Remarks:     req.Remarks,
+		SysType:     req.SysType,
 		TenantId:    tenantId,
 		CreateTime:  time.Now(),
 		CreateUser:  userId,
@@ -162,7 +163,52 @@ func (s *programService) GetLibraryList(tenantId, programId int) ([]dao.Library,
 	return libraries, nil
 }
 
-func (s *programService) RelationDeviceList(tenantId, resolution int) ([]deviceModel.LampPoleGroupDetail,
+func (s *programService) RelationDeviceList(tenantId, sysType, resolution int) ([]model.ProgramDeviceDetail,
 	*common.Errors) {
-	return nil, nil
+	var lampGroupIds []int
+	infoBoardMap := make(map[int][]model.ProgramDevice)
+	if sysType == model.SysTypeInfoBar {
+		infoBoardDevices := deviceService.InfoBoardService.GetByResolution(tenantId, resolution)
+		for _, device := range infoBoardDevices {
+			lampGroupIds = append(lampGroupIds, device.GroupId)
+			programDevice := model.ProgramDevice{
+				Id:         device.ID,
+				PublicName: device.InfoName,
+			}
+			if devices, isExist := infoBoardMap[device.GroupId]; isExist {
+				devices = append(devices, programDevice)
+				infoBoardMap[device.GroupId] = devices
+			} else {
+				infoBoardMap[device.GroupId] = []model.ProgramDevice{programDevice}
+			}
+		}
+
+	} else if sysType == model.SysTypeBroadcast {
+		ipBroadcastDevices := deviceService.IpBroadcastService.GetAll(tenantId)
+		for _, device := range ipBroadcastDevices {
+			lampGroupIds = append(lampGroupIds, device.GroupId)
+			programDevice := model.ProgramDevice{
+				Id:         device.ID,
+				PublicName: device.CastName,
+			}
+			if devices, isExist := infoBoardMap[device.GroupId]; isExist {
+				devices = append(devices, programDevice)
+				infoBoardMap[device.GroupId] = devices
+			} else {
+				infoBoardMap[device.GroupId] = []model.ProgramDevice{programDevice}
+			}
+		}
+	} else {
+		return nil, nil
+	}
+
+	lampPoleGroups := deviceService.LampPoleGroupService.GetByIds(tenantId, lampGroupIds)
+	var details []model.ProgramDeviceDetail
+	for _, lampPoleGroup := range lampPoleGroups {
+		details = append(details, model.ProgramDeviceDetail{
+			PublicName:    lampPoleGroup.PoleGroupName,
+			InfoBoardList: infoBoardMap[lampPoleGroup.ID],
+		})
+	}
+	return details, nil
 }

+ 8 - 0
go.mod

@@ -9,6 +9,7 @@ require (
 	github.com/go-sql-driver/mysql v1.6.0
 	github.com/golang-jwt/jwt v3.2.2+incompatible
 	github.com/jinzhu/gorm v1.9.16
+	github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f
 	github.com/minio/minio-go/v7 v7.0.43
 	github.com/mojocn/base64Captcha v1.3.5
 	github.com/satori/go.uuid v1.2.0
@@ -18,6 +19,7 @@ require (
 
 require (
 	github.com/dustin/go-humanize v1.0.0 // indirect
+	github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect
 	github.com/fogleman/gg v1.3.0 // indirect
 	github.com/gin-contrib/sse v0.1.0 // indirect
 	github.com/go-playground/locales v0.14.0 // indirect
@@ -27,11 +29,15 @@ require (
 	github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
 	github.com/google/go-cmp v0.5.8 // indirect
 	github.com/google/uuid v1.3.0 // indirect
+	github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect
 	github.com/jinzhu/inflection v1.0.0 // indirect
+	github.com/jonboulle/clockwork v0.3.0 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
 	github.com/klauspost/compress v1.15.9 // indirect
 	github.com/klauspost/cpuid/v2 v2.1.0 // indirect
 	github.com/leodido/go-urn v1.2.1 // indirect
+	github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570 // indirect
+	github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 // indirect
 	github.com/mattn/go-isatty v0.0.14 // indirect
 	github.com/minio/md5-simd v1.1.2 // indirect
 	github.com/minio/sha256-simd v1.0.0 // indirect
@@ -40,7 +46,9 @@ require (
 	github.com/onsi/ginkgo v1.16.5 // indirect
 	github.com/onsi/gomega v1.20.0 // indirect
 	github.com/pelletier/go-toml/v2 v2.0.1 // indirect
+	github.com/pkg/errors v0.9.1 // indirect
 	github.com/rs/xid v1.4.0 // indirect
+	github.com/tebeka/strftime v0.1.5 // indirect
 	github.com/ugorji/go/codec v1.2.7 // indirect
 	golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
 	golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect

+ 16 - 0
go.sum

@@ -15,6 +15,8 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4
 github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
 github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
 github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
+github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 h1:Ghm4eQYC0nEPnSJdVkTrXpu9KtoVCSo1hg7mtI7G9KU=
+github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw=
 github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
 github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
@@ -68,12 +70,16 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
 github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
 github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
+github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 h1:IPJ3dvxmJ4uczJe5YQdrYB16oTJlGSC/OyZDqUk9xX4=
+github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag=
 github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
 github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
 github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
 github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
 github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
 github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
+github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg=
+github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
 github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
 github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
 github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
@@ -92,6 +98,12 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
 github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
 github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
 github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
+github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570 h1:0iQektZGS248WXmGIYOwRXSQhD4qn3icjMpuxwO7qlo=
+github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8L9ld7wVsvEWQbuLrUZnCMnUmLZ+CGDzKtclrTlE=
+github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f h1:sgUSP4zdTUZYZgAGGtN5Lxk92rK+JUFOwf+FT99EEI4=
+github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f/go.mod h1:UGmTpUd3rjbtfIpwAPrcfmGf/Z1HS95TATB+m57TPB8=
+github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 h1:Bvq8AziQ5jFF4BHGAEDSqwPW1NJS3XshxbRCxtjFAZc=
+github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042/go.mod h1:TPpsiPUEh0zFL1Snz4crhMlBe60PYxRHr5oFF3rRYg0=
 github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
 github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
 github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
@@ -130,6 +142,8 @@ github.com/onsi/gomega v1.20.0/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeR
 github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU=
 github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
 github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
@@ -148,6 +162,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
 github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/tebeka/strftime v0.1.5 h1:1NQKN1NiQgkqd/2moD6ySP/5CoZQsKa1d3ZhJ44Jpmg=
+github.com/tebeka/strftime v0.1.5/go.mod h1:29/OidkoWHdEKZqzyDLUyC+LmgDgdHo4WAFCDT7D/Ig=
 github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
 github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
 github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=

+ 3 - 0
router/router.go

@@ -477,5 +477,8 @@ func InitRouter(engine *gin.Engine) {
 		programGroup.POST("/submit", multimedia.Program.Submit)
 		programGroup.POST("/getLibraryList", multimedia.Program.GetLibraryList)
 		programGroup.POST("/relationDeviceList", multimedia.Program.RelationDeviceList)
+		//todo 前端需要和relationDeviceList合并,使用一个接口
+		programGroup.POST("/ip-broadcast-relation-list", multimedia.Program.RelationIpBroadcastList)
+		programGroup.POST("/audit", multimedia.Program.Audit)
 	}
 }

+ 12 - 24
util/logger/lclog.go

@@ -2,6 +2,7 @@ package logger
 
 import (
 	"github.com/druidcaesa/gotool"
+	rotatelogs "github.com/lestrrat/go-file-rotatelogs"
 	"github.com/sirupsen/logrus"
 	"iot_manager_service/config"
 	"os"
@@ -22,33 +23,20 @@ func InitLog() {
 	}
 
 	// 日志文件
-	fileName := path.Join(logFilePath, logFileName) + time.Now().Format("20060102") + ".log"
-	if !gotool.FileUtils.Exists(fileName) {
-		create, err := os.Create(fileName)
-		if err != nil {
-			gotool.Logs.ErrorLog().Println(err)
-			panic(err)
-		}
-		defer create.Close()
-	}
-	// 写入文件
-	src, err := os.OpenFile(fileName, os.O_APPEND|os.O_WRONLY, os.ModeAppend)
-	if err != nil {
-		panic(err)
-	}
-
+	fileName := path.Join(logFilePath, logFileName)
+	writer, _ := rotatelogs.New(
+		fileName+".%Y%m%d.log",
+		rotatelogs.WithMaxAge(15*24*time.Hour),    // 文件最大保存时间
+		rotatelogs.WithRotationTime(24*time.Hour), // 日志切割时间间隔
+	)
 	// 实例化
 	logger := logrus.New()
 
-	// 设置输出
-	logger.Out = src
-
-	// 设置日志级别
-	logger.SetLevel(logrus.DebugLevel)
-
-	logger.Formatter = &logrus.JSONFormatter{
+	logger.SetFormatter(&logrus.JSONFormatter{
 		TimestampFormat: "2006-01-02 15:04:05.000",
-	}
-
+	})
+	// 设置日志级别
+	logger.SetLevel(logrus.InfoLevel)
+	logger.SetOutput(writer)
 	Logger = logger
 }