master
huanghai 5 years ago
parent 26f7972c4f
commit 1980197af1

@ -48,3 +48,14 @@ func PageBaseGlobal(in *BaseGlobalProto.QueryArg) ([]map[string]interface{}, int
list, count, err := SqlKit.QueryForPk(sql)
return list, count, err
}
// 通过全局变量的代码获取全局变量的信息
func GetBaseGlobalByCodes(globalCodes []string) ([]map[string]interface{}, int32, error) {
var myBuilder = builder.Dialect(builder.MYSQL).Select("global_id").From("t_base_global")
myBuilder.Where(builder.Eq{"b_use": 1})
myBuilder.And(builder.In("global_code", globalCodes))
//获取拼接完成的SQL语句
sql, _ := myBuilder.ToBoundSQL()
list, count, err := SqlKit.QueryForPk(sql)
return list, count, err
}

@ -24,6 +24,8 @@ service BaseGlobalManage {
rpc UpdateBaseGlobal (ModelArg) returns (Reply) {}
//()
rpc PageBaseGlobal (QueryArg) returns (Reply) {}
//
rpc GetBaseGlobalByCode (ModelArg) returns (Reply) {}
}
message ModelArg {

@ -171,3 +171,36 @@ func (s *Rpc) PageBaseGlobal(ctx context.Context, in *BaseGlobalProto.QueryArg)
return &reply, nil
}
}
// 通过全局变量的代码获取全局变量的信息
func (s *Rpc) GetBaseGlobalByCode(ctx context.Context, in *BaseGlobalProto.ModelArg) (*BaseGlobalProto.Reply, error) {
//异常处理
defer func() {
if err := recover(); err != nil {
fmt.Printf("%s\n", err)
}
}()
//rpc响应
var reply BaseGlobalProto.Reply
list, count, err := BaseGlobalDao.GetBaseGlobalByCodes([]string{in.GlobalCode})
//错误处理
if err != nil {
reply.Success = false
reply.Message = Const.DataBaseActionError
LogUtil.Error(ErrorConst.SqlQueryError, "执行GetBaseGlobalByCode时发生严重错误"+err.Error())
return &reply, err
}
if list != nil {
reply.Count = count
reply.Success = true
reply.Message = Const.SuccessDataBaseAction
reply.List = CommonUtil.SerializeToString(list)
return &reply, nil
} else {
reply.Count = 0
reply.Success = false
reply.Message = Const.SuccessDataBaseAction
reply.List = Const.BlankArrayString
return &reply, nil
}
}

Loading…
Cancel
Save