|
|
package SysDictService
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
"dsBaseWeb/Business/SysDict/SysDictProto"
|
|
|
"dsBaseWeb/Utils/GRpcUtil"
|
|
|
"dsBaseWeb/Utils/LogUtil"
|
|
|
"errors"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
/**
|
|
|
功能:根据字典分类和字典编码获取字典信息
|
|
|
作者:吴缤
|
|
|
时间:2020-05-22 16:07:03
|
|
|
*/
|
|
|
func GetSysDict(modelArg SysDictProto.ModelArg) (*SysDictProto.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 := SysDictProto.NewSysDictManageClient(conn)
|
|
|
Reply, err := c.GetSysDict(ctx, &modelArg)
|
|
|
if err != nil {
|
|
|
LogUtil.Error("根据字典分类和字典编码获取字典信息错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:根据字典分类、上级字典编码获取字典信息
|
|
|
作者:吴缤
|
|
|
时间:2020-05-22 16:07:28
|
|
|
*/
|
|
|
func PageSysDict(queryArg SysDictProto.QueryArg) (*SysDictProto.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 := SysDictProto.NewSysDictManageClient(conn)
|
|
|
Reply, err := c.PageSysDict(ctx, &queryArg)
|
|
|
if err != nil {
|
|
|
LogUtil.Error("根据字典分类、上级字典编码获取字典信息错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
func PageSysDictMultipleDictCode(multipleQueryArg SysDictProto.MultipleQueryArg) (*SysDictProto.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 := SysDictProto.NewSysDictManageClient(conn)
|
|
|
Reply, err := c.PageSysDictMultipleDictCode(ctx, &multipleQueryArg)
|
|
|
if err != nil {
|
|
|
LogUtil.Error("根据多个dictCode获取字典信息错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:获取学段信息
|
|
|
作者:吴缤
|
|
|
时间:2020-06-12 11:07:28
|
|
|
*/
|
|
|
func GetStage() (*SysDictProto.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 := SysDictProto.NewSysDictManageClient(conn)
|
|
|
Reply, err := c.GetStage(ctx, &SysDictProto.ModelArg{})
|
|
|
if err != nil {
|
|
|
LogUtil.Error("获取学段信息错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:根据学段ID获取学科信息
|
|
|
作者:吴缤
|
|
|
时间:2020-06-12 11:07:28
|
|
|
*/
|
|
|
func GetSubject(getSubjectArg SysDictProto.GetSubjectArg) (*SysDictProto.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 := SysDictProto.NewSysDictManageClient(conn)
|
|
|
Reply, err := c.GetSubject(ctx, &getSubjectArg)
|
|
|
if err != nil {
|
|
|
LogUtil.Error("获取学科信息错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:根据多个dict_kind获取字典信息
|
|
|
作者:吴缤
|
|
|
时间:2020-06-12 11:07:28
|
|
|
*/
|
|
|
func GetMultipleDict(getMultipleDictArg SysDictProto.GetMultipleDictArg) (*SysDictProto.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 := SysDictProto.NewSysDictManageClient(conn)
|
|
|
Reply, err := c.GetMultipleDict(ctx, &getMultipleDictArg)
|
|
|
if err != nil {
|
|
|
LogUtil.Error("获取字典信息错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:根据多个学段ID获取学段名称
|
|
|
作者:吴缤
|
|
|
时间:2020-06-12 11:07:28
|
|
|
*/
|
|
|
func GetStageName(getStageNameArg SysDictProto.GetStageNameArg) (*SysDictProto.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 := SysDictProto.NewSysDictManageClient(conn)
|
|
|
Reply, err := c.GetStageName(ctx, &getStageNameArg)
|
|
|
if err != nil {
|
|
|
LogUtil.Error("获取学段名称错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:根据多个学科ID获取学科名称
|
|
|
作者:吴缤
|
|
|
时间:2020-06-12 11:07:28
|
|
|
*/
|
|
|
func GetSubjectName(getSubjectNameArg SysDictProto.GetSubjectNameArg) (*SysDictProto.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 := SysDictProto.NewSysDictManageClient(conn)
|
|
|
Reply, err := c.GetSubjectName(ctx, &getSubjectNameArg)
|
|
|
if err != nil {
|
|
|
LogUtil.Error("获取学科名称错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|