mirror of
https://github.com/hkmadao/rtsp2rtmp.git
synced 2025-09-26 19:31:19 +08:00
用户管理代码生成
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/go-cmd/cmd"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/utils"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
ext_controller "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controllers/ext"
|
||||
ext_controller "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controller/ext"
|
||||
base_service "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/service/base"
|
||||
)
|
||||
|
||||
@@ -70,7 +70,7 @@ func (rs *FFmpegManager) checkBlockFFmpegProcess() {
|
||||
return
|
||||
}
|
||||
for _, camera := range es {
|
||||
if camera.OnlineStatus != 1 {
|
||||
if camera.OnlineStatus != true {
|
||||
v, b := rs.rcs.Load(camera.Code)
|
||||
if b {
|
||||
ffmpegInfo := v.(FFmpegInfo)
|
||||
@@ -125,7 +125,7 @@ func (s *FFmpegManager) startConnections() {
|
||||
if v, b := s.rcs.Load(camera.Code); b && v != nil {
|
||||
continue
|
||||
}
|
||||
if camera.Enabled != 1 {
|
||||
if camera.Enabled != true {
|
||||
continue
|
||||
}
|
||||
go s.connRtsp(camera.Code)
|
||||
@@ -150,7 +150,7 @@ func (ffmpegManager *FFmpegManager) connRtsp(code string) {
|
||||
logs.Error("find camera [%s] error : %v", code, err)
|
||||
return
|
||||
}
|
||||
if camera.Enabled != 1 {
|
||||
if camera.Enabled != true {
|
||||
logs.Error("camera [%s] disabled : %v", code)
|
||||
return
|
||||
}
|
||||
|
@@ -61,10 +61,10 @@ func NewFileFlvManager(pktStream <-chan av.Packet, code string, codecs []av.Code
|
||||
logs.Error("query camera error : %v", err)
|
||||
return ffm
|
||||
}
|
||||
if camera.OnlineStatus != 1 {
|
||||
if camera.OnlineStatus != true {
|
||||
return ffm
|
||||
}
|
||||
if camera.SaveVideo != 1 {
|
||||
if camera.SaveVideo != true {
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
|
@@ -87,10 +87,10 @@ func NewFileFlvWriter(
|
||||
logs.Error("query camera error : %v", err)
|
||||
return ffw
|
||||
}
|
||||
if camera.OnlineStatus != 1 {
|
||||
if camera.OnlineStatus != true {
|
||||
return ffw
|
||||
}
|
||||
if camera.SaveVideo != 1 {
|
||||
if camera.SaveVideo != true {
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
|
@@ -61,10 +61,10 @@ func NewHttpFlvManager(pktStream <-chan av.Packet, code string, codecs []av.Code
|
||||
logs.Error("query camera error : %v", err)
|
||||
return hfm
|
||||
}
|
||||
if camera.OnlineStatus != 1 {
|
||||
if camera.OnlineStatus != true {
|
||||
return hfm
|
||||
}
|
||||
if camera.Live != 1 {
|
||||
if camera.Live != true {
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
|
@@ -88,10 +88,10 @@ func NewHttpFlvWriter(
|
||||
logs.Error("query camera error : %v", err)
|
||||
return hfw
|
||||
}
|
||||
if camera.OnlineStatus != 1 {
|
||||
if camera.OnlineStatus != true {
|
||||
return hfw
|
||||
}
|
||||
if camera.Live != 1 {
|
||||
if camera.Live != true {
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
|
@@ -105,10 +105,10 @@ func (rfw *RtmpFlvWriter) flvWrite() {
|
||||
logs.Error("not found camera : %s", rfw.code)
|
||||
return
|
||||
}
|
||||
if camera.OnlineStatus != 1 {
|
||||
if camera.OnlineStatus != true {
|
||||
return
|
||||
}
|
||||
if camera.RtmpPushStatus != 1 {
|
||||
if camera.RtmpPushStatus != true {
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
|
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/ffmpegmanager"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/rtmppublisher"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
ext_controller "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controllers/ext"
|
||||
ext_controller "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controller/ext"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dao/entity"
|
||||
base_service "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/service/base"
|
||||
)
|
||||
@@ -170,7 +170,7 @@ func (r *rtmpServer) handleRtmpConn(conn *rtmp.Conn) {
|
||||
}
|
||||
r.conns.Store(camera.Code, conn)
|
||||
|
||||
camera.OnlineStatus = 1
|
||||
camera.OnlineStatus = true
|
||||
base_service.CameraUpdateById(camera)
|
||||
|
||||
done := make(chan int)
|
||||
@@ -228,7 +228,7 @@ func (r *rtmpServer) handleRtmpConn(conn *rtmp.Conn) {
|
||||
if err != nil {
|
||||
logs.Error("no camera error : %s", code)
|
||||
} else {
|
||||
camera.OnlineStatus = 0
|
||||
camera.OnlineStatus = false
|
||||
base_service.CameraUpdateById(camera)
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ func authentication(camera entity.Camera, code string, authCode string, conn *rt
|
||||
conn.Close()
|
||||
return false
|
||||
}
|
||||
if camera.Enabled != 1 {
|
||||
if camera.Enabled != true {
|
||||
logs.Error("camera %s disabled : %s", code, authCode)
|
||||
err := conn.Close()
|
||||
if err != nil {
|
||||
|
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/utils"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
|
||||
ext_controller "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controllers/ext"
|
||||
ext_controller "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controller/ext"
|
||||
base_service "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/service/base"
|
||||
)
|
||||
|
||||
@@ -99,7 +99,7 @@ func (s *RtspClientManager) startConnections() {
|
||||
if v, b := s.rcs.Load(camera.Code); b && v != nil {
|
||||
continue
|
||||
}
|
||||
if camera.Enabled != 1 {
|
||||
if camera.Enabled != true {
|
||||
continue
|
||||
}
|
||||
go s.connRtsp(camera.Code)
|
||||
@@ -127,7 +127,7 @@ func (s *RtspClientManager) connRtsp(code string) {
|
||||
logs.Error("find camera [%s] error : %v", code, err)
|
||||
return
|
||||
}
|
||||
if c.Enabled != 1 {
|
||||
if c.Enabled != true {
|
||||
logs.Error("camera [%s] disabled : %v", code)
|
||||
return
|
||||
}
|
||||
@@ -142,8 +142,8 @@ func (s *RtspClientManager) connRtsp(code string) {
|
||||
session, err := rtspv2.Dial(rtspClientOptions)
|
||||
if err != nil {
|
||||
logs.Error("camera [%s] conn : %v", c.Code, err)
|
||||
c.OnlineStatus = 0
|
||||
if c.OnlineStatus == 1 {
|
||||
c.OnlineStatus = false
|
||||
if c.OnlineStatus == true {
|
||||
base_service.CameraUpdateById(c)
|
||||
}
|
||||
return
|
||||
@@ -151,7 +151,7 @@ func (s *RtspClientManager) connRtsp(code string) {
|
||||
codecs := session.CodecData
|
||||
// logs.Warn("camera: %s codecs: %v", code, session.CodecData)
|
||||
|
||||
c.OnlineStatus = 1
|
||||
c.OnlineStatus = true
|
||||
base_service.CameraUpdateById(c)
|
||||
|
||||
done := make(chan int)
|
||||
@@ -214,7 +214,7 @@ Loop:
|
||||
if err != nil {
|
||||
logs.Error("no camera error : %s", code)
|
||||
} else {
|
||||
camera.OnlineStatus = 0
|
||||
camera.OnlineStatus = false
|
||||
base_service.CameraUpdateById(camera)
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/utils"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
dto_convert "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controllers/convert"
|
||||
dto_convert "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controller/convert"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dao/entity"
|
||||
camera_po "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dto/po/base/camera"
|
||||
base_service "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/service/base"
|
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/utils"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
dto_convert "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controllers/convert"
|
||||
dto_convert "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controller/convert"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dao/entity"
|
||||
camera_share_po "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dto/po/base/camera_share"
|
||||
base_service "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/service/base"
|
||||
@@ -43,7 +43,7 @@ func CameraShareAdd(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
cameraAfterSave, err := base_service.CameraShareSelectById(id)
|
||||
cameraShareAfterSave, err := base_service.CameraShareSelectById(id)
|
||||
if err != nil {
|
||||
logs.Error("query by id error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
@@ -51,7 +51,7 @@ func CameraShareAdd(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
vo, err := dto_convert.ConvertCameraShareToVO(cameraAfterSave)
|
||||
vo, err := dto_convert.ConvertCameraShareToVO(cameraShareAfterSave)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
@@ -98,7 +98,7 @@ func CameraShareUpdate(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
cameraAfterSave, err := base_service.CameraShareSelectById(id)
|
||||
cameraShareAfterSave, err := base_service.CameraShareSelectById(id)
|
||||
if err != nil {
|
||||
logs.Error("query by id error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
@@ -106,7 +106,7 @@ func CameraShareUpdate(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
vo, err := dto_convert.ConvertCameraShareToVO(cameraAfterSave)
|
||||
vo, err := dto_convert.ConvertCameraShareToVO(cameraShareAfterSave)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
@@ -130,7 +130,7 @@ func CameraShareRemove(ctx *gin.Context) {
|
||||
|
||||
var id = po.Id
|
||||
|
||||
cameraGetById, err := base_service.CameraShareSelectById(id)
|
||||
cameraShareGetById, err := base_service.CameraShareSelectById(id)
|
||||
if err != nil {
|
||||
logs.Error("query by id error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
@@ -138,14 +138,14 @@ func CameraShareRemove(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = base_service.CameraShareDelete(cameraGetById)
|
||||
_, err = base_service.CameraShareDelete(cameraShareGetById)
|
||||
if err != nil {
|
||||
logs.Error("delete error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
result := common.SuccessResultData(cameraGetById)
|
||||
result := common.SuccessResultData(cameraShareGetById)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ func CameraShareGetByIds(ctx *gin.Context) {
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
cameras, err := base_service.CameraShareSelectByIds(idList)
|
||||
cameraShares, err := base_service.CameraShareSelectByIds(idList)
|
||||
if err != nil {
|
||||
logs.Error("getByIds error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
@@ -194,7 +194,7 @@ func CameraShareGetByIds(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
voList, err := dto_convert.ConvertCameraShareToVOList(cameras)
|
||||
voList, err := dto_convert.ConvertCameraShareToVOList(cameraShares)
|
||||
if err != nil {
|
||||
logs.Error("getByIds error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
@@ -215,14 +215,14 @@ func CameraShareAq(ctx *gin.Context) {
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
cameras, err := base_service.CameraShareFindCollectionByCondition(condition)
|
||||
cameraShares, err := base_service.CameraShareFindCollectionByCondition(condition)
|
||||
if err != nil {
|
||||
logs.Error("aq error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
voList, err := dto_convert.ConvertCameraShareToVOList(cameras)
|
||||
voList, err := dto_convert.ConvertCameraShareToVOList(cameraShares)
|
||||
if err != nil {
|
||||
logs.Error("aq error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
@@ -251,11 +251,11 @@ func CameraShareAqPage(ctx *gin.Context) {
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
var cameras = make([]entity.CameraShare, 0)
|
||||
var cameraShares = make([]entity.CameraShare, 0)
|
||||
for _, data := range pageInfo.DataList {
|
||||
cameras = append(cameras, data.(entity.CameraShare))
|
||||
cameraShares = append(cameraShares, data.(entity.CameraShare))
|
||||
}
|
||||
voList, err := dto_convert.ConvertCameraShareToVOList(cameras)
|
||||
voList, err := dto_convert.ConvertCameraShareToVOList(cameraShares)
|
||||
if err != nil {
|
||||
logs.Error("aqPage error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
272
src/rtsp2rtmp/web/controller/base/token_controller.go
Normal file
272
src/rtsp2rtmp/web/controller/base/token_controller.go
Normal file
@@ -0,0 +1,272 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/utils"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
dto_convert "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controller/convert"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dao/entity"
|
||||
token_po "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dto/po/base/token"
|
||||
base_service "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/service/base"
|
||||
)
|
||||
|
||||
func TokenAdd(ctx *gin.Context) {
|
||||
ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
po := token_po.TokenPO{}
|
||||
err := ctx.BindJSON(&po)
|
||||
if err != nil {
|
||||
logs.Error("param error : %v", err)
|
||||
result := common.ErrorResult(fmt.Sprintf("param error : %v", err))
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
token, err := dto_convert.ConvertPOToToken(po)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
id, _ := utils.UUID()
|
||||
token.IdToken = id
|
||||
_, err = base_service.TokenCreate(token)
|
||||
if err != nil {
|
||||
logs.Error("insert error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
tokenAfterSave, err := base_service.TokenSelectById(id)
|
||||
if err != nil {
|
||||
logs.Error("query by id error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
vo, err := dto_convert.ConvertTokenToVO(tokenAfterSave)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
result := common.SuccessResultData(vo)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func TokenUpdate(ctx *gin.Context) {
|
||||
ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
po := token_po.TokenPO{}
|
||||
err := ctx.BindJSON(&po)
|
||||
if err != nil {
|
||||
logs.Error("param error : %v", err)
|
||||
result := common.ErrorResult(fmt.Sprintf("param error : %v", err))
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
token, err := dto_convert.ConvertPOToToken(po)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
var id = token.IdToken
|
||||
|
||||
_, err = base_service.TokenSelectById(id)
|
||||
if err != nil {
|
||||
logs.Error("query by id error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = base_service.TokenUpdateById(token)
|
||||
if err != nil {
|
||||
logs.Error("insert error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
tokenAfterSave, err := base_service.TokenSelectById(id)
|
||||
if err != nil {
|
||||
logs.Error("query by id error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
vo, err := dto_convert.ConvertTokenToVO(tokenAfterSave)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
result := common.SuccessResultData(vo)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func TokenRemove(ctx *gin.Context) {
|
||||
ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
po := token_po.TokenPO{}
|
||||
err := ctx.BindJSON(&po)
|
||||
if err != nil {
|
||||
logs.Error("param error : %v", err)
|
||||
result := common.ErrorResult(fmt.Sprintf("param error : %v", err))
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
var id = po.IdToken
|
||||
|
||||
tokenGetById, err := base_service.TokenSelectById(id)
|
||||
if err != nil {
|
||||
logs.Error("query by id error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = base_service.TokenDelete(tokenGetById)
|
||||
if err != nil {
|
||||
logs.Error("delete error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
result := common.SuccessResultData(tokenGetById)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func TokenGetById(ctx *gin.Context) {
|
||||
// ctx.Writeresult.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
id, ok := ctx.Params.Get("id")
|
||||
if !ok {
|
||||
logs.Error("get param id failed")
|
||||
result := common.ErrorResult("get param id failed")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
token, err := base_service.TokenSelectById(id)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
vo, err := dto_convert.ConvertTokenToVO(token)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
result := common.SuccessResultData(vo)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func TokenGetByIds(ctx *gin.Context) {
|
||||
// ctx.Writeresult.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
idsStr := ctx.Query("ids")
|
||||
idList := strings.Split(idsStr, ",")
|
||||
if len(idList) == 0 {
|
||||
logs.Error("get param ids failed")
|
||||
result := common.ErrorResult("get param ids failed")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
tokens, err := base_service.TokenSelectByIds(idList)
|
||||
if err != nil {
|
||||
logs.Error("getByIds error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
voList, err := dto_convert.ConvertTokenToVOList(tokens)
|
||||
if err != nil {
|
||||
logs.Error("getByIds error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
result := common.SuccessResultData(voList)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func TokenAq(ctx *gin.Context) {
|
||||
// ctx.Writeresult.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
condition := common.AqCondition{}
|
||||
err := ctx.BindJSON(&condition)
|
||||
if err != nil {
|
||||
logs.Error("param error : %v", err)
|
||||
result := common.ErrorResult(fmt.Sprintf("param error : %v", err))
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
tokens, err := base_service.TokenFindCollectionByCondition(condition)
|
||||
if err != nil {
|
||||
logs.Error("aq error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
voList, err := dto_convert.ConvertTokenToVOList(tokens)
|
||||
if err != nil {
|
||||
logs.Error("aq error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
result := common.SuccessResultData(voList)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func TokenAqPage(ctx *gin.Context) {
|
||||
// ctx.Writeresult.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
pageInfoInput := common.AqPageInfoInput{}
|
||||
err := ctx.BindJSON(&pageInfoInput)
|
||||
if err != nil {
|
||||
ctx.AbortWithError(500, err)
|
||||
logs.Error("param error : %v", err)
|
||||
result := common.ErrorResult(fmt.Sprintf("param error : %v", err))
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
pageInfo, err := base_service.TokenFindPageByCondition(pageInfoInput)
|
||||
if err != nil {
|
||||
logs.Error("aqPage error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
var tokens = make([]entity.Token, 0)
|
||||
for _, data := range pageInfo.DataList {
|
||||
tokens = append(tokens, data.(entity.Token))
|
||||
}
|
||||
voList, err := dto_convert.ConvertTokenToVOList(tokens)
|
||||
if err != nil {
|
||||
logs.Error("aqPage error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
var dataList = make([]interface{}, 0)
|
||||
for _, vo := range voList {
|
||||
dataList = append(dataList, vo)
|
||||
}
|
||||
pageInfo.DataList = dataList
|
||||
result := common.SuccessResultData(pageInfo)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
272
src/rtsp2rtmp/web/controller/base/user_controller.go
Normal file
272
src/rtsp2rtmp/web/controller/base/user_controller.go
Normal file
@@ -0,0 +1,272 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/utils"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
dto_convert "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controller/convert"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dao/entity"
|
||||
user_po "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dto/po/base/user"
|
||||
base_service "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/service/base"
|
||||
)
|
||||
|
||||
func UserAdd(ctx *gin.Context) {
|
||||
ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
po := user_po.UserPO{}
|
||||
err := ctx.BindJSON(&po)
|
||||
if err != nil {
|
||||
logs.Error("param error : %v", err)
|
||||
result := common.ErrorResult(fmt.Sprintf("param error : %v", err))
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
user, err := dto_convert.ConvertPOToUser(po)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
id, _ := utils.UUID()
|
||||
user.IdUser = id
|
||||
_, err = base_service.UserCreate(user)
|
||||
if err != nil {
|
||||
logs.Error("insert error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
userAfterSave, err := base_service.UserSelectById(id)
|
||||
if err != nil {
|
||||
logs.Error("query by id error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
vo, err := dto_convert.ConvertUserToVO(userAfterSave)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
result := common.SuccessResultData(vo)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func UserUpdate(ctx *gin.Context) {
|
||||
ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
po := user_po.UserPO{}
|
||||
err := ctx.BindJSON(&po)
|
||||
if err != nil {
|
||||
logs.Error("param error : %v", err)
|
||||
result := common.ErrorResult(fmt.Sprintf("param error : %v", err))
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
user, err := dto_convert.ConvertPOToUser(po)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
var id = user.IdUser
|
||||
|
||||
_, err = base_service.UserSelectById(id)
|
||||
if err != nil {
|
||||
logs.Error("query by id error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = base_service.UserUpdateById(user)
|
||||
if err != nil {
|
||||
logs.Error("insert error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
userAfterSave, err := base_service.UserSelectById(id)
|
||||
if err != nil {
|
||||
logs.Error("query by id error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
vo, err := dto_convert.ConvertUserToVO(userAfterSave)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
result := common.SuccessResultData(vo)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func UserRemove(ctx *gin.Context) {
|
||||
ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
po := user_po.UserPO{}
|
||||
err := ctx.BindJSON(&po)
|
||||
if err != nil {
|
||||
logs.Error("param error : %v", err)
|
||||
result := common.ErrorResult(fmt.Sprintf("param error : %v", err))
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
var id = po.IdUser
|
||||
|
||||
userGetById, err := base_service.UserSelectById(id)
|
||||
if err != nil {
|
||||
logs.Error("query by id error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = base_service.UserDelete(userGetById)
|
||||
if err != nil {
|
||||
logs.Error("delete error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
result := common.SuccessResultData(userGetById)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func UserGetById(ctx *gin.Context) {
|
||||
// ctx.Writeresult.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
id, ok := ctx.Params.Get("id")
|
||||
if !ok {
|
||||
logs.Error("get param id failed")
|
||||
result := common.ErrorResult("get param id failed")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
user, err := base_service.UserSelectById(id)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
vo, err := dto_convert.ConvertUserToVO(user)
|
||||
if err != nil {
|
||||
logs.Error("getById error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
result := common.SuccessResultData(vo)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func UserGetByIds(ctx *gin.Context) {
|
||||
// ctx.Writeresult.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
idsStr := ctx.Query("ids")
|
||||
idList := strings.Split(idsStr, ",")
|
||||
if len(idList) == 0 {
|
||||
logs.Error("get param ids failed")
|
||||
result := common.ErrorResult("get param ids failed")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
users, err := base_service.UserSelectByIds(idList)
|
||||
if err != nil {
|
||||
logs.Error("getByIds error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
|
||||
voList, err := dto_convert.ConvertUserToVOList(users)
|
||||
if err != nil {
|
||||
logs.Error("getByIds error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
result := common.SuccessResultData(voList)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func UserAq(ctx *gin.Context) {
|
||||
// ctx.Writeresult.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
condition := common.AqCondition{}
|
||||
err := ctx.BindJSON(&condition)
|
||||
if err != nil {
|
||||
logs.Error("param error : %v", err)
|
||||
result := common.ErrorResult(fmt.Sprintf("param error : %v", err))
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
users, err := base_service.UserFindCollectionByCondition(condition)
|
||||
if err != nil {
|
||||
logs.Error("aq error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
voList, err := dto_convert.ConvertUserToVOList(users)
|
||||
if err != nil {
|
||||
logs.Error("aq error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
result := common.SuccessResultData(voList)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func UserAqPage(ctx *gin.Context) {
|
||||
// ctx.Writeresult.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
pageInfoInput := common.AqPageInfoInput{}
|
||||
err := ctx.BindJSON(&pageInfoInput)
|
||||
if err != nil {
|
||||
ctx.AbortWithError(500, err)
|
||||
logs.Error("param error : %v", err)
|
||||
result := common.ErrorResult(fmt.Sprintf("param error : %v", err))
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
pageInfo, err := base_service.UserFindPageByCondition(pageInfoInput)
|
||||
if err != nil {
|
||||
logs.Error("aqPage error : %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
var users = make([]entity.User, 0)
|
||||
for _, data := range pageInfo.DataList {
|
||||
users = append(users, data.(entity.User))
|
||||
}
|
||||
voList, err := dto_convert.ConvertUserToVOList(users)
|
||||
if err != nil {
|
||||
logs.Error("aqPage error: %v", err)
|
||||
result := common.ErrorResult("internal error")
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
var dataList = make([]interface{}, 0)
|
||||
for _, vo := range voList {
|
||||
dataList = append(dataList, vo)
|
||||
}
|
||||
pageInfo.DataList = dataList
|
||||
result := common.SuccessResultData(pageInfo)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dao/entity"
|
||||
camera_po "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dto/po/base/camera"
|
||||
camera_vo "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dto/vo/base/camera"
|
||||
base_service "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/service/base"
|
||||
)
|
||||
|
||||
func ConvertPOToCamera(po camera_po.CameraPO) (camera entity.Camera, err error) {
|
||||
@@ -29,26 +28,27 @@ func ConvertCameraToVO(camera entity.Camera) (vo camera_vo.CameraVO, err error)
|
||||
err = fmt.Errorf("convertCameraToVO : %v", err)
|
||||
return
|
||||
}
|
||||
condition := common.GetEqualCondition("cameraId", vo.Id)
|
||||
var cameraShareVOList = make([]camera_vo.CameraShareVO, 0)
|
||||
var cameraShares = make([]entity.CameraShare, 0)
|
||||
cameraShares, err = base_service.CameraShareFindCollectionByCondition(condition)
|
||||
if err != nil {
|
||||
logs.Error("convertCameraToVO : %v", err)
|
||||
err = fmt.Errorf("convertCameraToVO : %v", err)
|
||||
return
|
||||
}
|
||||
for _, cameraShare := range cameraShares {
|
||||
var cameraShareVO = camera_vo.CameraShareVO{}
|
||||
err = common.EntityToVO(cameraShare, &cameraShareVO)
|
||||
if err != nil {
|
||||
logs.Error("convertCameraToVO : %v", err)
|
||||
err = fmt.Errorf("convertCameraToVO : %v", err)
|
||||
return
|
||||
}
|
||||
cameraShareVOList = append(cameraShareVOList, cameraShareVO)
|
||||
}
|
||||
vo.CameraShares = cameraShareVOList
|
||||
// condition := common.GetEqualCondition("cameraId", vo.Id)
|
||||
// var cameraShareVOList = make([]camera_vo.CameraShareVO, 0)
|
||||
// var cameraShares = make([]entity.CameraShare, 0)
|
||||
// cameraShares, err = base_service.CameraShareFindCollectionByCondition(condition)
|
||||
// if err != nil {
|
||||
// logs.Error("convertCameraToVO : %v", err)
|
||||
// err = fmt.Errorf("convertCameraToVO : %v", err)
|
||||
// return
|
||||
// }
|
||||
// for _, cameraShare := range cameraShares {
|
||||
// var cameraShareVO = camera_vo.CameraShareVO{}
|
||||
// err = common.EntityToVO(cameraShare, &cameraShareVO)
|
||||
// if err != nil {
|
||||
// logs.Error("convertCameraToVO : %v", err)
|
||||
// err = fmt.Errorf("convertCameraToVO : %v", err)
|
||||
// return
|
||||
// }
|
||||
// cameraShareVOList = append(cameraShareVOList, cameraShareVO)
|
||||
// }
|
||||
// vo.CameraShares = cameraShareVOList
|
||||
|
||||
return
|
||||
}
|
||||
|
@@ -11,8 +11,8 @@ import (
|
||||
base_service "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/service/base"
|
||||
)
|
||||
|
||||
func ConvertPOToCameraShare(po camera_share_po.CameraSharePO) (camerashare entity.CameraShare, err error) {
|
||||
err = common.POToEntity(po, &camerashare)
|
||||
func ConvertPOToCameraShare(po camera_share_po.CameraSharePO) (cameraShare entity.CameraShare, err error) {
|
||||
err = common.POToEntity(po, &cameraShare)
|
||||
if err != nil {
|
||||
logs.Error("convertPOToCameraShare : %v", err)
|
||||
err = fmt.Errorf("convertPOToCameraShare : %v", err)
|
||||
@@ -21,15 +21,15 @@ func ConvertPOToCameraShare(po camera_share_po.CameraSharePO) (camerashare entit
|
||||
return
|
||||
}
|
||||
|
||||
func ConvertCameraShareToVO(camerashare entity.CameraShare) (vo camera_share_vo.CameraShareVO, err error) {
|
||||
func ConvertCameraShareToVO(cameraShare entity.CameraShare) (vo camera_share_vo.CameraShareVO, err error) {
|
||||
vo = camera_share_vo.CameraShareVO{}
|
||||
err = common.EntityToVO(camerashare, &vo)
|
||||
err = common.EntityToVO(cameraShare, &vo)
|
||||
if err != nil {
|
||||
logs.Error("convertCameraShareToVO : %v", err)
|
||||
err = fmt.Errorf("convertCameraShareToVO : %v", err)
|
||||
return
|
||||
}
|
||||
camera, err := base_service.CameraSelectById(vo.CameraId)
|
||||
camera, err := base_service.CameraSelectById(vo.CameraId)
|
||||
if err != nil {
|
||||
logs.Error("convertCameraShareToVO : %v", err)
|
||||
err = fmt.Errorf("convertCameraShareToVO : %v", err)
|
||||
@@ -43,15 +43,16 @@ func ConvertCameraShareToVO(camerashare entity.CameraShare) (vo camera_share_vo.
|
||||
return
|
||||
}
|
||||
vo.Camera = cameraVO
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func ConvertCameraShareToVOList(camerashares []entity.CameraShare) (voList []camera_share_vo.CameraShareVO, err error) {
|
||||
func ConvertCameraShareToVOList(cameraShares []entity.CameraShare) (voList []camera_share_vo.CameraShareVO, err error) {
|
||||
voList = make([]camera_share_vo.CameraShareVO, 0)
|
||||
for _, camerashare := range camerashares {
|
||||
vo, err_convert := ConvertCameraShareToVO(camerashare)
|
||||
for _, cameraShare := range cameraShares {
|
||||
vo, err_convert := ConvertCameraShareToVO(cameraShare)
|
||||
if err_convert != nil {
|
||||
logs.Error("ConvertCameraShareToVOList : %v", err_convert)
|
||||
logs.Error("convertCameraShareToVO : %v", err_convert)
|
||||
err = fmt.Errorf("ConvertCameraShareToVOList : %v", err_convert)
|
||||
return
|
||||
}
|
47
src/rtsp2rtmp/web/controller/convert/token_convert.go
Normal file
47
src/rtsp2rtmp/web/controller/convert/token_convert.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dao/entity"
|
||||
token_po "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dto/po/base/token"
|
||||
token_vo "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dto/vo/base/token"
|
||||
)
|
||||
|
||||
func ConvertPOToToken(po token_po.TokenPO) (token entity.Token, err error) {
|
||||
err = common.POToEntity(po, &token)
|
||||
if err != nil {
|
||||
logs.Error("convertPOToToken : %v", err)
|
||||
err = fmt.Errorf("convertPOToToken : %v", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ConvertTokenToVO(token entity.Token) (vo token_vo.TokenVO, err error) {
|
||||
vo = token_vo.TokenVO{}
|
||||
err = common.EntityToVO(token, &vo)
|
||||
if err != nil {
|
||||
logs.Error("convertTokenToVO : %v", err)
|
||||
err = fmt.Errorf("convertTokenToVO : %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func ConvertTokenToVOList(tokens []entity.Token) (voList []token_vo.TokenVO, err error) {
|
||||
voList = make([]token_vo.TokenVO, 0)
|
||||
for _, token := range tokens {
|
||||
vo, err_convert := ConvertTokenToVO(token)
|
||||
if err_convert != nil {
|
||||
logs.Error("convertTokenToVO : %v", err_convert)
|
||||
err = fmt.Errorf("ConvertTokenToVOList : %v", err_convert)
|
||||
return
|
||||
}
|
||||
voList = append(voList, vo)
|
||||
}
|
||||
return
|
||||
}
|
47
src/rtsp2rtmp/web/controller/convert/user_convert.go
Normal file
47
src/rtsp2rtmp/web/controller/convert/user_convert.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dao/entity"
|
||||
user_po "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dto/po/base/user"
|
||||
user_vo "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dto/vo/base/user"
|
||||
)
|
||||
|
||||
func ConvertPOToUser(po user_po.UserPO) (user entity.User, err error) {
|
||||
err = common.POToEntity(po, &user)
|
||||
if err != nil {
|
||||
logs.Error("convertPOToUser : %v", err)
|
||||
err = fmt.Errorf("convertPOToUser : %v", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ConvertUserToVO(user entity.User) (vo user_vo.UserVO, err error) {
|
||||
vo = user_vo.UserVO{}
|
||||
err = common.EntityToVO(user, &vo)
|
||||
if err != nil {
|
||||
logs.Error("convertUserToVO : %v", err)
|
||||
err = fmt.Errorf("convertUserToVO : %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func ConvertUserToVOList(users []entity.User) (voList []user_vo.UserVO, err error) {
|
||||
voList = make([]user_vo.UserVO, 0)
|
||||
for _, user := range users {
|
||||
vo, err_convert := ConvertUserToVO(user)
|
||||
if err_convert != nil {
|
||||
logs.Error("convertUserToVO : %v", err_convert)
|
||||
err = fmt.Errorf("ConvertUserToVOList : %v", err_convert)
|
||||
return
|
||||
}
|
||||
voList = append(voList, vo)
|
||||
}
|
||||
return
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package controllers
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -33,8 +33,8 @@ func CameraEnabled(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
camera.Enabled = q.Enabled
|
||||
if q.Enabled != 1 {
|
||||
camera.OnlineStatus = 0
|
||||
if q.Enabled != true {
|
||||
camera.OnlineStatus = false
|
||||
}
|
||||
_, err = bas_service.CameraUpdateById(camera)
|
||||
if err != nil {
|
||||
@@ -43,7 +43,7 @@ func CameraEnabled(ctx *gin.Context) {
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
return
|
||||
}
|
||||
if q.Enabled != 1 {
|
||||
if q.Enabled != true {
|
||||
logs.Debug("close camera conn: %s", camera.Code)
|
||||
select {
|
||||
case codeStream <- camera.Code:
|
||||
@@ -82,10 +82,10 @@ func RtmpPushChange(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
switch {
|
||||
case q.RtmpPushStatus != 1:
|
||||
case q.RtmpPushStatus != true:
|
||||
logs.Info("camera [%s] stop push rtmp", q.Code)
|
||||
flvadmin.GetSingleRtmpFlvAdmin().StopWrite(q.Code)
|
||||
case q.RtmpPushStatus == 1:
|
||||
case q.RtmpPushStatus == true:
|
||||
flvadmin.GetSingleRtmpFlvAdmin().StartWrite(q.Code)
|
||||
logs.Info("camera [%s] start push rtmp", q.Code)
|
||||
}
|
||||
@@ -121,10 +121,10 @@ func CameraSaveVideoChange(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
switch {
|
||||
case q.SaveVideo != 1:
|
||||
case q.SaveVideo != true:
|
||||
logs.Info("camera [%s] stop save video", q.Code)
|
||||
flvadmin.GetSingleFileFlvAdmin().StopWrite(q.Code)
|
||||
case q.SaveVideo == 1:
|
||||
case q.SaveVideo == true:
|
||||
flvadmin.GetSingleFileFlvAdmin().StartWrite(q.Code)
|
||||
logs.Info("camera [%s] start save video", q.Code)
|
||||
}
|
||||
@@ -160,9 +160,9 @@ func CameraLiveChange(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
switch {
|
||||
case q.Live != 1:
|
||||
case q.Live != true:
|
||||
flvadmin.GetSingleHttpFlvAdmin().StopWrite(q.Code)
|
||||
case q.Live == 1:
|
||||
case q.Live == true:
|
||||
flvadmin.GetSingleHttpFlvAdmin().StartWrite(q.Code)
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package controllers
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
@@ -1,4 +1,4 @@
|
||||
package controllers
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
@@ -5,125 +5,128 @@ import (
|
||||
)
|
||||
|
||||
func GetCameraDesc() *common.EntityDesc {
|
||||
var entityInfo = common.EntityInfo{
|
||||
Name: "Camera",
|
||||
DisplayName: "摄像头",
|
||||
ClassName: "Camera",
|
||||
TableName: "camera",
|
||||
BasePath: "entity::camera",
|
||||
}
|
||||
var idAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "id",
|
||||
Name: "id",
|
||||
DisplayName: "摄像头主属性",
|
||||
DataType: "InternalPK",
|
||||
ValueType: "string",
|
||||
}
|
||||
var codeAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "code",
|
||||
Name: "code",
|
||||
DisplayName: "code",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
}
|
||||
var rtspUrlAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "rtsp_url",
|
||||
Name: "rtspUrl",
|
||||
DisplayName: "rtsp地址",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
}
|
||||
var rtmpUrlAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "rtmp_url",
|
||||
Name: "rtmpUrl",
|
||||
DisplayName: "rtmp推送地址",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
}
|
||||
var playAuthCodeAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "play_auth_code",
|
||||
Name: "playAuthCode",
|
||||
DisplayName: "播放权限码",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
}
|
||||
var onlineStatusAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "online_status",
|
||||
Name: "onlineStatus",
|
||||
DisplayName: "在线状态",
|
||||
DataType: "Boolean",
|
||||
ValueType: "bool",
|
||||
}
|
||||
var enabledAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "enabled",
|
||||
Name: "enabled",
|
||||
DisplayName: "启用状态",
|
||||
DataType: "Boolean",
|
||||
ValueType: "bool",
|
||||
}
|
||||
var rtmpPushStatusAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "rtmp_push_status",
|
||||
Name: "rtmpPushStatus",
|
||||
DisplayName: "rtmp推送状态",
|
||||
DataType: "Boolean",
|
||||
ValueType: "bool",
|
||||
}
|
||||
var saveVideoAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "save_video",
|
||||
Name: "saveVideo",
|
||||
DisplayName: "保存录像状态",
|
||||
DataType: "Boolean",
|
||||
ValueType: "bool",
|
||||
}
|
||||
var liveAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "live",
|
||||
Name: "live",
|
||||
DisplayName: "直播状态",
|
||||
DataType: "Boolean",
|
||||
ValueType: "bool",
|
||||
}
|
||||
var createdAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "created",
|
||||
Name: "created",
|
||||
DisplayName: "创建时间",
|
||||
DataType: "DateTime",
|
||||
ValueType: "string",
|
||||
}
|
||||
var cameraSharesAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "camera_shares",
|
||||
Name: "cameraShares",
|
||||
DisplayName: "摄像头分享",
|
||||
DataType: "InternalArray",
|
||||
ValueType: "",
|
||||
OutEntityName: "CameraShare",
|
||||
OutEntityPkAttributeName: "id",
|
||||
OutEntityReversalAttributeName: "camera",
|
||||
OutEntityIdReversalAttributeName: "cameraId",
|
||||
}
|
||||
var entityDesc = &common.EntityDesc{
|
||||
EntityInfo: entityInfo,
|
||||
PkAttributeInfo: idAttributeInfo,
|
||||
NormalFkIdAttributeInfos: []*common.AttributeInfo{},
|
||||
NormalFkAttributeInfos: []*common.AttributeInfo{},
|
||||
NormalChildren: []*common.AttributeInfo{
|
||||
cameraSharesAttributeInfo,
|
||||
},
|
||||
NormalOne2OneChildren: []*common.AttributeInfo{},
|
||||
AttributeInfoMap: map[string]*common.AttributeInfo{
|
||||
"id": idAttributeInfo,
|
||||
"code": codeAttributeInfo,
|
||||
"rtspUrl": rtspUrlAttributeInfo,
|
||||
"rtmpUrl": rtmpUrlAttributeInfo,
|
||||
"playAuthCode": playAuthCodeAttributeInfo,
|
||||
"onlineStatus": onlineStatusAttributeInfo,
|
||||
"enabled": enabledAttributeInfo,
|
||||
"rtmpPushStatus": rtmpPushStatusAttributeInfo,
|
||||
"saveVideo": saveVideoAttributeInfo,
|
||||
"live": liveAttributeInfo,
|
||||
"created": createdAttributeInfo,
|
||||
"cameraShares": cameraSharesAttributeInfo,
|
||||
},
|
||||
}
|
||||
var entityInfo = common.EntityInfo {
|
||||
Name: "Camera",
|
||||
DisplayName: "摄像头",
|
||||
ClassName: "Camera",
|
||||
TableName: "camera",
|
||||
BasePath: "entity::camera",
|
||||
}
|
||||
var idAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "id",
|
||||
Name: "id",
|
||||
DisplayName: "摄像头主属性",
|
||||
DataType: "InternalPK",
|
||||
ValueType: "string",
|
||||
};
|
||||
var codeAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "code",
|
||||
Name: "code",
|
||||
DisplayName: "编号",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
};
|
||||
var rtspUrlAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "rtsp_url",
|
||||
Name: "rtspUrl",
|
||||
DisplayName: "rtsp地址",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
};
|
||||
var rtmpUrlAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "rtmp_url",
|
||||
Name: "rtmpUrl",
|
||||
DisplayName: "rtmp推送地址",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
};
|
||||
var playAuthCodeAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "play_auth_code",
|
||||
Name: "playAuthCode",
|
||||
DisplayName: "播放权限码",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
};
|
||||
var onlineStatusAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "online_status",
|
||||
Name: "onlineStatus",
|
||||
DisplayName: "在线状态",
|
||||
DataType: "Boolean",
|
||||
ValueType: "bool",
|
||||
};
|
||||
var enabledAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "enabled",
|
||||
Name: "enabled",
|
||||
DisplayName: "启用状态",
|
||||
DataType: "Boolean",
|
||||
ValueType: "bool",
|
||||
};
|
||||
var rtmpPushStatusAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "rtmp_push_status",
|
||||
Name: "rtmpPushStatus",
|
||||
DisplayName: "rtmp推送状态",
|
||||
DataType: "Boolean",
|
||||
ValueType: "bool",
|
||||
};
|
||||
var saveVideoAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "save_video",
|
||||
Name: "saveVideo",
|
||||
DisplayName: "保存录像状态",
|
||||
DataType: "Boolean",
|
||||
ValueType: "bool",
|
||||
};
|
||||
var liveAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "live",
|
||||
Name: "live",
|
||||
DisplayName: "直播状态",
|
||||
DataType: "Boolean",
|
||||
ValueType: "bool",
|
||||
};
|
||||
var createdAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "created",
|
||||
Name: "created",
|
||||
DisplayName: "创建时间",
|
||||
DataType: "DateTime",
|
||||
ValueType: "string",
|
||||
};
|
||||
var cameraSharesAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "camera_shares",
|
||||
Name: "cameraShares",
|
||||
DisplayName: "摄像头分享",
|
||||
DataType: "InternalArray",
|
||||
ValueType: "",
|
||||
OutEntityName: "CameraShare",
|
||||
OutEntityPkAttributeName: "id",
|
||||
OutEntityReversalAttributeName: "camera",
|
||||
OutEntityIdReversalAttributeName: "cameraId",
|
||||
};
|
||||
var entityDesc = &common.EntityDesc {
|
||||
EntityInfo: entityInfo,
|
||||
PkAttributeInfo: idAttributeInfo,
|
||||
NormalFkIdAttributeInfos: []*common.AttributeInfo{
|
||||
},
|
||||
NormalFkAttributeInfos: []*common.AttributeInfo{
|
||||
},
|
||||
NormalChildren: []*common.AttributeInfo{
|
||||
cameraSharesAttributeInfo,
|
||||
},
|
||||
NormalOne2OneChildren: []*common.AttributeInfo{
|
||||
},
|
||||
AttributeInfoMap: map[string]*common.AttributeInfo{
|
||||
"id": idAttributeInfo,
|
||||
"code": codeAttributeInfo,
|
||||
"rtspUrl": rtspUrlAttributeInfo,
|
||||
"rtmpUrl": rtmpUrlAttributeInfo,
|
||||
"playAuthCode": playAuthCodeAttributeInfo,
|
||||
"onlineStatus": onlineStatusAttributeInfo,
|
||||
"enabled": enabledAttributeInfo,
|
||||
"rtmpPushStatus": rtmpPushStatusAttributeInfo,
|
||||
"saveVideo": saveVideoAttributeInfo,
|
||||
"live": liveAttributeInfo,
|
||||
"created": createdAttributeInfo,
|
||||
"cameraShares": cameraSharesAttributeInfo,
|
||||
},
|
||||
}
|
||||
|
||||
return entityDesc
|
||||
return entityDesc
|
||||
}
|
||||
|
113
src/rtsp2rtmp/web/dao/desc/camera_share_desc.go
Normal file
113
src/rtsp2rtmp/web/dao/desc/camera_share_desc.go
Normal file
@@ -0,0 +1,113 @@
|
||||
package desc
|
||||
|
||||
import (
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
)
|
||||
|
||||
func GetCameraShareDesc() *common.EntityDesc {
|
||||
var entityInfo = common.EntityInfo {
|
||||
Name: "CameraShare",
|
||||
DisplayName: "摄像头分享",
|
||||
ClassName: "CameraShare",
|
||||
TableName: "camera_share",
|
||||
BasePath: "entity::camera_share",
|
||||
}
|
||||
var idAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "id",
|
||||
Name: "id",
|
||||
DisplayName: "摄像头分享主属性",
|
||||
DataType: "InternalPK",
|
||||
ValueType: "string",
|
||||
};
|
||||
var nameAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "name",
|
||||
Name: "name",
|
||||
DisplayName: "名称",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
};
|
||||
var authCodeAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "auth_code",
|
||||
Name: "authCode",
|
||||
DisplayName: "权限码",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
};
|
||||
var enabledAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "enabled",
|
||||
Name: "enabled",
|
||||
DisplayName: "启用状态",
|
||||
DataType: "Boolean",
|
||||
ValueType: "bool",
|
||||
};
|
||||
var createdAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "created",
|
||||
Name: "created",
|
||||
DisplayName: "创建时间",
|
||||
DataType: "DateTime",
|
||||
ValueType: "string",
|
||||
};
|
||||
var startTimeAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "start_time",
|
||||
Name: "startTime",
|
||||
DisplayName: "开始时间",
|
||||
DataType: "DateTime",
|
||||
ValueType: "string",
|
||||
};
|
||||
var deadlineAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "deadline",
|
||||
Name: "deadline",
|
||||
DisplayName: "结束时间",
|
||||
DataType: "DateTime",
|
||||
ValueType: "string",
|
||||
};
|
||||
var cameraIdAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "camera_id",
|
||||
Name: "cameraId",
|
||||
DisplayName: "摄像头id",
|
||||
DataType: "InternalFK",
|
||||
ValueType: "string",
|
||||
InnerAttributeName: "camera",
|
||||
OutEntityName: "Camera",
|
||||
OutEntityPkAttributeName: "id",
|
||||
OutEntityReversalAttributeName: "cameraShares",
|
||||
};
|
||||
var cameraAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "camera",
|
||||
Name: "camera",
|
||||
DisplayName: "摄像头",
|
||||
DataType: "InternalRef",
|
||||
ValueType: "",
|
||||
InnerAttributeName: "cameraId",
|
||||
OutEntityName: "Camera",
|
||||
OutEntityPkAttributeName: "id",
|
||||
OutEntityReversalAttributeName: "cameraShares",
|
||||
};
|
||||
var entityDesc = &common.EntityDesc {
|
||||
EntityInfo: entityInfo,
|
||||
PkAttributeInfo: idAttributeInfo,
|
||||
NormalFkIdAttributeInfos: []*common.AttributeInfo{
|
||||
cameraIdAttributeInfo,
|
||||
},
|
||||
NormalFkAttributeInfos: []*common.AttributeInfo{
|
||||
cameraAttributeInfo,
|
||||
},
|
||||
NormalChildren: []*common.AttributeInfo{
|
||||
},
|
||||
NormalOne2OneChildren: []*common.AttributeInfo{
|
||||
},
|
||||
AttributeInfoMap: map[string]*common.AttributeInfo{
|
||||
"id": idAttributeInfo,
|
||||
"name": nameAttributeInfo,
|
||||
"authCode": authCodeAttributeInfo,
|
||||
"enabled": enabledAttributeInfo,
|
||||
"created": createdAttributeInfo,
|
||||
"startTime": startTimeAttributeInfo,
|
||||
"deadline": deadlineAttributeInfo,
|
||||
"cameraId": cameraIdAttributeInfo,
|
||||
"camera": cameraAttributeInfo,
|
||||
},
|
||||
}
|
||||
|
||||
return entityDesc
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
package desc
|
||||
|
||||
import (
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
)
|
||||
|
||||
func GetCameraShareDesc() *common.EntityDesc {
|
||||
var entityInfo = common.EntityInfo{
|
||||
Name: "CameraShare",
|
||||
DisplayName: "摄像头分享",
|
||||
ClassName: "CameraShare",
|
||||
TableName: "camera_share",
|
||||
BasePath: "entity::camera_share",
|
||||
}
|
||||
var idAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "id",
|
||||
Name: "id",
|
||||
DisplayName: "摄像头分享主属性",
|
||||
DataType: "InternalPK",
|
||||
ValueType: "string",
|
||||
}
|
||||
var nameAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "name",
|
||||
Name: "name",
|
||||
DisplayName: "名称",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
}
|
||||
var authCodeAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "auth_code",
|
||||
Name: "authCode",
|
||||
DisplayName: "权限码",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
}
|
||||
var enabledAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "enabled",
|
||||
Name: "enabled",
|
||||
DisplayName: "启用状态",
|
||||
DataType: "Boolean",
|
||||
ValueType: "bool",
|
||||
}
|
||||
var createdAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "created",
|
||||
Name: "created",
|
||||
DisplayName: "创建时间",
|
||||
DataType: "DateTime",
|
||||
ValueType: "string",
|
||||
}
|
||||
var startTimeAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "start_time",
|
||||
Name: "startTime",
|
||||
DisplayName: "开始时间",
|
||||
DataType: "DateTime",
|
||||
ValueType: "string",
|
||||
}
|
||||
var deadlineAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "deadline",
|
||||
Name: "deadline",
|
||||
DisplayName: "结束时间",
|
||||
DataType: "DateTime",
|
||||
ValueType: "string",
|
||||
}
|
||||
var cameraIdAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "camera_id",
|
||||
Name: "cameraId",
|
||||
DisplayName: "摄像头id",
|
||||
DataType: "InternalFK",
|
||||
ValueType: "string",
|
||||
InnerAttributeName: "camera",
|
||||
OutEntityName: "Camera",
|
||||
OutEntityPkAttributeName: "id",
|
||||
OutEntityReversalAttributeName: "cameraShares",
|
||||
}
|
||||
var cameraAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "camera",
|
||||
Name: "camera",
|
||||
DisplayName: "摄像头",
|
||||
DataType: "InternalRef",
|
||||
ValueType: "",
|
||||
InnerAttributeName: "cameraId",
|
||||
OutEntityName: "Camera",
|
||||
OutEntityPkAttributeName: "id",
|
||||
OutEntityReversalAttributeName: "cameraShares",
|
||||
}
|
||||
var entityDesc = &common.EntityDesc{
|
||||
EntityInfo: entityInfo,
|
||||
PkAttributeInfo: idAttributeInfo,
|
||||
NormalFkIdAttributeInfos: []*common.AttributeInfo{
|
||||
cameraIdAttributeInfo,
|
||||
},
|
||||
NormalFkAttributeInfos: []*common.AttributeInfo{
|
||||
cameraAttributeInfo,
|
||||
},
|
||||
NormalChildren: []*common.AttributeInfo{},
|
||||
NormalOne2OneChildren: []*common.AttributeInfo{},
|
||||
AttributeInfoMap: map[string]*common.AttributeInfo{
|
||||
"id": idAttributeInfo,
|
||||
"name": nameAttributeInfo,
|
||||
"authCode": authCodeAttributeInfo,
|
||||
"enabled": enabledAttributeInfo,
|
||||
"created": createdAttributeInfo,
|
||||
"startTime": startTimeAttributeInfo,
|
||||
"deadline": deadlineAttributeInfo,
|
||||
"cameraId": cameraIdAttributeInfo,
|
||||
"camera": cameraAttributeInfo,
|
||||
},
|
||||
}
|
||||
|
||||
return entityDesc
|
||||
}
|
83
src/rtsp2rtmp/web/dao/desc/token_desc.go
Normal file
83
src/rtsp2rtmp/web/dao/desc/token_desc.go
Normal file
@@ -0,0 +1,83 @@
|
||||
package desc
|
||||
|
||||
import (
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
)
|
||||
|
||||
func GetTokenDesc() *common.EntityDesc {
|
||||
var entityInfo = common.EntityInfo{
|
||||
Name: "Token",
|
||||
DisplayName: "令牌",
|
||||
ClassName: "Token",
|
||||
TableName: "sys_token",
|
||||
BasePath: "entity::token",
|
||||
}
|
||||
var idTokenAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "id_sys_token",
|
||||
Name: "idToken",
|
||||
DisplayName: "令牌主属性",
|
||||
DataType: "InternalPK",
|
||||
ValueType: "string",
|
||||
}
|
||||
var usernameAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "username",
|
||||
Name: "username",
|
||||
DisplayName: "用户名称",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
}
|
||||
var nickNameAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "nick_name",
|
||||
Name: "nickName",
|
||||
DisplayName: "昵称",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
}
|
||||
var createTimeAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "create_time",
|
||||
Name: "createTime",
|
||||
DisplayName: "创建时间",
|
||||
DataType: "DateTime",
|
||||
ValueType: "string",
|
||||
}
|
||||
var tokenAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "token",
|
||||
Name: "token",
|
||||
DisplayName: "令牌",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
}
|
||||
var expiredTimeAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "expired_time",
|
||||
Name: "expiredTime",
|
||||
DisplayName: "过期时间",
|
||||
DataType: "DateTime",
|
||||
ValueType: "string",
|
||||
}
|
||||
var userInfoStringAttributeInfo = &common.AttributeInfo{
|
||||
ColumnName: "user_info_string",
|
||||
Name: "userInfoString",
|
||||
DisplayName: "用户信息序列化",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
}
|
||||
var entityDesc = &common.EntityDesc{
|
||||
EntityInfo: entityInfo,
|
||||
PkAttributeInfo: idTokenAttributeInfo,
|
||||
NormalFkIdAttributeInfos: []*common.AttributeInfo{},
|
||||
NormalFkAttributeInfos: []*common.AttributeInfo{},
|
||||
NormalChildren: []*common.AttributeInfo{},
|
||||
NormalOne2OneChildren: []*common.AttributeInfo{},
|
||||
AttributeInfoMap: map[string]*common.AttributeInfo{
|
||||
"idToken": idTokenAttributeInfo,
|
||||
"username": usernameAttributeInfo,
|
||||
"nickName": nickNameAttributeInfo,
|
||||
"createTime": createTimeAttributeInfo,
|
||||
"token": tokenAttributeInfo,
|
||||
"expiredTime": expiredTimeAttributeInfo,
|
||||
"userInfoString": userInfoStringAttributeInfo,
|
||||
},
|
||||
}
|
||||
|
||||
return entityDesc
|
||||
}
|
103
src/rtsp2rtmp/web/dao/desc/user_desc.go
Normal file
103
src/rtsp2rtmp/web/dao/desc/user_desc.go
Normal file
@@ -0,0 +1,103 @@
|
||||
package desc
|
||||
|
||||
import (
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
)
|
||||
|
||||
func GetUserDesc() *common.EntityDesc {
|
||||
var entityInfo = common.EntityInfo {
|
||||
Name: "User",
|
||||
DisplayName: "系统用户",
|
||||
ClassName: "User",
|
||||
TableName: "sys_user",
|
||||
BasePath: "entity::user",
|
||||
}
|
||||
var idUserAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "id_user",
|
||||
Name: "idUser",
|
||||
DisplayName: "系统用户id",
|
||||
DataType: "InternalPK",
|
||||
ValueType: "string",
|
||||
};
|
||||
var accountAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "account",
|
||||
Name: "account",
|
||||
DisplayName: "登录账号 ",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
};
|
||||
var userPwdAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "user_pwd",
|
||||
Name: "userPwd",
|
||||
DisplayName: "用户密码 ",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
};
|
||||
var phoneAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "phone",
|
||||
Name: "phone",
|
||||
DisplayName: "手机号码",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
};
|
||||
var emailAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "email",
|
||||
Name: "email",
|
||||
DisplayName: "邮箱",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
};
|
||||
var nameAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "name",
|
||||
Name: "name",
|
||||
DisplayName: "姓名 ",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
};
|
||||
var nickNameAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "nick_name",
|
||||
Name: "nickName",
|
||||
DisplayName: "昵称",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
};
|
||||
var genderAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "gender",
|
||||
Name: "gender",
|
||||
DisplayName: "性别",
|
||||
DataType: "String",
|
||||
ValueType: "string",
|
||||
};
|
||||
var fgActiveAttributeInfo = &common.AttributeInfo {
|
||||
ColumnName: "fg_active",
|
||||
Name: "fgActive",
|
||||
DisplayName: "启用标志",
|
||||
DataType: "Boolean",
|
||||
ValueType: "bool",
|
||||
};
|
||||
var entityDesc = &common.EntityDesc {
|
||||
EntityInfo: entityInfo,
|
||||
PkAttributeInfo: idUserAttributeInfo,
|
||||
NormalFkIdAttributeInfos: []*common.AttributeInfo{
|
||||
},
|
||||
NormalFkAttributeInfos: []*common.AttributeInfo{
|
||||
},
|
||||
NormalChildren: []*common.AttributeInfo{
|
||||
},
|
||||
NormalOne2OneChildren: []*common.AttributeInfo{
|
||||
},
|
||||
AttributeInfoMap: map[string]*common.AttributeInfo{
|
||||
"idUser": idUserAttributeInfo,
|
||||
"account": accountAttributeInfo,
|
||||
"userPwd": userPwdAttributeInfo,
|
||||
"phone": phoneAttributeInfo,
|
||||
"email": emailAttributeInfo,
|
||||
"name": nameAttributeInfo,
|
||||
"nickName": nickNameAttributeInfo,
|
||||
"gender": genderAttributeInfo,
|
||||
"fgActive": fgActiveAttributeInfo,
|
||||
},
|
||||
}
|
||||
|
||||
return entityDesc
|
||||
}
|
@@ -3,12 +3,11 @@ package entity
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// 摄像头
|
||||
type Camera struct {
|
||||
// 摄像头主属性
|
||||
Id string `orm:"pk;column(id)" json:"id"`
|
||||
// code:
|
||||
Id string `orm:"pk;column(id)" json:"id"`
|
||||
// 编号:
|
||||
Code string `orm:"column(code)" json:"code"`
|
||||
// rtsp地址:
|
||||
RtspUrl string `orm:"column(rtsp_url)" json:"rtspUrl"`
|
||||
@@ -17,15 +16,15 @@ type Camera struct {
|
||||
// 播放权限码:
|
||||
PlayAuthCode string `orm:"column(play_auth_code)" json:"playAuthCode"`
|
||||
// 在线状态:
|
||||
OnlineStatus int `orm:"column(online_status)" json:"onlineStatus"`
|
||||
OnlineStatus bool `orm:"column(online_status)" json:"onlineStatus"`
|
||||
// 启用状态:
|
||||
Enabled int `orm:"column(enabled)" json:"enabled"`
|
||||
Enabled bool `orm:"column(enabled)" json:"enabled"`
|
||||
// rtmp推送状态:
|
||||
RtmpPushStatus int `orm:"column(rtmp_push_status)" json:"rtmpPushStatus"`
|
||||
RtmpPushStatus bool `orm:"column(rtmp_push_status)" json:"rtmpPushStatus"`
|
||||
// 保存录像状态:
|
||||
SaveVideo int `orm:"column(save_video)" json:"saveVideo"`
|
||||
SaveVideo bool `orm:"column(save_video)" json:"saveVideo"`
|
||||
// 直播状态:
|
||||
Live int `orm:"column(live)" json:"live"`
|
||||
Live bool `orm:"column(live)" json:"live"`
|
||||
// 创建时间:
|
||||
Created time.Time `orm:"column(created)" json:"created"`
|
||||
// 摄像头分享
|
||||
|
@@ -3,17 +3,16 @@ package entity
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// 摄像头分享
|
||||
type CameraShare struct {
|
||||
// 摄像头分享主属性
|
||||
Id string `orm:"pk;column(id)" json:"id"`
|
||||
Id string `orm:"pk;column(id)" json:"id"`
|
||||
// 名称:
|
||||
Name string `orm:"column(name)" json:"name"`
|
||||
// 权限码:
|
||||
AuthCode string `orm:"column(auth_code)" json:"authCode"`
|
||||
// 启用状态:
|
||||
Enabled int `orm:"column(enabled)" json:"enabled"`
|
||||
Enabled bool `orm:"column(enabled)" json:"enabled"`
|
||||
// 创建时间:
|
||||
Created time.Time `orm:"column(created)" json:"created"`
|
||||
// 开始时间:
|
22
src/rtsp2rtmp/web/dao/entity/token.go
Normal file
22
src/rtsp2rtmp/web/dao/entity/token.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
// 令牌
|
||||
type Token struct {
|
||||
// 令牌主属性
|
||||
IdToken string `orm:"pk;column(id_sys_token)" json:"idToken"`
|
||||
// 用户名称:
|
||||
Username string `orm:"column(username)" json:"username"`
|
||||
// 昵称:
|
||||
NickName string `orm:"column(nick_name)" json:"nickName"`
|
||||
// 创建时间:
|
||||
CreateTime time.Time `orm:"column(create_time)" json:"createTime"`
|
||||
// 令牌:
|
||||
Token string `orm:"column(token)" json:"token"`
|
||||
// 过期时间:
|
||||
ExpiredTime time.Time `orm:"column(expired_time)" json:"expiredTime"`
|
||||
// 用户信息序列化:
|
||||
UserInfoString string `orm:"column(user_info_string)" json:"userInfoString"`
|
||||
}
|
23
src/rtsp2rtmp/web/dao/entity/user.go
Normal file
23
src/rtsp2rtmp/web/dao/entity/user.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package entity
|
||||
|
||||
// 系统用户
|
||||
type User struct {
|
||||
// 系统用户id
|
||||
IdUser string `orm:"pk;column(id_user)" json:"idUser"`
|
||||
// 登录账号 :
|
||||
Account string `orm:"column(account)" json:"account"`
|
||||
// 用户密码 :
|
||||
UserPwd string `orm:"column(user_pwd)" json:"userPwd"`
|
||||
// 手机号码:
|
||||
Phone string `orm:"column(phone)" json:"phone"`
|
||||
// 邮箱:
|
||||
Email string `orm:"column(email)" json:"email"`
|
||||
// 姓名 :
|
||||
Name string `orm:"column(name)" json:"name"`
|
||||
// 昵称:
|
||||
NickName string `orm:"column(nick_name)" json:"nickName"`
|
||||
// 性别:
|
||||
Gender string `orm:"column(gender)" json:"gender"`
|
||||
// 启用标志:
|
||||
FgActive bool `orm:"column(fg_active)" json:"fgActive"`
|
||||
}
|
@@ -43,6 +43,8 @@ func init() {
|
||||
// 需要在init中注册定义的model
|
||||
orm.RegisterModel(new(entity.Camera))
|
||||
orm.RegisterModel(new(entity.CameraShare))
|
||||
orm.RegisterModelWithPrefix("sys_", new(entity.User))
|
||||
orm.RegisterModelWithPrefix("sys_", new(entity.Token))
|
||||
}
|
||||
|
||||
var descMap = make(map[string]*common.EntityDesc)
|
||||
@@ -50,6 +52,8 @@ var descMap = make(map[string]*common.EntityDesc)
|
||||
func init() {
|
||||
descMap["Camera"] = desc.GetCameraDesc()
|
||||
descMap["CameraShare"] = desc.GetCameraShareDesc()
|
||||
descMap["User"] = desc.GetUserDesc()
|
||||
descMap["Token"] = desc.GetTokenDesc()
|
||||
}
|
||||
|
||||
func GetDescMapByKey(key string) *common.EntityDesc {
|
||||
|
@@ -1,12 +1,14 @@
|
||||
package camera
|
||||
package po
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// 摄像头
|
||||
type CameraPO struct {
|
||||
// 摄像头主属性
|
||||
Id string `json:"id"`
|
||||
// code:
|
||||
// 编号:
|
||||
Code string `json:"code"`
|
||||
// rtsp地址:
|
||||
RtspUrl string `json:"rtspUrl"`
|
||||
@@ -15,15 +17,15 @@ type CameraPO struct {
|
||||
// 播放权限码:
|
||||
PlayAuthCode string `json:"playAuthCode"`
|
||||
// 在线状态:
|
||||
OnlineStatus int `json:"onlineStatus"`
|
||||
OnlineStatus bool `json:"onlineStatus"`
|
||||
// 启用状态:
|
||||
Enabled int `json:"enabled"`
|
||||
Enabled bool `json:"enabled"`
|
||||
// rtmp推送状态:
|
||||
RtmpPushStatus int `json:"rtmpPushStatus"`
|
||||
RtmpPushStatus bool `json:"rtmpPushStatus"`
|
||||
// 保存录像状态:
|
||||
SaveVideo int `json:"saveVideo"`
|
||||
SaveVideo bool `json:"saveVideo"`
|
||||
// 直播状态:
|
||||
Live int `json:"live"`
|
||||
Live bool `json:"live"`
|
||||
// 创建时间:
|
||||
Created time.Time `json:"created"`
|
||||
}
|
@@ -1,6 +1,8 @@
|
||||
package camerashare
|
||||
package po
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// 摄像头分享
|
||||
type CameraSharePO struct {
|
||||
@@ -11,7 +13,7 @@ type CameraSharePO struct {
|
||||
// 权限码:
|
||||
AuthCode string `json:"authCode"`
|
||||
// 启用状态:
|
||||
Enabled int `json:"enabled"`
|
||||
Enabled bool `json:"enabled"`
|
||||
// 创建时间:
|
||||
Created time.Time `json:"created"`
|
||||
// 开始时间:
|
22
src/rtsp2rtmp/web/dto/po/base/token/token_po.go
Normal file
22
src/rtsp2rtmp/web/dto/po/base/token/token_po.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package po
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
// 令牌
|
||||
type TokenPO struct {
|
||||
// 令牌主属性
|
||||
IdToken string `json:"idToken"`
|
||||
// 用户名称:
|
||||
Username string `json:"username"`
|
||||
// 昵称:
|
||||
NickName string `json:"nickName"`
|
||||
// 创建时间:
|
||||
CreateTime time.Time `json:"createTime"`
|
||||
// 令牌:
|
||||
Token string `json:"token"`
|
||||
// 过期时间:
|
||||
ExpiredTime time.Time `json:"expiredTime"`
|
||||
// 用户信息序列化:
|
||||
UserInfoString string `json:"userInfoString"`
|
||||
}
|
23
src/rtsp2rtmp/web/dto/po/base/user/user_po.go
Normal file
23
src/rtsp2rtmp/web/dto/po/base/user/user_po.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package po
|
||||
|
||||
// 系统用户
|
||||
type UserPO struct {
|
||||
// 系统用户id
|
||||
IdUser string `json:"idUser"`
|
||||
// 登录账号 :
|
||||
Account string `json:"account"`
|
||||
// 用户密码 :
|
||||
UserPwd string `json:"userPwd"`
|
||||
// 手机号码:
|
||||
Phone string `json:"phone"`
|
||||
// 邮箱:
|
||||
Email string `json:"email"`
|
||||
// 姓名 :
|
||||
Name string `json:"name"`
|
||||
// 昵称:
|
||||
NickName string `json:"nickName"`
|
||||
// 性别:
|
||||
Gender string `json:"gender"`
|
||||
// 启用标志:
|
||||
FgActive bool `json:"fgActive"`
|
||||
}
|
31
src/rtsp2rtmp/web/dto/vo/base/camera/camera_vo.go
Normal file
31
src/rtsp2rtmp/web/dto/vo/base/camera/camera_vo.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package vo
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// 摄像头
|
||||
type CameraVO struct {
|
||||
// 摄像头主属性
|
||||
Id string `json:"id"`
|
||||
// 编号:
|
||||
Code string `json:"code"`
|
||||
// rtsp地址:
|
||||
RtspUrl string `json:"rtspUrl"`
|
||||
// rtmp推送地址:
|
||||
RtmpUrl string `json:"rtmpUrl"`
|
||||
// 播放权限码:
|
||||
PlayAuthCode string `json:"playAuthCode"`
|
||||
// 在线状态:
|
||||
OnlineStatus bool `json:"onlineStatus"`
|
||||
// 启用状态:
|
||||
Enabled bool `json:"enabled"`
|
||||
// rtmp推送状态:
|
||||
RtmpPushStatus bool `json:"rtmpPushStatus"`
|
||||
// 保存录像状态:
|
||||
SaveVideo bool `json:"saveVideo"`
|
||||
// 直播状态:
|
||||
Live bool `json:"live"`
|
||||
// 创建时间:
|
||||
Created time.Time `json:"created"`
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
package camera
|
||||
|
||||
import "time"
|
||||
|
||||
// 摄像头
|
||||
type CameraVO struct {
|
||||
// 摄像头主属性
|
||||
Id string `json:"id"`
|
||||
// code:
|
||||
Code string `json:"code"`
|
||||
// rtsp地址:
|
||||
RtspUrl string `json:"rtspUrl"`
|
||||
// rtmp推送地址:
|
||||
RtmpUrl string `json:"rtmpUrl"`
|
||||
// 播放权限码:
|
||||
PlayAuthCode string `json:"playAuthCode"`
|
||||
// 在线状态:
|
||||
OnlineStatus int `json:"onlineStatus"`
|
||||
// 启用状态:
|
||||
Enabled int `json:"enabled"`
|
||||
// rtmp推送状态:
|
||||
RtmpPushStatus int `json:"rtmpPushStatus"`
|
||||
// 保存录像状态:
|
||||
SaveVideo int `json:"saveVideo"`
|
||||
// 直播状态:
|
||||
Live int `json:"live"`
|
||||
// 创建时间:
|
||||
Created time.Time `json:"created"`
|
||||
// 摄像头分享
|
||||
CameraShares []CameraShareVO `vo:"ignore" json:"cameraShares"`
|
||||
}
|
||||
|
||||
// 摄像头分享
|
||||
type CameraShareVO struct {
|
||||
// 摄像头分享主属性
|
||||
Id string `json:"id"`
|
||||
// 名称:
|
||||
Name string `json:"name"`
|
||||
// 权限码:
|
||||
AuthCode string `json:"authCode"`
|
||||
// 启用状态:
|
||||
Enabled int `json:"enabled"`
|
||||
// 创建时间:
|
||||
Created time.Time `json:"created"`
|
||||
// 开始时间:
|
||||
StartTime time.Time `json:"startTime"`
|
||||
// 结束时间:
|
||||
Deadline time.Time `json:"deadline"`
|
||||
// 摄像头id:
|
||||
CameraId string `json:"cameraId"`
|
||||
}
|
@@ -1,6 +1,8 @@
|
||||
package camerashare
|
||||
package vo
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// 摄像头分享
|
||||
type CameraShareVO struct {
|
||||
@@ -11,7 +13,7 @@ type CameraShareVO struct {
|
||||
// 权限码:
|
||||
AuthCode string `json:"authCode"`
|
||||
// 启用状态:
|
||||
Enabled int `json:"enabled"`
|
||||
Enabled bool `json:"enabled"`
|
||||
// 创建时间:
|
||||
Created time.Time `json:"created"`
|
||||
// 开始时间:
|
||||
@@ -20,15 +22,13 @@ type CameraShareVO struct {
|
||||
Deadline time.Time `json:"deadline"`
|
||||
// 摄像头id:
|
||||
CameraId string `json:"cameraId"`
|
||||
// 摄像头id:
|
||||
// 摄像头:
|
||||
Camera CameraVO `vo:"ignore" json:"camera"`
|
||||
}
|
||||
|
||||
// 摄像头
|
||||
type CameraVO struct {
|
||||
// 摄像头主属性
|
||||
Id string `json:"id"`
|
||||
// code:
|
||||
// 编号:
|
||||
Code string `json:"code"`
|
||||
// rtsp地址:
|
||||
RtspUrl string `json:"rtspUrl"`
|
||||
@@ -37,15 +37,15 @@ type CameraVO struct {
|
||||
// 播放权限码:
|
||||
PlayAuthCode string `json:"playAuthCode"`
|
||||
// 在线状态:
|
||||
OnlineStatus int `json:"onlineStatus"`
|
||||
OnlineStatus bool `json:"onlineStatus"`
|
||||
// 启用状态:
|
||||
Enabled int `json:"enabled"`
|
||||
Enabled bool `json:"enabled"`
|
||||
// rtmp推送状态:
|
||||
RtmpPushStatus int `json:"rtmpPushStatus"`
|
||||
RtmpPushStatus bool `json:"rtmpPushStatus"`
|
||||
// 保存录像状态:
|
||||
SaveVideo int `json:"saveVideo"`
|
||||
SaveVideo bool `json:"saveVideo"`
|
||||
// 直播状态:
|
||||
Live int `json:"live"`
|
||||
Live bool `json:"live"`
|
||||
// 创建时间:
|
||||
Created time.Time `json:"created"`
|
||||
}
|
22
src/rtsp2rtmp/web/dto/vo/base/token/token_vo.go
Normal file
22
src/rtsp2rtmp/web/dto/vo/base/token/token_vo.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package vo
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
// 令牌
|
||||
type TokenVO struct {
|
||||
// 令牌主属性
|
||||
IdToken string `json:"idToken"`
|
||||
// 用户名称:
|
||||
Username string `json:"username"`
|
||||
// 昵称:
|
||||
NickName string `json:"nickName"`
|
||||
// 创建时间:
|
||||
CreateTime time.Time `json:"createTime"`
|
||||
// 令牌:
|
||||
Token string `json:"token"`
|
||||
// 过期时间:
|
||||
ExpiredTime time.Time `json:"expiredTime"`
|
||||
// 用户信息序列化:
|
||||
UserInfoString string `json:"userInfoString"`
|
||||
}
|
23
src/rtsp2rtmp/web/dto/vo/base/user/user_vo.go
Normal file
23
src/rtsp2rtmp/web/dto/vo/base/user/user_vo.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package vo
|
||||
|
||||
// 系统用户
|
||||
type UserVO struct {
|
||||
// 系统用户id
|
||||
IdUser string `json:"idUser"`
|
||||
// 登录账号 :
|
||||
Account string `json:"account"`
|
||||
// 用户密码 :
|
||||
UserPwd string `json:"userPwd"`
|
||||
// 手机号码:
|
||||
Phone string `json:"phone"`
|
||||
// 邮箱:
|
||||
Email string `json:"email"`
|
||||
// 姓名 :
|
||||
Name string `json:"name"`
|
||||
// 昵称:
|
||||
NickName string `json:"nickName"`
|
||||
// 性别:
|
||||
Gender string `json:"gender"`
|
||||
// 启用标志:
|
||||
FgActive bool `json:"fgActive"`
|
||||
}
|
@@ -205,9 +205,9 @@ func (dynQuery *DynQueryPostgres) makeConditionsToken(conditionExpr ConditionExp
|
||||
simpleExprTokens = append(simpleExprTokens, "=", "?")
|
||||
vBool, ok := simpleExpr.Values[0].(bool)
|
||||
if ok {
|
||||
param := 0
|
||||
param := false
|
||||
if vBool {
|
||||
param = 1
|
||||
param = true
|
||||
}
|
||||
params = append(params, param)
|
||||
} else {
|
||||
@@ -217,9 +217,9 @@ func (dynQuery *DynQueryPostgres) makeConditionsToken(conditionExpr ConditionExp
|
||||
simpleExprTokens = append(simpleExprTokens, "!=", "?")
|
||||
vBool, ok := simpleExpr.Values[0].(bool)
|
||||
if ok {
|
||||
param := 0
|
||||
param := false
|
||||
if vBool {
|
||||
param = 1
|
||||
param = true
|
||||
}
|
||||
params = append(params, param)
|
||||
} else {
|
||||
|
@@ -46,7 +46,7 @@ func CameraDelete(e entity.Camera) (i int64, err error) {
|
||||
|
||||
func CameraSelectById(id string) (model entity.Camera, err error) {
|
||||
o := orm.NewOrm()
|
||||
model = entity.Camera{Id: id}
|
||||
model = entity.Camera{ Id: id }
|
||||
|
||||
err = o.Read(&model)
|
||||
|
||||
|
@@ -46,7 +46,7 @@ func CameraShareDelete(e entity.CameraShare) (i int64, err error) {
|
||||
|
||||
func CameraShareSelectById(id string) (model entity.CameraShare, err error) {
|
||||
o := orm.NewOrm()
|
||||
model = entity.CameraShare{Id: id}
|
||||
model = entity.CameraShare{ Id: id }
|
||||
|
||||
err = o.Read(&model)
|
||||
|
||||
|
228
src/rtsp2rtmp/web/service/base/token.go
Normal file
228
src/rtsp2rtmp/web/service/base/token.go
Normal file
@@ -0,0 +1,228 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dao/entity"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dyn_query"
|
||||
)
|
||||
|
||||
func getTokenName() string {
|
||||
return "Token"
|
||||
}
|
||||
|
||||
func TokenCreate(e entity.Token) (i int64, err error) {
|
||||
o := orm.NewOrm()
|
||||
i, err = o.Insert(&e)
|
||||
if err != nil && err != orm.ErrLastInsertIdUnavailable {
|
||||
logs.Error("insert error : %v", err)
|
||||
return i, err
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func TokenUpdateById(e entity.Token) (i int64, err error) {
|
||||
o := orm.NewOrm()
|
||||
i, err = o.Update(&e)
|
||||
if err != nil {
|
||||
logs.Error("update error : %v", err)
|
||||
return 0, err
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func TokenDelete(e entity.Token) (i int64, err error) {
|
||||
o := orm.NewOrm()
|
||||
i, err = o.Delete(&e)
|
||||
if err != nil {
|
||||
logs.Error("delete error : %v", err)
|
||||
return 0, err
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func TokenSelectById(id string) (model entity.Token, err error) {
|
||||
o := orm.NewOrm()
|
||||
model = entity.Token{ IdToken: id }
|
||||
|
||||
err = o.Read(&model)
|
||||
|
||||
if err == orm.ErrNoRows {
|
||||
logs.Error("record not found")
|
||||
return
|
||||
} else if err == orm.ErrMissPK {
|
||||
logs.Error("err miss pk")
|
||||
return
|
||||
} else if err != nil {
|
||||
logs.Error("selectById error: %v", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func TokenSelectByIds(ids []string) (models []entity.Token, err error) {
|
||||
idsNew := make([]interface{}, 0)
|
||||
for _, id := range ids {
|
||||
idsNew = append(idsNew, id)
|
||||
}
|
||||
condition := common.GetInCondition("idToken", idsNew)
|
||||
var querySqlBuilder, err_build = dyn_query.NewQuerySqlBuilder(condition, getTokenName())
|
||||
if err_build != nil {
|
||||
err = fmt.Errorf("selectByIds error: %v", err_build)
|
||||
return
|
||||
}
|
||||
var sqlStr, params, err_make_sql = querySqlBuilder.GetSql()
|
||||
if err_make_sql != nil {
|
||||
err = fmt.Errorf("selectByIds error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
// execute the raw query string
|
||||
_, err_query := o.Raw(sqlStr, params...).QueryRows(&models)
|
||||
if err_query != nil {
|
||||
err = fmt.Errorf("selectByIds error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func TokenFindCollectionByCondition(condition common.AqCondition) (models []entity.Token, err error) {
|
||||
var querySqlBuilder, err_build = dyn_query.NewQuerySqlBuilder(condition, getTokenName())
|
||||
if err_build != nil {
|
||||
err = fmt.Errorf("findCollectionByCondition error: %v", err_build)
|
||||
return
|
||||
}
|
||||
var sqlStr, params, err_make_sql = querySqlBuilder.GetSql()
|
||||
if err_make_sql != nil {
|
||||
err = fmt.Errorf("findCollectionByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
// execute the raw query string
|
||||
_, err_query := o.Raw(sqlStr, params...).QueryRows(&models)
|
||||
if err_query != nil {
|
||||
err = fmt.Errorf("findCollectionByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func TokenFindOneByCondition(condition common.AqCondition) (model entity.Token, err error) {
|
||||
var querySqlBuilder, err_build = dyn_query.NewQuerySqlBuilder(condition, getTokenName())
|
||||
if err_build != nil {
|
||||
err = fmt.Errorf("findOneByCondition error: %v", err_build)
|
||||
return
|
||||
}
|
||||
var sqlStr, params, err_make_sql = querySqlBuilder.GetSql()
|
||||
if err_make_sql != nil {
|
||||
err = fmt.Errorf("findOneByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
// execute the raw query string
|
||||
models := make([]entity.Token, 0)
|
||||
_, err_query := o.Raw(sqlStr, params...).QueryRows(&models)
|
||||
if err_query != nil {
|
||||
err = fmt.Errorf("findOneByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
if len(models) < 1 {
|
||||
err = fmt.Errorf("record not found")
|
||||
return
|
||||
}
|
||||
if len(models) > 1 {
|
||||
err = fmt.Errorf("record more than one")
|
||||
return
|
||||
}
|
||||
model = models[0]
|
||||
return
|
||||
}
|
||||
|
||||
func TokenFindPageByCondition(aqPageInfoInput common.AqPageInfoInput) (pageInfo common.PageInfo, err error) {
|
||||
condition := common.AqCondition{LogicNode: aqPageInfoInput.LogicNode, Orders: aqPageInfoInput.Orders}
|
||||
var querySqlBuilder, err_build = dyn_query.NewQuerySqlBuilder(condition, getTokenName())
|
||||
if err_build != nil {
|
||||
err = fmt.Errorf("findPageByCondition error: %v", err_build)
|
||||
return
|
||||
}
|
||||
var countSqlStr, params, err_make_sql = querySqlBuilder.GetCountSql()
|
||||
if err_make_sql != nil {
|
||||
err = fmt.Errorf("findPageByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
var pageSqlStr, _, err_make_page_sql = querySqlBuilder.GetPageSql(aqPageInfoInput.PageIndex, aqPageInfoInput.PageSize)
|
||||
if err_make_page_sql != nil {
|
||||
err = fmt.Errorf("findPageByCondition error: %v", err_make_page_sql)
|
||||
return
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
// execute the count raw query string
|
||||
var count uint64
|
||||
err_count_query := o.Raw(countSqlStr, params...).QueryRow(&count)
|
||||
if err_count_query != nil {
|
||||
err = fmt.Errorf("findPageByCondition error: %v", err_count_query)
|
||||
return
|
||||
}
|
||||
// execute the raw query string
|
||||
models := make([]entity.Token, 0)
|
||||
_, err_query := o.Raw(pageSqlStr, params...).QueryRows(&models)
|
||||
if err_query != nil {
|
||||
err = fmt.Errorf("findPageByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
dataList := make([]interface{}, 0)
|
||||
for _, model := range models {
|
||||
dataList = append(dataList, model)
|
||||
}
|
||||
pageInfoInput := common.PageInfoInput{PageIndex: aqPageInfoInput.PageIndex, PageSize: aqPageInfoInput.PageSize, TotalCount: count}
|
||||
pageInfo = common.PageInfo{PageInfoInput: pageInfoInput, DataList: dataList}
|
||||
return
|
||||
}
|
||||
|
||||
func TokenCountByCondition(condition common.AqCondition) (total uint64, err error) {
|
||||
var querySqlBuilder, err_build = dyn_query.NewQuerySqlBuilder(condition, getTokenName())
|
||||
if err_build != nil {
|
||||
err = fmt.Errorf("countByCondition error: %v", err_build)
|
||||
return
|
||||
}
|
||||
var countSqlStr, params, err_make_sql = querySqlBuilder.GetCountSql()
|
||||
if err_make_sql != nil {
|
||||
err = fmt.Errorf("countByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
// execute the count raw query string
|
||||
err_count_query := o.Raw(countSqlStr, params...).QueryRow(&total)
|
||||
if err_count_query != nil {
|
||||
err = fmt.Errorf("countByCondition error: %v", err_count_query)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func TokenExistsByCondition(condition common.AqCondition) (exist bool, err error) {
|
||||
var querySqlBuilder, err_build = dyn_query.NewQuerySqlBuilder(condition, getTokenName())
|
||||
if err_build != nil {
|
||||
err = fmt.Errorf("existsByCondition error: %v", err_build)
|
||||
return
|
||||
}
|
||||
var countSqlStr, params, err_make_sql = querySqlBuilder.GetCountSql()
|
||||
if err_make_sql != nil {
|
||||
err = fmt.Errorf("existsByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
// execute the count raw query string
|
||||
total := 0
|
||||
err_count_query := o.Raw(countSqlStr, params...).QueryRow(&total)
|
||||
if err_count_query != nil {
|
||||
err = fmt.Errorf("existsByCondition error: %v", err_count_query)
|
||||
return
|
||||
}
|
||||
exist = total > 0
|
||||
return
|
||||
}
|
228
src/rtsp2rtmp/web/service/base/user.go
Normal file
228
src/rtsp2rtmp/web/service/base/user.go
Normal file
@@ -0,0 +1,228 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dao/entity"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/dyn_query"
|
||||
)
|
||||
|
||||
func getUserName() string {
|
||||
return "User"
|
||||
}
|
||||
|
||||
func UserCreate(e entity.User) (i int64, err error) {
|
||||
o := orm.NewOrm()
|
||||
i, err = o.Insert(&e)
|
||||
if err != nil && err != orm.ErrLastInsertIdUnavailable {
|
||||
logs.Error("insert error : %v", err)
|
||||
return i, err
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func UserUpdateById(e entity.User) (i int64, err error) {
|
||||
o := orm.NewOrm()
|
||||
i, err = o.Update(&e)
|
||||
if err != nil {
|
||||
logs.Error("update error : %v", err)
|
||||
return 0, err
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func UserDelete(e entity.User) (i int64, err error) {
|
||||
o := orm.NewOrm()
|
||||
i, err = o.Delete(&e)
|
||||
if err != nil {
|
||||
logs.Error("delete error : %v", err)
|
||||
return 0, err
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func UserSelectById(id string) (model entity.User, err error) {
|
||||
o := orm.NewOrm()
|
||||
model = entity.User{ IdUser: id }
|
||||
|
||||
err = o.Read(&model)
|
||||
|
||||
if err == orm.ErrNoRows {
|
||||
logs.Error("record not found")
|
||||
return
|
||||
} else if err == orm.ErrMissPK {
|
||||
logs.Error("err miss pk")
|
||||
return
|
||||
} else if err != nil {
|
||||
logs.Error("selectById error: %v", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func UserSelectByIds(ids []string) (models []entity.User, err error) {
|
||||
idsNew := make([]interface{}, 0)
|
||||
for _, id := range ids {
|
||||
idsNew = append(idsNew, id)
|
||||
}
|
||||
condition := common.GetInCondition("idUser", idsNew)
|
||||
var querySqlBuilder, err_build = dyn_query.NewQuerySqlBuilder(condition, getUserName())
|
||||
if err_build != nil {
|
||||
err = fmt.Errorf("selectByIds error: %v", err_build)
|
||||
return
|
||||
}
|
||||
var sqlStr, params, err_make_sql = querySqlBuilder.GetSql()
|
||||
if err_make_sql != nil {
|
||||
err = fmt.Errorf("selectByIds error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
// execute the raw query string
|
||||
_, err_query := o.Raw(sqlStr, params...).QueryRows(&models)
|
||||
if err_query != nil {
|
||||
err = fmt.Errorf("selectByIds error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func UserFindCollectionByCondition(condition common.AqCondition) (models []entity.User, err error) {
|
||||
var querySqlBuilder, err_build = dyn_query.NewQuerySqlBuilder(condition, getUserName())
|
||||
if err_build != nil {
|
||||
err = fmt.Errorf("findCollectionByCondition error: %v", err_build)
|
||||
return
|
||||
}
|
||||
var sqlStr, params, err_make_sql = querySqlBuilder.GetSql()
|
||||
if err_make_sql != nil {
|
||||
err = fmt.Errorf("findCollectionByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
// execute the raw query string
|
||||
_, err_query := o.Raw(sqlStr, params...).QueryRows(&models)
|
||||
if err_query != nil {
|
||||
err = fmt.Errorf("findCollectionByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func UserFindOneByCondition(condition common.AqCondition) (model entity.User, err error) {
|
||||
var querySqlBuilder, err_build = dyn_query.NewQuerySqlBuilder(condition, getUserName())
|
||||
if err_build != nil {
|
||||
err = fmt.Errorf("findOneByCondition error: %v", err_build)
|
||||
return
|
||||
}
|
||||
var sqlStr, params, err_make_sql = querySqlBuilder.GetSql()
|
||||
if err_make_sql != nil {
|
||||
err = fmt.Errorf("findOneByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
// execute the raw query string
|
||||
models := make([]entity.User, 0)
|
||||
_, err_query := o.Raw(sqlStr, params...).QueryRows(&models)
|
||||
if err_query != nil {
|
||||
err = fmt.Errorf("findOneByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
if len(models) < 1 {
|
||||
err = fmt.Errorf("record not found")
|
||||
return
|
||||
}
|
||||
if len(models) > 1 {
|
||||
err = fmt.Errorf("record more than one")
|
||||
return
|
||||
}
|
||||
model = models[0]
|
||||
return
|
||||
}
|
||||
|
||||
func UserFindPageByCondition(aqPageInfoInput common.AqPageInfoInput) (pageInfo common.PageInfo, err error) {
|
||||
condition := common.AqCondition{LogicNode: aqPageInfoInput.LogicNode, Orders: aqPageInfoInput.Orders}
|
||||
var querySqlBuilder, err_build = dyn_query.NewQuerySqlBuilder(condition, getUserName())
|
||||
if err_build != nil {
|
||||
err = fmt.Errorf("findPageByCondition error: %v", err_build)
|
||||
return
|
||||
}
|
||||
var countSqlStr, params, err_make_sql = querySqlBuilder.GetCountSql()
|
||||
if err_make_sql != nil {
|
||||
err = fmt.Errorf("findPageByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
var pageSqlStr, _, err_make_page_sql = querySqlBuilder.GetPageSql(aqPageInfoInput.PageIndex, aqPageInfoInput.PageSize)
|
||||
if err_make_page_sql != nil {
|
||||
err = fmt.Errorf("findPageByCondition error: %v", err_make_page_sql)
|
||||
return
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
// execute the count raw query string
|
||||
var count uint64
|
||||
err_count_query := o.Raw(countSqlStr, params...).QueryRow(&count)
|
||||
if err_count_query != nil {
|
||||
err = fmt.Errorf("findPageByCondition error: %v", err_count_query)
|
||||
return
|
||||
}
|
||||
// execute the raw query string
|
||||
models := make([]entity.User, 0)
|
||||
_, err_query := o.Raw(pageSqlStr, params...).QueryRows(&models)
|
||||
if err_query != nil {
|
||||
err = fmt.Errorf("findPageByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
dataList := make([]interface{}, 0)
|
||||
for _, model := range models {
|
||||
dataList = append(dataList, model)
|
||||
}
|
||||
pageInfoInput := common.PageInfoInput{PageIndex: aqPageInfoInput.PageIndex, PageSize: aqPageInfoInput.PageSize, TotalCount: count}
|
||||
pageInfo = common.PageInfo{PageInfoInput: pageInfoInput, DataList: dataList}
|
||||
return
|
||||
}
|
||||
|
||||
func UserCountByCondition(condition common.AqCondition) (total uint64, err error) {
|
||||
var querySqlBuilder, err_build = dyn_query.NewQuerySqlBuilder(condition, getUserName())
|
||||
if err_build != nil {
|
||||
err = fmt.Errorf("countByCondition error: %v", err_build)
|
||||
return
|
||||
}
|
||||
var countSqlStr, params, err_make_sql = querySqlBuilder.GetCountSql()
|
||||
if err_make_sql != nil {
|
||||
err = fmt.Errorf("countByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
// execute the count raw query string
|
||||
err_count_query := o.Raw(countSqlStr, params...).QueryRow(&total)
|
||||
if err_count_query != nil {
|
||||
err = fmt.Errorf("countByCondition error: %v", err_count_query)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func UserExistsByCondition(condition common.AqCondition) (exist bool, err error) {
|
||||
var querySqlBuilder, err_build = dyn_query.NewQuerySqlBuilder(condition, getUserName())
|
||||
if err_build != nil {
|
||||
err = fmt.Errorf("existsByCondition error: %v", err_build)
|
||||
return
|
||||
}
|
||||
var countSqlStr, params, err_make_sql = querySqlBuilder.GetCountSql()
|
||||
if err_make_sql != nil {
|
||||
err = fmt.Errorf("existsByCondition error: %v", err_make_sql)
|
||||
return
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
// execute the count raw query string
|
||||
total := 0
|
||||
err_count_query := o.Raw(countSqlStr, params...).QueryRow(&total)
|
||||
if err_count_query != nil {
|
||||
err = fmt.Errorf("existsByCondition error: %v", err_count_query)
|
||||
return
|
||||
}
|
||||
exist = total > 0
|
||||
return
|
||||
}
|
@@ -61,17 +61,17 @@ func (t *task) offlineCamera() {
|
||||
logs.Error("query camera error : %v", err)
|
||||
}
|
||||
for _, cs := range css {
|
||||
if cs.OnlineStatus != 1 {
|
||||
if cs.OnlineStatus != true {
|
||||
continue
|
||||
}
|
||||
if fgUseFfmpeg {
|
||||
if exists := rtmpserver.GetSingleRtmpServer().ExistsPublisher(cs.Code); !exists {
|
||||
cs.OnlineStatus = 0
|
||||
cs.OnlineStatus = false
|
||||
base_service.CameraUpdateById(cs)
|
||||
}
|
||||
} else {
|
||||
if exists := rtspclientmanager.GetSingleRtspClientManager().ExistsPublisher(cs.Code); !exists {
|
||||
cs.OnlineStatus = 0
|
||||
cs.OnlineStatus = false
|
||||
base_service.CameraUpdateById(cs)
|
||||
}
|
||||
}
|
||||
|
@@ -13,8 +13,8 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/utils"
|
||||
"github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/common"
|
||||
base_controller "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controllers/base"
|
||||
ext_controller "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controllers/ext"
|
||||
base_controller "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controller/base"
|
||||
ext_controller "github.com/hkmadao/rtsp2rtmp/src/rtsp2rtmp/web/controller/ext"
|
||||
)
|
||||
|
||||
var tokens sync.Map
|
||||
@@ -63,6 +63,22 @@ func (w *web) webRun() {
|
||||
router.POST("/system/login", login)
|
||||
|
||||
router.GET("/live/:method/:code/:authCode.flv", ext_controller.HttpFlvPlay)
|
||||
// user
|
||||
router.POST("/user/add", base_controller.UserAdd)
|
||||
router.POST("/user/update", base_controller.UserUpdate)
|
||||
router.POST("/user/remove", base_controller.UserRemove)
|
||||
router.GET("/user/getById/:id", base_controller.UserGetById)
|
||||
router.GET("/user/getByIds", base_controller.UserGetByIds)
|
||||
router.POST("/user/aq", base_controller.UserAq)
|
||||
router.POST("/user/aqPage", base_controller.UserAqPage)
|
||||
// toke
|
||||
router.POST("/token/add", base_controller.TokenAdd)
|
||||
router.POST("/token/update", base_controller.TokenUpdate)
|
||||
router.POST("/token/remove", base_controller.TokenRemove)
|
||||
router.GET("/token/getById/:id", base_controller.TokenGetById)
|
||||
router.GET("/token/getByIds", base_controller.TokenGetByIds)
|
||||
router.POST("/token/aq", base_controller.TokenAq)
|
||||
router.POST("/token/aqPage", base_controller.TokenAqPage)
|
||||
// camera
|
||||
router.POST("/camera/add", base_controller.CameraAdd)
|
||||
router.POST("/camera/update", base_controller.CameraUpdate)
|
||||
|
Reference in New Issue
Block a user