|
|
package BaseMenuService
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
"dsBaseWeb/Business/BaseMenu/BaseMenuProto"
|
|
|
"dsBaseWeb/Utils/GRpcUtil"
|
|
|
"dsBaseWeb/Utils/LogUtil"
|
|
|
"errors"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
/**
|
|
|
功能:根据系统ID和身份ID获取菜单信息
|
|
|
作者:吴缤
|
|
|
时间:2021-01-04
|
|
|
*/
|
|
|
func PageBaseMenu(arg BaseMenuProto.QueryArg) (*BaseMenuProto.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 := BaseMenuProto.NewBaseMenuManageClient(conn)
|
|
|
Reply, err := c.PageBaseMenu(ctx, &arg)
|
|
|
if err != nil {
|
|
|
LogUtil.Error("根据系统ID和身份ID获取菜单信息错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:根据菜单ID获取该菜单信息
|
|
|
作者:吴缤
|
|
|
时间:2021-01-04
|
|
|
*/
|
|
|
func GetBaseMenu(arg BaseMenuProto.ModelArg) (*BaseMenuProto.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 := BaseMenuProto.NewBaseMenuManageClient(conn)
|
|
|
Reply, err := c.GetBaseMenu(ctx, &arg)
|
|
|
if err != nil {
|
|
|
LogUtil.Error("根据菜单ID获取该菜单信息错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:增加菜单信息
|
|
|
作者:吴缤
|
|
|
时间:2021-01-04
|
|
|
*/
|
|
|
func AddBaseMenu(arg BaseMenuProto.ModelArg) (*BaseMenuProto.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 := BaseMenuProto.NewBaseMenuManageClient(conn)
|
|
|
Reply, err := c.AddBaseMenu(ctx, &arg)
|
|
|
if err != nil {
|
|
|
LogUtil.Error("增加菜单信息错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:删除菜单信息
|
|
|
作者:吴缤
|
|
|
时间:2021-01-04
|
|
|
*/
|
|
|
func DeleteBaseMenu(arg BaseMenuProto.DeleteIdsArg) (*BaseMenuProto.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 := BaseMenuProto.NewBaseMenuManageClient(conn)
|
|
|
Reply, err := c.DeleteBaseMenu(ctx, &arg)
|
|
|
if err != nil {
|
|
|
LogUtil.Error("删除菜单信息错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:修改菜单信息
|
|
|
作者:吴缤
|
|
|
时间:2021-01-04
|
|
|
*/
|
|
|
func UpdateBaseMenu(arg BaseMenuProto.ModelArg) (*BaseMenuProto.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 := BaseMenuProto.NewBaseMenuManageClient(conn)
|
|
|
Reply, err := c.UpdateBaseMenu(ctx, &arg)
|
|
|
if err != nil {
|
|
|
LogUtil.Error("修改菜单信息错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:设置菜单排序
|
|
|
作者:吴缤
|
|
|
时间:2021-01-04
|
|
|
*/
|
|
|
func SetMenuSort(arg BaseMenuProto.SetMenuSortArg) (*BaseMenuProto.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 := BaseMenuProto.NewBaseMenuManageClient(conn)
|
|
|
Reply, err := c.SetMenuSort(ctx, &arg)
|
|
|
if err != nil {
|
|
|
LogUtil.Error("设置菜单排序错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|