2 İşlemeler fd2e95b22f ... 96c6085d58

Yazar SHA1 Mesaj Tarih
  engineerper 96c6085d58 Merge remote-tracking branch 'origin/master' 1 yıl önce
  engineerper 79fd4e18a4 commmit 1 yıl önce
5 değiştirilmiş dosya ile 69 ekleme ve 11 silme
  1. 1 1
      config.yaml
  2. 13 2
      go.mod
  3. 28 0
      go.sum
  4. 25 6
      main.go
  5. 2 2
      service/isapi/sipServer.go

+ 1 - 1
config.yaml

@@ -1,4 +1,4 @@
-#系统/后台相关
+ #系统/后台相关
 system:
   env: public
   addr: 9000

+ 13 - 2
go.mod

@@ -25,11 +25,22 @@ require (
 	gorm.io/gorm v1.25.5
 )
 
+require (
+	github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f // indirect
+	github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 // indirect
+	github.com/pkg/errors v0.9.1 // indirect
+	github.com/tencentcloud/tencentcloud-sdk-go v1.0.782 // indirect
+	github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.782 // indirect
+	github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.782 // indirect
+	github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.780 // indirect
+	gocv.io/x/gocv v0.35.0 // indirect
+)
+
 require (
 	github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
-	github.com/bytedance/sonic v1.9.1 // indirect
+	//github.com/bytedance/sonic v1.9.1 // indirect
 	github.com/cespare/xxhash/v2 v2.2.0 // indirect
-	github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
+	//github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
 	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
 	github.com/dustin/go-humanize v1.0.1 // indirect
 	github.com/fsnotify/fsnotify v1.6.0 // indirect

+ 28 - 0
go.sum

@@ -204,6 +204,7 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
 github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
 github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
 github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/hybridgroup/mjpeg v0.0.0-20140228234708-4680f319790e/go.mod h1:eagM805MRKrioHYuU7iKLUyFPVKqVV6um5DAvCkUtXs=
 github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
 github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
 github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
@@ -243,6 +244,10 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+
 github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
 github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
 github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
+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.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
 github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
 github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
@@ -266,9 +271,11 @@ github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt
 github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
 github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
 github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
+github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
 github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
 github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
 github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -317,6 +324,25 @@ github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
 github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
 github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
 github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
+github.com/tencentcloud/tencentcloud-sdk-go v1.0.780 h1:Fqg1bt8jbUhu4cJ3wSvJoENd1vpLj7pIGkfUdEScoh0=
+github.com/tencentcloud/tencentcloud-sdk-go v1.0.780/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4=
+github.com/tencentcloud/tencentcloud-sdk-go v1.0.781 h1:pMIp/w7JZdz8kxrFjqbZCA83xQeyOe+okJSzaqm0kQg=
+github.com/tencentcloud/tencentcloud-sdk-go v1.0.781/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4=
+github.com/tencentcloud/tencentcloud-sdk-go v1.0.782 h1:3CH0kg/M+UbB0FPozvFcfTHNC+zLZlkai0UiCGPWYJ4=
+github.com/tencentcloud/tencentcloud-sdk-go v1.0.782/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4=
+github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.780/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
+github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.781 h1:ZLcrm4Mp3pWZnlHh61oKx4LrNeZ6Dmdu4RxWMloULJw=
+github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.781/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
+github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.782 h1:du/bh8RvkLIHjpmpXtOT0lhwhPUdiobmxr32Sv6xAtA=
+github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.782/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
+github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.780 h1:TH1Yue6/avkQylkzbNf4qsyYdnxxZ6u88wC9l7HJqMo=
+github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.780/go.mod h1:zivJtasCyOpsjkLG45LPZfVZCMT3qzQNJ+yL/FPK/S8=
+github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.781 h1:t3meBdyVJhuU7MKTtcz3qAbvjcfuCjcbmMa4af4IjlM=
+github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.781/go.mod h1:P3kN49ZZCl/CiYUzyW9XU9e7EoWlSeZvtE1mMhLn7OA=
+github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.782 h1:KWOG2mTArNdoBhc8Y17lKTe6cjiXCDp2Bj+teyvJic0=
+github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.782/go.mod h1:ZIjKSDw6BqRyUOnIr+Wwzr8NXIppxcdUJM2hwhw+CtA=
+github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.780 h1:hiH/tc3y1p4hIWNJdvxzZBBSjh07PLj6GjHRS/u4rD0=
+github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.780/go.mod h1:E5tmeQ3bIO+spB5Rdgw8pcD/ZR7WqslfOAyzA1J5XLs=
 github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
 github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
 github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
@@ -363,6 +389,8 @@ go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
 go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
 go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
 go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
+gocv.io/x/gocv v0.35.0 h1:Qaxb5KdVyy8Spl4S4K0SMZ6CVmKtbfoSGQAxRD3FZlw=
+gocv.io/x/gocv v0.35.0/go.mod h1:oc6FvfYqfBp99p+yOEzs9tbYF9gOrAQSeL/dyIPefJU=
 golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
 golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
 golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=

+ 25 - 6
main.go

@@ -3,25 +3,27 @@ package main
 import (
 	"fmt"
 	"github.com/gin-gonic/gin"
+	rotatelogs "github.com/lestrrat/go-file-rotatelogs"
 	"github.com/sirupsen/logrus"
-
+	"lc-fangdaosha/eventServer"
+	"lc-fangdaosha/gatewayServer"
 	"lc-fangdaosha/global"
 	"lc-fangdaosha/initialize"
 	"lc-fangdaosha/service/system"
 	"net/http"
 	"os"
+	"path"
 	"time"
 )
 
 func main() {
-	logrus.SetLevel(logrus.DebugLevel)
-	logrus.SetOutput(os.Stdout)
-	logrus.SetReportCaller(true)
-	initialize.OtherInit() //初始化缓存
+	initLogrus()
+	go eventServer.StartEventServer() //摄像头事件监听服务端
+	go gatewayServer.GatewayServe()   //网关服务端
+	initialize.OtherInit()            //初始化缓存
 	//initialize.Redis()
 	global.Db = initialize.Gorm() //初始化数据库orm
 	if global.Db != nil {
-		//initialize.RegisterTables() //初始化表
 		// 程序结束前关闭数据库链接
 		db, _ := global.Db.DB()
 		defer db.Close()
@@ -54,3 +56,20 @@ func initServer(address string, router *gin.Engine) server {
 		MaxHeaderBytes: 1 << 20,
 	}
 }
+
+func initLogrus() {
+	err := os.MkdirAll("./log", os.ModeDir)
+	if err != nil {
+		panic(err)
+	}
+	fileName := path.Join("./log", "info")
+	writer, _ := rotatelogs.New(
+		fileName+".%Y%m%d.log",
+		rotatelogs.WithMaxAge(15*24*time.Hour),    // 文件最大保存时间
+		rotatelogs.WithRotationTime(24*time.Hour), // 日志切割时间间隔
+	)
+	logrus.SetLevel(logrus.DebugLevel)
+	logrus.SetOutput(os.Stdout)
+	logrus.SetReportCaller(true)
+	logrus.SetOutput(writer)
+}

+ 2 - 2
service/isapi/sipServer.go

@@ -14,7 +14,7 @@ type IsApiService struct {
 func GetSipUserID() (int, error) {
 	var is isapi.SipId
 	var is2 isapi.SipId
-	erro := global.Db.Debug().Transaction(func(tx *gorm.DB) error {
+	err := global.Db.Debug().Transaction(func(tx *gorm.DB) error {
 		err := tx.Select("id, user_id").Model(&is).First(&is).Debug().Error
 		if err != nil {
 			return err
@@ -26,5 +26,5 @@ func GetSipUserID() (int, error) {
 		fmt.Println("user_id ", is.UserId)
 		return nil
 	})
-	return is.UserId, erro
+	return is.UserId, err
 }