parent
8714ed0817
commit
bfefe0322b
|
@ -10,17 +10,6 @@ GoogleAuthState = ""
|
|||
GithubAuthClientID = ""
|
||||
GithubAuthClientSecret = ""
|
||||
GithubAuthState = ""
|
||||
defaultPageNum = 20
|
||||
defaultHomePageNum = 50
|
||||
defaultNotificationPageNum = 10
|
||||
UserNamingRestrictions = true
|
||||
accessKeyID = ""
|
||||
accessKeySecret = ""
|
||||
roleArn = ""
|
||||
homePageNodeNum = 8
|
||||
topicThanksCost = 15
|
||||
replyThanksCost = 10
|
||||
createTopicCost = 20
|
||||
createReplyCost = 5
|
||||
getReplyBonus = 5
|
||||
maxDailyCheckinBonus = 20
|
||||
|
|
|
@ -67,7 +67,7 @@ func (c *APIController) Signup() {
|
|||
}
|
||||
member, password, email, avatar := form.Username, form.Password, form.Email, form.Avatar
|
||||
|
||||
checkUserName, _ := beego.AppConfig.Bool("UserNamingRestrictions")
|
||||
checkUserName := object.UserNamingRestrictions
|
||||
if checkUserName {
|
||||
if !util.IsValidUsername(member) {
|
||||
resp = Response{Status: "error", Msg: "you could just have digital, letter and underline in you name", Data: ""}
|
||||
|
|
|
@ -18,8 +18,6 @@ import (
|
|||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
|
||||
"github.com/casbin/casbin-forum/object"
|
||||
"github.com/casbin/casbin-forum/util"
|
||||
)
|
||||
|
@ -55,15 +53,15 @@ func (c *APIController) AddThanks() {
|
|||
var resp Response
|
||||
if thanksType == "2" || thanksType == "1" {
|
||||
if thanksType == "2" {
|
||||
consumerRecord.Amount, _ = beego.AppConfig.Int("replyThanksCost")
|
||||
consumerRecord.Amount = object.ReplyThanksCost
|
||||
consumerRecord.Amount = -consumerRecord.Amount
|
||||
receiverRecord.Amount, _ = beego.AppConfig.Int("replyThanksCost")
|
||||
receiverRecord.Amount = object.ReplyThanksCost
|
||||
consumerRecord.ConsumptionType = 5
|
||||
receiverRecord.ConsumptionType = 3
|
||||
} else {
|
||||
consumerRecord.Amount, _ = beego.AppConfig.Int("topicThanksCost")
|
||||
consumerRecord.Amount = object.TopicThanksCost
|
||||
consumerRecord.Amount = -consumerRecord.Amount
|
||||
receiverRecord.Amount, _ = beego.AppConfig.Int("topicThanksCost")
|
||||
receiverRecord.Amount = object.TopicThanksCost
|
||||
consumerRecord.ConsumptionType = 4
|
||||
receiverRecord.ConsumptionType = 2
|
||||
}
|
||||
|
@ -96,7 +94,7 @@ func (c *APIController) GetConsumptionRecord() {
|
|||
memberId := c.GetSessionUser()
|
||||
limitStr := c.Input().Get("limit")
|
||||
pageStr := c.Input().Get("page")
|
||||
defaultLimit, _ := beego.AppConfig.Int("defaultPageNum")
|
||||
defaultLimit := object.DefaultBalancePageNum
|
||||
|
||||
var limit, offset int
|
||||
if len(limitStr) != 0 {
|
||||
|
@ -130,7 +128,7 @@ func (c *APIController) GetCheckinBonus() {
|
|||
}
|
||||
|
||||
var resp Response
|
||||
maxBonus, _ := beego.AppConfig.Int("maxDailyCheckinBonus")
|
||||
maxBonus := object.MaxDailyCheckinBonus
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
bonus := rand.Intn(maxBonus)
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@ package controllers
|
|||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
|
||||
"github.com/casbin/casbin-forum/object"
|
||||
"github.com/casbin/casbin-forum/util"
|
||||
)
|
||||
|
@ -135,7 +133,7 @@ func (c *APIController) GetFavorites() {
|
|||
favoritesTypeStr := c.Input().Get("type")
|
||||
limitStr := c.Input().Get("limit")
|
||||
pageStr := c.Input().Get("page")
|
||||
defaultLimit, _ := beego.AppConfig.Int("defaultPageNum")
|
||||
defaultLimit := object.DefaultPageNum
|
||||
|
||||
var limit, offset int
|
||||
if len(limitStr) != 0 {
|
||||
|
|
|
@ -17,8 +17,6 @@ package controllers
|
|||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
|
||||
"github.com/casbin/casbin-forum/object"
|
||||
"github.com/casbin/casbin-forum/util"
|
||||
)
|
||||
|
@ -61,7 +59,7 @@ func (c *APIController) GetNotifications() {
|
|||
memberId := c.GetSessionUser()
|
||||
limitStr := c.Input().Get("limit")
|
||||
pageStr := c.Input().Get("page")
|
||||
defaultLimit, _ := beego.AppConfig.Int("defaultNotificationPageNum")
|
||||
defaultLimit := object.DefaultNotificationPageNum
|
||||
|
||||
var limit, offset int
|
||||
if len(limitStr) != 0 {
|
||||
|
|
|
@ -18,8 +18,6 @@ import (
|
|||
"encoding/json"
|
||||
"strconv"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
|
||||
"github.com/casbin/casbin-forum/object"
|
||||
"github.com/casbin/casbin-forum/util"
|
||||
)
|
||||
|
@ -122,7 +120,7 @@ func (c *APIController) GetLatestReplies() {
|
|||
id := c.Input().Get("id")
|
||||
limitStr := c.Input().Get("limit")
|
||||
pageStr := c.Input().Get("page")
|
||||
defaultLimit, _ := beego.AppConfig.Int("nodePageTopicsNum")
|
||||
defaultLimit := object.DefaultPageNum
|
||||
var (
|
||||
limit, offset int
|
||||
err error
|
||||
|
|
|
@ -18,8 +18,6 @@ import (
|
|||
"encoding/json"
|
||||
"strconv"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
|
||||
"github.com/casbin/casbin-forum/object"
|
||||
"github.com/casbin/casbin-forum/util"
|
||||
)
|
||||
|
@ -33,7 +31,7 @@ type NewTopicForm struct {
|
|||
func (c *APIController) GetTopics() {
|
||||
limitStr := c.Input().Get("limit")
|
||||
pageStr := c.Input().Get("page")
|
||||
defaultLimit, _ := beego.AppConfig.Int("defaultHomePageNum")
|
||||
defaultLimit := object.DefaultHomePageNum
|
||||
|
||||
var limit, offset int
|
||||
if len(limitStr) != 0 {
|
||||
|
@ -169,7 +167,7 @@ func (c *APIController) GetTopicsByNode() {
|
|||
nodeId := c.Input().Get("node-id")
|
||||
limitStr := c.Input().Get("limit")
|
||||
pageStr := c.Input().Get("page")
|
||||
defaultLimit, _ := beego.AppConfig.Int("nodePageTopicsNum")
|
||||
defaultLimit := object.DefaultPageNum
|
||||
|
||||
var limit, offset int
|
||||
if len(limitStr) != 0 {
|
||||
|
@ -205,7 +203,7 @@ func (c *APIController) GetTopicsByTab() {
|
|||
tabId := c.Input().Get("tab-id")
|
||||
limitStr := c.Input().Get("limit")
|
||||
pageStr := c.Input().Get("page")
|
||||
defaultLimit, _ := beego.AppConfig.Int("nodePageTopicsNum")
|
||||
defaultLimit := object.DefaultHomePageNum
|
||||
|
||||
var limit, offset int
|
||||
if len(limitStr) != 0 {
|
||||
|
|
|
@ -18,8 +18,6 @@ import (
|
|||
"log"
|
||||
"sync"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
|
||||
"github.com/casbin/casbin-forum/util"
|
||||
)
|
||||
|
||||
|
@ -210,7 +208,7 @@ func CreateTopicConsumption(consumerId, id string) bool {
|
|||
CreatedTime: util.GetCurrentTime(),
|
||||
ConsumptionType: 8,
|
||||
}
|
||||
record.Amount, _ = beego.AppConfig.Int("createTopicCost")
|
||||
record.Amount = CreateTopicCost
|
||||
record.Amount = -record.Amount
|
||||
balance := GetMemberBalance(consumerId)
|
||||
if balance+record.Amount < 0 {
|
||||
|
@ -230,7 +228,7 @@ func CreateReplyConsumption(consumerId, id string) bool {
|
|||
CreatedTime: util.GetCurrentTime(),
|
||||
ConsumptionType: 6,
|
||||
}
|
||||
record.Amount, _ = beego.AppConfig.Int("createReplyCost")
|
||||
record.Amount = CreateReplyCost
|
||||
record.Amount = -record.Amount
|
||||
balance := GetMemberBalance(consumerId)
|
||||
if balance+record.Amount < 0 {
|
||||
|
@ -256,7 +254,7 @@ func GetReplyBonus(author, consumerId, id string) {
|
|||
CreatedTime: util.GetCurrentTime(),
|
||||
ConsumptionType: 7,
|
||||
}
|
||||
record.Amount, _ = beego.AppConfig.Int("createReplyCost")
|
||||
record.Amount = ReceiveReplyBonus
|
||||
balance := GetMemberBalance(consumerId)
|
||||
record.Balance = balance + record.Amount
|
||||
AddBalance(&record)
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2020 The casbin Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package object
|
||||
|
||||
var (
|
||||
DefaultPageNum = 20
|
||||
DefaultHomePageNum = 50
|
||||
DefaultNotificationPageNum = 10
|
||||
DefaultBalancePageNum = 25
|
||||
UserNamingRestrictions = true
|
||||
HomePageNodeNum = 8
|
||||
TopicThanksCost = 15
|
||||
ReplyThanksCost = 10
|
||||
CreateTopicCost = 20
|
||||
CreateReplyCost = 5
|
||||
ReceiveReplyBonus = 5
|
||||
MaxDailyCheckinBonus = 20
|
||||
)
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
package object
|
||||
|
||||
import "github.com/astaxie/beego"
|
||||
|
||||
type Tab struct {
|
||||
Id string `xorm:"varchar(100) notnull pk" json:"id"`
|
||||
Name string `xorm:"varchar(100)" json:"name"`
|
||||
|
@ -72,7 +70,7 @@ func GetDefaultTab() string {
|
|||
func GetNodesByTab(id string) []*Node {
|
||||
nodes := []*Node{}
|
||||
|
||||
num, _ := beego.AppConfig.Int("homePageNodeNum")
|
||||
num := HomePageNodeNum
|
||||
|
||||
if id == "all" {
|
||||
err := adapter.engine.Cols("id, name").Limit(num).Find(&nodes)
|
||||
|
|
Loading…
Reference in New Issue