Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c64580378 | |||
| e49164fa81 | |||
| 8265e24add | |||
| 283985df52 | |||
| 95adca04bd | |||
| 87039524a7 | |||
| 66cd21c35f | |||
| 7e64131931 | |||
| e30d40cfbb | |||
| 751ed0003d | |||
| 6d9f89a1d4 | |||
| bc329be03b | |||
| 4597a0a50d | |||
| 3dda86d170 | |||
| d847da7591 | |||
| e1eca90835 | |||
| 9283b8c284 | |||
| d8d9afa4d2 | |||
| 4d3829c345 | |||
| a23037a437 | |||
| 181295e54e | |||
| 8cc2499e21 | |||
| a2c49452b4 | |||
| ebf0df5ca8 | |||
| 73bf691ccc | |||
| b2e9701826 | |||
| 789b0a14d1 | |||
| 3ee64fcd8c | |||
| 527503b0d9 | |||
| a95b2fccd7 | |||
| 7e2abb43e3 | |||
| 48fd753a96 |
@@ -1,2 +1,3 @@
|
|||||||
/.idea/*
|
/.idea/*
|
||||||
.idea
|
.idea
|
||||||
|
/example/config/app.json
|
||||||
@@ -142,7 +142,7 @@ any additional terms or conditions. Notwithstanding the above, nothing herein
|
|||||||
shall supersede or modify the terms of any separate license agreement you
|
shall supersede or modify the terms of any separate license agreement you
|
||||||
may have executed with Licensor regarding such Contributions.
|
may have executed with Licensor regarding such Contributions.
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade names,
|
6. Trademarks. that License does not grant permission to use the trade names,
|
||||||
trademarks, service marks, or product names of the Licensor, except as required
|
trademarks, service marks, or product names of the Licensor, except as required
|
||||||
for reasonable and customary use in describing the origin of the Work and
|
for reasonable and customary use in describing the origin of the Work and
|
||||||
reproducing the content of the NOTICE file.
|
reproducing the content of the NOTICE file.
|
||||||
|
|||||||
+24
-10
@@ -1,11 +1,11 @@
|
|||||||
package hotime
|
package hotime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "./cache"
|
. "code.hoteas.com/golang/hotime/cache"
|
||||||
"./code"
|
"code.hoteas.com/golang/hotime/code"
|
||||||
. "./common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
. "./db"
|
. "code.hoteas.com/golang/hotime/db"
|
||||||
. "./log"
|
. "code.hoteas.com/golang/hotime/log"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"io"
|
"io"
|
||||||
@@ -30,7 +30,7 @@ type Application struct {
|
|||||||
WebConnectLog *logrus.Logger
|
WebConnectLog *logrus.Logger
|
||||||
Port string //端口号
|
Port string //端口号
|
||||||
TLSPort string //ssl访问端口号
|
TLSPort string //ssl访问端口号
|
||||||
connectListener []func(this *Context) bool //所有的访问监听,true按原计划继续使用,false表示有监听器处理
|
connectListener []func(that *Context) bool //所有的访问监听,true按原计划继续使用,false表示有监听器处理
|
||||||
connectDbFunc func(err ...*Error) (master, slave *sql.DB)
|
connectDbFunc func(err ...*Error) (master, slave *sql.DB)
|
||||||
configPath string
|
configPath string
|
||||||
Config Map
|
Config Map
|
||||||
@@ -258,12 +258,12 @@ func (that *Application) SetConfig(configPath ...string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetConnectListener 连接判断,返回true继续传输至控制层,false则停止传输
|
// SetConnectListener 连接判断,返回true继续传输至控制层,false则停止传输
|
||||||
func (that *Application) SetConnectListener(lis func(this *Context) bool) {
|
func (that *Application) SetConnectListener(lis func(that *Context) bool) {
|
||||||
that.connectListener = append(that.connectListener, lis)
|
that.connectListener = append(that.connectListener, lis)
|
||||||
}
|
}
|
||||||
|
|
||||||
//网络错误
|
//网络错误
|
||||||
//func (this *Application) session(w http.ResponseWriter, req *http.Request) {
|
//func (that *Application) session(w http.ResponseWriter, req *http.Request) {
|
||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
|
|
||||||
@@ -420,8 +420,14 @@ func (that *Application) handler(w http.ResponseWriter, req *http.Request) {
|
|||||||
header.Set("Cache-Control", "no-cache")
|
header.Set("Cache-Control", "no-cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Index(path, ".m3u8") != -1 {
|
t := strings.LastIndex(path, ".")
|
||||||
header.Add("Content-Type", "audio/mpegurl")
|
if t != -1 {
|
||||||
|
tt := path[t:]
|
||||||
|
|
||||||
|
if MimeMaps[tt] != "" {
|
||||||
|
|
||||||
|
header.Add("Content-Type", MimeMaps[tt])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//w.Write(data)
|
//w.Write(data)
|
||||||
@@ -529,14 +535,19 @@ func Init(config string) Application {
|
|||||||
appIns.SetCache()
|
appIns.SetCache()
|
||||||
appIns.MakeCode = &code.MakeCode{}
|
appIns.MakeCode = &code.MakeCode{}
|
||||||
codeConfig := appIns.Config.GetMap("codeConfig")
|
codeConfig := appIns.Config.GetMap("codeConfig")
|
||||||
|
appIns.MakeCodeRouter = Router{}
|
||||||
if codeConfig != nil {
|
if codeConfig != nil {
|
||||||
|
|
||||||
for k, _ := range codeConfig {
|
for k, _ := range codeConfig {
|
||||||
if appIns.Config.GetInt("mode") == 2 {
|
if appIns.Config.GetInt("mode") == 2 {
|
||||||
appIns.MakeCode.Db2JSON(k, codeConfig.GetString(k), &appIns.Db, true)
|
appIns.MakeCode.Db2JSON(k, codeConfig.GetString(k), &appIns.Db, true)
|
||||||
|
appIns.MakeCodeRouter[k] = Proj{}
|
||||||
} else if appIns.Config.GetInt("mode") == 3 {
|
} else if appIns.Config.GetInt("mode") == 3 {
|
||||||
appIns.MakeCode.Db2JSON(k, codeConfig.GetString(k), &appIns.Db, false)
|
appIns.MakeCode.Db2JSON(k, codeConfig.GetString(k), &appIns.Db, false)
|
||||||
|
appIns.MakeCodeRouter[k] = Proj{}
|
||||||
} else {
|
} else {
|
||||||
appIns.MakeCode.Db2JSON(k, codeConfig.GetString(k), nil, false)
|
appIns.MakeCode.Db2JSON(k, codeConfig.GetString(k), nil, false)
|
||||||
|
appIns.MakeCodeRouter[k] = Proj{}
|
||||||
}
|
}
|
||||||
//接入动态代码层
|
//接入动态代码层
|
||||||
if appIns.Router == nil {
|
if appIns.Router == nil {
|
||||||
@@ -615,6 +626,9 @@ func SetSqliteDB(appIns *Application, config Map) {
|
|||||||
|
|
||||||
func setMakeCodeLintener(name string, appIns *Application) {
|
func setMakeCodeLintener(name string, appIns *Application) {
|
||||||
appIns.SetConnectListener(func(context *Context) bool {
|
appIns.SetConnectListener(func(context *Context) bool {
|
||||||
|
if len(context.RouterString) < 2 || appIns.MakeCodeRouter[context.RouterString[0]] == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
if len(context.RouterString) > 1 && context.RouterString[0] == name {
|
if len(context.RouterString) > 1 && context.RouterString[0] == name {
|
||||||
if context.RouterString[1] == "hotime" && context.RouterString[2] == "login" {
|
if context.RouterString[1] == "hotime" && context.RouterString[2] == "login" {
|
||||||
return true
|
return true
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "../common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Vendored
+5
-5
@@ -1,7 +1,7 @@
|
|||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "../common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -30,14 +30,14 @@ type CacheDb struct {
|
|||||||
isInit bool
|
isInit bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CacheDb) GetError() *Error {
|
func (that *CacheDb) GetError() *Error {
|
||||||
|
|
||||||
return this.Error
|
return that.Error
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CacheDb) SetError(err *Error) {
|
func (that *CacheDb) SetError(err *Error) {
|
||||||
this.Error = err
|
that.Error = err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (that *CacheDb) initDbTable() {
|
func (that *CacheDb) initDbTable() {
|
||||||
|
|||||||
Vendored
+45
-45
@@ -1,7 +1,7 @@
|
|||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "../common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -17,47 +17,47 @@ type CacheMemory struct {
|
|||||||
mutex *sync.RWMutex
|
mutex *sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CacheMemory) GetError() *Error {
|
func (that *CacheMemory) GetError() *Error {
|
||||||
|
|
||||||
return this.Error
|
return that.Error
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CacheMemory) SetError(err *Error) {
|
func (that *CacheMemory) SetError(err *Error) {
|
||||||
this.Error = err
|
that.Error = err
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取Cache键只能为string类型
|
//获取Cache键只能为string类型
|
||||||
func (this *CacheMemory) get(key string) interface{} {
|
func (that *CacheMemory) get(key string) interface{} {
|
||||||
this.Error.SetError(nil)
|
that.Error.SetError(nil)
|
||||||
if this.Map == nil {
|
if that.Map == nil {
|
||||||
this.Map = Map{}
|
that.Map = Map{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if this.Map[key] == nil {
|
if that.Map[key] == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
data := this.Map.Get(key, this.Error).(cacheData)
|
data := that.Map.Get(key, that.Error).(cacheData)
|
||||||
if this.Error.GetError() != nil {
|
if that.Error.GetError() != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.time < time.Now().Unix() {
|
if data.time < time.Now().Unix() {
|
||||||
delete(this.Map, key)
|
delete(that.Map, key)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return data.data
|
return data.data
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CacheMemory) refreshMap() {
|
func (that *CacheMemory) refreshMap() {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
this.mutex.Lock()
|
that.mutex.Lock()
|
||||||
defer this.mutex.Unlock()
|
defer that.mutex.Unlock()
|
||||||
for key, v := range this.Map {
|
for key, v := range that.Map {
|
||||||
data := v.(cacheData)
|
data := v.(cacheData)
|
||||||
if data.time <= time.Now().Unix() {
|
if data.time <= time.Now().Unix() {
|
||||||
delete(this.Map, key)
|
delete(that.Map, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,15 +66,15 @@ func (this *CacheMemory) refreshMap() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//key value ,时间为时间戳
|
//key value ,时间为时间戳
|
||||||
func (this *CacheMemory) set(key string, value interface{}, time int64) {
|
func (that *CacheMemory) set(key string, value interface{}, time int64) {
|
||||||
this.Error.SetError(nil)
|
that.Error.SetError(nil)
|
||||||
var data cacheData
|
var data cacheData
|
||||||
|
|
||||||
if this.Map == nil {
|
if that.Map == nil {
|
||||||
this.Map = Map{}
|
that.Map = Map{}
|
||||||
}
|
}
|
||||||
|
|
||||||
dd := this.Map[key]
|
dd := that.Map[key]
|
||||||
|
|
||||||
if dd == nil {
|
if dd == nil {
|
||||||
data = cacheData{}
|
data = cacheData{}
|
||||||
@@ -85,74 +85,74 @@ func (this *CacheMemory) set(key string, value interface{}, time int64) {
|
|||||||
data.time = time
|
data.time = time
|
||||||
data.data = value
|
data.data = value
|
||||||
|
|
||||||
this.Map.Put(key, data)
|
that.Map.Put(key, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CacheMemory) delete(key string) {
|
func (that *CacheMemory) delete(key string) {
|
||||||
del := strings.Index(key, "*")
|
del := strings.Index(key, "*")
|
||||||
//如果通配删除
|
//如果通配删除
|
||||||
if del != -1 {
|
if del != -1 {
|
||||||
key = Substr(key, 0, del)
|
key = Substr(key, 0, del)
|
||||||
for k, _ := range this.Map {
|
for k, _ := range that.Map {
|
||||||
if strings.Index(k, key) != -1 {
|
if strings.Index(k, key) != -1 {
|
||||||
delete(this.Map, k)
|
delete(that.Map, k)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
delete(this.Map, key)
|
delete(that.Map, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CacheMemory) Cache(key string, data ...interface{}) *Obj {
|
func (that *CacheMemory) Cache(key string, data ...interface{}) *Obj {
|
||||||
|
|
||||||
x := RandX(1, 100000)
|
x := RandX(1, 100000)
|
||||||
if x > 99950 {
|
if x > 99950 {
|
||||||
this.refreshMap()
|
that.refreshMap()
|
||||||
}
|
}
|
||||||
if this.mutex == nil {
|
if that.mutex == nil {
|
||||||
this.mutex = &sync.RWMutex{}
|
that.mutex = &sync.RWMutex{}
|
||||||
}
|
}
|
||||||
|
|
||||||
reData := &Obj{Data: nil}
|
reData := &Obj{Data: nil}
|
||||||
|
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
this.mutex.RLock()
|
that.mutex.RLock()
|
||||||
reData.Data = this.get(key)
|
reData.Data = that.get(key)
|
||||||
this.mutex.RUnlock()
|
that.mutex.RUnlock()
|
||||||
return reData
|
return reData
|
||||||
}
|
}
|
||||||
tim := time.Now().Unix()
|
tim := time.Now().Unix()
|
||||||
|
|
||||||
if len(data) == 1 && data[0] == nil {
|
if len(data) == 1 && data[0] == nil {
|
||||||
this.mutex.Lock()
|
that.mutex.Lock()
|
||||||
this.delete(key)
|
that.delete(key)
|
||||||
this.mutex.Unlock()
|
that.mutex.Unlock()
|
||||||
return reData
|
return reData
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(data) == 1 {
|
if len(data) == 1 {
|
||||||
|
|
||||||
tim = tim + this.TimeOut
|
tim = tim + that.TimeOut
|
||||||
|
|
||||||
}
|
}
|
||||||
if len(data) == 2 {
|
if len(data) == 2 {
|
||||||
this.Error.SetError(nil)
|
that.Error.SetError(nil)
|
||||||
tempt := ObjToInt64(data[1], this.Error)
|
tempt := ObjToInt64(data[1], that.Error)
|
||||||
|
|
||||||
if tempt > tim {
|
if tempt > tim {
|
||||||
|
|
||||||
tim = tempt
|
tim = tempt
|
||||||
} else if this.Error.GetError() == nil {
|
} else if that.Error.GetError() == nil {
|
||||||
|
|
||||||
tim = tim + tempt
|
tim = tim + tempt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.mutex.Lock()
|
that.mutex.Lock()
|
||||||
this.set(key, data[0], tim)
|
that.set(key, data[0], tim)
|
||||||
this.mutex.Unlock()
|
that.mutex.Unlock()
|
||||||
return reData
|
return reData
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+51
-51
@@ -1,7 +1,7 @@
|
|||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "../common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
"github.com/garyburd/redigo/redis"
|
"github.com/garyburd/redigo/redis"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -20,65 +20,65 @@ type CacheRedis struct {
|
|||||||
*Error
|
*Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CacheRedis) GetError() *Error {
|
func (that *CacheRedis) GetError() *Error {
|
||||||
|
|
||||||
return this.Error
|
return that.Error
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CacheRedis) SetError(err *Error) {
|
func (that *CacheRedis) SetError(err *Error) {
|
||||||
this.Error = err
|
that.Error = err
|
||||||
}
|
}
|
||||||
|
|
||||||
//唯一标志
|
//唯一标志
|
||||||
func (this *CacheRedis) GetTag() int64 {
|
func (that *CacheRedis) GetTag() int64 {
|
||||||
|
|
||||||
if this.tag == int64(0) {
|
if that.tag == int64(0) {
|
||||||
this.tag = time.Now().UnixNano()
|
that.tag = time.Now().UnixNano()
|
||||||
}
|
}
|
||||||
return this.tag
|
return that.tag
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CacheRedis) reCon() bool {
|
func (that *CacheRedis) reCon() bool {
|
||||||
var err error
|
var err error
|
||||||
this.conn, err = redis.Dial("tcp", this.Host+":"+ObjToStr(this.Port))
|
that.conn, err = redis.Dial("tcp", that.Host+":"+ObjToStr(that.Port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.conn = nil
|
that.conn = nil
|
||||||
this.Error.SetError(err)
|
that.Error.SetError(err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if this.Pwd != "" {
|
if that.Pwd != "" {
|
||||||
_, err = this.conn.Do("AUTH", this.Pwd)
|
_, err = that.conn.Do("AUTH", that.Pwd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.conn = nil
|
that.conn = nil
|
||||||
this.Error.SetError(err)
|
that.Error.SetError(err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
func (this *CacheRedis) del(key string) {
|
func (that *CacheRedis) del(key string) {
|
||||||
del := strings.Index(key, "*")
|
del := strings.Index(key, "*")
|
||||||
if del != -1 {
|
if del != -1 {
|
||||||
val, err := redis.Strings(this.conn.Do("KEYS", key))
|
val, err := redis.Strings(that.conn.Do("KEYS", key))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.conn.Send("MULTI")
|
that.conn.Send("MULTI")
|
||||||
for i, _ := range val {
|
for i, _ := range val {
|
||||||
this.conn.Send("DEL", val[i])
|
that.conn.Send("DEL", val[i])
|
||||||
}
|
}
|
||||||
this.conn.Do("EXEC")
|
that.conn.Do("EXEC")
|
||||||
} else {
|
} else {
|
||||||
_, err := this.conn.Do("DEL", key)
|
_, err := that.conn.Do("DEL", key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.Error.SetError(err)
|
that.Error.SetError(err)
|
||||||
_, err = this.conn.Do("PING")
|
_, err = that.conn.Do("PING")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if this.reCon() {
|
if that.reCon() {
|
||||||
_, err = this.conn.Do("DEL", key)
|
_, err = that.conn.Do("DEL", key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,32 +86,32 @@ func (this *CacheRedis) del(key string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//key value ,时间为时间戳
|
//key value ,时间为时间戳
|
||||||
func (this *CacheRedis) set(key string, value string, time int64) {
|
func (that *CacheRedis) set(key string, value string, time int64) {
|
||||||
_, err := this.conn.Do("SET", key, value, "EX", ObjToStr(time))
|
_, err := that.conn.Do("SET", key, value, "EX", ObjToStr(time))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
this.Error.SetError(err)
|
that.Error.SetError(err)
|
||||||
_, err = this.conn.Do("PING")
|
_, err = that.conn.Do("PING")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if this.reCon() {
|
if that.reCon() {
|
||||||
_, err = this.conn.Do("SET", key, value, "EX", ObjToStr(time))
|
_, err = that.conn.Do("SET", key, value, "EX", ObjToStr(time))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CacheRedis) get(key string) *Obj {
|
func (that *CacheRedis) get(key string) *Obj {
|
||||||
reData := &Obj{}
|
reData := &Obj{}
|
||||||
var err error
|
var err error
|
||||||
reData.Data, err = redis.String(this.conn.Do("GET", key))
|
reData.Data, err = redis.String(that.conn.Do("GET", key))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reData.Data = nil
|
reData.Data = nil
|
||||||
if !strings.Contains(err.Error(), "nil returned") {
|
if !strings.Contains(err.Error(), "nil returned") {
|
||||||
this.Error.SetError(err)
|
that.Error.SetError(err)
|
||||||
_, err = this.conn.Do("PING")
|
_, err = that.conn.Do("PING")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if this.reCon() {
|
if that.reCon() {
|
||||||
reData.Data, err = redis.String(this.conn.Do("GET", key))
|
reData.Data, err = redis.String(that.conn.Do("GET", key))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,10 +121,10 @@ func (this *CacheRedis) get(key string) *Obj {
|
|||||||
return reData
|
return reData
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CacheRedis) Cache(key string, data ...interface{}) *Obj {
|
func (that *CacheRedis) Cache(key string, data ...interface{}) *Obj {
|
||||||
reData := &Obj{}
|
reData := &Obj{}
|
||||||
if this.conn == nil {
|
if that.conn == nil {
|
||||||
re := this.reCon()
|
re := that.reCon()
|
||||||
if !re {
|
if !re {
|
||||||
return reData
|
return reData
|
||||||
}
|
}
|
||||||
@@ -132,38 +132,38 @@ func (this *CacheRedis) Cache(key string, data ...interface{}) *Obj {
|
|||||||
//查询缓存
|
//查询缓存
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
|
|
||||||
reData = this.get(key)
|
reData = that.get(key)
|
||||||
return reData
|
return reData
|
||||||
|
|
||||||
}
|
}
|
||||||
tim := int64(0)
|
tim := int64(0)
|
||||||
//删除缓存
|
//删除缓存
|
||||||
if len(data) == 1 && data[0] == nil {
|
if len(data) == 1 && data[0] == nil {
|
||||||
this.del(key)
|
that.del(key)
|
||||||
return reData
|
return reData
|
||||||
}
|
}
|
||||||
//添加缓存
|
//添加缓存
|
||||||
if len(data) == 1 {
|
if len(data) == 1 {
|
||||||
|
|
||||||
if this.TimeOut == 0 {
|
if that.TimeOut == 0 {
|
||||||
//this.Time = Config.GetInt64("cacheShortTime")
|
//that.Time = Config.GetInt64("cacheShortTime")
|
||||||
}
|
}
|
||||||
|
|
||||||
tim += this.TimeOut
|
tim += that.TimeOut
|
||||||
}
|
}
|
||||||
if len(data) == 2 {
|
if len(data) == 2 {
|
||||||
this.Error.SetError(nil)
|
that.Error.SetError(nil)
|
||||||
tempt := ObjToInt64(data[1], this.Error)
|
tempt := ObjToInt64(data[1], that.Error)
|
||||||
if tempt > tim {
|
if tempt > tim {
|
||||||
|
|
||||||
tim = tempt
|
tim = tempt
|
||||||
} else if this.GetError() == nil {
|
} else if that.GetError() == nil {
|
||||||
|
|
||||||
tim = tim + tempt
|
tim = tim + tempt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set(key, ObjToStr(data[0]), tim)
|
that.set(key, ObjToStr(data[0]), tim)
|
||||||
|
|
||||||
return reData
|
return reData
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "../common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CacheIns interface {
|
type CacheIns interface {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package hotime
|
package hotime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "../hotime/common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -75,7 +75,8 @@ var TptProject = Proj{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//索引管理,便于检索以及权限
|
//索引管理,便于检索以及权限
|
||||||
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
|
if inData.GetString("index") != "" {
|
||||||
|
if inData.Get("parent_id") != nil {
|
||||||
Index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": that.RouterString[2]})
|
Index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": that.RouterString[2]})
|
||||||
parentIndex := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
|
parentIndex := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
|
||||||
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
|
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
|
||||||
@@ -86,6 +87,9 @@ var TptProject = Proj{
|
|||||||
v["index"] = strings.Replace(v.GetString("index"), Index.GetString("index"), inData.GetString("index"), -1)
|
v["index"] = strings.Replace(v.GetString("index"), Index.GetString("index"), inData.GetString("index"), -1)
|
||||||
that.Db.Update(that.RouterString[1], Map{"index": v["index"]}, Map{"id": v.GetCeilInt("id")})
|
that.Db.Update(that.RouterString[1], Map{"index": v["index"]}, Map{"id": v.GetCeilInt("id")})
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
delete(inData, "index")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,28 +166,29 @@ var TptProject = Proj{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
"hotime": Ctr{
|
"hotime": Ctr{
|
||||||
"login": func(this *Context) {
|
"login": func(that *Context) {
|
||||||
hotimeName := this.RouterString[0]
|
hotimeName := that.RouterString[0]
|
||||||
name := this.Req.FormValue("name")
|
name := that.Req.FormValue("name")
|
||||||
password := this.Req.FormValue("password")
|
password := that.Req.FormValue("password")
|
||||||
if name == "" || password == "" {
|
if name == "" || password == "" {
|
||||||
this.Display(3, "参数不足")
|
that.Display(3, "参数不足")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
user := this.Db.Get(hotimeName, "*", Map{"AND": Map{"OR": Map{"name": name, "phone": name}, "password": Md5(password)}})
|
user := that.Db.Get(hotimeName, "*", Map{"AND": Map{"OR": Map{"name": name, "phone": name}, "password": Md5(password)}})
|
||||||
if user == nil {
|
if user == nil {
|
||||||
this.Display(5, "登录失败")
|
that.Display(5, "登录失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.Session(hotimeName+"_id", user.GetCeilInt("id"))
|
that.Session(hotimeName+"_id", user.GetCeilInt("id"))
|
||||||
this.Session(hotimeName+"_name", name)
|
that.Session(hotimeName+"_name", name)
|
||||||
this.Display(0, this.SessionId)
|
delete(user, "password")
|
||||||
|
that.Display(0, user)
|
||||||
},
|
},
|
||||||
"logout": func(this *Context) {
|
"logout": func(that *Context) {
|
||||||
hotimeName := this.RouterString[0]
|
hotimeName := that.RouterString[0]
|
||||||
this.Session(hotimeName+"_id", nil)
|
that.Session(hotimeName+"_id", nil)
|
||||||
this.Session(hotimeName+"_name", nil)
|
that.Session(hotimeName+"_name", nil)
|
||||||
this.Display(0, "退出登录成功")
|
that.Display(0, "退出登录成功")
|
||||||
},
|
},
|
||||||
"info": func(that *Context) {
|
"info": func(that *Context) {
|
||||||
hotimeName := that.RouterString[0]
|
hotimeName := that.RouterString[0]
|
||||||
@@ -208,9 +213,18 @@ var TptProject = Proj{
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" {
|
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" {
|
||||||
|
|
||||||
|
//是角色表则取下角色值
|
||||||
|
if column.GetString("link") == "role" {
|
||||||
|
|
||||||
|
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), "id,auth,"+column.GetString("value"), Map{"id": v})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), "id,"+column.GetString("value"), Map{"id": v})
|
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), "id,"+column.GetString("value"), Map{"id": v})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
that.Display(0, re)
|
that.Display(0, re)
|
||||||
},
|
},
|
||||||
|
|||||||
+8
-2
@@ -1,7 +1,7 @@
|
|||||||
package code
|
package code
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "../common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Config = Map{
|
var Config = Map{
|
||||||
@@ -14,7 +14,13 @@ var Config = Map{
|
|||||||
//{"label": "测试表格", "table": "table", "icon": "el-icon-suitcase"},
|
//{"label": "测试表格", "table": "table", "icon": "el-icon-suitcase"},
|
||||||
//{"label": "系统管理", "name": "setting", "icon": "el-icon-setting",
|
//{"label": "系统管理", "name": "setting", "icon": "el-icon-setting",
|
||||||
// "menus": []Map{
|
// "menus": []Map{
|
||||||
// {"label": "用户管理", "table": "user"},
|
// {"label": "用户管理", "table": "user",
|
||||||
|
// "default": {
|
||||||
|
// "path": "info",
|
||||||
|
// "id": "1"
|
||||||
|
// },
|
||||||
|
// "auth": ["show","edit","info","add","delete"],
|
||||||
|
// },
|
||||||
// {"label": "组织管理", "table": "organization"},
|
// {"label": "组织管理", "table": "organization"},
|
||||||
// {"label": "地区管理", "table": "area"},
|
// {"label": "地区管理", "table": "area"},
|
||||||
// {"label": "角色管理", "table": "role"},
|
// {"label": "角色管理", "table": "role"},
|
||||||
|
|||||||
+22
-10
@@ -1,8 +1,8 @@
|
|||||||
package code
|
package code
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "../common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
"../db"
|
"code.hoteas.com/golang/hotime/db"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -141,7 +141,7 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB, makeCod
|
|||||||
that.TableConfig[v.GetString("name")] = Map{
|
that.TableConfig[v.GetString("name")] = Map{
|
||||||
"label": v.GetString("label"),
|
"label": v.GetString("label"),
|
||||||
"table": v.GetString("name"),
|
"table": v.GetString("name"),
|
||||||
"auth": []string{"add", "delete", "edit", "info"},
|
"auth": []string{"show", "add", "delete", "edit", "info"},
|
||||||
"columns": []Map{},
|
"columns": []Map{},
|
||||||
"search": []Map{
|
"search": []Map{
|
||||||
|
|
||||||
@@ -171,8 +171,8 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB, makeCod
|
|||||||
}
|
}
|
||||||
|
|
||||||
idSlice = append(idSlice, tableInfo)
|
idSlice = append(idSlice, tableInfo)
|
||||||
for _, info := range tableInfo {
|
for _, info1 := range tableInfo {
|
||||||
|
info := DeepCopyMap(info1).(Map)
|
||||||
if info.GetString("label") == "" {
|
if info.GetString("label") == "" {
|
||||||
info["label"] = info.GetString("name")
|
info["label"] = info.GetString("name")
|
||||||
}
|
}
|
||||||
@@ -193,11 +193,17 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB, makeCod
|
|||||||
//"add": false, "info": false, "edit": false, "list": true,
|
//"add": false, "info": false, "edit": false, "list": true,
|
||||||
//"must": false,
|
//"must": false,
|
||||||
}
|
}
|
||||||
|
|
||||||
//备注以空格隔开,空格后的是其他备注
|
//备注以空格隔开,空格后的是其他备注
|
||||||
indexNum := strings.Index(info.GetString("label"), ":")
|
indexNum := strings.Index(info.GetString("label"), " ")
|
||||||
if indexNum > 0 {
|
if indexNum > -1 {
|
||||||
coloum["label"] = info.GetString("label")[:indexNum]
|
coloum["label"] = info.GetString("label")[:indexNum]
|
||||||
}
|
}
|
||||||
|
//去除数据信息,是用:号分割的
|
||||||
|
indexNum = strings.Index(coloum.GetString("label"), ":")
|
||||||
|
if indexNum > -1 {
|
||||||
|
coloum["label"] = coloum.GetString("label")[:indexNum]
|
||||||
|
}
|
||||||
|
|
||||||
for _, ColumnName := range ColumnNameType {
|
for _, ColumnName := range ColumnNameType {
|
||||||
if (ColumnName.Strict && coloum.GetString("name") == ColumnName.Name) ||
|
if (ColumnName.Strict && coloum.GetString("name") == ColumnName.Name) ||
|
||||||
@@ -311,7 +317,6 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB, makeCod
|
|||||||
|
|
||||||
//生成id,判断数据库是否有改变,以保证数据库和配置文件匹配唯一
|
//生成id,判断数据库是否有改变,以保证数据库和配置文件匹配唯一
|
||||||
id := Md5(ObjToStr(idSlice))
|
id := Md5(ObjToStr(idSlice))
|
||||||
|
|
||||||
if id == that.Config.GetString("id") {
|
if id == that.Config.GetString("id") {
|
||||||
if isMake { //有生成包文件
|
if isMake { //有生成包文件
|
||||||
fmt.Println("有新的业务代码生成,请重新运行")
|
fmt.Println("有新的业务代码生成,请重新运行")
|
||||||
@@ -326,7 +331,7 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB, makeCod
|
|||||||
isMenusGet := false //判断是否被目录收录
|
isMenusGet := false //判断是否被目录收录
|
||||||
for indexKey, _ := range that.IndexMenus {
|
for indexKey, _ := range that.IndexMenus {
|
||||||
indexCode := strings.Index(indexKey, fk)
|
indexCode := strings.Index(indexKey, fk)
|
||||||
if indexCode == 0 {
|
if indexCode == 0 || indexCode == 4 {
|
||||||
isMenusGet = false
|
isMenusGet = false
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -352,7 +357,7 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB, makeCod
|
|||||||
//if tablePrefixCode != -1 {
|
//if tablePrefixCode != -1 {
|
||||||
for ck, _ := range that.TableColumns {
|
for ck, _ := range that.TableColumns {
|
||||||
//判断不止一个前缀相同
|
//判断不止一个前缀相同
|
||||||
if strings.Index(ck, prefixName) == 0 && ck != fk {
|
if (strings.Index(ck, prefixName) == 0 || strings.Index(prefixName, ck) == 4) && ck != fk {
|
||||||
isNewPrefix = true
|
isNewPrefix = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -372,8 +377,15 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB, makeCod
|
|||||||
}
|
}
|
||||||
//没有新前缀
|
//没有新前缀
|
||||||
if that.IndexMenus[prefixName] != nil {
|
if that.IndexMenus[prefixName] != nil {
|
||||||
|
if that.IndexMenus[prefixName+"/"+fk] == nil {
|
||||||
that.IndexMenus.GetMap(prefixName)["menus"] = append(that.IndexMenus.GetMap(prefixName).GetSlice("menus"), menuIns)
|
that.IndexMenus.GetMap(prefixName)["menus"] = append(that.IndexMenus.GetMap(prefixName).GetSlice("menus"), menuIns)
|
||||||
that.IndexMenus[prefixName+"/"+fk] = menuIns
|
that.IndexMenus[prefixName+"/"+fk] = menuIns
|
||||||
|
} else {
|
||||||
|
for k, v := range menuIns {
|
||||||
|
that.IndexMenus.GetMap(prefixName + "/" + fk)[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
that.Config["menus"] = append(that.Config.GetSlice("menus"), mMenu) //注入配置
|
that.Config["menus"] = append(that.Config.GetSlice("menus"), mMenu) //注入配置
|
||||||
|
|||||||
+17
-17
@@ -3,8 +3,8 @@ package code
|
|||||||
var InitTpt = `package {{name}}
|
var InitTpt = `package {{name}}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "../../../hotime"
|
. "code.hoteas.com/golang/hotime"
|
||||||
. "../../../hotime/common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ID = "{{id}}"
|
var ID = "{{id}}"
|
||||||
@@ -14,26 +14,26 @@ var Project = Proj{
|
|||||||
//"user": UserCtr,
|
//"user": UserCtr,
|
||||||
{{tablesCtr}}
|
{{tablesCtr}}
|
||||||
"hotime":Ctr{
|
"hotime":Ctr{
|
||||||
"login": func(this *Context) {
|
"login": func(that *Context) {
|
||||||
name := this.Req.FormValue("name")
|
name := that.Req.FormValue("name")
|
||||||
password := this.Req.FormValue("password")
|
password := that.Req.FormValue("password")
|
||||||
if name == "" || password == "" {
|
if name == "" || password == "" {
|
||||||
this.Display(3, "参数不足")
|
that.Display(3, "参数不足")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
user := this.Db.Get("admin", "*", Map{"AND": Map{"OR":Map{"name": name,"phone":name}, "password": Md5(password)}})
|
user := that.Db.Get("admin", "*", Map{"AND": Map{"OR":Map{"name": name,"phone":name}, "password": Md5(password)}})
|
||||||
if user == nil {
|
if user == nil {
|
||||||
this.Display(5, "登录失败")
|
that.Display(5, "登录失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.Session("admin_id", user.GetCeilInt("id"))
|
that.Session("admin_id", user.GetCeilInt("id"))
|
||||||
this.Session("admin_name", name)
|
that.Session("admin_name", name)
|
||||||
this.Display(0, this.SessionId)
|
that.Display(0, that.SessionId)
|
||||||
},
|
},
|
||||||
"logout": func(this *Context) {
|
"logout": func(that *Context) {
|
||||||
this.Session("admin_id", nil)
|
that.Session("admin_id", nil)
|
||||||
this.Session("admin_name", nil)
|
that.Session("admin_name", nil)
|
||||||
this.Display(0, "退出登录成功")
|
that.Display(0, "退出登录成功")
|
||||||
},
|
},
|
||||||
"info": func(that *Context) {
|
"info": func(that *Context) {
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
||||||
@@ -69,8 +69,8 @@ var Project = Proj{
|
|||||||
var CtrTpt = `package {{name}}
|
var CtrTpt = `package {{name}}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "../../../hotime"
|
. "code.hoteas.com/golang/hotime"
|
||||||
. "../../../hotime/common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ type ContextBase struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//唯一标志
|
//唯一标志
|
||||||
func (this *ContextBase) GetTag() string {
|
func (that *ContextBase) GetTag() string {
|
||||||
|
|
||||||
if this.tag == "" {
|
if that.tag == "" {
|
||||||
this.tag = ObjToStr(time.Now().Unix()) + ":" + ObjToStr(Random())
|
that.tag = ObjToStr(time.Now().Unix()) + ":" + ObjToStr(Random())
|
||||||
}
|
}
|
||||||
return this.tag
|
return that.tag
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -36,7 +36,7 @@ func StrFirstToUpper(str string) string {
|
|||||||
return strings.ToUpper(first) + other
|
return strings.ToUpper(first) + other
|
||||||
}
|
}
|
||||||
|
|
||||||
//相似度计算 ld compares two strings and returns the levenshtein distance between them.
|
// StrLd 相似度计算 ld compares two strings and returns the levenshtein distance between them.
|
||||||
func StrLd(s, t string, ignoreCase bool) int {
|
func StrLd(s, t string, ignoreCase bool) int {
|
||||||
if ignoreCase {
|
if ignoreCase {
|
||||||
s = strings.ToLower(s)
|
s = strings.ToLower(s)
|
||||||
@@ -142,7 +142,7 @@ func Md5(req string) string {
|
|||||||
return hex.EncodeToString(cipherStr)
|
return hex.EncodeToString(cipherStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
//随机数
|
// Rand 随机数
|
||||||
func Rand(count int) int {
|
func Rand(count int) int {
|
||||||
res := Random()
|
res := Random()
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
@@ -167,7 +167,7 @@ func Random() float64 {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//随机数范围
|
// RandX 随机数范围
|
||||||
func RandX(small int, max int) int {
|
func RandX(small int, max int) int {
|
||||||
res := 0
|
res := 0
|
||||||
//随机对象
|
//随机对象
|
||||||
@@ -219,7 +219,7 @@ func RandX(small int, max int) int {
|
|||||||
// GetDb()
|
// GetDb()
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//复制返回数组
|
// DeepCopyMap 复制返回数组
|
||||||
func DeepCopyMap(value interface{}) interface{} {
|
func DeepCopyMap(value interface{}) interface{} {
|
||||||
if valueMap, ok := value.(Map); ok {
|
if valueMap, ok := value.(Map); ok {
|
||||||
newMap := make(Map)
|
newMap := make(Map)
|
||||||
@@ -278,7 +278,7 @@ func DeepCopyMap(value interface{}) interface{} {
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//浮点数四舍五入保留小数
|
// Round 浮点数四舍五入保留小数
|
||||||
func Round(f float64, n int) float64 {
|
func Round(f float64, n int) float64 {
|
||||||
pow10_n := math.Pow10(n)
|
pow10_n := math.Pow10(n)
|
||||||
return math.Trunc((f+0.5/pow10_n)*pow10_n) / pow10_n
|
return math.Trunc((f+0.5/pow10_n)*pow10_n) / pow10_n
|
||||||
|
|||||||
+40
-40
@@ -10,108 +10,108 @@ import (
|
|||||||
type Map map[string]interface{}
|
type Map map[string]interface{}
|
||||||
|
|
||||||
//获取string
|
//获取string
|
||||||
func (this Map) GetString(key string, err ...*Error) string {
|
func (that Map) GetString(key string, err ...*Error) string {
|
||||||
|
|
||||||
if len(err) != 0 {
|
if len(err) != 0 {
|
||||||
err[0].SetError(nil)
|
err[0].SetError(nil)
|
||||||
}
|
}
|
||||||
return ObjToStr((this)[key])
|
return ObjToStr((that)[key])
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Map) Pointer() *Map {
|
func (that *Map) Pointer() *Map {
|
||||||
|
|
||||||
return this
|
return that
|
||||||
}
|
}
|
||||||
|
|
||||||
//增加接口
|
//增加接口
|
||||||
func (this Map) Put(key string, value interface{}) {
|
func (that Map) Put(key string, value interface{}) {
|
||||||
//if this==nil{
|
//if that==nil{
|
||||||
// this=Map{}
|
// that=Map{}
|
||||||
//}
|
//}
|
||||||
this[key] = value
|
that[key] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除接口
|
//删除接口
|
||||||
func (this Map) Delete(key string) {
|
func (that Map) Delete(key string) {
|
||||||
delete(this, key)
|
delete(that, key)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取Int
|
//获取Int
|
||||||
func (this Map) GetInt(key string, err ...*Error) int {
|
func (that Map) GetInt(key string, err ...*Error) int {
|
||||||
v := ObjToInt((this)[key], err...)
|
v := ObjToInt((that)[key], err...)
|
||||||
|
|
||||||
return v
|
return v
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取Int
|
//获取Int
|
||||||
func (this Map) GetInt64(key string, err ...*Error) int64 {
|
func (that Map) GetInt64(key string, err ...*Error) int64 {
|
||||||
v := ObjToInt64((this)[key], err...)
|
v := ObjToInt64((that)[key], err...)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取向上取整Int64
|
//获取向上取整Int64
|
||||||
func (this Map) GetCeilInt64(key string, err ...*Error) int64 {
|
func (that Map) GetCeilInt64(key string, err ...*Error) int64 {
|
||||||
v := ObjToCeilInt64((this)[key], err...)
|
v := ObjToCeilInt64((that)[key], err...)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取向上取整Int
|
//获取向上取整Int
|
||||||
func (this Map) GetCeilInt(key string, err ...*Error) int {
|
func (that Map) GetCeilInt(key string, err ...*Error) int {
|
||||||
v := ObjToCeilInt((this)[key], err...)
|
v := ObjToCeilInt((that)[key], err...)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取向上取整float64
|
//获取向上取整float64
|
||||||
func (this Map) GetCeilFloat64(key string, err ...*Error) float64 {
|
func (that Map) GetCeilFloat64(key string, err ...*Error) float64 {
|
||||||
v := ObjToCeilFloat64((this)[key], err...)
|
v := ObjToCeilFloat64((that)[key], err...)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取Float64
|
//获取Float64
|
||||||
func (this Map) GetFloat64(key string, err ...*Error) float64 {
|
func (that Map) GetFloat64(key string, err ...*Error) float64 {
|
||||||
|
|
||||||
v := ObjToFloat64((this)[key], err...)
|
v := ObjToFloat64((that)[key], err...)
|
||||||
|
|
||||||
return v
|
return v
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Map) GetSlice(key string, err ...*Error) Slice {
|
func (that Map) GetSlice(key string, err ...*Error) Slice {
|
||||||
|
|
||||||
//var v Slice
|
//var v Slice
|
||||||
v := ObjToSlice((this)[key], err...)
|
v := ObjToSlice((that)[key], err...)
|
||||||
|
|
||||||
return v
|
return v
|
||||||
|
|
||||||
}
|
}
|
||||||
func (this Map) GetBool(key string, err ...*Error) bool {
|
func (that Map) GetBool(key string, err ...*Error) bool {
|
||||||
|
|
||||||
//var v Slice
|
//var v Slice
|
||||||
v := ObjToBool((this)[key], err...)
|
v := ObjToBool((that)[key], err...)
|
||||||
|
|
||||||
return v
|
return v
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Map) GetMap(key string, err ...*Error) Map {
|
func (that Map) GetMap(key string, err ...*Error) Map {
|
||||||
//var data Slice
|
//var data Slice
|
||||||
|
|
||||||
v := ObjToMap((this)[key], err...)
|
v := ObjToMap((that)[key], err...)
|
||||||
|
|
||||||
return v
|
return v
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Map) Get(key string, err ...*Error) interface{} {
|
func (that Map) Get(key string, err ...*Error) interface{} {
|
||||||
|
|
||||||
if v, ok := (this)[key]; ok {
|
if v, ok := (that)[key]; ok {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
e := errors.New("没有存储key及对应的数据")
|
e := errors.New("没有存储key及对应的数据")
|
||||||
@@ -124,10 +124,10 @@ func (this Map) Get(key string, err ...*Error) interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//请传递指针过来
|
//请传递指针过来
|
||||||
func (this Map) ToStruct(stct interface{}) {
|
func (that Map) ToStruct(stct interface{}) {
|
||||||
|
|
||||||
data := reflect.ValueOf(stct).Elem()
|
data := reflect.ValueOf(stct).Elem()
|
||||||
for k, v := range this {
|
for k, v := range that {
|
||||||
ks := StrFirstToUpper(k)
|
ks := StrFirstToUpper(k)
|
||||||
dkey := data.FieldByName(ks)
|
dkey := data.FieldByName(ks)
|
||||||
if !dkey.IsValid() {
|
if !dkey.IsValid() {
|
||||||
@@ -135,13 +135,13 @@ func (this Map) ToStruct(stct interface{}) {
|
|||||||
}
|
}
|
||||||
switch dkey.Type().String() {
|
switch dkey.Type().String() {
|
||||||
case "int":
|
case "int":
|
||||||
dkey.SetInt(this.GetInt64(k))
|
dkey.SetInt(that.GetInt64(k))
|
||||||
case "int64":
|
case "int64":
|
||||||
dkey.Set(reflect.ValueOf(this.GetInt64(k)))
|
dkey.Set(reflect.ValueOf(that.GetInt64(k)))
|
||||||
case "float64":
|
case "float64":
|
||||||
dkey.Set(reflect.ValueOf(this.GetFloat64(k)))
|
dkey.Set(reflect.ValueOf(that.GetFloat64(k)))
|
||||||
case "string":
|
case "string":
|
||||||
dkey.Set(reflect.ValueOf(this.GetString(k)))
|
dkey.Set(reflect.ValueOf(that.GetString(k)))
|
||||||
case "interface{}":
|
case "interface{}":
|
||||||
dkey.Set(reflect.ValueOf(v))
|
dkey.Set(reflect.ValueOf(v))
|
||||||
}
|
}
|
||||||
@@ -149,13 +149,13 @@ func (this Map) ToStruct(stct interface{}) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Map) ToJsonString() string {
|
func (that Map) ToJsonString() string {
|
||||||
return ObjToStr(this)
|
return ObjToStr(that)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Map) JsonToMap(jsonStr string, err ...*Error) {
|
func (that Map) JsonToMap(jsonStr string, err ...*Error) {
|
||||||
e := json.Unmarshal([]byte(jsonStr), &this)
|
e := json.Unmarshal([]byte(jsonStr), &that)
|
||||||
if e != nil && len(err) != 0 {
|
if e != nil && len(err) != 0 {
|
||||||
err[0].SetError(e)
|
err[0].SetError(e)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,6 +135,15 @@ func ObjToFloat64(obj interface{}, e ...*Error) float64 {
|
|||||||
err = errors.New("没有合适的转换对象!")
|
err = errors.New("没有合适的转换对象!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if math.IsNaN(v) {
|
||||||
|
err = errors.New("float64 is NaN")
|
||||||
|
v = 0
|
||||||
|
}
|
||||||
|
if math.IsInf(v, 0) {
|
||||||
|
err = errors.New("float64 is Inf")
|
||||||
|
v = 0
|
||||||
|
}
|
||||||
if len(e) != 0 {
|
if len(e) != 0 {
|
||||||
e[0].SetError(err)
|
e[0].SetError(err)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
package hotime
|
package hotime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "./cache"
|
. "code.hoteas.com/golang/hotime/cache"
|
||||||
. "./common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
. "./db"
|
. "code.hoteas.com/golang/hotime/db"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|||||||
+7
-7
@@ -1,8 +1,8 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"../cache"
|
"code.hoteas.com/golang/hotime/cache"
|
||||||
. "../common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
@@ -165,7 +165,7 @@ func (that *HoTimeDB) Row(resl *sql.Rows) []Map {
|
|||||||
|
|
||||||
//
|
//
|
||||||
////code=0,1,2 0 backup all,1 backup data,2 backup ddl
|
////code=0,1,2 0 backup all,1 backup data,2 backup ddl
|
||||||
//func (this *HoTimeDB) Backup(path string, code int) {
|
//func (that *HoTimeDB) Backup(path string, code int) {
|
||||||
// var cmd *exec.Cmd
|
// var cmd *exec.Cmd
|
||||||
// switch code {
|
// switch code {
|
||||||
// case 0:cmd= exec.Command("mysqldump","-h"+ObjToStr(Config["dbHost"]), "-P"+ObjToStr(Config["dbPort"]),"-u"+ObjToStr(Config["dbUser"]), "-p"+ObjToStr(Config["dbPwd"]),ObjToStr(Config["dbName"]))
|
// case 0:cmd= exec.Command("mysqldump","-h"+ObjToStr(Config["dbHost"]), "-P"+ObjToStr(Config["dbPort"]),"-u"+ObjToStr(Config["dbUser"]), "-p"+ObjToStr(Config["dbPwd"]),ObjToStr(Config["dbName"]))
|
||||||
@@ -197,7 +197,7 @@ func (that *HoTimeDB) Row(resl *sql.Rows) []Map {
|
|||||||
// //db := ``
|
// //db := ``
|
||||||
// //fmt.Println(db)
|
// //fmt.Println(db)
|
||||||
// //
|
// //
|
||||||
// //tables := this.Query("show tables")
|
// //tables := that.Query("show tables")
|
||||||
// //lth := len(tables)
|
// //lth := len(tables)
|
||||||
// //if lth == 0 {
|
// //if lth == 0 {
|
||||||
// // return
|
// // return
|
||||||
@@ -212,7 +212,7 @@ func (that *HoTimeDB) Row(resl *sql.Rows) []Map {
|
|||||||
// //
|
// //
|
||||||
// //for i := 0; i < lth; i++ {
|
// //for i := 0; i < lth; i++ {
|
||||||
// // tt := tables[i]["Tables_in_"+db].(string)
|
// // tt := tables[i]["Tables_in_"+db].(string)
|
||||||
// // this.backupSave(path, tt, code)
|
// // that.backupSave(path, tt, code)
|
||||||
// // debug.FreeOSMemory()
|
// // debug.FreeOSMemory()
|
||||||
// //}
|
// //}
|
||||||
//
|
//
|
||||||
@@ -383,7 +383,7 @@ func (that *HoTimeDB) Exec(query string, args ...interface{}) (sql.Result, *Erro
|
|||||||
return resl, that.LastErr
|
return resl, that.LastErr
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (this *HoTimeDB)copy(data []Map)[]Map{
|
//func (that *HoTimeDB)copy(data []Map)[]Map{
|
||||||
// if data==nil{
|
// if data==nil{
|
||||||
// return nil
|
// return nil
|
||||||
// }
|
// }
|
||||||
@@ -836,7 +836,7 @@ func (that *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) {
|
|||||||
return where, res
|
return where, res
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.Db.Update("user",hotime.Map{"ustate":"1"},hotime.Map{"AND":hotime.Map{"OR":hotime.Map{"uid":4,"uname":"dasda"}},"ustate":1})
|
// that.Db.Update("user",hotime.Map{"ustate":"1"},hotime.Map{"AND":hotime.Map{"OR":hotime.Map{"uid":4,"uname":"dasda"}},"ustate":1})
|
||||||
func (that *HoTimeDB) notIn(k string, v interface{}, where string, res []interface{}) (string, []interface{}) {
|
func (that *HoTimeDB) notIn(k string, v interface{}, where string, res []interface{}) (string, []interface{}) {
|
||||||
//where:=""
|
//where:=""
|
||||||
//fmt.Println(reflect.ValueOf(v).Type().String())
|
//fmt.Println(reflect.ValueOf(v).Type().String())
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package aliyun
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
//"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type company struct {
|
||||||
|
ApiCode string
|
||||||
|
Url string
|
||||||
|
}
|
||||||
|
|
||||||
|
var Company = company{}
|
||||||
|
|
||||||
|
func (that *company) Init(apiCode string) {
|
||||||
|
//"06c6a07e89dd45c88de040ee1489eef7"
|
||||||
|
that.ApiCode = apiCode
|
||||||
|
that.Url = "http://api.81api.com"
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCompanyOtherAll 获取企业基础信息
|
||||||
|
func (that *company) GetCompanyOtherAll(name string) Map {
|
||||||
|
|
||||||
|
res := Map{}
|
||||||
|
data, e := that.GetCompanyPatentsInfo(name) //获取专利信息
|
||||||
|
if e != nil {
|
||||||
|
fmt.Println(e)
|
||||||
|
} else {
|
||||||
|
res["PatentsInfo"] = data.GetMap("data")
|
||||||
|
}
|
||||||
|
data, e = that.GetCompanyOtherCopyrightsInfo(name) //获取其他专利
|
||||||
|
if e != nil {
|
||||||
|
fmt.Println(e)
|
||||||
|
} else {
|
||||||
|
res["OtherCopyrightsInfo"] = data.GetMap("data")
|
||||||
|
}
|
||||||
|
data, e = that.GetCompanyTrademarksInfo(name) //获取商标
|
||||||
|
if e != nil {
|
||||||
|
fmt.Println(e)
|
||||||
|
} else {
|
||||||
|
res["TrademarksInfo"] = data.GetMap("data")
|
||||||
|
}
|
||||||
|
data, e = that.GetCompanySoftwareCopyrightsInfo(name) //获取软著
|
||||||
|
if e != nil {
|
||||||
|
fmt.Println(e)
|
||||||
|
} else {
|
||||||
|
res["SoftwareCopyrightsInfo"] = data.GetMap("data")
|
||||||
|
}
|
||||||
|
data, e = that.GetCompanyProfileTags(name) //获取大数据标签
|
||||||
|
if e != nil {
|
||||||
|
fmt.Println(e)
|
||||||
|
} else {
|
||||||
|
res["ProfileTags"] = data.GetSlice("data")
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCompanyBaseInfo 获取企业基础信息
|
||||||
|
func (that *company) GetCompanyBaseInfo(name string) (Map, error) {
|
||||||
|
url := "/getCompanyBaseInfo/"
|
||||||
|
|
||||||
|
body, err := that.basePost(url, name)
|
||||||
|
return ObjToMap(body), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCompanyPatentsInfo 获取专利信息
|
||||||
|
func (that *company) GetCompanyPatentsInfo(name string) (Map, error) {
|
||||||
|
url := "/getCompanyPatentsInfo/"
|
||||||
|
|
||||||
|
body, err := that.basePost(url, name)
|
||||||
|
return ObjToMap(body), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCompanyTrademarksInfo 获取商标信息
|
||||||
|
func (that *company) GetCompanyTrademarksInfo(name string) (Map, error) {
|
||||||
|
url := "/getCompanyTrademarksInfo/"
|
||||||
|
|
||||||
|
body, err := that.basePost(url, name)
|
||||||
|
return ObjToMap(body), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCompanySoftwareCopyrightsInfo 获取软著信息
|
||||||
|
func (that *company) GetCompanySoftwareCopyrightsInfo(name string) (Map, error) {
|
||||||
|
url := "/getCompanySoftwareCopyrightsInfo/"
|
||||||
|
|
||||||
|
body, err := that.basePost(url, name)
|
||||||
|
return ObjToMap(body), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCompanyOtherCopyrightsInfo 获取其他著作信息
|
||||||
|
func (that *company) GetCompanyOtherCopyrightsInfo(name string) (Map, error) {
|
||||||
|
url := "/getCompanyOtherCopyrightsInfo/"
|
||||||
|
|
||||||
|
body, err := that.basePost(url, name)
|
||||||
|
return ObjToMap(body), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCompanyProfileTags 获取大数据标签
|
||||||
|
func (that *company) GetCompanyProfileTags(name string) (Map, error) {
|
||||||
|
url := "/getCompanyProfileTags/"
|
||||||
|
body, err := that.basePost(url, name)
|
||||||
|
return ObjToMap(body), err
|
||||||
|
}
|
||||||
|
func (that *company) basePost(url string, name string) (string, error) {
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
|
||||||
|
reqest, err := http.NewRequest("GET", that.Url+url+name+"/?isRaiseErrorCode=1", nil)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Fatal error ", err.Error())
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
reqest.Header.Add("Authorization", "APPCODE "+that.ApiCode)
|
||||||
|
response, err := client.Do(reqest)
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Fatal error ", err.Error())
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
body, err := ioutil.ReadAll(response.Body)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
res := string(body)
|
||||||
|
fmt.Println(res)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package baidu
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BaiduMap struct {
|
||||||
|
Ak string
|
||||||
|
Url string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (that *BaiduMap) Init(Ak string) {
|
||||||
|
//"ak=ZeT902EZvVgIoGVWEFK3osUm"
|
||||||
|
that.Ak = Ak
|
||||||
|
that.Url = "https://api.map.baidu.com/place/v2/suggestion?output=json" + "&ak=" + Ak
|
||||||
|
//query
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPosition 获取定位列表
|
||||||
|
func (that *BaiduMap) GetPosition(name string, region string) (string, error) {
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
if region == "" {
|
||||||
|
region = "全国"
|
||||||
|
}
|
||||||
|
reqest, err := http.NewRequest("GET", that.Url+"&query="+url.PathEscape(name)+"®ion="+url.PathEscape(region), nil)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Fatal error ", err.Error())
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
response, err := client.Do(reqest)
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Fatal error ", err.Error())
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
body, err := ioutil.ReadAll(response.Body)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
//fmt.Println(string(body))
|
||||||
|
|
||||||
|
return string(body), err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var DefaultBaiDuMap BaiduMap
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
DefaultBaiDuMap = BaiduMap{}
|
||||||
|
}
|
||||||
+17
-21
@@ -10,29 +10,31 @@ import (
|
|||||||
//"fmt"
|
//"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DDY struct {
|
type dingdongyun struct {
|
||||||
ApiKey string
|
ApiKey string
|
||||||
YzmUrl string
|
YzmUrl string
|
||||||
TzUrl string
|
TzUrl string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *DDY) Init(apikey string) {
|
var DDY = dingdongyun{}
|
||||||
this.ApiKey = apikey
|
|
||||||
this.YzmUrl = "https://api.dingdongcloud.com/v2/sms/captcha/send.json"
|
func (that *dingdongyun) Init(apikey string) {
|
||||||
this.TzUrl = "https://api.dingdongcloud.com/v2/sms/notice/send.json"
|
that.ApiKey = apikey
|
||||||
|
that.YzmUrl = "https://api.dingdongcloud.com/v2/sms/captcha/send.json"
|
||||||
|
that.TzUrl = "https://api.dingdongcloud.com/v2/sms/notice/send.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
//发送短信验证码 code验证码如:123456 返回true表示发送成功flase表示发送失败
|
// SendYZM 发送短信验证码 code验证码如:123456 返回true表示发送成功flase表示发送失败
|
||||||
func (this *DDY) SendYZM(umoblie string, tpt string, data map[string]string) (bool, error) {
|
func (that *dingdongyun) SendYZM(umoblie string, tpt string, data map[string]string) (bool, error) {
|
||||||
for k, v := range data {
|
for k, v := range data {
|
||||||
tpt = strings.Replace(tpt, "{"+k+"}", v, -1)
|
tpt = strings.Replace(tpt, "{"+k+"}", v, -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.send(this.YzmUrl, umoblie, tpt)
|
return that.send(that.YzmUrl, umoblie, tpt)
|
||||||
}
|
}
|
||||||
|
|
||||||
//发送通知
|
// SendTz 发送通知
|
||||||
func (this *DDY) SendTz(umoblie []string, tpt string, data map[string]string) (bool, error) {
|
func (that *dingdongyun) SendTz(umoblie []string, tpt string, data map[string]string) (bool, error) {
|
||||||
for k, v := range data {
|
for k, v := range data {
|
||||||
tpt = strings.Replace(tpt, "{"+k+"}", v, -1)
|
tpt = strings.Replace(tpt, "{"+k+"}", v, -1)
|
||||||
}
|
}
|
||||||
@@ -44,14 +46,14 @@ func (this *DDY) SendTz(umoblie []string, tpt string, data map[string]string) (b
|
|||||||
}
|
}
|
||||||
umobleStr += "," + v
|
umobleStr += "," + v
|
||||||
}
|
}
|
||||||
return this.send(this.TzUrl, umobleStr, tpt)
|
return that.send(that.TzUrl, umobleStr, tpt)
|
||||||
}
|
}
|
||||||
|
|
||||||
//发送短信
|
//发送短信
|
||||||
func (this *DDY) send(mUrl string, umoblie string, content string) (bool, error) {
|
func (that *dingdongyun) send(mUrl string, umoblie string, content string) (bool, error) {
|
||||||
|
|
||||||
data_send_sms_yzm := url.Values{"apikey": {this.ApiKey}, "mobile": {umoblie}, "content": {content}}
|
data_send_sms_yzm := url.Values{"apikey": {that.ApiKey}, "mobile": {umoblie}, "content": {content}}
|
||||||
res, err := this.httpsPostForm(mUrl, data_send_sms_yzm)
|
res, err := that.httpsPostForm(mUrl, data_send_sms_yzm)
|
||||||
if err != nil && res == "" {
|
if err != nil && res == "" {
|
||||||
return false, errors.New("连接错误")
|
return false, errors.New("连接错误")
|
||||||
}
|
}
|
||||||
@@ -73,7 +75,7 @@ func (this *DDY) send(mUrl string, umoblie string, content string) (bool, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//调用url发送短信的连接
|
//调用url发送短信的连接
|
||||||
func (this *DDY) httpsPostForm(url string, data url.Values) (string, error) {
|
func (that *dingdongyun) httpsPostForm(url string, data url.Values) (string, error) {
|
||||||
resp, err := http.PostForm(url, data)
|
resp, err := http.PostForm(url, data)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -89,9 +91,3 @@ func (this *DDY) httpsPostForm(url string, data url.Values) (string, error) {
|
|||||||
return string(body), nil
|
return string(body), nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var DefaultDDY DDY
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
DefaultDDY = DDY{}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package download
|
package download
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "../../common"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
//下载文件
|
// Down 下载文件
|
||||||
func Down(url, path, name string, e ...*Error) bool {
|
func Down(url, path, name string, e ...*Error) bool {
|
||||||
|
|
||||||
os.MkdirAll(path, os.ModeDir)
|
os.MkdirAll(path, os.ModeDir)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func FileGet(path string) []byte {
|
|||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
|
|
||||||
//RSA加密
|
// RSA_Encrypt RSA加密
|
||||||
// plainText 要加密的数据
|
// plainText 要加密的数据
|
||||||
// path 公钥匙文件地址
|
// path 公钥匙文件地址
|
||||||
func RSA_Encrypt(plainText []byte, buf []byte) []byte {
|
func RSA_Encrypt(plainText []byte, buf []byte) []byte {
|
||||||
@@ -46,7 +46,7 @@ func RSA_Encrypt(plainText []byte, buf []byte) []byte {
|
|||||||
return cipherText
|
return cipherText
|
||||||
}
|
}
|
||||||
|
|
||||||
//RSA解密
|
// RSA_Decrypt RSA解密
|
||||||
// cipherText 需要解密的byte数据
|
// cipherText 需要解密的byte数据
|
||||||
// path 私钥文件路径
|
// path 私钥文件路径
|
||||||
func RSA_Decrypt(cipherText []byte, buf []byte) []byte {
|
func RSA_Decrypt(cipherText []byte, buf []byte) []byte {
|
||||||
@@ -97,7 +97,7 @@ func Demo() {
|
|||||||
fmt.Println(string(decrypt))
|
fmt.Println(string(decrypt))
|
||||||
}
|
}
|
||||||
|
|
||||||
//生成RSA私钥和公钥,保存到文件中
|
// GenerateRSAKey 生成RSA私钥和公钥,保存到文件中
|
||||||
// bits 证书大小
|
// bits 证书大小
|
||||||
func GenerateRSAKey(bits int, path string) {
|
func GenerateRSAKey(bits int, path string) {
|
||||||
//GenerateKey函数使用随机数据生成器random生成一对具有指定字位数的RSA密钥
|
//GenerateKey函数使用随机数据生成器random生成一对具有指定字位数的RSA密钥
|
||||||
|
|||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package tencent
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
|
"crypto/hmac"
|
||||||
|
"crypto/sha1"
|
||||||
|
"encoding/base64"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
gourl "net/url"
|
||||||
|
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type company struct {
|
||||||
|
secretId string
|
||||||
|
secretKey string
|
||||||
|
}
|
||||||
|
|
||||||
|
var Company = company{}
|
||||||
|
|
||||||
|
func (that *company) Init(secretId, secretKey string) {
|
||||||
|
// 云市场分配的密钥Id
|
||||||
|
//secretId := "xxxx"
|
||||||
|
//// 云市场分配的密钥Key
|
||||||
|
//secretKey := "xxxx"
|
||||||
|
that.secretId = secretId
|
||||||
|
that.secretKey = secretKey
|
||||||
|
}
|
||||||
|
|
||||||
|
func (that *company) calcAuthorization(source string) (auth string, datetime string, err error) {
|
||||||
|
|
||||||
|
timeLocation, _ := time.LoadLocation("Etc/GMT")
|
||||||
|
datetime = time.Now().In(timeLocation).Format("Mon, 02 Jan 2006 15:04:05 GMT")
|
||||||
|
signStr := fmt.Sprintf("x-date: %s\nx-source: %s", datetime, source)
|
||||||
|
|
||||||
|
// hmac-sha1
|
||||||
|
mac := hmac.New(sha1.New, []byte(that.secretKey))
|
||||||
|
mac.Write([]byte(signStr))
|
||||||
|
sign := base64.StdEncoding.EncodeToString(mac.Sum(nil))
|
||||||
|
|
||||||
|
auth = fmt.Sprintf("hmac id=\"%s\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"%s\"",
|
||||||
|
that.secretId, sign)
|
||||||
|
|
||||||
|
return auth, datetime, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (that *company) urlencode(params map[string]string) string {
|
||||||
|
var p = gourl.Values{}
|
||||||
|
for k, v := range params {
|
||||||
|
p.Add(k, v)
|
||||||
|
}
|
||||||
|
return p.Encode()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (that *company) GetCompany(name string) Map {
|
||||||
|
// 云市场分配的密钥Id
|
||||||
|
//secretId := "xxxx"
|
||||||
|
//// 云市场分配的密钥Key
|
||||||
|
//secretKey := "xxxx"
|
||||||
|
source := "market"
|
||||||
|
|
||||||
|
// 签名
|
||||||
|
auth, datetime, _ := that.calcAuthorization(source)
|
||||||
|
|
||||||
|
// 请求方法
|
||||||
|
method := "GET"
|
||||||
|
// 请求头
|
||||||
|
headers := map[string]string{"X-Source": source, "X-Date": datetime, "Authorization": auth}
|
||||||
|
|
||||||
|
// 查询参数
|
||||||
|
queryParams := make(map[string]string)
|
||||||
|
queryParams["keyword"] = name
|
||||||
|
// body参数
|
||||||
|
bodyParams := make(map[string]string)
|
||||||
|
|
||||||
|
// url参数拼接
|
||||||
|
url := "https://service-3jnh3ku8-1256140209.gz.apigw.tencentcs.com/release/business4/geet"
|
||||||
|
if len(queryParams) > 0 {
|
||||||
|
url = fmt.Sprintf("%s?%s", url, that.urlencode(queryParams))
|
||||||
|
}
|
||||||
|
|
||||||
|
bodyMethods := map[string]bool{"POST": true, "PUT": true, "PATCH": true}
|
||||||
|
var body io.Reader = nil
|
||||||
|
if bodyMethods[method] {
|
||||||
|
body = strings.NewReader(that.urlencode(bodyParams))
|
||||||
|
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
||||||
|
}
|
||||||
|
|
||||||
|
client := &http.Client{
|
||||||
|
Timeout: 5 * time.Second,
|
||||||
|
}
|
||||||
|
request, err := http.NewRequest(method, url, body)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
for k, v := range headers {
|
||||||
|
request.Header.Set(k, v)
|
||||||
|
}
|
||||||
|
response, err := client.Do(request)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
bodyBytes, err := ioutil.ReadAll(response.Body)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
res := string(bodyBytes)
|
||||||
|
fmt.Println(res)
|
||||||
|
return ObjToMap(res)
|
||||||
|
}
|
||||||
+46
-5
@@ -8,16 +8,57 @@ import (
|
|||||||
ocr "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr/v20181119"
|
ocr "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr/v20181119"
|
||||||
)
|
)
|
||||||
|
|
||||||
var credential = common.NewCredential(
|
type tencent struct {
|
||||||
|
secretId string
|
||||||
|
secretKey string
|
||||||
|
credential *common.Credential
|
||||||
|
}
|
||||||
|
|
||||||
|
var Tencent = tencent{}
|
||||||
|
|
||||||
|
func (that *tencent) Init(secretId, secretKey string) {
|
||||||
|
// 云市场分配的密钥Id
|
||||||
|
//secretId := "xxxx"
|
||||||
|
//// 云市场分配的密钥Key
|
||||||
|
//secretKey := "xxxx"
|
||||||
|
that.secretId = secretId
|
||||||
|
that.secretKey = secretKey
|
||||||
|
that.credential = common.NewCredential(
|
||||||
"AKIDOgT8cKCQksnY7yKATaYO7j9ORJzSYohP",
|
"AKIDOgT8cKCQksnY7yKATaYO7j9ORJzSYohP",
|
||||||
"GNXgjdN4czA9ya0FNMApVJzTmsmU0KSN",
|
"GNXgjdN4czA9ya0FNMApVJzTmsmU0KSN",
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func OCR(base64Str string) string {
|
func (that *tencent) OCRCOMPANY(base64Str string) string {
|
||||||
|
|
||||||
cpf := profile.NewClientProfile()
|
cpf := profile.NewClientProfile()
|
||||||
cpf.HttpProfile.Endpoint = "ocr.tencentcloudapi.com"
|
cpf.HttpProfile.Endpoint = "ocr.tencentcloudapi.com"
|
||||||
client, _ := ocr.NewClient(credential, "ap-guangzhou", cpf)
|
client, _ := ocr.NewClient(that.credential, "ap-guangzhou", cpf)
|
||||||
|
|
||||||
|
request := ocr.NewBizLicenseOCRRequest()
|
||||||
|
|
||||||
|
//request.ImageUrl = common.StringPtr("https://img0.baidu.com/it/u=2041013181,3227632688&fm=26&fmt=auto")
|
||||||
|
request.ImageBase64 = common.StringPtr(base64Str)
|
||||||
|
|
||||||
|
response, err := client.BizLicenseOCR(request)
|
||||||
|
if _, ok := err.(*errors.TencentCloudSDKError); ok {
|
||||||
|
fmt.Println("An API error has returned: %s", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("An API error has returned: %s", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
//fmt.Printf("%s", response.ToJsonString())
|
||||||
|
|
||||||
|
return response.ToJsonString()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (that *tencent) OCR(base64Str string) string {
|
||||||
|
|
||||||
|
cpf := profile.NewClientProfile()
|
||||||
|
cpf.HttpProfile.Endpoint = "ocr.tencentcloudapi.com"
|
||||||
|
client, _ := ocr.NewClient(that.credential, "ap-guangzhou", cpf)
|
||||||
|
|
||||||
request := ocr.NewGeneralAccurateOCRRequest()
|
request := ocr.NewGeneralAccurateOCRRequest()
|
||||||
|
|
||||||
@@ -38,11 +79,11 @@ func OCR(base64Str string) string {
|
|||||||
return response.ToJsonString()
|
return response.ToJsonString()
|
||||||
}
|
}
|
||||||
|
|
||||||
func Qrcode(base64Str string) string {
|
func (that *tencent) Qrcode(base64Str string) string {
|
||||||
|
|
||||||
cpf := profile.NewClientProfile()
|
cpf := profile.NewClientProfile()
|
||||||
cpf.HttpProfile.Endpoint = "ocr.tencentcloudapi.com"
|
cpf.HttpProfile.Endpoint = "ocr.tencentcloudapi.com"
|
||||||
client, _ := ocr.NewClient(credential, "ap-guangzhou", cpf)
|
client, _ := ocr.NewClient(that.credential, "ap-guangzhou", cpf)
|
||||||
|
|
||||||
request := ocr.NewQrcodeOCRRequest()
|
request := ocr.NewQrcodeOCRRequest()
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package upload
|
package upload
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "../../common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
@@ -15,7 +15,7 @@ type Upload struct {
|
|||||||
Path string
|
Path string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Upload) UpFile(Request *http.Request, fieldName, savefilepath, savePath string) (string, error) {
|
func (that *Upload) UpFile(Request *http.Request, fieldName, savefilepath, savePath string) (string, error) {
|
||||||
Request.ParseMultipartForm(32 << 20)
|
Request.ParseMultipartForm(32 << 20)
|
||||||
var filePath string
|
var filePath string
|
||||||
files := Request.MultipartForm.File
|
files := Request.MultipartForm.File
|
||||||
@@ -36,7 +36,7 @@ func (this *Upload) UpFile(Request *http.Request, fieldName, savefilepath, saveP
|
|||||||
data := time.Unix(int64(t), 0).Format("2006-01")
|
data := time.Unix(int64(t), 0).Format("2006-01")
|
||||||
path := ""
|
path := ""
|
||||||
if strings.EqualFold(savefilepath, "") {
|
if strings.EqualFold(savefilepath, "") {
|
||||||
path = this.Path + data
|
path = that.Path + data
|
||||||
} else {
|
} else {
|
||||||
path = savefilepath + data
|
path = savefilepath + data
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ func (this *Upload) UpFile(Request *http.Request, fieldName, savefilepath, saveP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
filename := time.Unix(int64(t), 0).Format("2006-01-02-15-22-25") + ObjToStr(Rand(6))
|
filename := time.Unix(int64(t), 0).Format("2006-01-02-15-22-25") + ObjToStr(Rand(6))
|
||||||
filePath = path + "/" + filename + this.Path
|
filePath = path + "/" + filename + that.Path
|
||||||
} else {
|
} else {
|
||||||
filePath = savePath
|
filePath = savePath
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
var adminCtr = Ctr{
|
|
||||||
"token": func(this *Context) {
|
|
||||||
this.Display(0, this.SessionId)
|
|
||||||
},
|
|
||||||
"test": func(this *Context) {
|
|
||||||
this.Session("id", this.SessionId)
|
|
||||||
},
|
|
||||||
//自带的登录
|
|
||||||
"login": func(this *Context) {
|
|
||||||
|
|
||||||
name := this.Req.FormValue("name")
|
|
||||||
pwd := this.Req.FormValue("password")
|
|
||||||
if len(name) < 2 ||
|
|
||||||
len(pwd) < 3 {
|
|
||||||
this.Display(3, "数据校验不通过")
|
|
||||||
}
|
|
||||||
where := Map{"password": Md5(pwd)}
|
|
||||||
if len(name) == 11 {
|
|
||||||
where["phone"] = name
|
|
||||||
} else {
|
|
||||||
where["name"] = name
|
|
||||||
}
|
|
||||||
|
|
||||||
admin := this.Db.Get("admin", "*", Map{"AND": where})
|
|
||||||
if admin == nil {
|
|
||||||
this.Display(4, "账户密码错误")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Session("id", admin.GetCeilInt("id"))
|
|
||||||
admin["password"] = nil
|
|
||||||
this.Display(0, admin)
|
|
||||||
|
|
||||||
},
|
|
||||||
"info": func(this *Context) {
|
|
||||||
admin := this.Db.Get("admin", "*", Map{"id": this.Session("id").ToInt()})
|
|
||||||
|
|
||||||
if admin == nil {
|
|
||||||
this.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
admin["password"] = nil
|
|
||||||
|
|
||||||
this.Display(0, admin)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Project 管理端项目
|
|
||||||
var Project = Proj{
|
|
||||||
//"user": UserCtr,
|
|
||||||
"product_spot_check": product_spot_checkCtr,
|
|
||||||
"product": productCtr,
|
|
||||||
"admin": adminCtr,
|
|
||||||
"sms": Sms,
|
|
||||||
"material": materialCtr,
|
|
||||||
"material_inout": material_inoutCtr,
|
|
||||||
"produce_product": produce_productCtr,
|
|
||||||
"produce": produceCtr,
|
|
||||||
"product_line": product_lineCtr,
|
|
||||||
}
|
|
||||||
|
|
||||||
//生成随机码的4位随机数
|
|
||||||
func getCode() string {
|
|
||||||
//res := ""
|
|
||||||
//for i := 0; i < 4; i++ {
|
|
||||||
res := ObjToStr(RandX(1000, 9999))
|
|
||||||
//}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
@@ -1,213 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
var materialCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
str, inData := that.MakeCode.Info(that.RouterString[1], data, that.Db)
|
|
||||||
where := Map{"id": that.RouterString[2]}
|
|
||||||
|
|
||||||
if len(inData) == 1 {
|
|
||||||
inData["id"] = where["id"]
|
|
||||||
where = Map{"AND": inData}
|
|
||||||
} else if len(inData) > 1 {
|
|
||||||
where["OR"] = inData
|
|
||||||
where = Map{"AND": where}
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Get(that.RouterString[1], str, where)
|
|
||||||
|
|
||||||
if re == nil {
|
|
||||||
that.Display(4, "找不到对应信息")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, v := range re {
|
|
||||||
column := that.MakeCode.TableColumns[that.RouterString[1]][k]
|
|
||||||
if column == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" {
|
|
||||||
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), "id,"+column.GetString("value"), Map{"id": v})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"add": func(that *Context) {
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
name := that.Req.FormValue("name")
|
|
||||||
img := that.Req.FormValue("img")
|
|
||||||
validity := ObjToInt(that.Req.FormValue("validity"))
|
|
||||||
num := ObjToInt(that.Req.FormValue("num"))
|
|
||||||
rule := that.Req.FormValue("rule")
|
|
||||||
content := that.Req.FormValue("content")
|
|
||||||
description := that.Req.FormValue("description")
|
|
||||||
if name == "" || rule == "" {
|
|
||||||
that.Display(3, "参数不足,请补充参数")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
data := Map{
|
|
||||||
"name": name,
|
|
||||||
"img": img,
|
|
||||||
"rule": rule,
|
|
||||||
"admin_id": adminID,
|
|
||||||
"count": 0,
|
|
||||||
"used": 0,
|
|
||||||
"saved": 0,
|
|
||||||
"num": num,
|
|
||||||
"validity": validity,
|
|
||||||
"description": description,
|
|
||||||
"content": content,
|
|
||||||
"create_time": time.Now().Unix(),
|
|
||||||
"modify_time": time.Now().Unix(),
|
|
||||||
}
|
|
||||||
|
|
||||||
id := that.Db.Insert("material", data)
|
|
||||||
if id == 0 {
|
|
||||||
that.Display(4, "添加材料失败,请重新添加")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
data["id"] = id
|
|
||||||
|
|
||||||
that.Display(0, data)
|
|
||||||
},
|
|
||||||
"update": func(that *Context) {
|
|
||||||
inData := that.MakeCode.Edit(that.RouterString[1], that.Req)
|
|
||||||
if inData == nil {
|
|
||||||
that.Display(3, "没有找到要更新的数据")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
|
|
||||||
Index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": that.RouterString[2]})
|
|
||||||
parentIndex := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
|
|
||||||
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
|
|
||||||
|
|
||||||
childNodes := that.Db.Select(that.RouterString[1], "id,`index`", Map{"index[~]": "," + that.RouterString[2] + ","})
|
|
||||||
|
|
||||||
for _, v := range childNodes {
|
|
||||||
v["index"] = strings.Replace(v.GetString("index"), Index.GetString("index"), inData.GetString("index"), -1)
|
|
||||||
that.Db.Update(that.RouterString[1], Map{"index": v["index"]}, Map{"id": v.GetCeilInt("id")})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Update(that.RouterString[1], inData, Map{"id": that.RouterString[2]})
|
|
||||||
|
|
||||||
if re == 0 {
|
|
||||||
that.Display(4, "更新数据失败")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"inout": func(that *Context) {
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
data := ObjToMap(that.Req.FormValue("data"))
|
|
||||||
|
|
||||||
texts := data.GetSlice("text")
|
|
||||||
textData := []Map{}
|
|
||||||
for k, _ := range texts {
|
|
||||||
v := texts.GetString(k)
|
|
||||||
if len(v) < 4 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
vs := that.Db.Select("material", "name,id,content,rule,num", Map{"content[~]": v[:len(v)/2]})
|
|
||||||
for _, v1 := range vs {
|
|
||||||
if len(textData) == 0 {
|
|
||||||
textData = append(textData, v1)
|
|
||||||
}
|
|
||||||
for _, vt := range textData {
|
|
||||||
if v1.GetString("id") != vt.GetString("id") {
|
|
||||||
|
|
||||||
add := true
|
|
||||||
for _, vt1 := range textData {
|
|
||||||
if vt1.GetCeilInt("id") == v1.GetCeilInt("id") {
|
|
||||||
add = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if add {
|
|
||||||
v1["count"] = 1
|
|
||||||
textData = append(textData, v1)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
vt["count"] = vt.GetCeilInt("count") + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qrcode := data.GetSlice("qrcode")
|
|
||||||
for k, _ := range qrcode {
|
|
||||||
v := qrcode.GetString(k)
|
|
||||||
if len(v) < 4 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
vs := that.Db.Select("material", "name,id,content,rule,num", Map{"content[~]": v[:len(v)/2]})
|
|
||||||
for _, v1 := range vs {
|
|
||||||
if len(textData) == 0 {
|
|
||||||
textData = append(textData, v1)
|
|
||||||
}
|
|
||||||
for _, vt := range textData {
|
|
||||||
if v1.GetString("id") != vt.GetString("id") {
|
|
||||||
v1["count"] = 1
|
|
||||||
textData = append(textData, v1)
|
|
||||||
} else {
|
|
||||||
vt["count"] = vt.GetCeilInt("count") + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, textData)
|
|
||||||
|
|
||||||
},
|
|
||||||
"search": func(that *Context) {
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
page := ObjToInt(that.Req.FormValue("page"))
|
|
||||||
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
|
|
||||||
|
|
||||||
if page < 1 {
|
|
||||||
page = 1
|
|
||||||
}
|
|
||||||
if pageSize <= 0 {
|
|
||||||
pageSize = 10
|
|
||||||
}
|
|
||||||
leftJoin := Map{"[><]admin": "material.admin_id=admin.id"}
|
|
||||||
columnStr := "material.id,material.name,material.img,material.count,material.used,material.saved,material.admin_id,admin.name AS admin_name,material.modify_time,material.state"
|
|
||||||
where := Map{"ORDER": "modify_time DESC"}
|
|
||||||
count := that.Db.Count("material", where)
|
|
||||||
reData := that.Db.Page(page, pageSize).
|
|
||||||
PageSelect("material", leftJoin, columnStr, where)
|
|
||||||
|
|
||||||
that.Display(0, Map{"count": count, "data": reData})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,188 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
var material_inoutCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
id := ObjToInt(that.Req.FormValue("id"))
|
|
||||||
if id == 0 {
|
|
||||||
that.Display(3, "请求参数不足,请检查参数")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Get("material_inout", "*", Map{"id": id})
|
|
||||||
|
|
||||||
if re == nil {
|
|
||||||
that.Display(4, "找不到对应信息")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"add": func(that *Context) {
|
|
||||||
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
img := that.Req.FormValue("img")
|
|
||||||
rule := that.Req.FormValue("rule")
|
|
||||||
materialId := ObjToInt(that.Req.FormValue("material_id"))
|
|
||||||
produceId := ObjToInt(that.Req.FormValue("produce_id"))
|
|
||||||
count := ObjToInt(that.Req.FormValue("num"))
|
|
||||||
state := ObjToInt(that.Req.FormValue("state"))
|
|
||||||
|
|
||||||
content := that.Req.FormValue("content")
|
|
||||||
description := that.Req.FormValue("description")
|
|
||||||
|
|
||||||
if rule == "" || materialId == 0 || count == 0 {
|
|
||||||
that.Display(3, "参数不足,请补充参数")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
count1 := count
|
|
||||||
if state > 0 {
|
|
||||||
count = -count
|
|
||||||
}
|
|
||||||
|
|
||||||
produce_material := that.Db.Get("produce_material", "id", Map{"AND": Map{"produce_id": produceId, "material_id": materialId}})
|
|
||||||
if produce_material == nil {
|
|
||||||
that.Db.Insert("produce_material", Map{"produce_id": produceId,
|
|
||||||
"create_time": time.Now().Unix(),
|
|
||||||
"modify_time": time.Now().Unix(),
|
|
||||||
"admin_id": adminID,
|
|
||||||
"material_id": materialId})
|
|
||||||
}
|
|
||||||
if state == 0 {
|
|
||||||
|
|
||||||
that.Db.Update("material", Map{"count[#]": "count+" + ObjToStr(count), "saved[#]": "saved+" + ObjToStr(count)}, Map{"id": materialId})
|
|
||||||
} else {
|
|
||||||
that.Db.Update("material", Map{"count[#]": "count" + ObjToStr(count), "used[#]": "used+" + ObjToStr(-count)}, Map{"id": materialId})
|
|
||||||
}
|
|
||||||
|
|
||||||
material := that.Db.Get("material", "*", Map{"id": materialId})
|
|
||||||
data := Map{
|
|
||||||
"img": img,
|
|
||||||
"rule": rule,
|
|
||||||
"admin_id": adminID,
|
|
||||||
"material_id": materialId,
|
|
||||||
"count": count1,
|
|
||||||
"saved": material.GetCeilInt("count"),
|
|
||||||
"create_time": time.Now().Unix(),
|
|
||||||
"modify_time": time.Now().Unix(),
|
|
||||||
"produce_id": produceId,
|
|
||||||
"description": description,
|
|
||||||
"content": content,
|
|
||||||
"state": state,
|
|
||||||
}
|
|
||||||
id := that.Db.Insert("material_inout", data)
|
|
||||||
|
|
||||||
if id == 0 {
|
|
||||||
that.Display(4, "添加出入库记录失败,请重新添加")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
data["id"] = id
|
|
||||||
|
|
||||||
that.Display(0, data)
|
|
||||||
},
|
|
||||||
"update": func(that *Context) {
|
|
||||||
inData := that.MakeCode.Edit(that.RouterString[1], that.Req)
|
|
||||||
if inData == nil {
|
|
||||||
that.Display(3, "没有找到要更新的数据")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
|
|
||||||
Index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": that.RouterString[2]})
|
|
||||||
parentIndex := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
|
|
||||||
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
|
|
||||||
|
|
||||||
childNodes := that.Db.Select(that.RouterString[1], "id,`index`", Map{"index[~]": "," + that.RouterString[2] + ","})
|
|
||||||
|
|
||||||
for _, v := range childNodes {
|
|
||||||
v["index"] = strings.Replace(v.GetString("index"), Index.GetString("index"), inData.GetString("index"), -1)
|
|
||||||
that.Db.Update(that.RouterString[1], Map{"index": v["index"]}, Map{"id": v.GetCeilInt("id")})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Update(that.RouterString[1], inData, Map{"id": that.RouterString[2]})
|
|
||||||
|
|
||||||
if re == 0 {
|
|
||||||
that.Display(4, "更新数据失败")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"remove": func(that *Context) {
|
|
||||||
inData := that.MakeCode.Delete(that.RouterString[1], that.Req)
|
|
||||||
if inData == nil {
|
|
||||||
that.Display(3, "请求参数不足")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
re := int64(0)
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
if inData.Get("parent_id") != nil && inData.GetSlice("index") != nil {
|
|
||||||
re = that.Db.Delete(that.RouterString[1], Map{"index[~]": "," + that.RouterString[2] + ","})
|
|
||||||
} else {
|
|
||||||
re = that.Db.Delete(that.RouterString[1], Map{"id": that.RouterString[2]})
|
|
||||||
}
|
|
||||||
|
|
||||||
if re == 0 {
|
|
||||||
that.Display(4, "删除数据失败")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
that.Display(0, "删除成功")
|
|
||||||
},
|
|
||||||
|
|
||||||
"search": func(that *Context) {
|
|
||||||
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
page := ObjToInt(that.Req.FormValue("page"))
|
|
||||||
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
|
|
||||||
materialId := ObjToInt(that.Req.FormValue("id"))
|
|
||||||
if page < 1 {
|
|
||||||
page = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if pageSize <= 0 {
|
|
||||||
pageSize = 10
|
|
||||||
}
|
|
||||||
columnStr := "material_inout.id,material_inout.material_id,material.name,material_inout.img,material_inout.count,material_inout.saved,material_inout.admin_id,admin.name AS admin_name,material_inout.modify_time,material_inout.state"
|
|
||||||
leftJoin := Map{"[><]material": "material_inout.material_id=material.id",
|
|
||||||
"[><]admin": "material_inout.admin_id=admin.id",
|
|
||||||
}
|
|
||||||
where := Map{"ORDER": "modify_time DESC"}
|
|
||||||
|
|
||||||
if materialId != 0 {
|
|
||||||
where["material_id"] = materialId
|
|
||||||
}
|
|
||||||
count := that.Db.Count("material_inout", where)
|
|
||||||
reData := that.Db.Page(page, pageSize).
|
|
||||||
PageSelect("material_inout", leftJoin, columnStr, where)
|
|
||||||
|
|
||||||
that.Display(0, Map{"count": count, "data": reData})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,201 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var produceCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
str, inData := that.MakeCode.Info(that.RouterString[1], data, that.Db)
|
|
||||||
where := Map{"id": that.RouterString[2]}
|
|
||||||
|
|
||||||
if len(inData) == 1 {
|
|
||||||
inData["id"] = where["id"]
|
|
||||||
where = Map{"AND": inData}
|
|
||||||
} else if len(inData) > 1 {
|
|
||||||
where["OR"] = inData
|
|
||||||
where = Map{"AND": where}
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Get(that.RouterString[1], str, where)
|
|
||||||
|
|
||||||
if re == nil {
|
|
||||||
that.Display(4, "找不到对应信息")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, v := range re {
|
|
||||||
column := that.MakeCode.TableColumns[that.RouterString[1]][k]
|
|
||||||
if column == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" {
|
|
||||||
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), "id,"+column.GetString("value"), Map{"id": v})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"add": func(that *Context) {
|
|
||||||
inData := that.MakeCode.Add(that.RouterString[1], that.Req)
|
|
||||||
if inData == nil {
|
|
||||||
that.Display(3, "请求参数不足")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Insert(that.RouterString[1], inData)
|
|
||||||
|
|
||||||
if re == 0 {
|
|
||||||
that.Display(4, "无法插入对应数据")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
|
|
||||||
index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
|
|
||||||
inData["index"] = index.GetString("index") + ObjToStr(re) + ","
|
|
||||||
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
|
|
||||||
} else if inData.GetString("index") != "" {
|
|
||||||
inData["index"] = "," + ObjToStr(re) + ","
|
|
||||||
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"update": func(that *Context) {
|
|
||||||
inData := that.MakeCode.Edit(that.RouterString[1], that.Req)
|
|
||||||
if inData == nil {
|
|
||||||
that.Display(3, "没有找到要更新的数据")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
|
|
||||||
Index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": that.RouterString[2]})
|
|
||||||
parentIndex := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
|
|
||||||
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
|
|
||||||
|
|
||||||
childNodes := that.Db.Select(that.RouterString[1], "id,`index`", Map{"index[~]": "," + that.RouterString[2] + ","})
|
|
||||||
|
|
||||||
for _, v := range childNodes {
|
|
||||||
v["index"] = strings.Replace(v.GetString("index"), Index.GetString("index"), inData.GetString("index"), -1)
|
|
||||||
that.Db.Update(that.RouterString[1], Map{"index": v["index"]}, Map{"id": v.GetCeilInt("id")})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Update(that.RouterString[1], inData, Map{"id": that.RouterString[2]})
|
|
||||||
|
|
||||||
if re == 0 {
|
|
||||||
that.Display(4, "更新数据失败")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"remove": func(that *Context) {
|
|
||||||
inData := that.MakeCode.Delete(that.RouterString[1], that.Req)
|
|
||||||
if inData == nil {
|
|
||||||
that.Display(3, "请求参数不足")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
re := int64(0)
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
if inData.Get("parent_id") != nil && inData.GetSlice("index") != nil {
|
|
||||||
re = that.Db.Delete(that.RouterString[1], Map{"index[~]": "," + that.RouterString[2] + ","})
|
|
||||||
} else {
|
|
||||||
re = that.Db.Delete(that.RouterString[1], Map{"id": that.RouterString[2]})
|
|
||||||
}
|
|
||||||
|
|
||||||
if re == 0 {
|
|
||||||
that.Display(4, "删除数据失败")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
that.Display(0, "删除成功")
|
|
||||||
},
|
|
||||||
"check": func(that *Context) {
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
data := ObjToMap(that.Req.FormValue("data"))
|
|
||||||
|
|
||||||
texts := data.GetSlice("text")
|
|
||||||
textData := []Map{}
|
|
||||||
for k, _ := range texts {
|
|
||||||
v := texts.GetString(k)
|
|
||||||
if len(v) < 3 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
vs := that.Db.Select("produce", Map{"[>]product": "produce.product_id=product.id"}, "produce.name,produce.id,produce.product_id,product.name AS product_name,product.rule_check,product.rule_spot_check", Map{"produce.sn[~]": v[:len(v)/2+1]})
|
|
||||||
for _, v1 := range vs {
|
|
||||||
if len(textData) == 0 {
|
|
||||||
textData = append(textData, v1)
|
|
||||||
}
|
|
||||||
for _, vt := range textData {
|
|
||||||
if v1.GetString("id") != vt.GetString("id") {
|
|
||||||
|
|
||||||
add := true
|
|
||||||
for _, vt1 := range textData {
|
|
||||||
if vt1.GetCeilInt("id") == v1.GetCeilInt("id") {
|
|
||||||
add = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if add {
|
|
||||||
v1["count"] = 1
|
|
||||||
textData = append(textData, v1)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
vt["count"] = vt.GetCeilInt("count") + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qrcode := data.GetSlice("qrcode")
|
|
||||||
for k, _ := range qrcode {
|
|
||||||
v := qrcode.GetString(k)
|
|
||||||
if len(v) < 3 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
vs := that.Db.Select("produce", Map{"[>]product": "produce.product_id=product.id"}, "produce.name,produce.id,produce.product_id,product.name AS product_name,product.rule_check,product.rule_spot_check", Map{"produce.sn[~]": v[:len(v)/2+1]})
|
|
||||||
for _, v1 := range vs {
|
|
||||||
if len(textData) == 0 {
|
|
||||||
textData = append(textData, v1)
|
|
||||||
}
|
|
||||||
for _, vt := range textData {
|
|
||||||
if v1.GetString("id") != vt.GetString("id") {
|
|
||||||
v1["count"] = 1
|
|
||||||
textData = append(textData, v1)
|
|
||||||
} else {
|
|
||||||
vt["count"] = vt.GetCeilInt("count") + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, textData)
|
|
||||||
|
|
||||||
},
|
|
||||||
"search": func(that *Context) {
|
|
||||||
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
columnStr := "produce.id,produce.sn,produce.name,produce.state,produce.product_id,product.name AS product_name"
|
|
||||||
where := Map{"produce.state[!]": 0, "ORDER": "produce.modify_time DESC"}
|
|
||||||
|
|
||||||
reData := that.Db.Select("produce", Map{"[>]product": "produce.product_id=product.id"}, columnStr, where)
|
|
||||||
|
|
||||||
that.Display(0, reData)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
var produce_productCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
id := ObjToInt(that.Req.FormValue("id"))
|
|
||||||
sn := that.Req.FormValue("sn")
|
|
||||||
if id == 0 && sn == "" {
|
|
||||||
that.Display(3, "请求参数不足,请检查参数")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
where := Map{}
|
|
||||||
if id != 0 {
|
|
||||||
where["produce_product.id"] = id
|
|
||||||
} else {
|
|
||||||
where["produce_product.sn"] = sn
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Get("produce_product",
|
|
||||||
|
|
||||||
Map{"[><]product": "produce_product.product_id=product.id",
|
|
||||||
"[><]produce": "produce_product.produce_id=produce.id",
|
|
||||||
},
|
|
||||||
"produce_product.id,produce_product.product_id,product.name AS product_name,"+
|
|
||||||
"produce_product.modify_time,produce_product.state,product.rule_spot_check,produce_product.produce_id,produce.name AS produce_name", where)
|
|
||||||
|
|
||||||
if re == nil {
|
|
||||||
that.Display(4, "找不到对应信息")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"add": func(that *Context) {
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
sn := that.Req.FormValue("sn")
|
|
||||||
product_id := ObjToInt(that.Req.FormValue("product_id"))
|
|
||||||
produce_id := ObjToInt(that.Req.FormValue("produce_id"))
|
|
||||||
product_line_id := ObjToInt(that.Req.FormValue("product_line_id"))
|
|
||||||
//state := ObjToInt(that.Req.FormValue("state"))
|
|
||||||
//rule_check := that.Req.FormValue("rule_check")
|
|
||||||
//description := that.Req.FormValue("description")
|
|
||||||
if sn == "" {
|
|
||||||
that.Display(3, "参数不足,请补充参数")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
data := Map{
|
|
||||||
|
|
||||||
"sn": sn,
|
|
||||||
"product_id": product_id,
|
|
||||||
"produce_id": produce_id,
|
|
||||||
"create_time": time.Now().Unix(),
|
|
||||||
"modify_time": time.Now().Unix(),
|
|
||||||
}
|
|
||||||
|
|
||||||
data1 := ObjToMap(data.ToJsonString())
|
|
||||||
data1["product_line_id"] = product_line_id
|
|
||||||
id := that.Db.Insert("produce_product", data1)
|
|
||||||
if id == 0 {
|
|
||||||
that.Display(4, "添加新成品失败,请重新添加")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//data["id"] = id
|
|
||||||
//data["rule"] = rule_check
|
|
||||||
//data["produce_product_id"] = id
|
|
||||||
//data["state"] = state
|
|
||||||
//data["description"] = description
|
|
||||||
//id = that.Db.Insert("product_check", data)
|
|
||||||
//if id == 0 {
|
|
||||||
// that.Display(4, "添加质检失败,请重新添加")
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
that.Display(0, data)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
var productCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
str, inData := that.MakeCode.Info(that.RouterString[1], data, that.Db)
|
|
||||||
where := Map{"id": that.RouterString[2]}
|
|
||||||
|
|
||||||
if len(inData) == 1 {
|
|
||||||
inData["id"] = where["id"]
|
|
||||||
where = Map{"AND": inData}
|
|
||||||
} else if len(inData) > 1 {
|
|
||||||
where["OR"] = inData
|
|
||||||
where = Map{"AND": where}
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Get(that.RouterString[1], str, where)
|
|
||||||
|
|
||||||
if re == nil {
|
|
||||||
that.Display(4, "找不到对应信息")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, v := range re {
|
|
||||||
column := that.MakeCode.TableColumns[that.RouterString[1]][k]
|
|
||||||
if column == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" {
|
|
||||||
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), "id,"+column.GetString("value"), Map{"id": v})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"add": func(that *Context) {
|
|
||||||
inData := that.MakeCode.Add(that.RouterString[1], that.Req)
|
|
||||||
if inData == nil {
|
|
||||||
that.Display(3, "请求参数不足")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Insert(that.RouterString[1], inData)
|
|
||||||
|
|
||||||
if re == 0 {
|
|
||||||
that.Display(4, "无法插入对应数据")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
|
|
||||||
index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
|
|
||||||
inData["index"] = index.GetString("index") + ObjToStr(re) + ","
|
|
||||||
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
|
|
||||||
} else if inData.GetString("index") != "" {
|
|
||||||
inData["index"] = "," + ObjToStr(re) + ","
|
|
||||||
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"update": func(that *Context) {
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
id := ObjToInt(that.Req.FormValue("id"))
|
|
||||||
//抽检更新
|
|
||||||
ruleSpotCheck := that.Req.FormValue("rule_spot_check")
|
|
||||||
if ruleSpotCheck != "" {
|
|
||||||
spotCheckPercentage := ObjToInt(that.Req.FormValue("spot_check_percentage"))
|
|
||||||
if id == 0 || ruleSpotCheck == "" {
|
|
||||||
that.Display(3, "请求参数不足,请检查参数")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Update("product", Map{"rule_spot_check": ruleSpotCheck, "spot_check_percentage": spotCheckPercentage, "modify_time": time.Now().Unix()}, Map{"id": id})
|
|
||||||
if re == 0 {
|
|
||||||
that.Display(4, "更新失败,无法更新抽检参数")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//质检更新
|
|
||||||
ruleCheck := that.Req.FormValue("rule_check")
|
|
||||||
if id == 0 || ruleCheck == "" {
|
|
||||||
that.Display(3, "请求参数不足,请检查参数")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Update("product", Map{"rule_check": ruleCheck, "modify_time": time.Now().Unix()}, Map{"id": id})
|
|
||||||
|
|
||||||
if re == 0 {
|
|
||||||
that.Display(4, "更新失败,无法更新质检参数")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, "更新成功")
|
|
||||||
},
|
|
||||||
|
|
||||||
"search": func(that *Context) {
|
|
||||||
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
page := ObjToInt(that.Req.FormValue("page"))
|
|
||||||
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
|
|
||||||
|
|
||||||
if page < 1 {
|
|
||||||
page = 1
|
|
||||||
}
|
|
||||||
if pageSize <= 0 {
|
|
||||||
pageSize = 10
|
|
||||||
}
|
|
||||||
|
|
||||||
leftJoin := Map{"[><]admin": "product.admin_id=admin.id"}
|
|
||||||
columnStr := "product.id,product.name,product.img,product.count,product.used,product.saved,product.spot_check_count,product.admin_id,admin.name AS admin_name,product.modify_time,product.state"
|
|
||||||
where := Map{"ORDER": "modify_time DESC"}
|
|
||||||
count := that.Db.Count("product", where)
|
|
||||||
reData := that.Db.Page(page, pageSize).
|
|
||||||
PageSelect("product", leftJoin, columnStr, where)
|
|
||||||
|
|
||||||
that.Display(0, Map{"count": count, "data": reData})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var product_lineCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
str, inData := that.MakeCode.Info(that.RouterString[1], data, that.Db)
|
|
||||||
where := Map{"id": that.RouterString[2]}
|
|
||||||
|
|
||||||
if len(inData) == 1 {
|
|
||||||
inData["id"] = where["id"]
|
|
||||||
where = Map{"AND": inData}
|
|
||||||
} else if len(inData) > 1 {
|
|
||||||
where["OR"] = inData
|
|
||||||
where = Map{"AND": where}
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Get(that.RouterString[1], str, where)
|
|
||||||
|
|
||||||
if re == nil {
|
|
||||||
that.Display(4, "找不到对应信息")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, v := range re {
|
|
||||||
column := that.MakeCode.TableColumns[that.RouterString[1]][k]
|
|
||||||
if column == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" {
|
|
||||||
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), "id,"+column.GetString("value"), Map{"id": v})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"add": func(that *Context) {
|
|
||||||
inData := that.MakeCode.Add(that.RouterString[1], that.Req)
|
|
||||||
if inData == nil {
|
|
||||||
that.Display(3, "请求参数不足")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Insert(that.RouterString[1], inData)
|
|
||||||
|
|
||||||
if re == 0 {
|
|
||||||
that.Display(4, "无法插入对应数据")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
|
|
||||||
index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
|
|
||||||
inData["index"] = index.GetString("index") + ObjToStr(re) + ","
|
|
||||||
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
|
|
||||||
} else if inData.GetString("index") != "" {
|
|
||||||
inData["index"] = "," + ObjToStr(re) + ","
|
|
||||||
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"update": func(that *Context) {
|
|
||||||
inData := that.MakeCode.Edit(that.RouterString[1], that.Req)
|
|
||||||
if inData == nil {
|
|
||||||
that.Display(3, "没有找到要更新的数据")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
|
|
||||||
Index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": that.RouterString[2]})
|
|
||||||
parentIndex := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
|
|
||||||
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
|
|
||||||
|
|
||||||
childNodes := that.Db.Select(that.RouterString[1], "id,`index`", Map{"index[~]": "," + that.RouterString[2] + ","})
|
|
||||||
|
|
||||||
for _, v := range childNodes {
|
|
||||||
v["index"] = strings.Replace(v.GetString("index"), Index.GetString("index"), inData.GetString("index"), -1)
|
|
||||||
that.Db.Update(that.RouterString[1], Map{"index": v["index"]}, Map{"id": v.GetCeilInt("id")})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Update(that.RouterString[1], inData, Map{"id": that.RouterString[2]})
|
|
||||||
|
|
||||||
if re == 0 {
|
|
||||||
that.Display(4, "更新数据失败")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"remove": func(that *Context) {
|
|
||||||
inData := that.MakeCode.Delete(that.RouterString[1], that.Req)
|
|
||||||
if inData == nil {
|
|
||||||
that.Display(3, "请求参数不足")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
re := int64(0)
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
if inData.Get("parent_id") != nil && inData.GetSlice("index") != nil {
|
|
||||||
re = that.Db.Delete(that.RouterString[1], Map{"index[~]": "," + that.RouterString[2] + ","})
|
|
||||||
} else {
|
|
||||||
re = that.Db.Delete(that.RouterString[1], Map{"id": that.RouterString[2]})
|
|
||||||
}
|
|
||||||
|
|
||||||
if re == 0 {
|
|
||||||
that.Display(4, "删除数据失败")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
that.Display(0, "删除成功")
|
|
||||||
},
|
|
||||||
|
|
||||||
"search": func(that *Context) {
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//page := ObjToInt(that.Req.FormValue("page"))
|
|
||||||
//pageSize := ObjToInt(that.Req.FormValue("pageSize"))
|
|
||||||
//
|
|
||||||
//if page < 1 {
|
|
||||||
// page = 1
|
|
||||||
//}
|
|
||||||
//if pageSize <= 0 {
|
|
||||||
// pageSize = 10
|
|
||||||
//}
|
|
||||||
|
|
||||||
//leftJoin := Map{"[><]admin": "product.admin_id=admin.id"}
|
|
||||||
|
|
||||||
where := Map{"state": 0, "ORDER": "modify_time DESC"}
|
|
||||||
//count := that.Db.Count("product", where)
|
|
||||||
reData := that.Db.Select("product_line", "*", where)
|
|
||||||
|
|
||||||
that.Display(0, reData)
|
|
||||||
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
var product_spot_checkCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
id := ObjToInt(that.Req.FormValue("id"))
|
|
||||||
if id == 0 {
|
|
||||||
that.Display(3, "请求参数不足,请检查参数")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
re := that.Db.Get("product_spot_check",
|
|
||||||
|
|
||||||
Map{"[><]product": "product_spot_check.product_id=product.id",
|
|
||||||
"[><]produce": "product_spot_check.produce_id=produce.id",
|
|
||||||
},
|
|
||||||
"id,img,product_id,product.name AS product_name,admin_id,"+
|
|
||||||
"modify_time,state,rule,produce_id,produce.name AS produce_name", Map{"id": id})
|
|
||||||
|
|
||||||
if re == nil {
|
|
||||||
that.Display(4, "找不到对应信息")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
that.Display(0, re)
|
|
||||||
},
|
|
||||||
"add": func(that *Context) {
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//img := that.Req.FormValue("img")
|
|
||||||
sn := that.Req.FormValue("sn")
|
|
||||||
rule := that.Req.FormValue("rule_spot_check")
|
|
||||||
description := that.Req.FormValue("description")
|
|
||||||
produceProductId := ObjToInt(that.Req.FormValue("produce_product_id"))
|
|
||||||
|
|
||||||
//count := ObjToInt(that.Req.FormValue("count"))
|
|
||||||
state := ObjToInt(that.Req.FormValue("state"))
|
|
||||||
if rule == "" || produceProductId == 0 {
|
|
||||||
that.Display(3, "参数不足,请补充参数")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
produceProduct := that.Db.Get("produce_product", "*", Map{"id": produceProductId})
|
|
||||||
if produceProduct == nil {
|
|
||||||
that.Display(4, "找不到成品记录,无法进行抽检")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//判断是否已经抽检了
|
|
||||||
alreadyCheck := that.Db.Get("product_spot_check", "id", Map{"produce_product_id": produceProductId})
|
|
||||||
|
|
||||||
if alreadyCheck == nil {
|
|
||||||
|
|
||||||
that.Db.Update("product", Map{"spot_check_count[#]": "spot_check_count+1"},
|
|
||||||
Map{"id": produceProduct.GetCeilInt("product_id")})
|
|
||||||
|
|
||||||
that.Db.Update("produce", Map{"spot_check_count[#]": "spot_check_count+1"},
|
|
||||||
Map{"id": produceProduct.GetCeilInt("produce_id")})
|
|
||||||
}
|
|
||||||
|
|
||||||
data := Map{
|
|
||||||
"sn": sn,
|
|
||||||
"rule": rule,
|
|
||||||
"admin_id": adminID,
|
|
||||||
"create_time": time.Now().Unix(),
|
|
||||||
"modify_time": time.Now().Unix(),
|
|
||||||
"product_id": produceProduct.GetCeilInt("product_id"),
|
|
||||||
"produce_id": produceProduct.GetCeilInt("produce_id"),
|
|
||||||
"produce_product_id": produceProductId,
|
|
||||||
"description": description,
|
|
||||||
"state": state,
|
|
||||||
}
|
|
||||||
|
|
||||||
id := that.Db.Insert("product_spot_check", data)
|
|
||||||
if id == 0 {
|
|
||||||
that.Display(4, "添加抽检记录失败,请重新添加")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
data["id"] = id
|
|
||||||
|
|
||||||
that.Display(0, data)
|
|
||||||
},
|
|
||||||
"search": func(that *Context) {
|
|
||||||
|
|
||||||
adminID := that.Session("id").ToInt()
|
|
||||||
|
|
||||||
if adminID == 0 {
|
|
||||||
that.Display(2, "登录失效,请重新登录")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
page := ObjToInt(that.Req.FormValue("page"))
|
|
||||||
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
|
|
||||||
productId := ObjToInt(that.Req.FormValue("id"))
|
|
||||||
|
|
||||||
if page < 1 {
|
|
||||||
page = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if pageSize <= 0 {
|
|
||||||
pageSize = 10
|
|
||||||
}
|
|
||||||
|
|
||||||
columnStr := "product_spot_check.id,product_spot_check.product_id,product_spot_check.sn,product.name,product_spot_check.img,product_spot_check.admin_id,admin.name AS admin_name,product_spot_check.modify_time,product_spot_check.state"
|
|
||||||
leftJoin := Map{"[><]product": "product_spot_check.product_id=product.id",
|
|
||||||
"[><]admin": "product_spot_check.admin_id=admin.id",
|
|
||||||
}
|
|
||||||
|
|
||||||
where := Map{"ORDER": "id DESC"}
|
|
||||||
|
|
||||||
if productId != 0 {
|
|
||||||
where["product_id"] = productId
|
|
||||||
}
|
|
||||||
|
|
||||||
count := that.Db.Count("product_spot_check", where)
|
|
||||||
|
|
||||||
reData := that.Db.Page(page, pageSize).
|
|
||||||
PageSelect("product_spot_check", leftJoin, columnStr, where)
|
|
||||||
|
|
||||||
that.Display(0, Map{"count": count, "data": reData})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
"../../dri/ddsms"
|
|
||||||
)
|
|
||||||
|
|
||||||
var Sms = Ctr{
|
|
||||||
//只允许微信验证过的或者登录成功的发送短信
|
|
||||||
"send": func(this *Context) {
|
|
||||||
//if this.Session("uid").Data == nil && this.Session("wechatInfo").Data == nil {
|
|
||||||
// this.Display(2, "没有授权")
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
if len(this.Req.FormValue("token")) != 32 {
|
|
||||||
this.Display(2, "没有授权")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
phone := this.Req.FormValue("phone")
|
|
||||||
if len(phone) < 11 {
|
|
||||||
this.Display(3, "手机号格式错误")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
code := getCode()
|
|
||||||
this.Session("phone", phone)
|
|
||||||
this.Session("code", code)
|
|
||||||
|
|
||||||
ddsms.DefaultDDY.SendYZM(phone, this.Config.GetString("smsLogin"), map[string]string{"code": code})
|
|
||||||
|
|
||||||
this.Display(0, "发送成功")
|
|
||||||
},
|
|
||||||
}
|
|
||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"avatarPath": "avatar/2006/01/02/",
|
||||||
"cache": {
|
"cache": {
|
||||||
"db": {
|
"db": {
|
||||||
"db": false,
|
"db": false,
|
||||||
@@ -24,7 +25,7 @@
|
|||||||
"db": {
|
"db": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"host": "192.168.6.253",
|
"host": "192.168.6.253",
|
||||||
"name": "myhs",
|
"name": "iedc_dev",
|
||||||
"password": "dasda8454456",
|
"password": "dasda8454456",
|
||||||
"port": "3306",
|
"port": "3306",
|
||||||
"prefix": "",
|
"prefix": "",
|
||||||
@@ -42,8 +43,14 @@
|
|||||||
"4": "数据处理异常",
|
"4": "数据处理异常",
|
||||||
"5": "数据结果异常"
|
"5": "数据结果异常"
|
||||||
},
|
},
|
||||||
|
"imgPath": "img/2006/01/02/",
|
||||||
"mode": 3,
|
"mode": 3,
|
||||||
"port": "8080",
|
"port": "8081",
|
||||||
"sessionName": "HOTIME",
|
"sessionName": "HOTIME",
|
||||||
"tpt": "tpt"
|
"smsKey": "b0eb4bf0198b9983cffcb85b69fdf4fa",
|
||||||
|
"smsLogin": "【政企超链接】您的验证码为:{code},请在5分钟内使用,切勿将验证码泄露于他人,如非本人操作请忽略。",
|
||||||
|
"tpt": "tpt",
|
||||||
|
"wechatAppID": "wx2edb802f5c3ae1ae",
|
||||||
|
"wechatAppSecret": "4ff97e523c3de6bad47051b568522386",
|
||||||
|
"wxFilePath": "wxfile/2006/01/02/"
|
||||||
}
|
}
|
||||||
Binary file not shown.
+2
-18
@@ -1,9 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"../../hotime"
|
"code.hoteas.com/golang/hotime"
|
||||||
"../dri/ddsms"
|
|
||||||
"./app"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -13,19 +11,5 @@ func main() {
|
|||||||
fmt.Println(date, date.Unix())
|
fmt.Println(date, date.Unix())
|
||||||
//fmt.Println("0123456"[1:7])
|
//fmt.Println("0123456"[1:7])
|
||||||
appIns := hotime.Init("config/config.json")
|
appIns := hotime.Init("config/config.json")
|
||||||
//RESTfull接口适配
|
appIns.Run(hotime.Router{})
|
||||||
appIns.SetConnectListener(func(context *hotime.Context) bool {
|
|
||||||
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
//makeCode := code.MakeCode{}
|
|
||||||
//fmt.Println(common.ObjToStr(makeCode.Db2JSON("admin","test",appIns.Db)))
|
|
||||||
if ddsms.DefaultDDY.ApiKey == "" {
|
|
||||||
ddsms.DefaultDDY.Init(appIns.Config.GetString("smsKey"))
|
|
||||||
}
|
|
||||||
|
|
||||||
appIns.Run(hotime.Router{
|
|
||||||
"app": app.Project,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
|||||||
.left-nav-home-bar{background:#2c3759!important}.left-nav-home-bar,.left-nav-home-bar i{color:#fff!important}.el-submenu .el-menu-item{height:40px;line-height:40px}.el-menu .el-submenu__title{height:46px;line-height:46px}.left-nav-home-bar i{margin-bottom:6px!important}.el-menu-item-group__title{padding:0 0 0 20px}.head-left[data-v-297b6686],.head-right[data-v-297b6686]{display:flex;justify-content:center;flex-direction:column}.head-right[data-v-297b6686]{align-items:flex-end}.el-upload{height:100px;width:100px}.el-upload img[data-v-012633a9]{height:100%;width:100%;-o-object-fit:cover;object-fit:cover;display:block}.el-upload i[data-v-012633a9]{font-size:40px;margin:30% 31%;display:block}.form-file-item .upload-file .el-upload{width:100px;height:auto;line-height:0;background-color:transparent}.form-file-item .el-button--small{height:32px}.el-input-number--mini{width:100px;margin-right:5px}.el-input-number--mini .el-input{width:100px!important}.basic-form{width:400px}.basic-form .el-input,.basic-form .el-select{width:84px;margin-right:5px}.form-file-item{margin-bottom:5px}.form-file-item .el-upload{width:60px;height:60px;line-height:60px}.form-file-item .file-item .name{width:100px}.form-file-item .name{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.form-list .form-common-item{display:flex;margin-bottom:5px}.form-common-item .name,.form-common-item .value{width:88px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.select-list .select-list-item{display:flex;margin-bottom:5px}.select-list-item .name{width:76px}.select-list-item .name,.select-list-item .value{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.select-list-item .value{width:77px}.select-wrap{text-align:left;margin-bottom:5px}.select-wrap .select-add-name{display:inline-block;width:87px;text-align:right}.select-wrap .el-input{width:84px}.el-input__inner{padding-left:10px;padding-right:5px}.el-upload{height:60px;width:60px;background:#eee;overflow:hidden}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
.not-show-tab-label .el-tabs__header,.not-show-tab-search{display:none}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
.el-upload{height:100px;width:100px}.el-upload img[data-v-012633a9]{height:100%;width:100%;-o-object-fit:cover;object-fit:cover;display:block}.el-upload i[data-v-012633a9]{font-size:40px;margin:30% 31%;display:block}.form-file-item .upload-file .el-upload{width:100px;height:auto;line-height:0;background-color:transparent}.form-file-item .el-button--small{height:32px}.el-input-number--mini{width:100px;margin-right:5px}.el-input-number--mini .el-input{width:100px!important}.basic-form{width:400px}.basic-form .el-input,.basic-form .el-select{width:84px;margin-right:5px}.form-file-item{margin-bottom:5px}.form-file-item .el-upload{width:60px;height:60px;line-height:60px}.form-file-item .file-item .name{width:100px}.form-file-item .name{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.form-list .form-common-item{display:flex;margin-bottom:5px}.form-common-item .name,.form-common-item .value{width:88px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.select-list .select-list-item{display:flex;margin-bottom:5px}.select-list-item .name{width:76px}.select-list-item .name,.select-list-item .value{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.select-list-item .value{width:77px}.select-wrap{text-align:left;margin-bottom:5px}.select-wrap .select-add-name{display:inline-block;width:87px;text-align:right}.select-wrap .el-input{width:84px}.el-input__inner{padding-left:10px;padding-right:5px}.el-upload{height:60px;width:60px;background:#eee;overflow:hidden}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
body[data-v-581864d3],dd[data-v-581864d3],dl[data-v-581864d3],form[data-v-581864d3],h1[data-v-581864d3],h2[data-v-581864d3],h3[data-v-581864d3],h4[data-v-581864d3],h5[data-v-581864d3],h6[data-v-581864d3],html[data-v-581864d3],ol[data-v-581864d3],p[data-v-581864d3],pre[data-v-581864d3],tbody[data-v-581864d3],textarea[data-v-581864d3],tfoot[data-v-581864d3],thead[data-v-581864d3],ul[data-v-581864d3]{margin:0;font-size:14px;font-family:Microsoft YaHei}dl[data-v-581864d3],ol[data-v-581864d3],ul[data-v-581864d3]{padding:0}li[data-v-581864d3]{list-style:none}input[data-v-581864d3]{border:none;outline:none;font-family:Microsoft YaHei;background-color:#fff}a[data-v-581864d3]{font-family:Microsoft YaHei;text-decoration:none}[data-v-581864d3]{margin:0;padding:0}.login[data-v-581864d3]{position:relative;width:100%;height:100%;background-color:#353d56}.login-item[data-v-581864d3]{position:absolute;top:calc(50% - 244px);left:calc(50% - 244px);width:488px;height:488px;padding:80px 0 152px 0;box-sizing:border-box;background-size:468px 468px}.login-item .left-title[data-v-581864d3]{display:inline-block;width:236px;height:100%;border-right:2px solid #88919e;text-align:center;padding-top:68px;box-sizing:border-box}.login-item .left-title p[data-v-581864d3]{font-size:30px;line-height:50px;color:#fff}.login-item .right-content[data-v-581864d3]{display:inline-block;vertical-align:top;padding-left:42px;box-sizing:border-box}.login-item .right-content .login-title[data-v-581864d3]{font-size:16px;color:#fff}.errorMsg[data-v-581864d3]{width:100%;height:34px;line-height:34px;color:red;font-size:14px;overflow:hidden}.login-item .right-content .inputWrap[data-v-581864d3]{width:204px;height:36px;line-height:36px;color:#99a3b2;font-size:14px;border-bottom:3px solid #98a2b1;margin-bottom:10px}.login-item .right-content .inputWrap input[data-v-581864d3]{background-color:transparent;color:#99a3b2}.login-btn[data-v-581864d3]{width:88px;height:36px;text-align:center;line-height:36px;font-size:14px;color:#fff;background-color:#4f619b;border-radius:18px;margin-top:60px;cursor:pointer}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
.form-file-item .upload-file .el-upload{width:100px;height:auto;line-height:0;background-color:transparent}.form-file-item .el-button--small{height:32px}.el-input-number--mini{width:100px;margin-right:5px}.el-input-number--mini .el-input{width:100px!important}.basic-form{width:400px}.basic-form .el-input,.basic-form .el-select{width:84px;margin-right:5px}.form-file-item{margin-bottom:5px}.form-file-item .el-upload{width:60px;height:60px;line-height:60px}.form-file-item .file-item .name{width:100px}.form-file-item .name{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.form-list .form-common-item{display:flex;margin-bottom:5px}.form-common-item .name,.form-common-item .value{width:88px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.select-list .select-list-item{display:flex;margin-bottom:5px}.select-list-item .name{width:76px}.select-list-item .name,.select-list-item .value{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.select-list-item .value{width:77px}.select-wrap{text-align:left;margin-bottom:5px}.select-wrap .select-add-name{display:inline-block;width:87px;text-align:right}.select-wrap .el-input{width:84px}.el-input__inner{padding-left:10px;padding-right:5px}.el-upload,.el-upload-list--picture-card .el-upload-list__item{height:60px;width:60px}.el-upload-list__item.is-success.focusing .el-icon-close-tip{display:none!important}.el-upload{height:100px;width:100px;background:#eee;overflow:hidden}.file-upload .el-upload{background:transparent;width:100%;height:auto;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.file-upload .el-upload .el-button{margin-right:10px}.el-upload img[data-v-4b440c12]{height:100%;width:100%;-o-object-fit:cover;object-fit:cover;display:block}.el-upload i[data-v-4b440c12]{font-size:40px;margin:30% 31%;display:block}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
h3[data-v-28af1b93]{margin:40px 0 0}ul[data-v-28af1b93]{list-style-type:none;padding:0}li[data-v-28af1b93]{display:inline-block;margin:0 10px}a[data-v-28af1b93]{color:#42b983}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 66 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 297 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 120 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 50 KiB |
Binary file not shown.
Binary file not shown.
@@ -1,3 +0,0 @@
|
|||||||
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title></title><style>body{
|
|
||||||
margin: 0px;
|
|
||||||
}</style><link href="css/chunk-2b8aef56.7087d841.css" rel="prefetch"><link href="css/chunk-38db7d04.2b6ce0ac.css" rel="prefetch"><link href="css/chunk-5c99f384.31e35517.css" rel="prefetch"><link href="css/chunk-60f282ff.83752cba.css" rel="prefetch"><link href="css/chunk-a74869b6.c460e209.css" rel="prefetch"><link href="css/chunk-d1a9ebe6.5cc24c46.css" rel="prefetch"><link href="js/chunk-28c289a1.0ed6fefe.js" rel="prefetch"><link href="js/chunk-2b8aef56.8330998b.js" rel="prefetch"><link href="js/chunk-2c065dd6.d9c3e429.js" rel="prefetch"><link href="js/chunk-38db7d04.18ee879a.js" rel="prefetch"><link href="js/chunk-58db4e7f.c298e695.js" rel="prefetch"><link href="js/chunk-5c99f384.be52d852.js" rel="prefetch"><link href="js/chunk-60f282ff.cbb91cc0.js" rel="prefetch"><link href="js/chunk-78ba61e2.520b239c.js" rel="prefetch"><link href="js/chunk-a74869b6.01e5db7b.js" rel="prefetch"><link href="js/chunk-d1a9ebe6.fba0f501.js" rel="prefetch"><link href="css/app.5e2eb449.css" rel="preload" as="style"><link href="js/app.c87636c4.js" rel="preload" as="script"><link href="css/app.5e2eb449.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but hotime doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/app.c87636c4.js"></script></body></html>
|
|
||||||
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 +0,0 @@
|
|||||||
(window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-2c065dd6"],{1:function(t,e){},2934:function(t,e,n){"use strict";n.d(e,"e",function(){return o}),n.d(e,"d",function(){return a}),n.d(e,"b",function(){return s}),n.d(e,"c",function(){return u}),n.d(e,"a",function(){return c}),n.d(e,"f",function(){return d});var e=n("b0c0"),r=n("b775"),e=n("4328"),i=n.n(e);function o(t,e){return Object(r.b)({url:t,method:"GET",params:e})}function a(t,e){return Object(r.b)({url:t,method:"GET",params:e})}function s(t,e){return Object(r.b)({url:t,method:"DELETE",data:i.a.stringify(e)})}function u(t,e){return Object(r.b)({url:t,method:"PUT",data:i.a.stringify(e)})}function c(t,e){return Object(r.b)({url:t,method:"POST",data:i.a.stringify(e)})}function d(t){var e=new FormData;return e.append("file",t,t.name),Object(r.b)({url:"file",headers:{"Content-Type":"multipart/form-data"},method:"POST",data:e})}},"83c5":function(t,e,n){"use strict";n("159b");e.a={list:{},constructor:function(){this.list={}},$on:function(t,e){this.list[t]=this.list[t]||[],this.list[t].push(e)},$emit:function(t,e){this.list[t]&&this.list[t].forEach(function(t){t(e)})},$off:function(t){this.list[t]&&delete this.list[t]}}},b775:function(t,e,n){"use strict";n.d(e,"a",function(){return u});var r=n("d3b7"),i=n("bc3a"),r=n.n(i),i=n("4328"),o=n.n(i),a=n("2bea"),s=n("56d7"),u="";r.a.defaults.withCredentials=!0,r.a.defaults.headers.post["Content-Type"]="application/x-www-form-urlencoded;charset=UTF-8";r=r.a.create({baseURL:u,timeout:2e4});r.interceptors.request.use(function(t){return"get"===t.method&&(t.paramsSerializer=function(t){return o.a.stringify(t,{arrayFormat:"repeat"})}),t.withCredentials=!0,t},function(t){Promise.reject(t)}),r.interceptors.response.use(function(t){return 2!==t.data.statu?t.data:(a.b.Message({showClose:!0,message:"登录信息丢失,请重新登陆!",type:"error",duration:2e3,offset:100}),void s.app.$router.push({path:"/login"}))},function(t){var e="err:"+t,n={};return t.response?n=t.response.data:(-1!=e.indexOf("timeout")?(n.code=500,n.message="请求超时,请稍后再试"):-1!=e.indexOf("Network Error")?(n.code=500,n.message="网络错误,请稍后再试"):(n.code=500,n.message=""+t),n)}),e.b=r}}]);
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
|||||||
(window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-58db4e7f"],{"159b":function(c,n,o){var r,t=o("da84"),a=o("fdbc"),f=o("17c2"),i=o("9112");for(r in a){var u=t[r],u=u&&u.prototype;if(u&&u.forEach!==f)try{i(u,"forEach",f)}catch(c){u.forEach=f}}},"17c2":function(c,n,o){"use strict";var r=o("b727").forEach,o=o("a640")("forEach");c.exports=o?[].forEach:function(c){return r(this,c,1<arguments.length?arguments[1]:void 0)}},a640:function(c,n,o){"use strict";var r=o("d039");c.exports=function(c,n){var o=[][c];return!!o&&r(function(){o.call(null,n||function(){throw 1},1)})}}}]);
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
|||||||
(window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-a74869b6"],{1:function(t,e){},2934:function(t,e,n){"use strict";n.d(e,"e",function(){return a}),n.d(e,"d",function(){return s}),n.d(e,"b",function(){return i}),n.d(e,"c",function(){return c}),n.d(e,"a",function(){return u}),n.d(e,"f",function(){return d});var e=n("b0c0"),o=n("b775"),e=n("4328"),r=n.n(e);function a(t,e){return Object(o.b)({url:t,method:"GET",params:e})}function s(t,e){return Object(o.b)({url:t,method:"GET",params:e})}function i(t,e){return Object(o.b)({url:t,method:"DELETE",data:r.a.stringify(e)})}function c(t,e){return Object(o.b)({url:t,method:"PUT",data:r.a.stringify(e)})}function u(t,e){return Object(o.b)({url:t,method:"POST",data:r.a.stringify(e)})}function d(t){var e=new FormData;return e.append("file",t,t.name),Object(o.b)({url:"file",headers:{"Content-Type":"multipart/form-data"},method:"POST",data:e})}},"40a7":function(t,e,n){},"578a":function(t,e,n){"use strict";n.r(e);n("b0c0");var s=n("9f9f");Object(s.O)("data-v-581864d3");var i={class:"login",style:{width:"100%",height:"100vh"}},c={class:"login-item"},u={class:"left-title"},d={class:"right-content"},l=Object(s.o)("p",{class:"login-title"},"登录",-1),f={style:{height:"40px"}},b={class:"inputWrap"},p=Object(s.r)(" 账号:"),m={class:"inputWrap"},h=Object(s.r)(" 密码:");Object(s.M)();var o=n("2934"),r={name:"Login",data:function(){return{showLog:!1,showLogInfo:"",label:"HoTime DashBoard",form:{name:"",password:""}}},methods:{login:function(){var e=this;if(""==this.name||""==this.password)return this.showLogInfo="参数不足!",void(this.showLog=!0);Object(o.a)(window.Hotime.data.name+"/hotime/login",e.form).then(function(t){return 0!=t.status?(e.showLogInfo=t.error.msg,void(e.showLog=!0)):void e.$router.push({path:"/"})})}},mounted:function(){this.label=window.Hotime.data.label}};n("8d39");r.render=function(t,e,n,o,r,a){return Object(s.L)(),Object(s.n)("div",i,[Object(s.o)("div",c,[Object(s.o)("div",u,[Object(s.o)("p",null,Object(s.Y)(r.label),1)]),Object(s.o)("div",d,[l,Object(s.o)("div",f,[Object(s.kb)(Object(s.o)("p",{class:"errorMsg"},Object(s.Y)(r.showLogInfo),513),[[s.gb,r.showLog]])]),Object(s.o)("p",b,[p,Object(s.kb)(Object(s.o)("input",{type:"text","onUpdate:modelValue":e[0]||(e[0]=function(t){return r.form.name=t}),class:"accountVal"},null,512),[[s.fb,r.form.name]])]),Object(s.o)("p",m,[h,Object(s.kb)(Object(s.o)("input",{type:"password","onUpdate:modelValue":e[1]||(e[1]=function(t){return r.form.password=t}),class:"passwordVal"},null,512),[[s.fb,r.form.password]])]),Object(s.o)("p",{class:"login-btn",onClick:e[2]||(e[2]=function(){return a.login&&a.login.apply(a,arguments)})},"登录")])])])},r.__scopeId="data-v-581864d3";e.default=r},"8d39":function(t,e,n){"use strict";n("40a7")},b775:function(t,e,n){"use strict";n.d(e,"a",function(){return c});var o=n("d3b7"),r=n("bc3a"),o=n.n(r),r=n("4328"),a=n.n(r),s=n("2bea"),i=n("56d7"),c="";o.a.defaults.withCredentials=!0,o.a.defaults.headers.post["Content-Type"]="application/x-www-form-urlencoded;charset=UTF-8";o=o.a.create({baseURL:c,timeout:2e4});o.interceptors.request.use(function(t){return"get"===t.method&&(t.paramsSerializer=function(t){return a.a.stringify(t,{arrayFormat:"repeat"})}),t.withCredentials=!0,t},function(t){Promise.reject(t)}),o.interceptors.response.use(function(t){return 2!==t.data.statu?t.data:(s.b.Message({showClose:!0,message:"登录信息丢失,请重新登陆!",type:"error",duration:2e3,offset:100}),void i.app.$router.push({path:"/login"}))},function(t){var e="err:"+t,n={};return t.response?n=t.response.data:(-1!=e.indexOf("timeout")?(n.code=500,n.message="请求超时,请稍后再试"):-1!=e.indexOf("Network Error")?(n.code=500,n.message="网络错误,请稍后再试"):(n.code=500,n.message=""+t),n)}),e.b=o}}]);
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
|||||||
(window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-d1a9ebe6"],{"587e":function(a,e,t){"use strict";t.r(e);var n=t("9f9f");Object(n.O)("data-v-28af1b93");var v={class:"hello"},b=Object(n.q)('<p data-v-28af1b93> For a guide and recipes on how to configure / customize this project,<br data-v-28af1b93> check out the <a href="https://cli.vuejs.org" target="_blank" rel="noopener" data-v-28af1b93>vue-cli documentation</a>. </p><h3 data-v-28af1b93>Installed CLI Plugins</h3><ul data-v-28af1b93><li data-v-28af1b93><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener" data-v-28af1b93>babel</a></li><li data-v-28af1b93><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener" data-v-28af1b93>eslint</a></li></ul><h3 data-v-28af1b93>Essential Links</h3><ul data-v-28af1b93><li data-v-28af1b93><a href="https://vuejs.org" target="_blank" rel="noopener" data-v-28af1b93>Core Docs</a></li><li data-v-28af1b93><a href="https://forum.vuejs.org" target="_blank" rel="noopener" data-v-28af1b93>Forum</a></li><li data-v-28af1b93><a href="https://chat.vuejs.org" target="_blank" rel="noopener" data-v-28af1b93>Community Chat</a></li><li data-v-28af1b93><a href="https://twitter.com/vuejs" target="_blank" rel="noopener" data-v-28af1b93>Twitter</a></li><li data-v-28af1b93><a href="https://news.vuejs.org" target="_blank" rel="noopener" data-v-28af1b93>News</a></li></ul><h3 data-v-28af1b93>Ecosystem</h3><ul data-v-28af1b93><li data-v-28af1b93><a href="https://router.vuejs.org" target="_blank" rel="noopener" data-v-28af1b93>vue-router</a></li><li data-v-28af1b93><a href="https://vuex.vuejs.org" target="_blank" rel="noopener" data-v-28af1b93>vuex</a></li><li data-v-28af1b93><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener" data-v-28af1b93>vue-devtools</a></li><li data-v-28af1b93><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener" data-v-28af1b93>vue-loader</a></li><li data-v-28af1b93><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener" data-v-28af1b93>awesome-vue</a></li></ul>',7);Object(n.M)();var r={name:"HelloWorld",props:{msg:String}};t("6fe9");r.render=function(a,e,t,r,l,o){return Object(n.L)(),Object(n.n)("div",v,[Object(n.o)("h1",null,Object(n.Y)(t.msg),1),b])},r.__scopeId="data-v-28af1b93";e.default=r},"6fe9":function(a,e,t){"use strict";t("e8a7")},e8a7:function(a,e,t){}}]);
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
module code.hoteas.com/golang/hotime
|
||||||
|
|
||||||
|
go 1.16
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/garyburd/redigo v1.6.3
|
||||||
|
github.com/go-sql-driver/mysql v1.6.0
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.12
|
||||||
|
github.com/sirupsen/logrus v1.8.1
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.364
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.364
|
||||||
|
golang.org/x/net v0.0.0-20220225172249-27dd8689420f
|
||||||
|
)
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/garyburd/redigo v1.6.3 h1:HCeeRluvAgMusMomi1+6Y5dmFOdYV/JzoRrrbFlkGIc=
|
||||||
|
github.com/garyburd/redigo v1.6.3/go.mod h1:rTb6epsqigu3kYKBnaF028A7Tf/Aw5s0cqA47doKKqw=
|
||||||
|
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
||||||
|
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.12 h1:TJ1bhYJPV44phC+IMu1u2K/i5RriLTPe+yc68XDJ1Z0=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||||
|
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||||
|
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||||
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.364 h1:X1Jws4XqrTH+p7FBQ7BpjW4qFXObKHWm0/XhW/GvqRs=
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.364/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.364 h1:kbor60vo37v7Hu+i17gooox9Rw281fVHNna8zwtDG1w=
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.364/go.mod h1:LeIUBOLhc+Y5YCEpZrULPD9lgoXXV4/EmIcoEvmHz9c=
|
||||||
|
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
|
||||||
|
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
||||||
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
+6
-6
@@ -44,17 +44,17 @@ func Run() {
|
|||||||
appIns.Run(hotime.Router{
|
appIns.Run(hotime.Router{
|
||||||
"app": hotime.Proj{
|
"app": hotime.Proj{
|
||||||
"index": hotime.Ctr{
|
"index": hotime.Ctr{
|
||||||
"test": func(this *hotime.Context) {
|
"test": func(that *hotime.Context) {
|
||||||
fmt.Println(this.Db.GetTag())
|
fmt.Println(that.Db.GetTag())
|
||||||
//x := this.Db.Action(func(db hotime.HoTimeDB) bool {
|
//x := that.Db.Action(func(db hotime.HoTimeDB) bool {
|
||||||
//
|
//
|
||||||
// db.Insert("user", hotime.Map{"unickname": "dasdas"})
|
// db.Insert("user", hotime.Map{"unickname": "dasdas"})
|
||||||
//
|
//
|
||||||
// return true
|
// return true
|
||||||
//})
|
//})
|
||||||
this.Display(0, 1)
|
that.Display(0, 1)
|
||||||
},
|
},
|
||||||
"websocket": func(this *hotime.Context) {
|
"websocket": func(that *hotime.Context) {
|
||||||
hdler := websocket.Handler(func(ws *websocket.Conn) {
|
hdler := websocket.Handler(func(ws *websocket.Conn) {
|
||||||
for true {
|
for true {
|
||||||
msg := make([]byte, 5120)
|
msg := make([]byte, 5120)
|
||||||
@@ -73,7 +73,7 @@ func Run() {
|
|||||||
fmt.Printf("Send: %s\n", msg[:m])
|
fmt.Printf("Send: %s\n", msg[:m])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
hdler.ServeHTTP(this.Resp, this.Req)
|
hdler.ServeHTTP(that.Resp, that.Req)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
package hotime
|
package hotime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "./cache"
|
. "code.hoteas.com/golang/hotime/cache"
|
||||||
. "./common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
//session对象
|
//session对象
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ type Ctr map[string]Method
|
|||||||
type Proj map[string]Ctr
|
type Proj map[string]Ctr
|
||||||
type Router map[string]Proj
|
type Router map[string]Proj
|
||||||
type MethodRouter map[string]Method //直接字符串关联函数
|
type MethodRouter map[string]Method //直接字符串关联函数
|
||||||
type Method func(this *Context)
|
type Method func(that *Context)
|
||||||
|
|||||||
Reference in New Issue
Block a user