controller

package
v0.0.0-...-8297867 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2016 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src string, dest string) (bool, error)

Copy file

func CreateDir

func CreateDir(src string) error

Create a folder

func CutFile

func CutFile(src string, newSrc string) error

Modify the file name Can be used to cut files.

func DeleteFile

func DeleteFile(src string) error

Delete file

func GetFileInfo

func GetFileInfo(src string) (os.FileInfo, error)

Get file information

func GetFileList

func GetFileList(src string, filter string, isSrc bool) ([]string, error)

Gets a list of files under the folder src string filter string eg : gif|jpg isSrc bool

func GetFileListCount

func GetFileListCount(src string) (int, error)

Gets the number of files in the folder

func GetFileNames

func GetFileNames(src string) (map[string]string, error)

Gets the file name and type

func GetFileSha1

func GetFileSha1(src string) (string, error)

Calculates the file sha1 value

func GetFileSize

func GetFileSize(src string) int64

Get the file size

func GetPathSep

func GetPathSep() string

Gets the system path separator

func GetTimeDirSrc

func GetTimeDirSrc(src string, appendFileType string) (string, error)

Gets the directory path for the time build eg : Return and create the path ,"[src]/201611/" eg : Return and create the path ,"[src]/201611/2016110102-03[appendFileType]"

func GetURLNameType

func GetURLNameType(sendURL string) map[string]string

Get the file name and type by URL

func IPAddrsGetExternal

func IPAddrsGetExternal() string

Obtain an IP address from the network

func IPAddrsGetInternal

func IPAddrsGetInternal() string

Get the local IP address

func IsExist

func IsExist(src string) bool

Determine whether the file exists

func IsFile

func IsFile(src string) bool

Determine whether the file

func IsFolder

func IsFolder(src string) bool

To determine whether the folder

func LoadConfigFile

func LoadConfigFile(configSrc string) (map[string]interface{}, error)

Read the configuration file

func LoadFile

func LoadFile(src string) ([]byte, error)

Load file

func SaveConfigFile

func SaveConfigFile(configSrc string, configData interface{}) error

Write the configuration file

func SessionGet

func SessionGet(w http.ResponseWriter, r *http.Request, sessionMark string) (map[interface{}]interface{}, bool)

Get the session data

func SessionSet

func SessionSet(w http.ResponseWriter, r *http.Request, sessionMark string, data map[interface{}]interface{}) bool

Write session data

func SimpleHttpGet

func SimpleHttpGet(sendURL string, params map[string][]string) ([]byte, error)

Gets the URL data get mode

func SimpleHttpPost

func SimpleHttpPost(sendURL string, params map[string][]string) ([]byte, error)

Gets the URL data post mode

func WriteFile

func WriteFile(src string, content []byte) error

Write file If the file does not exist, it is created.

func WriteFileAppend

func WriteFileAppend(src string, content []byte, isForward bool) error

Append data to a file

Types

type Coll

type Coll struct {
	// contains filtered or unexported fields
}

coll struct

func (*Coll) AutoTask

func (this *Coll) AutoTask()

auto coll task

func (*Coll) ChangeStatus

func (this *Coll) ChangeStatus(name string, b bool) bool

Change the collector operating status

func (*Coll) CheckCollExisit

func (this *Coll) CheckCollExisit(name string) bool

Check that the Collector is present

func (*Coll) ClearColl

func (this *Coll) ClearColl(name string) bool

Empty a data set

func (*Coll) ClearLog

func (this *Coll) ClearLog(name string) bool

clear log

func (*Coll) CollCloseDB

func (this *Coll) CollCloseDB(thisChildren *CollChildren, collOperate *CollOperate)

coll close database

func (*Coll) CollConnectDB

func (this *Coll) CollConnectDB(thisChildren *CollChildren, collOperate *CollOperate) bool

coll connect db

func (*Coll) CollDebug

func (this *Coll) CollDebug()

Collect debug

func (*Coll) CollEnd

func (this *Coll) CollEnd(thisChildren *CollChildren, collOperate *CollOperate)

coll end

func (*Coll) CollFeig

func (this *Coll) CollFeig()

Collect feig

func (*Coll) CollJiandan

func (this *Coll) CollJiandan()

Collect jiandan.net page data

func (*Coll) CollJiandanIndex

func (this *Coll) CollJiandanIndex()

Collect jiandan.net index data

func (*Coll) CollLocal

func (this *Coll) CollLocal()

Collect local data

func (*Coll) CollLocalAutoSave

func (this *Coll) CollLocalAutoSave(thisChildren *CollChildren, collOperate *CollOperate, collLocalDir string, localName string, filter string, fileMinSize int64, parentFolderName string)

