package BaseRoleService import ( "context" "dsBaseWeb/Business/BaseRole/BaseRoleProto" "dsBaseWeb/Utils/GRpcUtil" "dsBaseWeb/Utils/LogUtil" "errors" "time" ) /** 功能:根据系统ID或身份ID获取角色信息 作者:吴缤 时间:2021-01-04 */ func PageBaseRole(arg BaseRoleProto.QueryArg) (*BaseRoleProto.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 := BaseRoleProto.NewBaseRoleManageClient(conn) Reply, err := c.PageBaseRole(ctx, &arg) if err != nil { LogUtil.Error("根据系统ID或身份ID获取角色信息错误: ", err.Error()) } return Reply, err } /** 功能:根据角色ID获取该菜单信息 作者:吴缤 时间:2021-01-04 */ func GetBaseRole(arg BaseRoleProto.ModelArg) (*BaseRoleProto.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 := BaseRoleProto.NewBaseRoleManageClient(conn) Reply, err := c.GetBaseRole(ctx, &arg) if err != nil { LogUtil.Error("根据角色ID获取该菜单信息错误: ", err.Error()) } return Reply, err } /** 功能:增加角色信息 作者:吴缤 时间:2021-01-04 */ func AddBaseRole(arg BaseRoleProto.ModelArg) (*BaseRoleProto.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 := BaseRoleProto.NewBaseRoleManageClient(conn) Reply, err := c.AddBaseRole(ctx, &arg) if err != nil { LogUtil.Error("增加角色信息错误: ", err.Error()) } return Reply, err } /** 功能:删除角色信息 作者:吴缤 时间:2021-01-04 */ func DeleteBaseRole(arg BaseRoleProto.DeleteIdsArg) (*BaseRoleProto.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 := BaseRoleProto.NewBaseRoleManageClient(conn) Reply, err := c.DeleteBaseRole(ctx, &arg) if err != nil { LogUtil.Error("删除角色信息错误: ", err.Error()) } return Reply, err } /** 功能:修改角色信息 作者:吴缤 时间:2021-01-04 */ func UpdateBaseRole(arg BaseRoleProto.ModelArg) (*BaseRoleProto.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 := BaseRoleProto.NewBaseRoleManageClient(conn) Reply, err := c.UpdateBaseRole(ctx, &arg) if err != nil { LogUtil.Error("修改角色信息错误: ", err.Error()) } return Reply, err }