From 63e024e77d8e0fefd8818f1b744cbfc5e36b50fe Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期六, 14 十二月 2019 14:56:32 +0800 Subject: [PATCH] fix localconfig --- controllers/syssetcont.go | 68 +++++++++++++++++++++++++++++++-- 1 files changed, 63 insertions(+), 5 deletions(-) diff --git a/controllers/syssetcont.go b/controllers/syssetcont.go index 96705e3..8bc66fc 100644 --- a/controllers/syssetcont.go +++ b/controllers/syssetcont.go @@ -16,6 +16,7 @@ type LocalConfigVo struct { Id string `json:"id"` + AlarmIp string `json:"alarm_ip,omitempty" example:"192.168.1.182"` AlarmPort int `json:"alarm_port,omitempty" example:"22122"` AlarmThresholdType int `json:"alarm_threshold_type"` //鎶ヨ闃堝�肩被鍨嬭缃細1:鎸夋渶楂樺垎,2:鎸夐槇鍊间互涓� @@ -31,6 +32,12 @@ ServerType int `json:"server_type,omitempty" example:"1"` Reserved string `json:"reserved,omitempty" example:"1"` RealMax int `json:"real_max"` //瀹炴椂澶勭悊鐨勬渶澶ц矾鏁� +} + +type ResourceConfigVo struct { + IpType int `json:"ipType"` //0:鏈満ip锛�1锛氭紓绉籭p + ServiceIp string `json:"serviceIp"` //澶栭儴鏈嶅姟ip + Domain string `json:"domain"` //鍩熷悕 } type Gb28181ConfigVo struct { @@ -78,8 +85,8 @@ // @Produce json // @Tags sysset // @Param config body controllers.LocalConfigVo true "鎶ヨ鍜屽瓨鍌ㄤ俊鎭暟鎹�" -// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}" -// @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}" +// @Success 200 {string} json "{"code":200, msg:"", success:true}" +// @Failure 500 {string} json "{"code":500, msg:"", success:false}" // @Router /data/api-v/sysset/alarmEdit [POST] func (sset SysSetController) AlarmEdit(c *gin.Context) { var args LocalConfigVo @@ -101,7 +108,6 @@ // @Security ApiKeyAuth // @Summary 瀛樺偍淇℃伅淇敼 // @Description 瀛樺偍淇℃伅淇敼 -// @Accept json // @Produce json // @Tags sysset // @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}" @@ -159,7 +165,7 @@ func (sset SysSetController) GetDevInfo(c *gin.Context) { var api dbapi.SysSetApi b, sysconf := api.GetServerInfo() - resData := make(map[string]string, 0) + resData := make(map[string]interface{}, 0) if !b { // 鏌ヨ鏄惁瀛樺湪 util.ResponseFormat(c, code.ServiceInsideError, "鏌ヨ澶辫触") } else { @@ -172,6 +178,14 @@ resData["subMask"] = mask resData["gateway"] = gateway resData["dns"] = dns + resData["min_video_len"] = sysconf.CutMinDuration + resData["max_video_len"] = sysconf.CutMaxDuration + resData["alarm_ip"] = sysconf.AlarmIp + resData["alarm_port"] = sysconf.AlarmPort + resData["web_pic_ip"] = sysconf.WebPicIp + resData["web_pic_port"] = sysconf.WebPicPort + resData["es_pic_ip"] = sysconf.EsPicIp + resData["es_pic_port"] = sysconf.EsPicPort resData["deviceNum"] = config.Server.DeviceNum resData["deviceType"] = config.Server.DeviceType @@ -283,7 +297,6 @@ // @Security ApiKeyAuth // @Summary 娴嬭瘯鍚屾鏃堕棿 // @Description 娴嬭瘯鍚屾鏃堕棿鏈嶅姟鍣ㄦ槸鍚﹀彲鐢� -// @Accept json // @Produce json // @Tags sysset // @Param server query string true "鏃堕棿鏈嶅姟鍣╥p" @@ -404,6 +417,7 @@ // @Summary 璁剧疆瀹氭椂閲嶅惎 // @Description 璁剧疆瀹氭椂閲嶅惎浠诲姟鐨勯厤缃鍒� +// @Accept x-www-form-urlencoded // @Produce json // @Tags sysset // @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}" @@ -430,3 +444,47 @@ util.ResponseFormat(c, code.Success, "閰嶇疆鎴愬姛") } + +// @Security ApiKeyAuth +// @Summary 鑾峰彇瀛樺偍瀵瑰鏈嶅姟淇℃伅 +// @Description 鑾峰彇瀛樺偍瀵瑰鏈嶅姟淇℃伅 +// @Produce json +// @Tags sysset +// @Success 200 {string} json "{"code":200, msg:"", success:true}" +// @Failure 500 {string} json "{"code":500, msg:"", success:false}" +// @Router /data/api-v/sysset/getResourceConfig [get] +func (sset SysSetController) GetResourceConfig(c *gin.Context) { + var sysApi dbapi.SysSetApi + b,d := sysApi.GetResourceConfig() + if b { + util.ResponseFormat(c,code.Success,d) + } else { + util.ResponseFormat(c,code.ComError,"") + } +} + +// @Security ApiKeyAuth +// @Summary 瀛樺偍瀵瑰鏈嶅姟淇℃伅 +// @Description 瀛樺偍瀵瑰鏈嶅姟淇℃伅 +// @Accept json +// @Produce json +// @Tags sysset +// @Param reqBoby body controllers.ResourceConfigVo true "post璇锋眰锛宩son鍙傛暟" +// @Success 200 {string} json "{"code":200, msg:"", success:true}" +// @Failure 500 {string} json "{"code":500, msg:"", success:false}" +// @Router /data/api-v/sysset/saveResourceConfig [post] +func (sset SysSetController) SaveResourceConfig(c *gin.Context) { + var reqBody ResourceConfigVo + c.BindJSON(&reqBody) + if reqBody.ServiceIp == "" && reqBody.Domain == "" { + util.ResponseFormat(c,code.RequestParamError,"") + return + } + var sysApi dbapi.SysSetApi + paramBody := util.Struct2Map(reqBody) + if b,_ := sysApi.SaveResourceConfig(paramBody); b { + util.ResponseFormat(c,code.Success,"") + } else { + util.ResponseFormat(c,code.ComError,"") + } +} \ No newline at end of file -- Gitblit v1.8.0