local保存网页数据采集器

func (*Coll) CollLocalDownloadMovie

func (this *Coll) CollLocalDownloadMovie(thisChildren *CollChildren, collOperate *CollOperate, collLocalDir string)

local下载视频数据采集器

func (*Coll) CollLocalEnd

func (this *Coll) CollLocalEnd(thisChildren *CollChildren, collOperate *CollOperate, name string, parentSrc string)

local专用通用清理模块 删除所有文件

func (*Coll) CollLocalManhua

func (this *Coll) CollLocalManhua(thisChildren *CollChildren, collOperate *CollOperate, collLocalDir string)

local漫画数据采集器

func (*Coll) CollLocalParentFiles

func (this *Coll) CollLocalParentFiles(thisChildren *CollChildren, collOperate *CollOperate, localName string, parentTitle string, parentSrc string, parentType string, fileSrcList []string) bool

local专用通用采集模块 thisChildren *CollChildren collOperate *CollOperate localName string 子采集器名称 parentTitle string 上级目录名称 parentSrc string 上级目录路径 parentType string 上级目录类型,区分用途 fileSrcList []string 子文件路径列表

func (*Coll) CollLocalSaveImgsHtml

func (this *Coll) CollLocalSaveImgsHtml(thisChildren *CollChildren, collOperate *CollOperate, collLocalDir string)

local保存网页数据采集器

func (*Coll) CollLocalStart

func (this *Coll) CollLocalStart(collOperate *CollOperate, collLocalDir string, name string, fileFilter string) (string, []string)

local专用通用启动模块 在内部采集启动前,务必运行该模块 collOperate *CollOperate collLocalDir string local总采集器路径 name string 子采集器名称 fileFilter string 可选,文件列表过滤文件,不支持二级子目录下文件过滤,但会返回相关目录名称,eg : jpg|gif|txt return string - 该采集项目存储目录路径 return []string - 该目录下文件列表

func (*Coll) CollLocalTxt

func (this *Coll) CollLocalTxt(thisChildren *CollChildren, collOperate *CollOperate, collLocalDir string)

local文本数据采集器

func (*Coll) CollMeizitu

func (this *Coll) CollMeizitu()

Collect Mzitu data

func (*Coll) CollStart

func (this *Coll) CollStart(thisChildren *CollChildren, collOperate *CollOperate) bool

coll start

func (*Coll) CollXiuhaotu

func (this *Coll) CollXiuhaotu()

Collect xiuhaotu data

func (*Coll) CollXiuren

func (this *Coll) CollXiuren()

Collect xiuren data

func (*Coll) CreateCollListChildren

func (this *Coll) CreateCollListChildren(name string) CollChildren

Create new CollListChildren

func (*Coll) DebugErrorHTMLDoc

func (this *Coll) DebugErrorHTMLDoc(name string, doc *goquery.Document)

Sending an HTML to the error file was originally text for debugging.

func (*Coll) DebugErrorHTMLNode

func (this *Coll) DebugErrorHTMLNode(name string, html *goquery.Selection)

Sending an HTML to the error file was originally text for debugging.

func (*Coll) DebugErrorHTMLStr

func (this *Coll) DebugErrorHTMLStr(name string, html string)

Sending an HTML to the error file was originally text for debugging.

func (*Coll) GetCollChildren

func (this *Coll) GetCollChildren(name string) *CollChildren

Gets the CollListChildren handle

func (*Coll) GetStatus

func (this *Coll) GetStatus() (map[string]interface{}, bool)

Gets the running state

func (*Coll) Run

func (this *Coll) Run(name string)

Runs a collector

func (*Coll) View

func (this *Coll) View(collName string, id int64) string

Gets the list to the JSON data format

func (*Coll) ViewList

func (this *Coll) ViewList(collName string, parent int64, star int, searchTitle string, page int, max int, sort int, desc bool) ([]map[string]string, bool)

Gets the list to the JSON data format

type CollChildren

type CollChildren struct {
	// contains filtered or unexported fields
}

Collector list children

type CollFields

type CollFields struct {
	// contains filtered or unexported fields
}

Collector Type

type CollList

type CollList struct {
	// contains filtered or unexported fields
}

Collector list

type CollOperate

type CollOperate struct {
	// contains filtered or unexported fields
}

func (*CollOperate) AutoCollFile

func (this *CollOperate) AutoCollFile(url string, name string, parent string, parentID int64) int64

Automatically builds new data return -1 - The data has been collected return 0 - Acquisition failed return >0 - Acquires the new ID of the data

func (*CollOperate) AutoCollParent

func (this *CollOperate) AutoCollParent(parentTitle string, parentURL string) (int64, string)

Create an upper level ID

