package siterpc import ( "encoding/json" "errors" ) /** * 取所有配置 * 2021/09/04 * GZ */ func GetAllConfig(site_id, dbname string, url ...string) ([]map[string]string, error) { if dbname == "" { return nil, errors.New("参数错误") } conn, err := rpc_server_conn(url...) if err != nil { return nil, err } defer conn.Close() arg := SiteConfigItemReqArg{site_id, dbname, ""} req, err := SetReqData(arg) if err != nil { return nil, err } res := &Response{} err = conn.GetAllConfig(req, res) if err != nil { return nil, err } res_data_de, err := GetResData(res) if err != nil { return nil, err } if res_data_de == "" { return nil, nil } var res_arr []map[string]string err = json.Unmarshal([]byte(res_data_de), &res_arr) if err != nil { return nil, err } return res_arr, nil } /** * 分组下所有配置 * 2021/09/04 * GZ */ func GetGroupConfig(site_id, dbname string, groupname string, url ...string) ([]map[string]string, error) { if dbname == "" { return nil, errors.New("参数错误") } conn, err := rpc_server_conn(url...) if err != nil { return nil, err } defer conn.Close() arg := SiteConfigItemReqArg{site_id, dbname, groupname} req, err := SetReqData(arg) if err != nil { return nil, err } res := &Response{} err = conn.GetGroupConfig(req, res) if err != nil { return nil, err } res_data_de, err := GetResData(res) if err != nil { return nil, err } if res_data_de == "" { return nil, nil } var res_arr []map[string]string err = json.Unmarshal([]byte(res_data_de), &res_arr) if err != nil { return nil, err } return res_arr, nil }