上传修改时间服务器时间接口
This commit is contained in:
parent
b2bd909b91
commit
b1bfc4e385
1
bin/timestamp.text
Normal file
1
bin/timestamp.text
Normal file
@ -0,0 +1 @@
|
||||
15.000000
|
@ -59,6 +59,7 @@
|
||||
"data":"",
|
||||
}
|
||||
```
|
||||
|
||||
### 邮件发放API
|
||||
- 接口名:createmail
|
||||
- 接口说明:web 服务器给玩家发送邮件
|
||||
@ -112,4 +113,26 @@
|
||||
"msg":"成功",
|
||||
"data":"",
|
||||
}
|
||||
```
|
||||
|
||||
### 修改服务器时间
|
||||
- 接口名:modifyopentime
|
||||
- 接口说明:修改区服服务当前时间用于QA测试
|
||||
- 请求地址:{IP}:{port}/modifyopentime
|
||||
- 请求参数:offest(请求时间戳|签名),sign(签名)
|
||||
- 请求样例
|
||||
```
|
||||
{
|
||||
"offest":12,
|
||||
"sign":"asjioqiowjeioqjweijqwejoi"
|
||||
}
|
||||
```
|
||||
- 返回参数 code(0:成功 -1 失败),msg(结果描述),data(返回的额外数据)
|
||||
- 返回样例
|
||||
```
|
||||
{
|
||||
"code":0,
|
||||
"msg":"成功",
|
||||
"data":"",
|
||||
}
|
||||
```
|
@ -22,7 +22,9 @@ func (this *Api_Comp) CreateNotify(c *engine.Context) {
|
||||
msg string
|
||||
data interface{}
|
||||
)
|
||||
defer c.JSON(http.StatusOK, &Respond{Code: code, Message: msg, Data: data})
|
||||
defer func() {
|
||||
c.JSON(http.StatusOK, &Respond{Code: code, Message: msg, Data: data})
|
||||
}()
|
||||
if sign := gin.ParamSign(this.options.Key, map[string]interface{}{"Title": req.Title, "Ctime": req.Ctime, "Rtime": req.Rtime}); sign != req.Sign {
|
||||
this.module.Errorf("LoginByCaptchaReq SignError sgin:%s", sign)
|
||||
code = pb.ErrorCode_SignError
|
||||
|
48
modules/web/api_modifytime.go
Normal file
48
modules/web/api_modifytime.go
Normal file
@ -0,0 +1,48 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/gin"
|
||||
"go_dreamfactory/lego/sys/gin/engine"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ModifyopentimeReq struct {
|
||||
Offest int64 `json:"offest"` // uid
|
||||
Sign string `json:"sign"`
|
||||
}
|
||||
|
||||
//修改开服时间
|
||||
func (this *Api_Comp) Modifyopentime(c *engine.Context) {
|
||||
req := &ModifyopentimeReq{}
|
||||
err := c.BindJSON(&req)
|
||||
this.module.Debugf("CreateNotify:%+v err:%v", req, err)
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
msg string
|
||||
)
|
||||
defer func() {
|
||||
c.JSON(http.StatusOK, &Respond{Code: code, Message: msg, Data: nil})
|
||||
}()
|
||||
if sign := gin.ParamSign(this.options.Key, map[string]interface{}{"offest": req.Offest}); sign != req.Sign {
|
||||
this.module.Errorf("Modifyopentime SignError sgin:%s", sign)
|
||||
code = pb.ErrorCode_SignError
|
||||
msg = pb.GetErrorCodeMsg(code)
|
||||
return
|
||||
}
|
||||
configure.SetOffsettime(time.Duration(req.Offest) * time.Second)
|
||||
if err := this.module.service.RpcBroadcast(
|
||||
context.Background(),
|
||||
comm.Service_Worker,
|
||||
string(comm.Rpc_ConfigureUpDate),
|
||||
&pb.EmptyReq{},
|
||||
&pb.EmptyResp{}); err != nil {
|
||||
this.module.Errorln(err)
|
||||
msg = err.Error()
|
||||
code = pb.ErrorCode_RpcFuncExecutionError
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/gin/engine"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type OpenTime struct {
|
||||
Optime string `json:"optime"` //开服时间
|
||||
Mytime string `json:"mytime"` //修改后的开服时间
|
||||
}
|
||||
|
||||
//获取开服时间
|
||||
func (this *Api_Comp) Getopentime(c *engine.Context) {
|
||||
data := &OpenTime{
|
||||
Optime: this.module.service.GetOpentime().Format("2006-01-02 15:04:05"),
|
||||
Mytime: this.module.service.GetOpentime().Add(configure.GetOffsettime()).Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
c.JSON(http.StatusOK, &Respond{
|
||||
Code: 0,
|
||||
Message: "成功",
|
||||
Data: data,
|
||||
})
|
||||
}
|
||||
|
||||
//修改开服时间
|
||||
func (this *Api_Comp) Modifyopentime(c *engine.Context) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
msg string
|
||||
offest time.Duration
|
||||
)
|
||||
opentime := c.PostForm("opentime")
|
||||
defer func() {
|
||||
c.JSON(http.StatusOK, &Respond{
|
||||
Code: code,
|
||||
Message: msg,
|
||||
Data: opentime,
|
||||
})
|
||||
}()
|
||||
t, err := time.ParseInLocation("2006-01-02 15:04:05", opentime, time.Local)
|
||||
if nil != err || t.IsZero() {
|
||||
this.module.Errorln(err)
|
||||
msg = fmt.Sprintf("opentime:%s 格式异常", opentime)
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
offest = t.Sub(this.module.service.GetOpentime())
|
||||
configure.SetOffsettime(offest)
|
||||
if err := this.module.service.RpcBroadcast(
|
||||
context.Background(),
|
||||
comm.Service_Worker,
|
||||
string(comm.Rpc_ConfigureUpDate),
|
||||
&pb.EmptyReq{},
|
||||
&pb.EmptyResp{}); err != nil {
|
||||
this.module.Errorln(err)
|
||||
msg = err.Error()
|
||||
code = pb.ErrorCode_RpcFuncExecutionError
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user