Browse Source

Merge branch 'master' into yb_3.0

# Conflicts:
#	models/home.go
hsun 2 years ago
parent
commit
69dd99a164
4 changed files with 43 additions and 5 deletions
  1. 1 1
      models/classify.go
  2. 3 2
      models/home.go
  3. 22 0
      utils/common.go
  4. 17 2
      utils/config.go

+ 1 - 1
models/classify.go

@@ -32,7 +32,7 @@ func GetClassifyById(classifyId int) (item *Classify, err error) {
 }
 
 func GetClassifyList() (item []*Classify, err error) {
-	sql := ` SELECT * FROM classify WHERE parent_id = 0 AND classify_name not in('权益研报','双周报','月报') `
+	sql := ` SELECT * FROM classify WHERE parent_id = 0 AND classify_name not in("权益研报","双周报","月报","晨报","周报","草根调研","需求报告","会议纪要","大事点评","年报合集","宏观点评") `
 	o := orm.NewOrm()
 	o.Using("rddp")
 	_, err = o.Raw(sql).QueryRows(&item)

+ 3 - 2
models/home.go

@@ -25,8 +25,8 @@ func ListHome(userId, maxPermission, userPermission int, permissionStr string) (
 	o.Using("rddp")
 	//sql := `SELECT id,classify_name FROM classify WHERE parent_id=0 ORDER BY create_time ASC `
 
-	//暂时将双周报、月报、晨报、周报隐藏
-	sql := `SELECT id,classify_name FROM classify WHERE parent_id=0 and classify_name not IN("双周报","月报","晨报","周报") ORDER BY create_time ASC `
+	//暂时将双周报、月报隐藏
+	sql := `SELECT id,classify_name FROM classify WHERE parent_id=0 and classify_name not IN("双周报","月报","晨报","周报","草根调研","需求报告","会议纪要","大事点评","年报合集") ORDER BY create_time ASC `
 	_, err = o.Raw(sql).QueryRows(&items)
 	if err != nil {
 		fmt.Println("Get classify Err:" + err.Error())
@@ -49,6 +49,7 @@ func ListHome(userId, maxPermission, userPermission int, permissionStr string) (
 		}
 		subSql := `SELECT id ,classify_name FROM classify   `
 		subSql += subWhere
+		subSql += ` and classify_name not IN("宏观点评")`
 		subSql += ` ORDER BY sort ASC `
 		_, err = o.Raw(subSql, item.ClassifyId).QueryRows(&subItems)
 		if err != nil {

+ 22 - 0
utils/common.go

@@ -11,6 +11,7 @@ import (
 	"image/png"
 	"math"
 	"math/rand"
+	"net"
 	"os"
 	"os/exec"
 	"regexp"
@@ -550,3 +551,24 @@ func ConvertToFormatDay(excelDaysString string) string {
 	resultTime := time.Unix(int64(baseOriginSecond+realDiffSecond), 0).Format("2006-01-02")
 	return resultTime
 }
+
+func GetLocalIP() (ip string, err error) {
+	addrs, err := net.InterfaceAddrs()
+	if err != nil {
+		return
+	}
+	for _, addr := range addrs {
+		ipAddr, ok := addr.(*net.IPNet)
+		if !ok {
+			continue
+		}
+		if ipAddr.IP.IsLoopback() {
+			continue
+		}
+		if !ipAddr.IP.IsGlobalUnicast() {
+			continue
+		}
+		return ipAddr.IP.String(), nil
+	}
+	return
+}

+ 17 - 2
utils/config.go

@@ -49,12 +49,27 @@ func init() {
 	}
 	RunMode = tmpRunMode
 	if RunMode == "" {
-		RunMode = "release"
+		localIp, err := GetLocalIP()
+		fmt.Println("localIp:", localIp)
+		if localIp == "10.0.0.123" {
+			RunMode = "debug"
+		} else {
+			RunMode = "release"
+		}
+		fmt.Println("RunMode:", RunMode)
 		configPath := `/home/code/config/hongze_api/conf/app.conf`
-		err := web.LoadAppConfig("ini", configPath)
+		fmt.Println("configPath:", configPath)
+		err = web.LoadAppConfig("ini", configPath)
 		if err != nil {
 			fmt.Println("web.LoadAppConfig Err:" + err.Error())
 		}
+
+		//RunMode = "release"
+		//configPath := `/home/code/config/hongze_api/conf/app.conf`
+		//err := web.LoadAppConfig("ini", configPath)
+		//if err != nil {
+		//	fmt.Println("web.LoadAppConfig Err:" + err.Error())
+		//}
 	}
 
 	config, err := web.AppConfig.GetSection(RunMode)