From 7ce84b3d1e45d35c7c9f73561893039a05c16995 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期五, 20 十二月 2019 19:38:18 +0800
Subject: [PATCH] fix unTargz
---
controllers/syssetcont.go | 481 ++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 416 insertions(+), 65 deletions(-)
diff --git a/controllers/syssetcont.go b/controllers/syssetcont.go
index bf26d51..bdd04a8 100644
--- a/controllers/syssetcont.go
+++ b/controllers/syssetcont.go
@@ -1,44 +1,62 @@
package controllers
import (
+ "net/http"
+ "regexp"
+ "strconv"
+ "webserver/extend/code"
+ "webserver/extend/config"
+ "webserver/extend/sys"
+ "webserver/extend/util"
+ "webserver/middlewares/auth"
+ "webserver/service"
+
"basic.com/dbapi.git"
"github.com/gin-gonic/gin"
- "webserver/extend/code"
- "webserver/extend/util"
)
type SysSetController struct {
-
}
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"`
- WebPicIp string `json:"web_pic_ip,omitempty" example:""`
- WebPicPort int `json:"web_pic_port,omitempty" example:"22122"`
- EsPicIp string `json:"es_pic_ip,omitempty" example:""`
- EsPicPort int `json:"es_pic_port,omitempty" example:"22122"`
- CutMaxDuration int `json:"cut_max_duration,omitempty" example:"20"`
- CutMinDuration int `json:"cut_min_duration,omitempty" example:"5"`
- ServerId string `json:"server_id,omitempty" example:"鍒嗘瀽璁惧id"`
- ServerName string `json:"server_name,omitempty" example:"鍒嗘瀽璁惧鍚嶇О"`
- ServerType int `json:"server_type,omitempty" example:"1"`
- Reserved string `json:"reserved,omitempty" example:"1"`
- RealMax int `json:"real_max"`//瀹炴椂澶勭悊鐨勬渶澶ц矾鏁�
+ 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:鎸夐槇鍊间互涓�
+ AlarmThreshold int `json:"alarm_threshold"` //鎶ヨ闃堝��
+ WebPicIp string `json:"web_pic_ip,omitempty" example:""`
+ WebPicPort int `json:"web_pic_port,omitempty" example:"22122"`
+ EsPicIp string `json:"es_pic_ip,omitempty" example:""`
+ EsPicPort int `json:"es_pic_port,omitempty" example:"22122"`
+ CutMaxDuration int `json:"cut_max_duration,omitempty" example:"20"`
+ CutMinDuration int `json:"cut_min_duration,omitempty" example:"5"`
+ ServerId string `json:"server_id,omitempty" example:"鍒嗘瀽璁惧id"`
+ ServerName string `json:"server_name,omitempty" example:"鍒嗘瀽璁惧鍚嶇О"`
+ ServerType int `json:"server_type,omitempty" example:"1"`
+ Reserved string `json:"reserved,omitempty" example:"1"`
+ RealMax int `json:"real_max"` //瀹炴椂澶勭悊鐨勬渶澶ц矾鏁�
}
type Gb28181ConfigVo struct {
- Id string `json:"Id"`
- ServerIp string `json:"ServerIp" example:"鍥芥爣鏈嶅姟鍣↖P"`
- ServerPort int `json:"ServerPort" example:"鏈嶅姟鍣ㄧ鍙�:8060"`
- PublicId string `json:"PublicId" example:"鍥芥爣鏈嶅姟鍣↖d"`
- GbServerPort int `json:"GbServerPort" example:"鍥芥爣鏈嶅姟绔彛:7060"`
- IsAuth bool `json:"IsAuth" example:"鏄惁寮�鍚壌鏉�:true"`
- Password string `json:"Password" example:"瀵嗙爜"`
- UpdateTime string `json:"UpdateTime"`
+ Id string `json:"Id"`
+ ServerIp string `json:"ServerIp" example:"鍥芥爣鏈嶅姟鍣↖P"`
+ ServerPort int `json:"ServerPort" example:"骞冲彴鏈嶅姟绔彛:7060"`
+ PublicId string `json:"PublicId" example:"骞冲彴鏈嶅姟Id"`
+ GbServerPort int `json:"GbServerPort" example:"鍥芥爣鏈嶅姟绔彛:8060"`
+ IsAuth bool `json:"IsAuth" example:"鏄惁寮�鍚壌鏉�:true"`
+ Password string `json:"Password" example:"瀵嗙爜"`
+ UpdateTime string `json:"UpdateTime"`
}
+type SysClockConfigVo struct {
+ TimeZone string `json:"timeZone" example:"鏃跺尯"`
+ NTP bool `json:"ntp" example:"NTP鏍℃椂"`
+ NTPServer string `json:"ntpServer" example:"NTP鏈嶅姟鍣ㄥ湴鍧�"`
+ Interval int `json:"interval" example:"鑷姩鏍℃椂闂撮殧"`
+ NewTime string `json:"newTime" example:"鎵嬪姩鎸囧畾鏃堕棿"`
+}
+
+// @Security ApiKeyAuth
// @Summary 瀛樺偍淇℃伅鏌ヨ
// @Description 瀛樺偍淇℃伅鏌ヨ
// @Accept json
@@ -47,16 +65,17 @@
// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
// @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}"
// @Router /data/api-v/sysset/alarmServerShow [GET]
-func (sset SysSetController) AlarmServerShow(c *gin.Context){
+func (sset SysSetController) AlarmServerShow(c *gin.Context) {
var api dbapi.SysSetApi
b, sysconf := api.GetServerInfo()
- if b{
- util.ResponseFormat(c,code.Success,sysconf)
+ if b {
+ util.ResponseFormat(c, code.Success, sysconf)
} else {
- util.ResponseFormat(c,code.ComError,"鏌ヨ澶辫触")
+ util.ResponseFormat(c, code.ComError, "鏌ヨ澶辫触")
}
}
+// @Security ApiKeyAuth
// @Summary 瀛樺偍淇℃伅淇敼
// @Description 瀛樺偍淇℃伅淇敼
// @Accept json
@@ -69,29 +88,29 @@
func (sset SysSetController) AlarmEdit(c *gin.Context) {
var args LocalConfigVo
err := c.BindJSON(&args)
- if err !=nil {
- util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
return
}
var api dbapi.SysSetApi
paramBody := util.Struct2Map(args)
- b,data := api.AlarmEdit(paramBody)
+ b, data := api.AlarmEdit(paramBody)
if b {
- util.ResponseFormat(c,code.Success,data)
- }else {
- util.ResponseFormat(c,code.ComError,"淇濆瓨澶辫触")
+ util.ResponseFormat(c, code.Success, data)
+ } else {
+ util.ResponseFormat(c, code.ComError, "淇濆瓨澶辫触")
}
}
+// @Security ApiKeyAuth
// @Summary 瀛樺偍淇℃伅淇敼
// @Description 瀛樺偍淇℃伅淇敼
-// @Accept json
// @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/videoLenShow [GET]
-func (sset SysSetController) VideoLenShow(c *gin.Context){
+func (sset SysSetController) VideoLenShow(c *gin.Context) {
var api dbapi.SysSetApi
b, sysconf := api.GetServerInfo()
if b {
@@ -101,17 +120,18 @@
// 瀛樺湪鍒欎慨鏀�
util.ResponseFormat(c, code.Success, resData)
} else {
- util.ResponseFormat(c,code.ComError,"鏌ヨ澶辫触")
+ util.ResponseFormat(c, code.ComError, "鏌ヨ澶辫触")
}
}
+// @Security ApiKeyAuth
// @Summary 瑙嗛鎴彇鏃堕暱淇敼
// @Description 瑙嗛鎴彇鏃堕暱淇℃伅
// @Accept x-www-form-urlencoded
// @Produce json
// @Tags sysset
-// @Param min_video_len query string true "瑙嗛鎴彇鏈�鐭椂闀�"
-// @Param max_video_len query string true "瑙嗛鎴彇鏈�闀挎椂闀�"
+// @Param min_video_len formData string true "瑙嗛鎴彇鏈�鐭椂闀�"
+// @Param max_video_len formData string true "瑙嗛鎴彇鏈�闀挎椂闀�"
// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
// @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}"
// @Router /data/api-v/sysset/videoLenEdit [POST]
@@ -122,14 +142,15 @@
max_video_len := c.Request.FormValue("max_video_len")
min_video_len := c.Request.FormValue("min_video_len")
var api dbapi.SysSetApi
- b,data := api.VideoLenEdit(max_video_len,min_video_len)
- if b{
- util.ResponseFormat(c,code.UpdateSuccess,data)
+ b, data := api.VideoLenEdit(max_video_len, min_video_len)
+ if b {
+ util.ResponseFormat(c, code.UpdateSuccess, data)
} else {
- util.ResponseFormat(c,code.ComError,"淇濆瓨澶辫触")
+ util.ResponseFormat(c, code.ComError, "淇濆瓨澶辫触")
}
}
+// @Security ApiKeyAuth
// @Summary 鑾峰彇鍒嗘瀽璁惧淇℃伅
// @Description 鍒嗘瀽璁惧淇℃伅
// @Accept json
@@ -143,40 +164,63 @@
b, sysconf := api.GetServerInfo()
resData := make(map[string]string, 0)
if !b { // 鏌ヨ鏄惁瀛樺湪
- util.ResponseFormat(c, code.ServiceInsideError,"鏌ヨ澶辫触")
- }else {
- resData["dev_id"] = sysconf.GetServerId()
- resData["dev_name"] = sysconf.GetServerName()
- // 瀛樺湪
+ util.ResponseFormat(c, code.ServiceInsideError, "鏌ヨ澶辫触")
+ } else {
+ resData["server_id"] = sysconf.GetServerId()
+ resData["server_name"] = sysconf.GetServerName()
+ ipv4, mask, _ := sys.GetLocalIP(config.Server.NetworkAdapter)
+ gateway, _ := sys.GetDefaultRoute(config.Server.NetworkAdapter)
+ dns, _ := sys.GetDnsServer()
+ resData["ip"] = ipv4
+ resData["subMask"] = mask
+ resData["gateway"] = gateway
+ resData["dns"] = dns
+
+ resData["deviceNum"] = config.Server.DeviceNum
+ resData["deviceType"] = config.Server.DeviceType
+ resData["deviceSerialNum"] = config.Server.DeviceSerialNum
+ resData["masterVersion"] = config.Server.MasterVersion
+ resData["webVersion"] = config.Server.WebVersion
+ resData["channelCount"] = config.Server.ChannelCount
+ resData["diskCount"] = config.Server.DiskCount
+
util.ResponseFormat(c, code.Success, resData)
}
}
+// @Security ApiKeyAuth
// saveDevInfo dev_id dev_name
// @Summary 淇濆瓨瑙嗛鍒嗘瀽璁惧淇℃伅
// @Description 鍒嗘瀽璁惧淇℃伅
// @Accept x-www-form-urlencoded
// @Produce json
// @Tags sysset
-// @Param dev_name query string true "鍒嗘瀽璁惧鍚嶇О"
+// @Param dev_name formData string true "鍒嗘瀽璁惧鍚嶇О"
// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
// @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}"
// @Router /data/api-v/sysset/saveDevInfo [POST]
-func (sset SysSetController) SaveDevInfo(c *gin.Context){
-
- dev_name := c.Request.FormValue("dev_name")
+func (sset SysSetController) SaveDevInfo(c *gin.Context) {
+ dev_name := c.PostForm("server_name")
var api dbapi.SysSetApi
- paramBody :=make(map[string]interface{},0)
+ paramBody := make(map[string]interface{}, 0)
paramBody["serverName"] = dev_name
- b,data := api.SaveServerInfo(paramBody)
+
+ // 璁剧疆ip
+ isOk, msg := sys.SetNetworkConfig(c.PostForm("ip"), c.PostForm("subMask"), c.PostForm("gateway"), c.PostForm("dns"))
+ if !isOk {
+ util.ResponseFormat(c, code.ComError, msg)
+ return
+ }
+
+ b, data := api.SaveServerInfo(paramBody)
if b { // 鏌ヨ鏄惁瀛樺湪
- util.ResponseFormat(c,code.Success,data)
- } else { // 瀛樺湪鍙婁慨鏀� 涓嶅瓨鍦� 鍗虫坊鍔�
- util.ResponseFormat(c,code.ComError,"淇濆瓨澶辫触")
+ util.ResponseFormat(c, code.Success, data)
+ } else { // 瀛樺湪鍙婁慨鏀� 涓嶅瓨鍦� 鍗虫坊鍔�
+ util.ResponseFormat(c, code.ComError, "淇濆瓨澶辫触")
}
}
-
+// @Security ApiKeyAuth
// @Summary GB28181璁剧疆鏌ヨ
// @Description GB28181璁剧疆淇℃伅鏌ヨ
// @Accept json
@@ -189,12 +233,13 @@
var api dbapi.SysSetApi
b, data := api.Gb28181ConfigShow()
if b {
- util.ResponseFormat(c,code.Success,data)
+ util.ResponseFormat(c, code.Success, data)
} else {
- util.ResponseFormat(c,code.ComError,"鏌ヨ澶辫触")
+ util.ResponseFormat(c, code.ComError, "鏌ヨ澶辫触")
}
}
+// @Security ApiKeyAuth
// @Summary GB28181璁剧疆淇℃伅淇敼
// @Description GB28181璁剧疆淇敼
// @Accept json
@@ -207,16 +252,322 @@
func (sset SysSetController) Gb28181ConfigEdit(c *gin.Context) {
var args Gb28181ConfigVo
err := c.BindJSON(&args)
- if err !=nil {
- util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
return
}
var api dbapi.SysSetApi
paramBody := util.Struct2Map(args)
b, data := api.Gb28181ConfigEdit(paramBody)
if b {
- util.ResponseFormat(c,code.UpdateSuccess,data)
+ util.ResponseFormat(c, code.UpdateSuccess, data)
} else {
- util.ResponseFormat(c,code.ComError,"鏇存柊澶辫触")
+ util.ResponseFormat(c, code.ComError, "鏇存柊澶辫触")
}
}
+
+// @Security ApiKeyAuth
+// @Summary 鑾峰彇鏃堕棿閰嶇疆
+// @Description 绯荤粺鏃堕棿閰嶇疆淇℃伅
+// @Accept json
+// @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/clockInfo [GET]
+func (sset SysSetController) GetClockinfo(c *gin.Context) {
+ resData := make(map[string]interface{}, 0)
+ resData["time_zone"], resData["local_time"] = sys.TimeZone()
+ resData["ntp"], resData["ntp_server"], resData["interval"] = sys.NTPConfig()
+
+ util.ResponseFormat(c, code.Success, resData)
+}
+
+// @Security ApiKeyAuth
+// @Summary 娴嬭瘯鍚屾鏃堕棿
+// @Description 娴嬭瘯鍚屾鏃堕棿鏈嶅姟鍣ㄦ槸鍚﹀彲鐢�
+// @Produce json
+// @Tags sysset
+// @Param server query string true "鏃堕棿鏈嶅姟鍣╥p"
+// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
+// @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}"
+// @Router /data/api-v/sysset/ntpTest [GET]
+func (sset SysSetController) TestNTPServer(c *gin.Context) {
+ ntpServer := c.Query("server")
+
+ if root := sys.CheckRootPermissions(); !root {
+ util.ResponseFormat(c, code.ServiceInsideError, "鏈嶅姟鍣ㄦ病鏈変慨鏀规椂闂寸殑鏉冮檺")
+ return
+ }
+
+ isConn := sys.RunNTPDate(ntpServer)
+ if !isConn {
+ util.ResponseFormat(c, code.RequestParamError, "NTP鏈嶅姟鍣ㄤ笉鍙敤")
+ return
+ }
+
+ util.ResponseFormat(c, code.Success, "")
+
+}
+
+// @Security ApiKeyAuth
+// @Summary 璁剧疆绯荤粺鏃堕棿
+// @Description 鏍℃绯荤粺鏃堕棿
+// @Accept json
+// @Produce json
+// @Tags sysset
+// @Param config body controllers.SysClockConfigVo true "鏍℃椂淇℃伅"
+// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
+// @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}"
+// @Router /data/api-v/sysset/updateClock [POST]
+func (sset SysSetController) SetSysClock(c *gin.Context) {
+ var args SysClockConfigVo
+ err := c.BindJSON(&args)
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
+ return
+ }
+
+ if args.TimeZone != "CST" && args.TimeZone != "UTC" {
+ if r := sys.SetTimeZone(args.TimeZone); !r {
+ util.ResponseFormat(c, code.RequestParamError, "鏃跺尯鍙傛暟閿欒")
+ return
+ }
+ }
+
+ if !args.NTP {
+ if r := sys.SetLocalTime(args.NewTime); !r {
+ util.ResponseFormat(c, code.RequestParamError, "鎸囧畾鐨勬椂闂村弬鏁伴敊璇�")
+ return
+ }
+ } else {
+ if r := sys.EnableNTPCron(args.NTPServer, args.Interval); !r {
+ util.ResponseFormat(c, code.RequestParamError, "鎸囧畾鐨勬湇鍔″櫒鍦板潃閿欒")
+ return
+ }
+ }
+
+ util.ResponseFormat(c, code.UpdateSuccess, "閰嶇疆鎴愬姛")
+}
+
+// @Security ApiKeyAuth
+// @Summary 鏌ヨ绯荤粺杩愯淇℃伅
+// @Description 鑾峰彇褰撳墠绯荤粺鐨勮繍琛岀姸鎬侊紝CPU, GPU, 鍐呭瓨绛�
+// @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/sysinfo [GET]
+func (sset SysSetController) GetSysInfo(c *gin.Context) {
+ info := sys.GetSysInfo()
+ util.ResponseFormat(c, code.UpdateSuccess, info)
+}
+
+// @Security ApiKeyAuth
+// @Summary 鏌ヨ绯荤粺鐘舵�侀槇鍊艰缃�
+// @Description 鑾峰彇褰撳墠绯荤粺鐨勮繍琛岀姸鎬侊紝CPU, GPU, 鍐呭瓨鐨勯槇鍊奸厤缃�
+// @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/sysThresholds [GET]
+func (sset SysSetController) GetSysThresholds(c *gin.Context) {
+ util.ResponseFormat(c, code.UpdateSuccess, config.Server.SysThresholds)
+}
+
+// @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/reboot [GET]
+func (sset SysSetController) RebootOS(c *gin.Context) {
+ if isOk, msg := sys.Reboot(); !isOk {
+ util.ResponseFormat(c, code.UpdateFail, msg)
+ return
+ }
+
+ util.ResponseFormat(c, code.Success, "姝e湪閲嶅惎")
+}
+
+// @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/rebootTask [GET]
+func (sset SysSetController) GetRebootTask(c *gin.Context) {
+ _, msg := sys.ReadRebootTaskInCrontab()
+ util.ResponseFormat(c, code.Success, msg)
+}
+
+// @Summary 璁剧疆瀹氭椂閲嶅惎
+// @Description 璁剧疆瀹氭椂閲嶅惎浠诲姟鐨勯厤缃鍒�
+// @Accept x-www-form-urlencoded
+// @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/rebootTask [POST]
+func (sset SysSetController) SetRebootTask(c *gin.Context) {
+ task := c.PostForm("task")
+ if len(task) < 1 {
+ sys.CleanRebootTask()
+ util.ResponseFormat(c, code.Success, "閰嶇疆鎴愬姛")
+ return
+ }
+
+ regEx := `^([0-9*]+\s){4}[0-9*]+$`
+ if r, _ := regexp.MatchString(regEx, task); !r {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟閿欒")
+ return
+ }
+
+ if r := sys.UpdateRebootTask(task); !r {
+ util.ResponseFormat(c, code.UpdateFail, "閰嶇疆澶辫触")
+ return
+ }
+
+ util.ResponseFormat(c, code.Success, "閰嶇疆鎴愬姛")
+}
+
+// @Security ApiKeyAuth
+// @Summary 绯荤粺鏇存柊鍖呬笂浼�(鍒嗗潡妫�鏌�)
+// @Description 绯荤粺鏇存柊鍖呬笂浼�(鍒嗗潡妫�鏌�)
+// @Accept multipart/form-data
+// @Produce json
+// @Tags sysset
+// @Param chunkNumber formData int true "褰撳墠鏄鍑犱釜鍒嗗潡"
+// @Param chunkSize formData int true "姣忎竴鍧楃殑澶у皬"
+// @Param currentChunkSize formData int true "褰撳墠鍧楃殑澶у皬"
+// @Param identifier formData string true "鏁翠釜鏂囦欢鐨勫敮涓�鏍囪瘑锛岀洰鍓嶆槸md5"
+// @Param filename formData string true "鏂囦欢鍚嶇О"
+// @Param relativePath formData string true "鏂囦欢鍦ㄥ鎴风鐢佃剳鐨勮矾寰�"
+// @Param totalChunks formData int true "鏂囦欢鎬诲潡鏁�"
+// @Success 200 {string} json "{"code":200, msg:"", success:true}"
+// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
+// @Router /data/api-v/sysset/patchUpdate [get]
+func (sset SysSetController) PatchUpdateCheck(c *gin.Context) {
+ authDriver := auth.GenerateAuthDriver()
+ userM := (*authDriver).User(c)
+ if userM ==nil {
+ util.ResponseFormat(c,code.TokenNotFound,"鐧诲綍杩囨湡锛岃鐧诲綍")
+ return
+ }
+ chunkNumber, e1 := strconv.Atoi(c.Request.FormValue("chunkNumber"))
+ chunkSize, e2 := strconv.Atoi(c.Request.FormValue("chunkSize"))
+ currentChunkSize, e3 := strconv.Atoi(c.Request.FormValue("currentChunkSize"))
+ identifier := c.Request.FormValue("identifier")
+ filename := c.Request.FormValue("filename")
+ relativePath := c.Request.FormValue("relativePath")
+ totalChunks, e5 := strconv.Atoi(c.Request.FormValue("totalChunks"))
+ if identifier == "" || e1 != nil || e2 != nil || e3 != nil || e5 !=nil {
+ util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
+ return
+ }
+ var arg = service.FileChunkCheckVo {
+ UserId: userM["id"].(string),
+ FileName: filename,
+ Identifier: identifier,
+ RelativePath: relativePath,
+ TotalChunks: totalChunks,
+ ChunkNumber: chunkNumber,
+ ChunkSize: chunkSize,
+ CurrentChunkSize:currentChunkSize,
+ }
+ var sv service.SysService
+ if b := sv.CheckUpdateFile(&arg);b {
+ c.String(http.StatusOK,"found")
+ } else {
+ c.String(http.StatusNoContent,"")
+ }
+}
+
+// @Security ApiKeyAuth
+// @Summary 绯荤粺鏇存柊鍖呬笂浼�
+// @Description 绯荤粺鏇存柊鍖呬笂浼�
+// @Accept multipart/form-data
+// @Produce json
+// @Tags sysset
+// @Param chunkNumber formData int true "褰撳墠鏄鍑犱釜鍒嗗潡"
+// @Param chunkSize formData int true "姣忎竴鍧楃殑澶у皬"
+// @Param currentChunkSize formData int true "褰撳墠鍧楃殑澶у皬"
+// @Param totalSize formData string true "鏂囦欢鎬诲ぇ灏�"
+// @Param identifier formData string true "鏁翠釜鏂囦欢鐨勫敮涓�鏍囪瘑锛岀洰鍓嶆槸md5"
+// @Param filename formData string true "鏂囦欢鍚嶇О"
+// @Param relativePath formData string true "鏂囦欢鍦ㄥ鎴风鐢佃剳鐨勮矾寰�"
+// @Param totalChunks formData int true "鏂囦欢鎬诲潡鏁�"
+// @Param file formData file true "鏂囦欢鍒嗙墖鍐呭"
+// @Success 200 {string} json "{"code":200, msg:"", success:true}"
+// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
+// @Router /data/api-v/sysset/patchUpdate [post]
+func (sset SysSetController) PatchUpdate(c *gin.Context) {
+ authDriver := auth.GenerateAuthDriver()
+ userM := (*authDriver).User(c)
+ if userM == nil {
+ util.ResponseFormat(c, code.TokenNotFound, "鐧诲綍杩囨湡锛岃鐧诲綍")
+ return
+ }
+ chunkNumber, e1 := strconv.Atoi(c.Request.FormValue("chunkNumber"))
+ chunkSize, e2 := strconv.Atoi(c.Request.FormValue("chunkSize"))
+ currentChunkSize, e3 := strconv.Atoi(c.Request.FormValue("currentChunkSize"))
+ totalSize, e4 := strconv.ParseInt(c.Request.FormValue("totalSize"), 10, 64)
+ identifier := c.Request.FormValue("identifier")
+ filename := c.Request.FormValue("filename")
+ relativePath := c.Request.FormValue("relativePath")
+ totalChunks, e5 := strconv.Atoi(c.Request.FormValue("totalChunks"))
+ file, header, e6 := c.Request.FormFile("file")
+ if identifier == "" || e1 != nil || e2 != nil || e3 != nil || e4 != nil || e5 != nil || e6 != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
+ return
+ }
+ var arg = service.FileUploadVo{
+ UserId: userM["id"].(string),
+ FileName: filename,
+ Identifier: identifier,
+ RelativePath: relativePath,
+ TotalSize: totalSize,
+ TotalChunks: totalChunks,
+ ChunkNumber: chunkNumber,
+ ChunkSize: chunkSize,
+ CurrentChunkSize: currentChunkSize,
+ File: &file,
+ Header: header,
+ }
+ var sv service.SysService
+ if b := sv.PatchUpload(&arg); b {
+ util.ResponseFormat(c, code.Success, "")
+ } else {
+ util.ResponseFormat(c, code.ComError, "")
+ }
+}
+
+
+// @Security ApiKeyAuth
+// @Summary 寮�濮嬪崌绾�
+// @Description 寮�濮嬪崌绾�
+// @Accept multipart/form-data
+// @Produce json
+// @Tags sysset
+// @Param identifier formData string true "鏁翠釜鏂囦欢鐨勫敮涓�鏍囪瘑锛岀洰鍓嶆槸md5"
+// @Param filename formData string true "鏂囦欢鍚嶇О"
+// @Success 200 {string} json "{"code":200, msg:"", success:true}"
+// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
+// @Router /data/api-v/sysset/upgrade [post]
+func (sset SysSetController) Upgrade(c *gin.Context) {
+ identifier := c.Request.FormValue("identifier")
+ filename := c.Request.FormValue("filename")
+ if identifier == "" || filename == "" {
+ util.ResponseFormat(c,code.RequestParamError,"")
+ return
+ }
+ var sv service.SysService
+ if b,err := sv.Upgrade(identifier, filename);b {
+ util.ResponseFormat(c,code.UpgradeSuccess,"鍗囩骇鎴愬姛")
+ } else {
+ util.ResponseFormat(c,code.UpgradeFail,err.Error())
+ }
+}
\ No newline at end of file
--
Gitblit v1.8.0