增加表关联新建功能,同时修复数据库bug
This commit is contained in:
+2
-2
@@ -197,7 +197,7 @@ func (that *MakeCode) Db2JSON(name string, path string, db db.HoTimeDB) {
|
||||
//"must": false,
|
||||
}
|
||||
//备注以空格隔开,空格后的是其他备注
|
||||
indexNum := strings.Index(info.GetString("label"), " ")
|
||||
indexNum := strings.Index(info.GetString("label"), ":")
|
||||
if indexNum > 0 {
|
||||
coloum["label"] = info.GetString("label")[:indexNum]
|
||||
}
|
||||
@@ -241,7 +241,7 @@ func (that *MakeCode) Db2JSON(name string, path string, db db.HoTimeDB) {
|
||||
//if coloum.GetString("type") == "select" {
|
||||
|
||||
options := Slice{}
|
||||
comments := strings.Split(info.GetString("label"), " ")
|
||||
comments := strings.Split(info.GetString("label"), ":")
|
||||
if len(comments) >= 2 {
|
||||
optionComment := strings.Split(comments[1], ",")
|
||||
for _, v := range optionComment {
|
||||
|
||||
+7
-4
@@ -440,8 +440,11 @@ func (that *HoTimeDB) Select(table string, qu ...interface{}) []Map {
|
||||
} else {
|
||||
query += " *"
|
||||
}
|
||||
|
||||
query += " FROM " + that.Prefix + table
|
||||
if !strings.Contains(table, ".") && !strings.Contains(table, " AS ") {
|
||||
query += " FROM `" + that.Prefix + table + "`"
|
||||
} else {
|
||||
query += " FROM " + that.Prefix + table
|
||||
}
|
||||
|
||||
if join {
|
||||
for k, v := range qu[0].(Map) {
|
||||
@@ -919,7 +922,7 @@ func (that *HoTimeDB) cond(tag string, data Map) (string, []interface{}) {
|
||||
// Update 更新数据
|
||||
func (that *HoTimeDB) Update(table string, data Map, where Map) int64 {
|
||||
|
||||
query := "UPDATE " + that.Prefix + table + " SET "
|
||||
query := "UPDATE `" + that.Prefix + table + "` SET "
|
||||
//UPDATE Person SET Address = 'Zhongshan 23', City = 'Nanjing' WHERE LastName = 'Wilson'
|
||||
qs := make([]interface{}, 0)
|
||||
tp := len(data)
|
||||
@@ -1007,7 +1010,7 @@ func (that *HoTimeDB) Insert(table string, data map[string]interface{}) int64 {
|
||||
}
|
||||
|
||||
}
|
||||
query := "INSERT INTO " + that.Prefix + table + queryString + "VALUES" + valueString
|
||||
query := "INSERT INTO `" + that.Prefix + table + "` " + queryString + "VALUES" + valueString
|
||||
|
||||
res, err := that.Exec(query, values...)
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
. "../../../hotime"
|
||||
)
|
||||
|
||||
var ID = "f3fb4577ad6c15aedadd869e2bf6663c"
|
||||
|
||||
// Project 管理端项目
|
||||
var Project = Proj{
|
||||
//"user": UserCtr,
|
||||
"admin": adminCtr,
|
||||
"category": categoryCtr,
|
||||
"ctg_order_date": ctg_order_dateCtr,
|
||||
"order": orderCtr,
|
||||
"org": orgCtr,
|
||||
"role": roleCtr,
|
||||
"user": userCtr,
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
. "../../../hotime"
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
tencentSendYzm(phone, code)
|
||||
|
||||
this.Display(0, "发送成功")
|
||||
},
|
||||
}
|
||||
@@ -9,11 +9,18 @@
|
||||
"codeConfig": {
|
||||
"admin": "config/app.json"
|
||||
},
|
||||
"codeConfig1": {
|
||||
"admin": {
|
||||
"config": "config/app.json",
|
||||
"package": "admin",
|
||||
"rule": "config/rule.json"
|
||||
}
|
||||
},
|
||||
"crossDomain": "auto",
|
||||
"db": {
|
||||
"mysql": {
|
||||
"host": "192.168.6.253",
|
||||
"name": "hotimego",
|
||||
"name": "bzyy",
|
||||
"password": "dasda8454456",
|
||||
"port": "3306",
|
||||
"prefix": "",
|
||||
@@ -31,8 +38,9 @@
|
||||
"4": "数据处理异常",
|
||||
"5": "数据结果异常"
|
||||
},
|
||||
"mode": 2,
|
||||
"mode": 0,
|
||||
"port": "80",
|
||||
"sessionName": "HOTIME",
|
||||
"smsYzmTpt": "【乐呵呵旅游网】您正在进行身份验证,验证码{验证码},打死不要告诉别人哦!!!",
|
||||
"tpt": "tpt"
|
||||
}
|
||||
+73
-52
@@ -4,9 +4,8 @@ import (
|
||||
"../../hotime"
|
||||
"../../hotime/common"
|
||||
"./admin"
|
||||
"errors"
|
||||
"./app"
|
||||
"fmt"
|
||||
"golang.org/x/net/websocket"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -14,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
fmt.Println(time.Now().Weekday().String())
|
||||
appIns := hotime.Init("config/config.json")
|
||||
//RESTfull接口适配
|
||||
appIns.SetConnectListener(func(context *hotime.Context) bool {
|
||||
@@ -73,26 +72,47 @@ func main() {
|
||||
//列表检索
|
||||
if len(context.RouterString) == 2 &&
|
||||
context.Req.Method == "GET" {
|
||||
if context.Router[context.RouterString[0]][context.RouterString[1]]["search"] == nil {
|
||||
return true
|
||||
}
|
||||
context.Router[context.RouterString[0]][context.RouterString[1]]["search"](context)
|
||||
}
|
||||
//新建
|
||||
if len(context.RouterString) == 2 &&
|
||||
context.Req.Method == "POST" {
|
||||
if context.Router[context.RouterString[0]][context.RouterString[1]]["add"] == nil {
|
||||
return true
|
||||
}
|
||||
context.Router[context.RouterString[0]][context.RouterString[1]]["add"](context)
|
||||
}
|
||||
//查询单条
|
||||
if len(context.RouterString) == 3 &&
|
||||
context.Req.Method == "GET" {
|
||||
|
||||
if context.Router[context.RouterString[0]][context.RouterString[1]]["info"] == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
context.Router[context.RouterString[0]][context.RouterString[1]]["info"](context)
|
||||
}
|
||||
//更新
|
||||
if len(context.RouterString) == 3 &&
|
||||
context.Req.Method == "PUT" {
|
||||
|
||||
if context.Router[context.RouterString[0]][context.RouterString[1]]["update"] == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
context.Router[context.RouterString[0]][context.RouterString[1]]["update"](context)
|
||||
}
|
||||
//移除
|
||||
if len(context.RouterString) == 3 &&
|
||||
context.Req.Method == "DELETE" {
|
||||
|
||||
if context.Router[context.RouterString[0]][context.RouterString[1]]["remove"] == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
context.Router[context.RouterString[0]][context.RouterString[1]]["remove"](context)
|
||||
}
|
||||
context.View()
|
||||
@@ -104,54 +124,55 @@ func main() {
|
||||
|
||||
appIns.Run(hotime.Router{
|
||||
"admin": admin.Project,
|
||||
"app": hotime.Proj{
|
||||
"index": hotime.Ctr{
|
||||
"test": func(this *hotime.Context) {
|
||||
|
||||
data := this.Db.Get("cached", "*")
|
||||
fmt.Println(data)
|
||||
fmt.Println(this.Session("test").ToCeilInt())
|
||||
this.Session("test1", 98984984)
|
||||
fmt.Println(this.Session("test1").Data)
|
||||
this.Error.SetError(errors.New("dasdasdas"))
|
||||
//fmt.Println(this.Db.GetTag())
|
||||
//this.Application.Log.Error("dasdasdas")
|
||||
//this.Log.Error("dadasdasd")
|
||||
//x:=this.Db.Action(func(db hotime.HoTimeDB) bool {
|
||||
//
|
||||
// db.Insert("user",hotime.Map{"unickname":"dasdas"})
|
||||
//
|
||||
// return true
|
||||
//})
|
||||
//hotime.LogError("dasdasdasdasdas")
|
||||
this.Display(5, "dsadas")
|
||||
},
|
||||
"websocket": func(this *hotime.Context) {
|
||||
hdler := websocket.Handler(func(ws *websocket.Conn) {
|
||||
for true {
|
||||
msg := make([]byte, 5120)
|
||||
n, err := ws.Read(msg)
|
||||
go func() {
|
||||
time.Sleep(time.Second * 5)
|
||||
ws.Write([]byte("dsadasdasgregergrerge"))
|
||||
|
||||
}()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fmt.Printf("Receive: %s\n", msg[:n])
|
||||
|
||||
send_msg := "[" + string(msg[:n]) + "]"
|
||||
m, err := ws.Write([]byte(send_msg))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fmt.Printf("Send: %s\n", msg[:m])
|
||||
}
|
||||
})
|
||||
hdler.ServeHTTP(this.Resp, this.Req)
|
||||
},
|
||||
},
|
||||
},
|
||||
"app": app.Project,
|
||||
//"app": hotime.Proj{
|
||||
// "index": hotime.Ctr{
|
||||
// "test": func(this *hotime.Context) {
|
||||
//
|
||||
// data := this.Db.Get("cached", "*")
|
||||
// fmt.Println(data)
|
||||
// fmt.Println(this.Session("test").ToCeilInt())
|
||||
// this.Session("test1", 98984984)
|
||||
// fmt.Println(this.Session("test1").Data)
|
||||
// this.Error.SetError(errors.New("dasdasdas"))
|
||||
// //fmt.Println(this.Db.GetTag())
|
||||
// //this.Application.Log.Error("dasdasdas")
|
||||
// //this.Log.Error("dadasdasd")
|
||||
// //x:=this.Db.Action(func(db hotime.HoTimeDB) bool {
|
||||
// //
|
||||
// // db.Insert("user",hotime.Map{"unickname":"dasdas"})
|
||||
// //
|
||||
// // return true
|
||||
// //})
|
||||
// //hotime.LogError("dasdasdasdasdas")
|
||||
// this.Display(5, "dsadas")
|
||||
// },
|
||||
// "websocket": func(this *hotime.Context) {
|
||||
// hdler := websocket.Handler(func(ws *websocket.Conn) {
|
||||
// for true {
|
||||
// msg := make([]byte, 5120)
|
||||
// n, err := ws.Read(msg)
|
||||
// go func() {
|
||||
// time.Sleep(time.Second * 5)
|
||||
// ws.Write([]byte("dsadasdasgregergrerge"))
|
||||
//
|
||||
// }()
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
// fmt.Printf("Receive: %s\n", msg[:n])
|
||||
//
|
||||
// send_msg := "[" + string(msg[:n]) + "]"
|
||||
// m, err := ws.Write([]byte(send_msg))
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
// fmt.Printf("Send: %s\n", msg[:m])
|
||||
// }
|
||||
// })
|
||||
// hdler.ServeHTTP(this.Resp, this.Req)
|
||||
// },
|
||||
// },
|
||||
//},
|
||||
})
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
h3[data-v-b9167eee]{margin:40px 0 0}ul[data-v-b9167eee]{list-style-type:none;padding:0}li[data-v-b9167eee]{display:inline-block;margin:0 10px}a[data-v-b9167eee]{color:#42b983}
|
||||
@@ -0,0 +1 @@
|
||||
.el-upload{height:100px;width:100px;background:#eee;overflow:hidden}.el-upload img[data-v-6c7786a3]{height:100%;width:100%;-o-object-fit:cover;object-fit:cover;display:block}.el-upload i[data-v-6c7786a3]{font-size:40px;margin:30% 31%;display:block}
|
||||
@@ -0,0 +1 @@
|
||||
.el-upload{height:100px;width:100px;background:#eee;overflow:hidden}.el-upload img[data-v-08891adc]{height:100%;width:100%;-o-object-fit:cover;object-fit:cover;display:block}.el-upload i[data-v-08891adc]{font-size:40px;margin:30% 31%;display:block}
|
||||
@@ -0,0 +1 @@
|
||||
.not-show-tab-label .el-tabs__header,.not-show-tab-search{display:none}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
Binary file not shown.
+3
-28
@@ -1,28 +1,3 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Sample of websocket with golang</title>
|
||||
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
var ws = new WebSocket("ws://localhost:80/app/index/websocket");
|
||||
ws.onmessage = function(e) {
|
||||
|
||||
$('<li>').text(e.data).appendTo($ul);
|
||||
};
|
||||
var $ul = $('#msg-list');
|
||||
$('#sendBtn').click(function(){
|
||||
var data = $('#name').val();
|
||||
ws.send(data);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<input id="name" type="text"/>
|
||||
<input type="button" id="sendBtn" value="send"/>
|
||||
<ul id="msg-list"></ul>
|
||||
</body>
|
||||
</html>
|
||||
<!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>hotime</title><style>body{
|
||||
margin: 0px;
|
||||
}</style><link href="css/chunk-1c438cad.2fd7d31d.css" rel="prefetch"><link href="css/chunk-33a591b6.c9205cb6.css" rel="prefetch"><link href="css/chunk-7439f1d8.d21501a2.css" rel="prefetch"><link href="css/chunk-ef454b32.e4ca99de.css" rel="prefetch"><link href="js/chunk-1c438cad.3f82f09e.js" rel="prefetch"><link href="js/chunk-2d238068.ace3c99b.js" rel="prefetch"><link href="js/chunk-33a591b6.b442fc2f.js" rel="prefetch"><link href="js/chunk-3b58c314.349138a7.js" rel="prefetch"><link href="js/chunk-7439f1d8.1acd0ee6.js" rel="prefetch"><link href="js/chunk-c4f57cb2.0ec370ce.js" rel="prefetch"><link href="js/chunk-ef454b32.e8e8b1b2.js" rel="prefetch"><link href="css/app.40aa38f6.css" rel="preload" as="style"><link href="js/app.52f44003.js" rel="preload" as="script"><link href="css/app.40aa38f6.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.52f44003.js"></script></body></html>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
(window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-1c438cad"],{8497:function(e,a,t){"use strict";t("c45a")},c45a:function(e,a,t){},fdab:function(e,a,t){"use strict";t.r(a);var v=t("f2bf"),r=Object(v.hb)("data-v-b9167eee");Object(v.I)("data-v-b9167eee");var n={class:"hello"},b=Object(v.m)('<p data-v-b9167eee> For a guide and recipes on how to configure / customize this project,<br data-v-b9167eee> check out the <a href="https://cli.vuejs.org" target="_blank" rel="noopener" data-v-b9167eee>vue-cli documentation</a>. </p><h3 data-v-b9167eee>Installed CLI Plugins</h3><ul data-v-b9167eee><li data-v-b9167eee><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener" data-v-b9167eee>babel</a></li><li data-v-b9167eee><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener" data-v-b9167eee>eslint</a></li></ul><h3 data-v-b9167eee>Essential Links</h3><ul data-v-b9167eee><li data-v-b9167eee><a href="https://vuejs.org" target="_blank" rel="noopener" data-v-b9167eee>Core Docs</a></li><li data-v-b9167eee><a href="https://forum.vuejs.org" target="_blank" rel="noopener" data-v-b9167eee>Forum</a></li><li data-v-b9167eee><a href="https://chat.vuejs.org" target="_blank" rel="noopener" data-v-b9167eee>Community Chat</a></li><li data-v-b9167eee><a href="https://twitter.com/vuejs" target="_blank" rel="noopener" data-v-b9167eee>Twitter</a></li><li data-v-b9167eee><a href="https://news.vuejs.org" target="_blank" rel="noopener" data-v-b9167eee>News</a></li></ul><h3 data-v-b9167eee>Ecosystem</h3><ul data-v-b9167eee><li data-v-b9167eee><a href="https://router.vuejs.org" target="_blank" rel="noopener" data-v-b9167eee>vue-router</a></li><li data-v-b9167eee><a href="https://vuex.vuejs.org" target="_blank" rel="noopener" data-v-b9167eee>vuex</a></li><li data-v-b9167eee><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener" data-v-b9167eee>vue-devtools</a></li><li data-v-b9167eee><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener" data-v-b9167eee>vue-loader</a></li><li data-v-b9167eee><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener" data-v-b9167eee>awesome-vue</a></li></ul>',7);Object(v.G)();var l=r(function(e,a,t,r,l,o){return Object(v.F)(),Object(v.j)("div",n,[Object(v.o)("h1",null,Object(v.S)(t.msg),1),b])}),r={name:"HelloWorld",props:{msg:String}};t("8497");r.render=l,r.__scopeId="data-v-b9167eee";a.default=r}}]);
|
||||
@@ -0,0 +1 @@
|
||||
(window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-2d238068"],{fe2e:function(t,e,n){"use strict";n.r(e);var h=n("f2bf"),j=Object(h.hb)("data-v-9e95abd2"),n={data:function(){return{routerViewShow:!0,items:[]}},mounted:function(){this.routeInit()},methods:{createItems:function(t,e){return e.push({path:t.path,label:t.label,icon:t.icon,table:t.table}),e=null!=t.parent.path?this.createItems(t.parent,e):e},routeInit:function(){var t=this;this.routerViewShow=!1,setTimeout(function(){t.routerViewShow=!0},50);var e=window.Hotime.mapData[this.$route.path],n=[];null!=e&&((n=this.createItems(e,n)).reverse(),0!=n.length&&null==n[0].table&&(n[0].path="/"),this.items=n)}},watch:{$route:function(t){this.routeInit(t)}}};n.render=j(function(t,e,n,r,c,o){var a=Object(h.O)("el-breadcrumb-item"),u=Object(h.O)("el-breadcrumb"),i=Object(h.O)("el-header"),b=Object(h.O)("router-view"),l=Object(h.O)("el-container");return Object(h.F)(),Object(h.j)(l,{style:{height:"100%"}},{default:j(function(){return[Object(h.o)(i,{style:{height:"30px",padding:"0px"}},{default:j(function(){return[Object(h.o)(u,{"separator-class":"el-icon-arrow-right",style:{"margin-bottom":"30px"}},{default:j(function(){return[(Object(h.F)(!0),Object(h.j)(h.b,null,Object(h.M)(c.items,function(t){return Object(h.F)(),Object(h.j)(a,{key:t.path,to:{path:t.path}},{default:j(function(){return[Object(h.o)("i",{class:t.icon,style:{"margin-right":"3px"}},null,2),Object(h.n)(Object(h.S)(t.label),1)]}),_:2},1032,["to"])}),128))]}),_:1})]}),_:1}),Object(h.o)(l,{style:{"overflow-y":"auto"}},{default:j(function(){return[c.routerViewShow?(Object(h.F)(),Object(h.j)(b,{key:0},{default:j(function(t){var e=t.Component;return[Object(h.o)(h.e,{name:"el-zoom-in-center"},{default:j(function(){return[(Object(h.F)(),Object(h.j)(h.c,null,[(Object(h.F)(),Object(h.j)(Object(h.Q)(e)))],1024))]}),_:2},1024)]}),_:1})):Object(h.k)("",!0)]}),_:1})]}),_:1})}),n.__scopeId="data-v-9e95abd2";e.default=n}}]);
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user