本文整理匯總了Golang中github.com/c-darwin/dcoin-go/packages/utils.Int64ToStr函數的典型用法代碼示例。如果您正苦於以下問題:Golang Int64ToStr函數的具體用法?Golang Int64ToStr怎麽用?Golang Int64ToStr使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Int64ToStr函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RepaymentCreditRollback
func (p *Parser) RepaymentCreditRollback() error {
creditData, err := p.OneRow("SELECT to_user_id, currency_id FROM credits WHERE id = ?", p.TxMaps.Int64["credit_id"]).Int64()
if err != nil {
return p.ErrInfo(err)
}
err = p.generalRollback("wallets", p.TxUserID, "AND currency_id = "+utils.Int64ToStr(creditData["currency_id"]), false)
if err != nil {
return p.ErrInfo(err)
}
err = p.generalRollback("wallets", creditData["to_user_id"], "AND currency_id = "+utils.Int64ToStr(creditData["currency_id"]), false)
if err != nil {
return p.ErrInfo(err)
}
err = p.selectiveRollback([]string{"amount", "tx_hash", "tx_block_id"}, "credits", "id="+utils.Int64ToStr(p.TxMaps.Int64["credit_id"]), false)
if err != nil {
return p.ErrInfo(err)
}
// возможно нужно обновить таблицу points_status
err = p.pointsUpdateMain(creditData["to_user_id"])
if err != nil {
return p.ErrInfo(err)
}
// возможно нужно обновить таблицу points_status
err = p.pointsUpdateMain(p.TxUserID)
if err != nil {
return p.ErrInfo(err)
}
return nil
}
示例2: NewPromisedAmount
func (p *Parser) NewPromisedAmount() error {
addSqlNames := ""
addSqlValues := ""
if p.BlockData.BlockId > 27134 {
paymentSystemsIds := strings.Split(string(p.TxMaps.String["payment_systems_ids"]), ",")
for i, v := range paymentSystemsIds {
addSqlNames += fmt.Sprintf("ps%d,", (i + 1))
addSqlValues += fmt.Sprintf("%s,", v)
}
}
//добавляем promised_amount в БД
err := p.ExecSql(`
INSERT INTO promised_amount (
user_id,
amount,
currency_id,
` + addSqlNames + `
video_type,
video_url_id,
votes_start_time
)
VALUES (
` + utils.Int64ToStr(p.TxMaps.Int64["user_id"]) + `,
` + utils.Float64ToStr(p.TxMaps.Money["amount"]) + `,
` + utils.Int64ToStr(p.TxMaps.Int64["currency_id"]) + `,
` + addSqlValues + `
'` + p.TxMaps.String["video_type"] + `',
'` + p.TxMaps.String["video_url_id"] + `',
` + utils.Int64ToStr(p.BlockData.Time) + `
)`)
if err != nil {
return p.ErrInfo(err)
}
// проверим, не наш ли это user_id
myUserId, myBlockId, myPrefix, _, err := p.GetMyUserId(p.TxMaps.Int64["user_id"])
if err != nil {
return err
}
if p.TxUserID == myUserId && myBlockId <= p.BlockData.BlockId {
// Удалим, т.к. попало в блок
err = p.ExecSql("DELETE FROM "+myPrefix+"my_promised_amount WHERE amount = ? AND currency_id = ?", p.TxMaps.Money["amount"], p.TxMaps.Int64["currency_id"])
if err != nil {
return p.ErrInfo(err)
}
}
return nil
}
示例3: Chat
func (c *Controller) Chat() (string, error) {
myChatName := utils.Int64ToStr(c.SessUserId)
// возможно у отпарвителя есть ник
name, err := c.Single(`SELECT name FROM users WHERE user_id = ?`, c.SessUserId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
if len(name) > 0 {
myChatName = name
}
TemplateStr, err := makeTemplate("chat", "chat", &chatPage{
Community: c.Community,
CountSignArr: c.CountSignArr,
CountSign: c.CountSign,
Lang: c.Lang,
ShowSignData: c.ShowSignData,
SignData: "",
MyChatName: myChatName,
UserId: c.SessUserId,
IOS: utils.IOS(),
Mobile: utils.Mobile()})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
示例4: makeVcomplex
func makeVcomplex(json_data []byte) (*vComplex, error) {
vComplex := new(vComplex)
err := json.Unmarshal(json_data, &vComplex)
if err != nil {
vComplex_ := new(vComplex_)
err = json.Unmarshal(json_data, &vComplex_)
if err != nil {
vComplex__ := new(vComplex__)
err = json.Unmarshal(json_data, &vComplex__)
if err != nil {
return vComplex, err
}
vComplex.Referral = vComplex__.Referral
vComplex.Currency = vComplex__.Currency
vComplex.Admin = utils.StrToInt64(vComplex__.Admin)
} else {
vComplex.Referral = make(map[string]string)
for k, v := range vComplex_.Referral {
vComplex.Referral[k] = utils.Int64ToStr(v)
}
vComplex.Currency = vComplex_.Currency
vComplex.Admin = vComplex_.Admin
}
}
return vComplex, nil
}
示例5: checkAvailableKey
func (a *AvailablekeyStruct) checkAvailableKey(key string) (int64, string, error) {
publicKeyAsn, err := utils.GetPublicFromPrivate(key)
if err != nil {
log.Debug("%v", err)
return 0, "", utils.ErrInfo(err)
}
log.Debug("publicKeyAsn: %s", publicKeyAsn)
userId, err := a.Single("SELECT user_id FROM users WHERE hex(public_key_0) = ?", publicKeyAsn).Int64()
if err != nil {
return 0, "", utils.ErrInfo(err)
}
log.Debug("userId: %s", userId)
if userId == 0 {
return 0, "", errors.New("null userId")
}
allTables, err := a.GetAllTables()
if err != nil {
return 0, "", utils.ErrInfo(err)
}
// может другой юзер уже начал смену ключа. актуально для пула
if utils.InSliceString(utils.Int64ToStr(userId)+"_my_table", allTables) {
return 0, "", errors.New("exists _my_table")
}
return userId, string(publicKeyAsn), nil
}
示例6: NewPhoto
func (c *Controller) NewPhoto() (string, error) {
c.r.ParseForm()
userId := int64(utils.StrToFloat64(c.r.FormValue("user_id")))
data, err := c.OneRow("SELECT photo_block_id, photo_max_miner_id, miners_keepers FROM miners_data WHERE user_id = ?", userId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
// получим ID майнеров, у которых лежат фото нужного нам юзера
minersIds := utils.GetMinersKeepers(data["photo_block_id"], data["photo_max_miner_id"], data["miners_keepers"], true)
// берем 1 случайный из 10-и ID майнеров
k := utils.RandInt(0, len(minersIds))
minerId := minersIds[k]
host, err := c.Single("SELECT http_host FROM miners_data WHERE miner_id = ?", minerId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
result, err := json.Marshal(map[string]string{"face": host + "public/face_" + utils.Int64ToStr(userId) + ".jpg", "profile": host + "public/profile_" + utils.Int64ToStr(userId) + ".jpg"})
if err != nil {
return "", utils.ErrInfo(err)
}
return string(result), nil
}
示例7: CfCatalog
func (c *Controller) CfCatalog() (string, error) {
var err error
log.Debug("CfCatalog")
categoryId := utils.Int64ToStr(int64(utils.StrToFloat64(c.Parameters["category_id"])))
log.Debug("categoryId", categoryId)
var curCategory string
addSql := ""
if categoryId != "0" {
addSql = `AND category_id = ` + categoryId
curCategory = c.Lang["cf_category_"+categoryId]
}
cfUrl := ""
projects := make(map[string]map[string]string)
cfProjects, err := c.GetAll(`
SELECT cf_projects.id, lang_id, blurb_img, country, city, currency_id, end_time, amount
FROM cf_projects
LEFT JOIN cf_projects_data ON cf_projects_data.project_id = cf_projects.id
WHERE del_block_id = 0 AND
end_time > ? AND
lang_id = ?
`+addSql+`
ORDER BY funders DESC
LIMIT 100
`, 100, utils.Time(), c.LangInt)
if err != nil {
return "", utils.ErrInfo(err)
}
for _, data := range cfProjects {
CfProjectData, err := c.GetCfProjectData(utils.StrToInt64(data["id"]), utils.StrToInt64(data["end_time"]), c.LangInt, utils.StrToFloat64(data["amount"]), cfUrl)
if err != nil {
return "", utils.ErrInfo(err)
}
for k, v := range CfProjectData {
data[k] = v
}
projects[data["id"]] = data
}
cfCategory := utils.MakeCfCategories(c.Lang)
TemplateStr, err := makeTemplate("cf_catalog", "cfCatalog", &cfCatalogPage{
Lang: c.Lang,
CfCategory: cfCategory,
CurrencyList: c.CurrencyList,
CurCategory: curCategory,
Projects: projects,
UserId: c.SessUserId,
CategoryId: categoryId,
CfUrl: cfUrl})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
示例8: Upgrade1
func (c *Controller) Upgrade1() (string, error) {
log.Debug("Upgrade1")
userFace := ""
/*userProfile := ""
path := "public/"+utils.Int64ToStr(c.SessUserId)+"_user_profile.jpg"
if _, err := os.Stat(path); err == nil {
userProfile = path
}*/
path := *utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_face.jpg"
if _, err := os.Stat(path); err == nil {
userFace = "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_face.jpg"
}
step := "1"
nextStep := "2"
photoType := "face"
photo := userFace
saveAndGotoStep := strings.Replace(c.Lang["save_and_goto_step"], "[num]", "3", -1)
upgradeMenu := utils.MakeUpgradeMenu(1)
TemplateStr, err := makeTemplate("upgrade_1_and_2", "upgrade1And2", &upgrade1Page{
Alert: c.Alert,
Lang: c.Lang,
CountSignArr: c.CountSignArr,
ShowSignData: c.ShowSignData,
SaveAndGotoStep: saveAndGotoStep,
UpgradeMenu: upgradeMenu,
UserId: c.SessUserId,
PhotoType: photoType,
Photo: photo,
Step: step,
NextStep: nextStep,
IOS: utils.IOS(),
Mobile: utils.Mobile()})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
示例9: VotesPromisedAmountRollback
func (p *Parser) VotesPromisedAmountRollback() error {
// вычитаем баллы
p.pointsRollback(p.Variables.Int64["promised_amount_points"])
// удаляем логирование, чтобы юзер {$this->tx_data['user_id']} не смог повторно проголосовать
err := p.ExecSql("DELETE FROM log_votes WHERE user_id = ? AND voting_id = ? AND type = 'promised_amount'", p.TxMaps.Int64["user_id"], p.TxMaps.Int64["promised_amount_id"])
if err != nil {
return p.ErrInfo(err)
}
// обновляем голоса
err = p.ExecSql("UPDATE promised_amount SET votes_"+utils.Int64ToStr(p.TxMaps.Int64["result"])+" = votes_"+utils.Int64ToStr(p.TxMaps.Int64["result"])+" - 1 WHERE id = ?", p.TxMaps.Int64["promised_amount_id"])
if err != nil {
return p.ErrInfo(err)
}
data, err := p.OneRow("SELECT status, user_id, log_id FROM promised_amount WHERE id = ?", p.TxMaps.Int64["promised_amount_id"]).String()
if err != nil {
return p.ErrInfo(err)
}
// если статус mining или rejected, значит голос был решающим
if data["status"] == "mining" || data["status"] == "rejected" {
// восстановим из лога
logData, err := p.OneRow("SELECT status, start_time, tdc_amount_update, prev_log_id FROM log_promised_amount WHERE log_id = ?", data["log_id"]).String()
if err != nil {
return p.ErrInfo(err)
}
err = p.ExecSql("UPDATE promised_amount SET status = ?, start_time = ?, tdc_amount_update = ?, log_id = ? WHERE id = ?", logData["status"], logData["start_time"], logData["tdc_amount_update"], logData["prev_log_id"], p.TxMaps.Int64["promised_amount_id"])
if err != nil {
return p.ErrInfo(err)
}
// подчищаем _log
err = p.ExecSql("DELETE FROM log_promised_amount WHERE log_id = ?", data["log_id"])
if err != nil {
return p.ErrInfo(err)
}
p.rollbackAI("log_promised_amount", 1)
// был ли добавлен woc
woc, err := p.Single("SELECT id FROM promised_amount WHERE currency_id = 1 AND woc_block_id = ? AND user_id = ?", p.BlockData.BlockId, data["user_id"]).Int64()
if err != nil {
return p.ErrInfo(err)
}
if woc > 0 {
err = p.ExecSql("DELETE FROM promised_amount WHERE id = ?", woc)
if err != nil {
return p.ErrInfo(err)
}
p.rollbackAI("promised_amount", 1)
}
}
return nil
}
示例10: ChangeHost
func (c *Controller) ChangeHost() (string, error) {
txType := "ChangeHost"
txTypeId := utils.TypeInt(txType)
timeNow := utils.Time()
if !c.PoolAdmin || c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("access denied"))
}
data, err := c.OneRow("SELECT http_host, tcp_host, host_status FROM " + c.MyPrefix + "my_table").String()
if err != nil {
return "", utils.ErrInfo(err)
}
data2, err := c.OneRow("SELECT http_host, tcp_host, e_host FROM miners_data WHERE user_id = ?", c.SessUserId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
if len(data["http_host"]) == 0 {
data["http_host"] = data2["http_host"]
}
if len(data["tcp_host"]) == 0 {
data["tcp_host"] = data2["tcp_host"]
}
if len(data["e_host"]) == 0 {
data["e_host"] = data2["e_host"]
}
if data["e_host"] == "" {
data["e_host"] = "0"
}
statusArray := map[string]string{"my_pending": c.Lang["local_pending"], "approved": c.Lang["status_approved"]}
data["host_status"] = statusArray[data["host_status"]]
limitsText := strings.Replace(c.Lang["change_host_limits_text"], "[limit]", utils.Int64ToStr(c.Variables.Int64["limit_change_host"]), -1)
limitsText = strings.Replace(limitsText, "[period]", c.Periods[c.Variables.Int64["limit_change_host_period"]], -1)
TemplateStr, err := makeTemplate("change_host", "changeHost", &changeHostPage{
Alert: c.Alert,
UserId: c.SessUserId,
CountSignArr: c.CountSignArr,
Data: data,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId,
LimitsText: limitsText,
ShowSignData: c.ShowSignData,
Community: c.Community,
SignData: "",
Lang: c.Lang})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
示例11: ChangeArbitratorConditionsRollback
func (p *Parser) ChangeArbitratorConditionsRollback() error {
err := p.selectiveRollback([]string{"url"}, "users", "user_id="+utils.Int64ToStr(p.TxUserID), false)
if err != nil {
return p.ErrInfo(err)
}
err = p.generalRollback("arbitrator_conditions", p.TxUserID, "", false)
if err != nil {
return p.ErrInfo(err)
}
return nil
}
示例12: NewUserRollback
func (p *Parser) NewUserRollback() error {
// если работаем в режиме пула, то ищем тех, у кого записан такой ключ
community, err := p.DCDB.GetCommunityUsers()
if err != nil {
return p.ErrInfo(err)
}
if len(community) > 0 {
for _, userId := range community {
myPrefix := utils.Int64ToStr(userId) + "_"
// проверим, не наш ли это public_key, чтобы записать полученный user_id в my_table
myPublicKey, err := p.DCDB.Single("SELECT public_key FROM "+myPrefix+"my_keys WHERE hex(public_key) = ?", p.TxMap["public_key_hex"]).String()
if err != nil {
return p.ErrInfo(err)
}
if myPublicKey != "" {
// теперь у нас полноценный юзерский акк, и его можно апргрейдить до майнерского
err = p.DCDB.ExecSql("UPDATE " + myPrefix + "my_table SET user_id = 0, status = 'my_pending', notification_status = 0")
if err != nil {
return p.ErrInfo(err)
}
err = p.DCDB.ExecSql("UPDATE "+myPrefix+"my_keys SET block_id = 0 WHERE block_id = ?", p.BlockData.BlockId)
if err != nil {
return p.ErrInfo(err)
}
}
}
} else {
// проверим, не наш ли это public_key
myPublicKey, err := p.DCDB.Single("SELECT public_key FROM my_keys WHERE hex(public_key) = ?", p.TxMap["public_key_hex"]).String()
if err != nil {
return p.ErrInfo(err)
}
if myPublicKey != "" {
err = p.DCDB.ExecSql("UPDATE my_table SET user_id = 0, status = 'my_pending', notification_status = 0")
if err != nil {
return p.ErrInfo(err)
}
err = p.DCDB.ExecSql("UPDATE my_keys SET block_id = 0 WHERE block_id = ?", p.BlockData.BlockId)
if err != nil {
return p.ErrInfo(err)
}
}
}
err = p.DCDB.ExecSql("DELETE FROM users WHERE hex(public_key_0) = ?", p.TxMap["public_key_hex"])
if err != nil {
return p.ErrInfo(err)
}
err = p.rollbackAI("users", 1)
if err != nil {
return p.ErrInfo(err)
}
return nil
}
示例13: UnbanNodes
func UnbanNodes(chBreaker chan bool, chAnswer chan string) {
defer func() {
if r := recover(); r != nil {
log.Error("daemon Recovered", r)
panic(r)
}
}()
GoroutineName := "UnbanNodes"
d := new(daemon)
d.DCDB = DbConnect(chBreaker, chAnswer, GoroutineName)
if d.DCDB == nil {
return
}
d.goRoutineName = GoroutineName
d.chAnswer = chAnswer
d.chBreaker = chBreaker
d.sleepTime = 3600
if !d.CheckInstall(chBreaker, chAnswer, GoroutineName) {
return
}
d.DCDB = DbConnect(chBreaker, chAnswer, GoroutineName)
if d.DCDB == nil {
return
}
BEGIN:
for {
log.Info(GoroutineName)
MonitorDaemonCh <- []string{GoroutineName, utils.Int64ToStr(utils.Time())}
// проверим, не нужно ли нам выйти из цикла
if CheckDaemonsRestart(chBreaker, chAnswer, GoroutineName) {
break BEGIN
}
err = d.ExecSql("DELETE FROM nodes_ban")
if err != nil {
if d.dPrintSleep(err, d.sleepTime) {
break BEGIN
}
continue BEGIN
}
if d.dSleep(d.sleepTime) {
break BEGIN
}
}
log.Debug("break BEGIN %v", GoroutineName)
}
示例14: DeleteVideo
func (c *Controller) DeleteVideo() (string, error) {
if !c.NodeAdmin || c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
if c.r.FormValue("type") == "mp4" {
err := os.Remove(*utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_video.mp4")
if err != nil {
return "", utils.ErrInfo(err)
}
} else if c.r.FormValue("type") == "webm_ogg" {
err := os.Remove(*utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_video.ogv")
if err != nil {
return "", utils.ErrInfo(err)
}
err = os.Remove(*utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_video.webm")
if err != nil {
return "", utils.ErrInfo(err)
}
}
return ``, nil
}
示例15: CropPhoto
func (c *Controller) CropPhoto() (string, error) {
if c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
photo := strings.Split(c.r.FormValue("photo"), ",")
if len(photo) != 2 {
return "", errors.New("Incorrect photo")
}
binary, err := base64.StdEncoding.DecodeString(photo[1])
if err != nil {
return "", err
}
img, _, err := image.Decode(bytes.NewReader(binary))
if err != nil {
return "", err
}
path := ""
if c.r.FormValue("type") == "face" {
path = *utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_face.jpg"
} else {
path = *utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_profile.jpg"
}
out, err := os.Create(path)
if err != nil {
return "", err
}
err = jpeg.Encode(out, img, &jpeg.Options{85})
if err != nil {
return "", err
}
return `{"success":"ok"}`, nil
}