Exemple #1
0
func CheckError(err error, info string) bool {
	if err != nil {
		log.Error(info, ":", err)
		return false
	}
	return true
}
Exemple #2
0
//获取系统参数表
func GetValueFromSysConfig(txn *xorm.Session, key string) (models.SystemConfig, error) {
	var val models.SystemConfig
	val.Ename = key
	has, err := txn.Get(&val)
	if !has || !CheckError(err, "取系统参数失败") {
		log.Error("取系统参数失败:", key)
		return val, errors.New("failed")
	}
	return val, nil
}
Exemple #3
0
func InnerJsonToString(data interface{}) string {
	var content []byte
	var err error
	content, err = json.Marshal(data)
	if err != nil {
		log.Error(err.Error())
		return err.Error()
	}
	//add JSON len
	con4moment := string(content)
	return con4moment
}
Exemple #4
0
func JsonToString(data interface{}) string {
	var content []byte
	var err error

	content, err = json.Marshal(data)
	if err != nil {
		log.Error(err.Error())
		return err.Error()
	}
	//add JSON len
	con4moment := string(content)

	retbyte := Encrypt([]byte(con4moment), []byte(KEY_ENCYPT))
	writeBackData := base64.StdEncoding.EncodeToString(retbyte)
	conLen, _ := FillString(strconv.Itoa(len(con4moment)), "0", "left", 8)
	retStr := conLen + string(writeBackData)
	return retStr
	// return con4moment
}