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 } }