func (*CollOperate) AutoCollParentFiles

func (this *CollOperate) AutoCollParentFiles(parentTitle string, parentURL string, urls []string) int64

Automatically collect collection

func (*CollOperate) CheckDataSha1

func (this *CollOperate) CheckDataSha1(sha1 string) bool

Check whether the file is duplicated

func (*CollOperate) CheckDataURL

func (this *CollOperate) CheckDataURL(url string) bool

Check whether the file is duplicated

func (*CollOperate) ClearColl

func (this *CollOperate) ClearColl() bool

Empty a data set

func (*CollOperate) ClearLog

func (this *CollOperate) ClearLog()

clear log

func (*CollOperate) CreateNewData

func (this *CollOperate) CreateNewData(parent int64, sha1 string, src string, url string, name string, fileType string, size string) int64

Create a new data record

func (*CollOperate) DeleteData

func (this *CollOperate) DeleteData(id int64) bool

Delete a collection of data

func (*CollOperate) DeleteFile

func (this *CollOperate) DeleteFile(src string) bool

Delete a file

func (*CollOperate) GetCacheFIleInfo

func (this *CollOperate) GetCacheFIleInfo(url string) (map[string]string, bool)

Gets the buffer file information

func (*CollOperate) GetFileSha1

func (this *CollOperate) GetFileSha1(src string) string

Gets the file SHA1 value

func (*CollOperate) GetLog

func (this *CollOperate) GetLog(name string) string

Get the latest log content

func (*CollOperate) GetNowTimeUnix

func (this *CollOperate) GetNowTimeUnix() int64

get now time unix

func (*CollOperate) GetStrSha1

func (this *CollOperate) GetStrSha1(str string) string

Gets the str SHA1 value

func (*CollOperate) NewLog

func (this *CollOperate) NewLog(msg string, err error)

send log name string - Log name, corresponding to language configuration name append string - Additional content err error - error

func (*CollOperate) SaveCacheToFile

func (this *CollOperate) SaveCacheToFile(parentName string, cacheFileInfo map[string]string) string

Save the buffer file to the file database parentName string - The name of the previous archive cacheFileInfo map[string]string - File information source string - data source

func (*CollOperate) UpdateData

func (this *CollOperate) UpdateData(id int64, parent int64, star int, name string) bool

Update the data record information

func (*CollOperate) ViewDataList

func (this *CollOperate) ViewDataList(parent int64, star int, searchTitle string, page int, max int, sort int, desc bool) ([]map[string]string, bool)

View the data list

func (*CollOperate) ViewDataSrc

func (this *CollOperate) ViewDataSrc(id int64) string

View the data src

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

controller class

func (*Controller) Init

func (this *Controller) Init()

Initialize the structure

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database operation module

func (*Database) Close

func (this *Database) Close() error

Close the database connection

func (*Database) Connect

func (this *Database) Connect(dbType string, dbDNS string) error

Connect to the database

func (*Database) Delete

func (this *Database) Delete(table string, id int64) (int64, error)

Removes the specified id

func (*Database) GetField

func (this *Database) GetField(table string, fields []string, field string, value string) (*sql.Row, error)

Gets the specified field

func (*Database) GetFieldsToStr

func (this *Database) GetFieldsToStr(fields []string) string

Obtains a field string based on the number of fields.

func (*Database) GetID

func (this *Database) GetID(table string, fields []string, id int) (*sql.Row, error)

Gets the specified ID

func (*Database) GetList

func (this *Database) GetList(table string, fields []string, page int, max int, sort int, desc bool) (map[int]map[string]interface{}, error)

get the list

func (*Database) GetPageSortStr

func (this *Database) GetPageSortStr(page int, max int, sort string, desc bool) string

Get the sql pagination combo section.

func (*Database) GetResultToList

func (this *Database) GetResultToList(fields []string, result *sql.Rows) (map[int]map[string]interface{}, error)

Obtain a list of data according to the field.

func (*Database) Insert

func (this *Database) Insert(table string, fields []string, values []string)

This is just a placeholder

func (*Database) Update

func (this *Database) Update(table string, setField string, setValue string, id int) (int64, error)

update data

type Handle

type Handle struct {
	// contains filtered or unexported fields
}

The page handle

func (*Handle) CheckLogin

func (this *Handle) CheckLogin(w http.ResponseWriter, r *http.Request) bool

Check that you are logged in

func (*Handle) CheckURLPost

func (this *Handle) CheckURLPost(r *http.Request) bool

Check the post data

func (*Handle) GetTempSrc

func (this *Handle) GetTempSrc(name string) string

Get the template file path

func (*Handle) Init

func (this *Handle) Init(db *Database)

func (*Handle) PostText

