Comp mysql 5.5. Add show alien config. Fix upload globally. Better the install process.
This commit is contained in:
parent
64ca363f96
commit
e8a5a4a60b
4
build/conf/tank.json
Normal file
4
build/conf/tank.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"ServerPort": 6010,
|
||||
"MatterPath": ""
|
||||
}
|
@ -1 +1 @@
|
||||
<!DOCTYPE html><html><head><title>蓝眼云盘</title><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"><meta name=renderer content=webkit><meta name=viewport content="user-scalable=no,width=device-width,initial-scale=1,maximum-scale=1"><meta name=msapplication-tap-highlight content=no><meta name=apple-mobile-web-app-capable content=yes><link rel="shortcut icon" href=/favicon.ico><link href=/static/css/app.8f25c40ccf3b41a15359de6f3ba1cf6e.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script><script type=text/javascript src=/static/js/vendor.40273dbea93c564c558d.js></script><script type=text/javascript src=/static/js/app.c417733a892cd77dbffb.js></script></body></html>
|
||||
<!DOCTYPE html><html><head><title>蓝眼云盘</title><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"><meta name=renderer content=webkit><meta name=viewport content="user-scalable=no,width=device-width,initial-scale=1,maximum-scale=1"><meta name=msapplication-tap-highlight content=no><meta name=apple-mobile-web-app-capable content=yes><link rel="shortcut icon" href=/favicon.ico><link href=/static/css/app.d2d5042e8c39ebc5341e323cd9d451c9.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script><script type=text/javascript src=/static/js/vendor.28b2a104c5c31556c9b7.js></script><script type=text/javascript src=/static/js/app.3d9457a26b0397abb3e4.js></script></body></html>
|
File diff suppressed because one or more lines are too long
10
build/html/static/js/app.3d9457a26b0397abb3e4.js
Normal file
10
build/html/static/js/app.3d9457a26b0397abb3e4.js
Normal file
File diff suppressed because one or more lines are too long
1
build/html/static/js/app.3d9457a26b0397abb3e4.js.map
Normal file
1
build/html/static/js/app.3d9457a26b0397abb3e4.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,9 +1,5 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
)
|
||||
|
||||
type BaseDao struct {
|
||||
Bean
|
||||
}
|
||||
|
@ -13,11 +13,12 @@ type IBase interface {
|
||||
TableName() string
|
||||
}
|
||||
|
||||
//Mysql 5.5只支持一个CURRENT_TIMESTAMP的默认值,因此时间的默认值都使用蓝眼云盘第一个发布版本时间 2018-01-01 00:00:00
|
||||
type Base struct {
|
||||
Uuid string `json:"uuid" gorm:"type:char(36);primary_key;unique"`
|
||||
Sort int64 `json:"sort" gorm:"type:bigint(20) not null"`
|
||||
UpdateTime time.Time `json:"updateTime" gorm:"type:timestamp not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"`
|
||||
CreateTime time.Time `json:"createTime" gorm:"type:timestamp not null;default:CURRENT_TIMESTAMP"`
|
||||
UpdateTime time.Time `json:"updateTime" gorm:"type:timestamp not null;default:CURRENT_TIMESTAMP"`
|
||||
CreateTime time.Time `json:"createTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"`
|
||||
}
|
||||
|
||||
//将 Struct 转换成map[string]interface{}类型
|
||||
|
@ -65,6 +65,9 @@ func (this *ConfigItem) validate() bool {
|
||||
if this.ServerPort == 0 {
|
||||
LOGGER.Error("ServerPort 未配置")
|
||||
return false
|
||||
} else {
|
||||
//只要配置文件中有配置端口,就使用。
|
||||
CONFIG.ServerPort = this.ServerPort
|
||||
}
|
||||
|
||||
if this.MysqlUsername == "" {
|
||||
@ -134,9 +137,10 @@ func (this *Config) ReadFromConfigFile() {
|
||||
this.Installed = false
|
||||
} else {
|
||||
this.Item = &ConfigItem{}
|
||||
LOGGER.Warn("读取配置文件:%s", filePath)
|
||||
err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(content, this.Item)
|
||||
if err != nil {
|
||||
LOGGER.Error("配置文件格式错误!")
|
||||
LOGGER.Error("配置文件格式错误! 即将进入安装过程!")
|
||||
this.Installed = false
|
||||
return
|
||||
}
|
||||
@ -144,7 +148,7 @@ func (this *Config) ReadFromConfigFile() {
|
||||
//验证项是否齐全
|
||||
itemValidate := this.Item.validate()
|
||||
if !itemValidate {
|
||||
LOGGER.Error("配置文件信息不齐全!")
|
||||
LOGGER.Error("配置文件信息不齐全! 即将进入安装过程!")
|
||||
this.Installed = false
|
||||
return
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package rest
|
||||
|
||||
import (
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
"github.com/nu7hatch/gouuid"
|
||||
"time"
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
|
||||
"github.com/nu7hatch/gouuid"
|
||||
"time"
|
||||
)
|
||||
|
@ -8,7 +8,7 @@ type DownloadToken struct {
|
||||
Base
|
||||
UserUuid string `json:"userUuid" gorm:"type:char(36) not null"`
|
||||
MatterUuid string `json:"matterUuid" gorm:"type:char(36) not null;index:idx_mu"`
|
||||
ExpireTime time.Time `json:"expireTime" gorm:"type:timestamp not null;default:CURRENT_TIMESTAMP"`
|
||||
ExpireTime time.Time `json:"expireTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"`
|
||||
Ip string `json:"ip" gorm:"type:varchar(128) not null"`
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package rest
|
||||
|
||||
import (
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
|
||||
"github.com/nu7hatch/gouuid"
|
||||
"time"
|
||||
)
|
||||
|
@ -3,11 +3,10 @@ package rest
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
"github.com/nu7hatch/gouuid"
|
||||
"os"
|
||||
"time"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ImageCacheDao struct {
|
||||
@ -114,7 +113,6 @@ func (this *ImageCacheDao) Page(page int, pageSize int, userUuid string, matterU
|
||||
return pager
|
||||
}
|
||||
|
||||
|
||||
//创建
|
||||
func (this *ImageCacheDao) Create(imageCache *ImageCache) *ImageCache {
|
||||
|
||||
@ -150,17 +148,16 @@ func (this *ImageCacheDao) deleteFileAndDir(imageCache *ImageCache) {
|
||||
//删除文件
|
||||
err := os.Remove(filePath)
|
||||
if err != nil {
|
||||
this.logger.Error(fmt.Sprintf("删除磁盘上的文件%s出错,不做任何处理 %s", filePath, err.Error()))
|
||||
this.logger.Error(fmt.Sprintf("删除磁盘上的文件%s出错 %s", filePath, err.Error()))
|
||||
}
|
||||
|
||||
//删除这一层文件夹
|
||||
err = os.Remove(dirPath)
|
||||
if err != nil {
|
||||
this.logger.Error(fmt.Sprintf("删除磁盘上的文件夹%s出错,不做任何处理 %s", dirPath, err.Error()))
|
||||
this.logger.Error(fmt.Sprintf("删除磁盘上的文件夹%s出错 %s", dirPath, err.Error()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//删除一个文件,数据库中删除,物理磁盘上删除。
|
||||
func (this *ImageCacheDao) Delete(imageCache *ImageCache) {
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"fmt"
|
||||
"github.com/disintegration/imaging"
|
||||
"image"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"github.com/disintegration/imaging"
|
||||
"strings"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
//@Service
|
||||
|
@ -444,12 +444,12 @@ func (this *InstallController) Finish(writer http.ResponseWriter, request *http.
|
||||
MysqlPassword: mysqlPassword,
|
||||
}
|
||||
|
||||
//用json的方式输出返回值。
|
||||
jsonStr, _ := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(configItem)
|
||||
//用json的方式输出返回值。为了让格式更好看。
|
||||
jsonStr, _ := jsoniter.ConfigCompatibleWithStandardLibrary.MarshalIndent(configItem, "", " ")
|
||||
|
||||
//写入到配置文件中
|
||||
//写入到配置文件中(不能使用os.O_APPEND 否则会追加)
|
||||
filePath := GetConfPath() + "/tank.json"
|
||||
f, err := os.OpenFile(filePath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
|
||||
f, err := os.OpenFile(filePath, os.O_RDWR|os.O_CREATE, 0777)
|
||||
this.PanicError(err)
|
||||
_, err = f.Write(jsonStr)
|
||||
this.PanicError(err)
|
||||
|
@ -169,6 +169,7 @@ func (this *MatterController) Page(writer http.ResponseWriter, request *http.Req
|
||||
userUuid := request.FormValue("userUuid")
|
||||
name := request.FormValue("name")
|
||||
dir := request.FormValue("dir")
|
||||
alien := request.FormValue("alien")
|
||||
orderDir := request.FormValue("orderDir")
|
||||
orderSize := request.FormValue("orderSize")
|
||||
orderName := request.FormValue("orderName")
|
||||
@ -229,7 +230,7 @@ func (this *MatterController) Page(writer http.ResponseWriter, request *http.Req
|
||||
},
|
||||
}
|
||||
|
||||
pager := this.matterDao.Page(page, pageSize, puuid, userUuid, name, dir, extensions, sortArray)
|
||||
pager := this.matterDao.Page(page, pageSize, puuid, userUuid, name, dir, alien, extensions, sortArray)
|
||||
|
||||
return this.Success(pager)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package rest
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
|
||||
"github.com/nu7hatch/gouuid"
|
||||
"os"
|
||||
"strings"
|
||||
@ -146,7 +146,7 @@ func (this *MatterDao) List(puuid string, userUuid string, sortArray []OrderPair
|
||||
}
|
||||
|
||||
//获取某个文件夹下所有的文件和子文件
|
||||
func (this *MatterDao) Page(page int, pageSize int, puuid string, userUuid string, name string, dir string, extensions []string, sortArray []OrderPair) *Pager {
|
||||
func (this *MatterDao) Page(page int, pageSize int, puuid string, userUuid string, name string, dir string, alien string, extensions []string, sortArray []OrderPair) *Pager {
|
||||
|
||||
var wp = &WherePair{}
|
||||
|
||||
@ -168,6 +168,12 @@ func (this *MatterDao) Page(page int, pageSize int, puuid string, userUuid strin
|
||||
wp = wp.And(&WherePair{Query: "dir = ?", Args: []interface{}{0}})
|
||||
}
|
||||
|
||||
if alien == "true" {
|
||||
wp = wp.And(&WherePair{Query: "alien = ?", Args: []interface{}{1}})
|
||||
} else if alien == "false" {
|
||||
wp = wp.And(&WherePair{Query: "alien = ?", Args: []interface{}{0}})
|
||||
}
|
||||
|
||||
var conditionDB *gorm.DB
|
||||
if extensions != nil && len(extensions) > 0 {
|
||||
var orWp = &WherePair{}
|
||||
@ -282,4 +288,4 @@ func (this *MatterDao) SizeBetweenTime(startTime time.Time, endTime time.Time) i
|
||||
row := db.Row()
|
||||
row.Scan(&size)
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ func (this *PreferenceController) Edit(writer http.ResponseWriter, request *http
|
||||
faviconUrl := request.FormValue("faviconUrl")
|
||||
footerLine1 := request.FormValue("footerLine1")
|
||||
footerLine2 := request.FormValue("footerLine2")
|
||||
showAlienStr := request.FormValue("showAlien")
|
||||
|
||||
preference := this.preferenceDao.Fetch()
|
||||
preference.Name = name
|
||||
@ -67,6 +68,11 @@ func (this *PreferenceController) Edit(writer http.ResponseWriter, request *http
|
||||
preference.FaviconUrl = faviconUrl
|
||||
preference.FooterLine1 = footerLine1
|
||||
preference.FooterLine2 = footerLine2
|
||||
if showAlienStr == "true" {
|
||||
preference.ShowAlien = true
|
||||
} else if showAlienStr == "false" {
|
||||
preference.ShowAlien = false
|
||||
}
|
||||
|
||||
preference = this.preferenceDao.Save(preference)
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
"github.com/nu7hatch/gouuid"
|
||||
"time"
|
||||
)
|
||||
@ -20,7 +19,7 @@ func (this *PreferenceDao) Fetch() *Preference {
|
||||
|
||||
if db.Error.Error() == "record not found" {
|
||||
preference.Name = "蓝眼云盘"
|
||||
preference.Version = VERSION
|
||||
preference.ShowAlien = true
|
||||
this.Create(preference)
|
||||
return preference
|
||||
} else {
|
||||
|
@ -7,7 +7,7 @@ type Preference struct {
|
||||
FaviconUrl string `json:"faviconUrl" gorm:"type:varchar(255)"`
|
||||
FooterLine1 string `json:"footerLine1" gorm:"type:varchar(1024)"`
|
||||
FooterLine2 string `json:"footerLine2" gorm:"type:varchar(1024)"`
|
||||
Version string `json:"version" gorm:"type:varchar(45)"`
|
||||
ShowAlien bool `json:"showAlien" gorm:"type:tinyint(1) not null;default:1"`
|
||||
}
|
||||
|
||||
// set File's table name to be `profiles`
|
||||
|
@ -1,7 +1,7 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
|
||||
"github.com/nu7hatch/gouuid"
|
||||
"time"
|
||||
)
|
||||
|
@ -8,7 +8,7 @@ type Session struct {
|
||||
Base
|
||||
UserUuid string `json:"userUuid" gorm:"type:char(36)"`
|
||||
Ip string `json:"ip" gorm:"type:varchar(128) not null"`
|
||||
ExpireTime time.Time `json:"expireTime" gorm:"type:timestamp not null;default:CURRENT_TIMESTAMP"`
|
||||
ExpireTime time.Time `json:"expireTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"`
|
||||
}
|
||||
|
||||
// set User's table name to be `profiles`
|
||||
|
@ -1,7 +1,7 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
|
||||
"github.com/nu7hatch/gouuid"
|
||||
"time"
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
|
||||
"github.com/nu7hatch/gouuid"
|
||||
"time"
|
||||
)
|
||||
|
@ -37,7 +37,7 @@ type User struct {
|
||||
City string `json:"city" gorm:"type:varchar(45)"`
|
||||
AvatarUrl string `json:"avatarUrl" gorm:"type:varchar(255)"`
|
||||
LastIp string `json:"lastIp" gorm:"type:varchar(128)"`
|
||||
LastTime time.Time `json:"lastTime" gorm:"type:timestamp not null;default:CURRENT_TIMESTAMP"`
|
||||
LastTime time.Time `json:"lastTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"`
|
||||
SizeLimit int64 `json:"sizeLimit" gorm:"type:bigint(20) not null;default:-1"`
|
||||
Status string `json:"status" gorm:"type:varchar(45)"`
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"fmt"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
//给密码字符串加密
|
||||
|
Loading…
Reference in New Issue
Block a user