package BaseGlobalService import ( "context" "dsBaseWeb/Business/BaseGlobal/BaseGlobalProto" "dsBaseWeb/Utils/GRpcUtil" "dsBaseWeb/Utils/LogUtil" "errors" "time" ) /** 功能:增加全局变量 作者:吴缤 时间:2020-04-22 */ func AddBaseGlobal(modelArg BaseGlobalProto.ModelArg) (*BaseGlobalProto.Reply, error) { //1、准备动作:连接服务器 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() conn := GRpcUtil.GetConnection() if conn == nil { return nil, errors.New("RPC服务未启动!") } c := BaseGlobalProto.NewBaseGlobalManageClient(conn) Reply, err := c.AddBaseGlobal(ctx, &modelArg) if err != nil { LogUtil.Error("增加全局变量错误: ", err.Error()) } return Reply, err } /** 功能:删除全局变量 作者:吴缤 时间:2020-04-22 */ func DeleteBaseGlobal(deleteIdsArg BaseGlobalProto.DeleteIdsArg) (*BaseGlobalProto.Reply, error) { //1、准备动作:连接服务器 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() conn := GRpcUtil.GetConnection() if conn == nil { return nil, errors.New("RPC服务未启动!") } c := BaseGlobalProto.NewBaseGlobalManageClient(conn) Reply, err := c.DeleteBaseGlobal(ctx, &deleteIdsArg) if err != nil { LogUtil.Error("删除全局变量错误: ", err.Error()) } return Reply, err } /** 功能:修改全局变量 作者:吴缤 时间:2020-04-22 */ func UpdateBaseGlobal(modelArg BaseGlobalProto.ModelArg) (*BaseGlobalProto.Reply, error) { //1、准备动作:连接服务器 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() conn := GRpcUtil.GetConnection() if conn == nil { return nil, errors.New("RPC服务未启动!") } c := BaseGlobalProto.NewBaseGlobalManageClient(conn) Reply, err := c.UpdateBaseGlobal(ctx, &modelArg) if err != nil { LogUtil.Error("修改全局变量错误: ", err.Error()) } return Reply, err } /** 功能:根据全局变量列表 作者:吴缤 时间:2020-04-22 */ func PageBaseGlobal(queryArg BaseGlobalProto.QueryArg) (*BaseGlobalProto.Reply, error) { //1、准备动作:连接服务器 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() conn := GRpcUtil.GetConnection() if conn == nil { return nil, errors.New("RPC服务未启动!") } c := BaseGlobalProto.NewBaseGlobalManageClient(conn) Reply, err := c.PageBaseGlobal(ctx, &queryArg) if err != nil { LogUtil.Error("根据全局变量列表错误: ", err.Error()) } return Reply, err } /** 功能:获取全局变量信息 作者:吴缤 时间:2020-06-09 16:26:22 */ func GetBaseGlobal(modelArg BaseGlobalProto.ModelArg) (*BaseGlobalProto.Reply, error) { //1、准备动作:连接服务器 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() conn := GRpcUtil.GetConnection() if conn == nil { return nil, errors.New("RPC服务未启动!") } //2、业务传参 c := BaseGlobalProto.NewBaseGlobalManageClient(conn) Reply, err := c.GetBaseGlobal(ctx, &modelArg) if err != nil { LogUtil.Error("获取全局变量信息错误: ", err.Error()) } return Reply, err }