func (this *Handle) PostText(w http.ResponseWriter, r *http.Request, content string)

Output text directly to the browser

func (*Handle) ShowTemplate

func (this *Handle) ShowTemplate(w http.ResponseWriter, r *http.Request, templateFileName string, data interface{})

Output template

func (*Handle) ToURL

func (this *Handle) ToURL(w http.ResponseWriter, r *http.Request, urlName string)

Jump to URL

func (*Handle) UpdateLanguage

func (this *Handle) UpdateLanguage()

Update the language data

type Language

type Language struct {
	// contains filtered or unexported fields
}

Language configuration processor

func (*Language) Get

func (this *Language) Get(name string) string

Get the language

func (*Language) Init

func (this *Language) Init(languageType string) bool

Initialize the language configuration processor

type Log

type Log struct {
	// contains filtered or unexported fields
}

log struct You need to set the related configuration. IP address if the output is set, otherwise you can leave empty.

func (*Log) GetNowTime

func (this *Log) GetNowTime() string

Gets the current time

func (*Log) NewLog

func (this *Log) NewLog(msg string, err error)

New log The log is automatically sent according to the settings.

func (*Log) SendFile

func (this *Log) SendFile(content string)

Send log to file

func (*Log) SendFmtPrintln

func (this *Log) SendFmtPrintln(msg string)

Send logs to the console

func (*Log) SetIsForward

func (this *Log) SetIsForward(b bool)

Set isForward

func (*Log) SetOneFileName

func (this *Log) SetOneFileName(name string)

Set oneFileName

func (*Log) UpdateIP

func (this *Log) UpdateIP()

Update the IP address

type MatchString

type MatchString struct {
}

Authentication and query modules

func (*MatchString) CheckEmail

func (this *MatchString) CheckEmail(str string) bool

Verify email

func (*MatchString) CheckPassword

func (this *MatchString) CheckPassword(str string) bool

Verify the 6-20 digit password

func (*MatchString) CheckUsername

func (this *MatchString) CheckUsername(str string) bool

Verify the 4-16-digit user name

func (*MatchString) GetRandStr

func (this *MatchString) GetRandStr(n int) string

Get a random number n - range

func (*MatchString) GetSha1

func (this *MatchString) GetSha1(content string) string

Gets the string sha1 value

func (*MatchString) SubStr

func (this *MatchString) SubStr(str string, start int, length int) string

sub string

type Router

type Router struct {
	// contains filtered or unexported fields
}

router

func (*Router) RunServer

func (this *Router) RunServer(db *Database)

Start the server

type User

type User struct {
	// contains filtered or unexported fields
}

The user operates the module

func (*User) ChangeLoginSession

func (this *User) ChangeLoginSession(w http.ResponseWriter, r *http.Request, b bool) bool

Change the session state

func (*User) CheckLogin

func (this *User) CheckLogin(w http.ResponseWriter, r *http.Request) bool

Check the login status

func (*User) CreateNewUser

func (this *User) CreateNewUser(username string, passwd string) int64

Create a new user

func (*User) DeleteUser

func (this *User) DeleteUser(id int64) bool

delete user

func (*User) GetLoginSession

func (this *User) GetLoginSession(w http.ResponseWriter, r *http.Request) bool

Gets the session state

func (*User) GetNowTimeUnix

func (this *User) GetNowTimeUnix() int64

get now time unix

func (*User) GetPasswdSha1

func (this *User) GetPasswdSha1(passwd string) string

Gets the password SHA1 value

func (*User) GetUnixTime

func (this *User) GetUnixTime() int64

Gets the unix timestamp

func (*User) Init

func (this *User) Init(db *Database, timeout int64)

Initialize the user action module

func (*User) LoginIn

func (this *User) LoginIn(w http.ResponseWriter, r *http.Request, username string, passwd string) bool

log in

func (*User) Logout

func (this *User) Logout(w http.ResponseWriter, r *http.Request) bool

sign out

func (*User) SearchUsername

func (this *User) SearchUsername(username string) int64

Search for the user name get column

func (*User) UpdateIP

func (this *User) UpdateIP()

Update the IP address

func (*User) UpdateLoginInfo

func (this *User) UpdateLoginInfo(id int64) bool

Update table information

func (*User) UpdateUser

func (this *User) UpdateUser(id int, username string, passwd string, isDisabled bool) bool

Update user information

func (*User) ViewUser

func (this *User) ViewUser(id int) (UserFieldsStruct, bool)

Gets the specified user

func (*User) ViewUserList

func (this *User) ViewUserList(searchUser string, page int, max int, sort int, desc bool) (map[int]map[string]interface{}, bool)

Gets the list of users

type UserFieldsStruct

type UserFieldsStruct struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL