Merge branch 'zct-v2' of https://code.hoteas.com/golang/hotime into zhoupengwei
This commit is contained in:
commit
d20bcc162c
15
code.go
15
code.go
@ -44,7 +44,9 @@ var TptProject = Proj{
|
|||||||
}
|
}
|
||||||
|
|
||||||
link := strings.Replace(column.GetString("name"), "_id", "", -1)
|
link := strings.Replace(column.GetString("name"), "_id", "", -1)
|
||||||
|
if link == "parent" {
|
||||||
|
link = that.RouterString[1]
|
||||||
|
}
|
||||||
re[link] = that.Db.Get(column.GetString("link"), seStr, Map{"id": v})
|
re[link] = that.Db.Get(column.GetString("link"), seStr, Map{"id": v})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,7 +64,9 @@ var TptProject = Proj{
|
|||||||
}
|
}
|
||||||
|
|
||||||
link := strings.Replace(column.GetString("name"), "_id", "", -1)
|
link := strings.Replace(column.GetString("name"), "_id", "", -1)
|
||||||
|
if link == "parent" {
|
||||||
|
link = that.RouterString[1]
|
||||||
|
}
|
||||||
re[link] = that.Db.Get(column.GetString("link"), seStr, Map{"id": v})
|
re[link] = that.Db.Get(column.GetString("link"), seStr, Map{"id": v})
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -106,7 +110,6 @@ var TptProject = Proj{
|
|||||||
hotimeName := that.RouterString[0]
|
hotimeName := that.RouterString[0]
|
||||||
inData := that.MakeCodeRouter[hotimeName].Edit(that.RouterString[1], that.Req)
|
inData := that.MakeCodeRouter[hotimeName].Edit(that.RouterString[1], that.Req)
|
||||||
|
|
||||||
|
|
||||||
if inData == nil {
|
if inData == nil {
|
||||||
that.Display(3, "没有找到要更新的数据")
|
that.Display(3, "没有找到要更新的数据")
|
||||||
return
|
return
|
||||||
@ -188,6 +191,7 @@ var TptProject = Proj{
|
|||||||
|
|
||||||
for _, v := range reData {
|
for _, v := range reData {
|
||||||
v.RangeSort(func(k string, v1 interface{}) (isEnd bool) {
|
v.RangeSort(func(k string, v1 interface{}) (isEnd bool) {
|
||||||
|
|
||||||
//如果有table字段则代为link
|
//如果有table字段则代为link
|
||||||
if v["table"] != nil && v["table_id"] != nil {
|
if v["table"] != nil && v["table_id"] != nil {
|
||||||
|
|
||||||
@ -203,11 +207,12 @@ var TptProject = Proj{
|
|||||||
}
|
}
|
||||||
|
|
||||||
column := that.MakeCodeRouter[hotimeName].TableColumns[that.RouterString[1]][k]
|
column := that.MakeCodeRouter[hotimeName].TableColumns[that.RouterString[1]][k]
|
||||||
|
|
||||||
if column == nil {
|
if column == nil {
|
||||||
return true
|
return isEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
if column["list"] != false && column["name"] == "parent_id" && column.GetString("link") != "" {
|
if (column["list"] == nil || column["list"] == true) && column["name"] == "parent_id" && column.GetString("link") != "" {
|
||||||
|
|
||||||
parentC := that.Db.Get(column.GetString("link"), column.GetString("value"), Map{"id": v.GetCeilInt(k)})
|
parentC := that.Db.Get(column.GetString("link"), column.GetString("value"), Map{"id": v.GetCeilInt(k)})
|
||||||
v[column.GetString("link")+"_"+column.GetString("name")+"_"+column.GetString("value")] = ""
|
v[column.GetString("link")+"_"+column.GetString("name")+"_"+column.GetString("value")] = ""
|
||||||
|
@ -64,6 +64,7 @@ var ColumnNameType = []ColumnShow{
|
|||||||
{"idcard", false, true, true, false, "", false},
|
{"idcard", false, true, true, false, "", false},
|
||||||
{"id", true, false, true, false, "", true},
|
{"id", true, false, true, false, "", true},
|
||||||
{"parent_id", true, true, true, false, "", true},
|
{"parent_id", true, true, true, false, "", true},
|
||||||
|
{"amount", true, true, true, false, "money", true},
|
||||||
{"content", false, false, false, false, "textArea", false},
|
{"content", false, false, false, false, "textArea", false},
|
||||||
{"info", false, true, true, false, "textArea", false},
|
{"info", false, true, true, false, "textArea", false},
|
||||||
//"sn"{true,true,true,""},
|
//"sn"{true,true,true,""},
|
||||||
|
@ -598,7 +598,7 @@ func (that *MakeCode) Info(table string, userData Map, db *db.HoTimeDB) (string,
|
|||||||
//初始化ruleData
|
//初始化ruleData
|
||||||
if ruleData == nil {
|
if ruleData == nil {
|
||||||
ruleData = Map{}
|
ruleData = Map{}
|
||||||
for _, v := range that.TableColumns["admin"] {
|
for _, v := range that.TableColumns[that.FileConfig.GetString("table")] {
|
||||||
if v.GetString("link") != "" &&
|
if v.GetString("link") != "" &&
|
||||||
v.GetString("name") != "parent_id" &&
|
v.GetString("name") != "parent_id" &&
|
||||||
userData.Get(v.GetString("name")) != nil {
|
userData.Get(v.GetString("name")) != nil {
|
||||||
@ -786,11 +786,16 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
|||||||
v.GetString("link") + "." + v.GetString("value") + " AS " +
|
v.GetString("link") + "." + v.GetString("value") + " AS " +
|
||||||
v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + ","
|
v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + ","
|
||||||
|
|
||||||
|
if v.GetString("value") == "name" && that.TableColumns[v.GetString("link")]["nickname"] != nil {
|
||||||
|
reStr += v.GetString("link") + ".nickname AS " +
|
||||||
|
v.GetString("link") + "_" + v.GetString("name") + "_nickname,"
|
||||||
|
}
|
||||||
|
|
||||||
if that.TableColumns[v.GetString("link")]["phone"] != nil {
|
if that.TableColumns[v.GetString("link")]["phone"] != nil {
|
||||||
reStr += table + "." + v.GetString("name") + "," +
|
reStr += v.GetString("link") + ".phone AS " +
|
||||||
v.GetString("link") + ".phone AS " +
|
|
||||||
v.GetString("link") + "_" + v.GetString("name") + "_phone,"
|
v.GetString("link") + "_" + v.GetString("name") + "_phone,"
|
||||||
}
|
}
|
||||||
|
|
||||||
leftJoin["[>]"+v.GetString("link")] =
|
leftJoin["[>]"+v.GetString("link")] =
|
||||||
table + "." + v.GetString("name") + "=" +
|
table + "." + v.GetString("name") + "=" +
|
||||||
v.GetString("link") + ".id"
|
v.GetString("link") + ".id"
|
||||||
@ -814,7 +819,7 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
|||||||
//初始化ruleData
|
//初始化ruleData
|
||||||
if ruleData == nil {
|
if ruleData == nil {
|
||||||
ruleData = Map{}
|
ruleData = Map{}
|
||||||
for _, v := range that.TableColumns["admin"] {
|
for _, v := range that.TableColumns[that.FileConfig.GetString("table")] {
|
||||||
if v.GetString("link") != "" &&
|
if v.GetString("link") != "" &&
|
||||||
v.GetString("name") != "parent_id" &&
|
v.GetString("name") != "parent_id" &&
|
||||||
userData.Get(v.GetString("name")) != nil {
|
userData.Get(v.GetString("name")) != nil {
|
||||||
@ -885,15 +890,32 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//日期类型
|
//日期类型
|
||||||
if searchItemName == "daterange" && v.GetString("type") == "time" {
|
if searchItemName == "daterange" {
|
||||||
|
if v.GetString("type") == "unixtime" {
|
||||||
//fmt.Println(req.Form["daterange"])
|
//fmt.Println(req.Form["daterange"])
|
||||||
if len(req.Form["daterange"]) == 1 {
|
if len(req.Form["daterange"]) == 1 {
|
||||||
daterange[table+"."+v.GetString("name")+"[<]"] = req.FormValue("daterange")
|
daterange[table+"."+v.GetString("name")+"[<]"] = req.FormValue("daterange")
|
||||||
} else {
|
} else if len(req.Form["daterange"]) == 2 {
|
||||||
|
|
||||||
daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
|
daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if v.GetString("type") == "time" {
|
||||||
|
//fmt.Println(req.Form["daterange"])
|
||||||
|
|
||||||
|
if len(req.Form["daterange"]) == 1 {
|
||||||
|
t := time.Unix(ObjToCeilInt64(req.FormValue("daterange")), 0).Format("2006-01-02 15:04:05")
|
||||||
|
|
||||||
|
daterange[table+"."+v.GetString("name")+"[<]"] = t
|
||||||
|
|
||||||
|
} else if len(req.Form["daterange"]) == 2 {
|
||||||
|
t1 := time.Unix(ObjToCeilInt64(req.Form["daterange"][0]), 0).Format("2006-01-02 15:04:05")
|
||||||
|
t2 := time.Unix(ObjToCeilInt64(req.Form["daterange"][1]), 0).Format("2006-01-02 15:04:05")
|
||||||
|
daterange[table+"."+v.GetString("name")+"[<>]"] = Slice{t1, t2}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if searchItem.GetString("name") == "sort" {
|
if searchItem.GetString("name") == "sort" {
|
||||||
@ -944,11 +966,11 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(daterange) > 1 {
|
if len(daterange) > 1 {
|
||||||
//if data["AND"] == nil {
|
if data == nil || len(data) == 0 {
|
||||||
|
data = Map{"OR": daterange}
|
||||||
|
} else {
|
||||||
data = Map{"AND": Map{"AND": data, "OR": daterange}}
|
data = Map{"AND": Map{"AND": data, "OR": daterange}}
|
||||||
//}else{
|
}
|
||||||
// data = Map{"AND": Map{"AND": data, "OR": daterange}}
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(data) > 1 {
|
if len(data) > 1 {
|
||||||
|
@ -460,15 +460,15 @@ func (that *HoTimeDB) Select(table string, qu ...interface{}) []Map {
|
|||||||
v := testQuData[k]
|
v := testQuData[k]
|
||||||
switch Substr(k, 0, 3) {
|
switch Substr(k, 0, 3) {
|
||||||
case "[>]":
|
case "[>]":
|
||||||
query += " LEFT JOIN " + Substr(k, 3, len(k)-3) + " ON " + v.(string)
|
query += " LEFT JOIN `" + Substr(k, 3, len(k)-3) + "` ON " + v.(string)
|
||||||
case "[<]":
|
case "[<]":
|
||||||
query += " RIGHT JOIN " + Substr(k, 3, len(k)-3) + " ON " + v.(string)
|
query += " RIGHT JOIN `" + Substr(k, 3, len(k)-3) + "` ON " + v.(string)
|
||||||
}
|
}
|
||||||
switch Substr(k, 0, 4) {
|
switch Substr(k, 0, 4) {
|
||||||
case "[<>]":
|
case "[<>]":
|
||||||
query += " FULL JOIN " + Substr(k, 4, len(k)-4) + " ON " + v.(string)
|
query += " FULL JOIN `" + Substr(k, 4, len(k)-4) + "` ON " + v.(string)
|
||||||
case "[><]":
|
case "[><]":
|
||||||
query += " INNER JOIN " + Substr(k, 4, len(k)-4) + " ON " + v.(string)
|
query += " INNER JOIN `" + Substr(k, 4, len(k)-4) + "` ON " + v.(string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
118
example/app/AES.go
Normal file
118
example/app/AES.go
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"code.hoteas.com/golang/hotime/common"
|
||||||
|
"crypto/aes"
|
||||||
|
"crypto/cipher"
|
||||||
|
"encoding/base64"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
//高级加密标准(Adevanced Encryption Standard ,AES)
|
||||||
|
|
||||||
|
//16,24,32位字符串的话,分别对应AES-128,AES-192,AES-256 加密方法
|
||||||
|
//key不能泄露
|
||||||
|
var PwdKey = []byte("mif022h3g9geAHUHY432,:da1adag389")
|
||||||
|
|
||||||
|
//PKCS7 填充模式
|
||||||
|
func pKCS7Padding(ciphertext []byte, blockSize int) []byte {
|
||||||
|
padding := blockSize - len(ciphertext)%blockSize
|
||||||
|
//Repeat()函数的功能是把切片[]byte{byte(padding)}复制padding个,然后合并成新的字节切片返回
|
||||||
|
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
|
||||||
|
return append(ciphertext, padtext...)
|
||||||
|
}
|
||||||
|
|
||||||
|
//填充的反向操作,删除填充字符串
|
||||||
|
func pKCS7UnPadding(origData []byte) ([]byte, error) {
|
||||||
|
//获取数据长度
|
||||||
|
length := len(origData)
|
||||||
|
if length == 0 {
|
||||||
|
return nil, errors.New("加密字符串错误!")
|
||||||
|
} else {
|
||||||
|
//获取填充字符串长度
|
||||||
|
unpadding := int(origData[length-1])
|
||||||
|
//截取切片,删除填充字节,并且返回明文
|
||||||
|
return origData[:(length - unpadding)], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//实现加密
|
||||||
|
func AesEcrypt(origData []byte, key []byte) ([]byte, error) {
|
||||||
|
//创建加密算法实例
|
||||||
|
block, err := aes.NewCipher(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
//获取块的大小
|
||||||
|
blockSize := block.BlockSize()
|
||||||
|
//对数据进行填充,让数据长度满足需求
|
||||||
|
origData = pKCS7Padding(origData, blockSize)
|
||||||
|
//采用AES加密方法中CBC加密模式
|
||||||
|
blocMode := cipher.NewCBCEncrypter(block, key[:blockSize])
|
||||||
|
crypted := make([]byte, len(origData))
|
||||||
|
//执行加密
|
||||||
|
blocMode.CryptBlocks(crypted, origData)
|
||||||
|
return crypted, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//实现解密
|
||||||
|
func AesDeCrypt(cypted []byte, key []byte) (bytes []byte, err error) {
|
||||||
|
//异常处理
|
||||||
|
defer func() {
|
||||||
|
if e := recover(); e != nil {
|
||||||
|
//that.SetError(errors.New(fmt.Sprint(err)), LOG_FMT)
|
||||||
|
fmt.Println(err)
|
||||||
|
err = errors.New(common.ObjToStr(e))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
//创建加密算法实例
|
||||||
|
block, err := aes.NewCipher(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取块大小
|
||||||
|
blockSize := block.BlockSize()
|
||||||
|
//创建加密客户端实例
|
||||||
|
blockMode := cipher.NewCBCDecrypter(block, key[:blockSize])
|
||||||
|
origData := make([]byte, len(cypted))
|
||||||
|
//这个函数也可以用来解密
|
||||||
|
blockMode.CryptBlocks(origData, cypted)
|
||||||
|
//去除填充字符串
|
||||||
|
origData, err = pKCS7UnPadding(origData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return origData, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//加密base64
|
||||||
|
func EnPwdCode(pwd []byte) (string, error) {
|
||||||
|
result, err := AesEcrypt(pwd, PwdKey)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return base64.StdEncoding.EncodeToString(result), err
|
||||||
|
}
|
||||||
|
|
||||||
|
//解密
|
||||||
|
func DePwdCode(pwd string) ([]byte, error) {
|
||||||
|
//解密base64字符串
|
||||||
|
pwdByte, err := base64.StdEncoding.DecodeString(pwd)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
//执行AES解密
|
||||||
|
return AesDeCrypt(pwdByte, PwdKey)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//func main() {
|
||||||
|
// str := []byte("12fff我是ww.topgoer.com的站长枯藤")
|
||||||
|
// pwd, _ := EnPwdCode(str)
|
||||||
|
// bytes, _ := DePwdCode(pwd)
|
||||||
|
// fmt.Println(string(bytes))
|
||||||
|
//}
|
@ -139,7 +139,7 @@ var DeclareCtr = Ctr{
|
|||||||
//标签分析
|
//标签分析
|
||||||
if tags != nil {
|
if tags != nil {
|
||||||
for _, v := range tags {
|
for _, v := range tags {
|
||||||
dtag := that.Db.Select("declare_tag", Map{"[><]`declare`": "declare_tag.declare_id=declare.id"}, "declare_tag.declare_id", Map{"AND": Map{"OR": Map{"declare.policy_level": Slice{"省", "市"}, "declare.dispatch_department[~]": qu}, "declare_tag.tag_id": v}})
|
dtag := that.Db.Select("declare_tag", Map{"[><]declare": "declare_tag.declare_id=declare.id"}, "declare_tag.declare_id", Map{"AND": Map{"OR": Map{"declare.policy_level": Slice{"省", "市"}, "declare.dispatch_department[~]": qu}, "declare_tag.tag_id": v}})
|
||||||
for _, v1 := range dtag {
|
for _, v1 := range dtag {
|
||||||
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
if declares[v1.GetCeilInt64("declare_id")] == nil {
|
||||||
declares[v1.GetCeilInt64("declare_id")] = v1
|
declares[v1.GetCeilInt64("declare_id")] = v1
|
||||||
@ -388,15 +388,15 @@ var DeclareCtr = Ctr{
|
|||||||
|
|
||||||
res = append(res, article)
|
res = append(res, article)
|
||||||
}
|
}
|
||||||
minMoney := 0
|
minMoney := float64(0)
|
||||||
maxMoney := 0
|
maxMoney := float64(0)
|
||||||
for _, v := range res {
|
for _, v := range res {
|
||||||
if v.GetMap("declare") != nil {
|
if v.GetMap("declare") != nil {
|
||||||
if v.GetMap("declare").GetInt("money_scope_min") < minMoney {
|
if v.GetMap("declare").GetFloat64("money_scope_min") < minMoney {
|
||||||
minMoney = v.GetMap("declare").GetInt("money_scope_min")
|
minMoney = v.GetMap("declare").GetFloat64("money_scope_min")
|
||||||
}
|
}
|
||||||
if v.GetMap("declare").GetInt("money_scope_max") > maxMoney {
|
if v.GetMap("declare").GetFloat64("money_scope_max") > maxMoney {
|
||||||
maxMoney = v.GetMap("declare").GetInt("money_scope_max")
|
maxMoney = v.GetMap("declare").GetFloat64("money_scope_max")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -410,11 +410,11 @@ var DeclareCtr = Ctr{
|
|||||||
"del_flag": 0,
|
"del_flag": 0,
|
||||||
}
|
}
|
||||||
if maxMoney != minMoney {
|
if maxMoney != minMoney {
|
||||||
seData["money_scope"] = ObjToStr(minMoney) + "-" + ObjToStr(maxMoney) + "万元"
|
seData["money_scope"] = ObjToStr(ObjToInt(minMoney)) + "-" + ObjToStr(ObjToInt(maxMoney)) + ""
|
||||||
} else if maxMoney == 0 {
|
} else if maxMoney == 0 {
|
||||||
seData["money_scope"] = ""
|
seData["money_scope"] = ""
|
||||||
} else {
|
} else {
|
||||||
seData["money_scope"] = ObjToStr(maxMoney) + "万元"
|
seData["money_scope"] = ObjToStr(ObjToInt(maxMoney)) + ""
|
||||||
}
|
}
|
||||||
|
|
||||||
//匹配记录存储
|
//匹配记录存储
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
. "code.hoteas.com/golang/hotime/common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Project 管理端项目
|
// Project 管理端项目
|
||||||
@ -22,6 +23,7 @@ var Project = Proj{
|
|||||||
"search_record": SearchRecordCtr,
|
"search_record": SearchRecordCtr,
|
||||||
"sms": Sms,
|
"sms": Sms,
|
||||||
"tag": TagCtr,
|
"tag": TagCtr,
|
||||||
|
"upan": UpanCtr,
|
||||||
"user": UserCtr,
|
"user": UserCtr,
|
||||||
"vip_order": VipOrderCtr,
|
"vip_order": VipOrderCtr,
|
||||||
"websocket": WebsocketCtr,
|
"websocket": WebsocketCtr,
|
||||||
@ -45,15 +47,19 @@ func getCode() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//认证公共方案
|
//认证公共方案
|
||||||
func auth(that *Context, phone, companyName string) error {
|
func auth(that *Context, phone, companyName, userName string) error {
|
||||||
|
|
||||||
user := that.Db.Get("user", "id,phone,salesman_id,company_id,provider_id", Map{"id": that.Session("user_id").ToCeilInt()})
|
user := that.Db.Get("user", "id,phone,salesman_id,company_id,provider_id,name", Map{"id": that.Session("user_id").ToCeilInt()})
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return errors.New("找不到用户")
|
return errors.New("找不到用户")
|
||||||
}
|
}
|
||||||
|
company := that.Db.Get("company", "name,id", Map{"id": user.GetCeilInt("company_id")})
|
||||||
|
|
||||||
|
if company == nil {
|
||||||
|
return errors.New("找不到企业")
|
||||||
|
}
|
||||||
//手机号与原来的不同则进行绑定
|
//手机号与原来的不同则进行绑定
|
||||||
if phone != user.GetString("phone") {
|
if phone != user.GetString("phone") || companyName != company.GetString("name") || user.GetString("name") != userName {
|
||||||
//微信验证成功
|
//微信验证成功
|
||||||
if that.Session("wechat_phone").ToStr() == phone {
|
if that.Session("wechat_phone").ToStr() == phone {
|
||||||
that.Db.Update("user", Map{"phone": phone}, Map{"id": user.GetCeilInt("id")})
|
that.Db.Update("user", Map{"phone": phone}, Map{"id": user.GetCeilInt("id")})
|
||||||
@ -65,7 +71,7 @@ func auth(that *Context, phone, companyName string) error {
|
|||||||
|
|
||||||
return errors.New("验证码错误")
|
return errors.New("验证码错误")
|
||||||
} else {
|
} else {
|
||||||
that.Db.Update("user", Map{"phone": phone}, Map{"id": user.GetCeilInt("id")})
|
that.Db.Update("user", Map{"phone": phone, "name": userName}, Map{"id": user.GetCeilInt("id")})
|
||||||
if user.GetCeilInt("company_id") != 0 {
|
if user.GetCeilInt("company_id") != 0 {
|
||||||
that.Db.Update("company", Map{"phone": phone}, Map{"id": user.GetCeilInt("company_id")})
|
that.Db.Update("company", Map{"phone": phone}, Map{"id": user.GetCeilInt("company_id")})
|
||||||
}
|
}
|
||||||
@ -74,7 +80,7 @@ func auth(that *Context, phone, companyName string) error {
|
|||||||
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
company := that.Db.Get("company", "name,id", Map{"id": user.GetCeilInt("company_id")})
|
//company := that.Db.Get("company", "name,id", Map{"id": user.GetCeilInt("company_id")})
|
||||||
if company != nil {
|
if company != nil {
|
||||||
that.Db.Update("company", Map{"name": companyName}, Map{"id": company.GetCeilInt64("id")})
|
that.Db.Update("company", Map{"name": companyName}, Map{"id": company.GetCeilInt64("id")})
|
||||||
if user.GetCeilInt64("salesman_id") != 0 {
|
if user.GetCeilInt64("salesman_id") != 0 {
|
||||||
@ -109,3 +115,15 @@ func auth(that *Context, phone, companyName string) error {
|
|||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FilterEmoji 过滤 emoji 表情
|
||||||
|
func FilterEmoji(content string) string {
|
||||||
|
new_content := ""
|
||||||
|
for _, value := range content {
|
||||||
|
_, size := utf8.DecodeRuneInString(string(value))
|
||||||
|
if size <= 3 {
|
||||||
|
new_content += string(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new_content
|
||||||
|
}
|
||||||
|
@ -17,12 +17,13 @@ var OrderCtr = Ctr{
|
|||||||
providerId := ObjToInt(that.Req.FormValue("provider_id"))
|
providerId := ObjToInt(that.Req.FormValue("provider_id"))
|
||||||
phone := that.Req.FormValue("phone")
|
phone := that.Req.FormValue("phone")
|
||||||
companyName := that.Req.FormValue("company_name")
|
companyName := that.Req.FormValue("company_name")
|
||||||
if providerId == 0 || len(phone) != 11 || len(companyName) < 4 {
|
userName := that.Req.FormValue("user_name")
|
||||||
|
if providerId == 0 || len(phone) != 11 || len(companyName) < 4 || len(userName) < 2 {
|
||||||
that.Display(3, "请求参数异常")
|
that.Display(3, "请求参数异常")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := auth(that, phone, companyName)
|
err := auth(that, phone, companyName, userName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
that.Display(3, err.Error())
|
that.Display(3, err.Error())
|
||||||
return
|
return
|
||||||
|
@ -47,7 +47,7 @@ var ProviderCtr = Ctr{
|
|||||||
pageSize = 20
|
pageSize = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
data := Map{"del_flag": 0}
|
data := Map{"del_flag": 0, "state": 0}
|
||||||
keywords := that.Req.FormValue("keywords")
|
keywords := that.Req.FormValue("keywords")
|
||||||
if keywords != "" {
|
if keywords != "" {
|
||||||
data["OR"] = Map{"name[~]": keywords, "title[~]": keywords}
|
data["OR"] = Map{"name[~]": keywords, "title[~]": keywords}
|
||||||
|
91
example/app/upan.go
Normal file
91
example/app/upan.go
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "code.hoteas.com/golang/hotime"
|
||||||
|
"code.hoteas.com/golang/hotime/common"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var UpanCtr = Ctr{
|
||||||
|
"login": func(that *Context) {
|
||||||
|
timestamp := that.Req.FormValue("timestamp")
|
||||||
|
sn := that.Req.FormValue("sn")
|
||||||
|
|
||||||
|
//str,_:=EnPwdCode([]byte(lus[len(lus)-1]+":"+ObjToStr(t)))//
|
||||||
|
re, e := DePwdCode(sn)
|
||||||
|
|
||||||
|
if e != nil {
|
||||||
|
that.Display(3, "数据异常")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reStr := string(re)
|
||||||
|
realSn := strings.Replace(reStr, ":"+timestamp, "", -1)
|
||||||
|
if len(realSn)+len(timestamp)+1 != len(reStr) {
|
||||||
|
that.Display(4, "数据验证失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Println("U盘校验", realSn)
|
||||||
|
user := that.Db.Get("user", "*", common.Map{"upankey": realSn})
|
||||||
|
if user == nil {
|
||||||
|
that.Display(5, "还没有绑定用户")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
that.Session("user_id", user.GetCeilInt("id"))
|
||||||
|
that.Display(0, "登录成功")
|
||||||
|
},
|
||||||
|
|
||||||
|
"create": func(that *Context) {
|
||||||
|
timestamp := that.Req.FormValue("timestamp")
|
||||||
|
sn := that.Req.FormValue("sn")
|
||||||
|
|
||||||
|
//str,_:=EnPwdCode([]byte(lus[len(lus)-1]+":"+ObjToStr(t)))//
|
||||||
|
re, e := DePwdCode(sn)
|
||||||
|
|
||||||
|
if e != nil {
|
||||||
|
fmt.Println(e)
|
||||||
|
that.Display(3, "数据异常")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reStr := string(re)
|
||||||
|
realSn := strings.Replace(reStr, ":"+timestamp, "", -1)
|
||||||
|
if len(realSn)+len(timestamp)+1 != len(reStr) {
|
||||||
|
that.Display(4, "数据验证失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("U盘校验", realSn)
|
||||||
|
|
||||||
|
uuser := that.Db.Get("user", "id", common.Map{"upankey": realSn})
|
||||||
|
|
||||||
|
if uuser != nil {
|
||||||
|
that.Display(4, "已经绑定了其他企业")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
phone := that.Req.FormValue("phone")
|
||||||
|
companyName := that.Req.FormValue("company_name")
|
||||||
|
userName := that.Req.FormValue("user_name")
|
||||||
|
|
||||||
|
if len(phone) != 11 || len(companyName) < 4 || len(userName) < 2 {
|
||||||
|
that.Display(3, "请求参数异常")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//验证不成功则反馈
|
||||||
|
err := auth(that, phone, companyName, userName)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
that.Display(3, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
num := that.Db.Update("user", common.Map{"upankey": realSn}, common.Map{"id": that.Session("user_id").Data})
|
||||||
|
if num == 0 {
|
||||||
|
that.Display(4, "更新失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
that.Display(0, "绑定成功")
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
@ -24,6 +24,17 @@ var UserCtr = Ctr{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.GetCeilInt("company_id") == 0 {
|
||||||
|
companyId := that.Db.Insert("company", Map{
|
||||||
|
"user_id": user["id"],
|
||||||
|
"create_time[#]": "now()",
|
||||||
|
"modify_time[#]": "now()",
|
||||||
|
"del_flag": 0,
|
||||||
|
})
|
||||||
|
user["company_id"] = companyId
|
||||||
|
that.Db.Update("user", Map{"company_id": companyId}, Map{"id": user.GetCeilInt("id")})
|
||||||
|
}
|
||||||
|
|
||||||
delete(user, "password")
|
delete(user, "password")
|
||||||
|
|
||||||
company := that.Db.Get("company", "id,name", Map{"id": user.GetCeilInt("company_id")})
|
company := that.Db.Get("company", "id,name", Map{"id": user.GetCeilInt("company_id")})
|
||||||
|
@ -18,7 +18,8 @@ var VipOrderCtr = Ctr{
|
|||||||
|
|
||||||
phone := that.Req.FormValue("phone")
|
phone := that.Req.FormValue("phone")
|
||||||
companyName := that.Req.FormValue("company_name")
|
companyName := that.Req.FormValue("company_name")
|
||||||
if len(phone) != 11 || len(companyName) < 4 {
|
userName := that.Req.FormValue("user_name")
|
||||||
|
if len(phone) != 11 || len(companyName) < 4 || len(userName) < 2 {
|
||||||
that.Display(3, "请求参数异常")
|
that.Display(3, "请求参数异常")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -37,7 +38,8 @@ var VipOrderCtr = Ctr{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := auth(that, phone, companyName)
|
err := auth(that, phone, companyName, userName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
that.Display(3, err.Error())
|
that.Display(3, err.Error())
|
||||||
return
|
return
|
||||||
@ -46,7 +48,7 @@ var VipOrderCtr = Ctr{
|
|||||||
data := Map{
|
data := Map{
|
||||||
"sn": "SN" + time.Now().Format("20060102150405") + getSn(),
|
"sn": "SN" + time.Now().Format("20060102150405") + getSn(),
|
||||||
//"name":"1年VIP会员",
|
//"name":"1年VIP会员",
|
||||||
"amount": 72000, //720元
|
"amount": 36000, //720元
|
||||||
"user_id": user.GetCeilInt64("id"),
|
"user_id": user.GetCeilInt64("id"),
|
||||||
"company_id": user.GetCeilInt("company_id"),
|
"company_id": user.GetCeilInt("company_id"),
|
||||||
"expiration_time": time.Now().Add(365 * 24 * time.Hour).Format("2006-01-02 15:04:05"),
|
"expiration_time": time.Now().Add(365 * 24 * time.Hour).Format("2006-01-02 15:04:05"),
|
||||||
@ -73,7 +75,7 @@ var VipOrderCtr = Ctr{
|
|||||||
data["amount"] = 36000
|
data["amount"] = 36000
|
||||||
//tp=tp
|
//tp=tp
|
||||||
}
|
}
|
||||||
data["amount"] = 1
|
//data["amount"] = 1
|
||||||
|
|
||||||
if user.GetCeilInt("salesman_id") != 0 {
|
if user.GetCeilInt("salesman_id") != 0 {
|
||||||
data["salesman_id"] = user.GetCeilInt("salesman_id")
|
data["salesman_id"] = user.GetCeilInt("salesman_id")
|
||||||
|
@ -29,7 +29,7 @@ var Wechath5 = Ctr{
|
|||||||
"retoken": resToken.RefreshToken,
|
"retoken": resToken.RefreshToken,
|
||||||
"appid": appid,
|
"appid": appid,
|
||||||
"unionid": userInfo.Unionid,
|
"unionid": userInfo.Unionid,
|
||||||
"nickname": userInfo.Nickname,
|
"nickname": FilterEmoji(userInfo.Nickname),
|
||||||
"avatar": userInfo.HeadImgURL,
|
"avatar": userInfo.HeadImgURL,
|
||||||
"create_time[#]": "now()",
|
"create_time[#]": "now()",
|
||||||
"modify_time[#]": "now()",
|
"modify_time[#]": "now()",
|
||||||
@ -39,6 +39,7 @@ var Wechath5 = Ctr{
|
|||||||
|
|
||||||
userId := 0
|
userId := 0
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
||||||
//有sn就关联业务员
|
//有sn就关联业务员
|
||||||
parentId := ObjToInt(that.Req.FormValue("parent_id"))
|
parentId := ObjToInt(that.Req.FormValue("parent_id"))
|
||||||
if parentId == 0 {
|
if parentId == 0 {
|
||||||
@ -83,6 +84,7 @@ var Wechath5 = Ctr{
|
|||||||
if user == nil {
|
if user == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//用户都有企服人员关联
|
//用户都有企服人员关联
|
||||||
if user.GetCeilInt("salesman_id") != 0 {
|
if user.GetCeilInt("salesman_id") != 0 {
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
. "code.hoteas.com/golang/hotime"
|
. "code.hoteas.com/golang/hotime"
|
||||||
. "code.hoteas.com/golang/hotime/common"
|
. "code.hoteas.com/golang/hotime/common"
|
||||||
"time"
|
"time"
|
||||||
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Project 管理端项目
|
// Project 管理端项目
|
||||||
@ -33,3 +34,15 @@ func getCode() string {
|
|||||||
//}
|
//}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 过滤 emoji 表情
|
||||||
|
func FilterEmoji(content string) string {
|
||||||
|
new_content := ""
|
||||||
|
for _, value := range content {
|
||||||
|
_, size := utf8.DecodeRuneInString(string(value))
|
||||||
|
if size <= 3 {
|
||||||
|
new_content += string(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new_content
|
||||||
|
}
|
||||||
|
@ -30,9 +30,9 @@ var MattersCtr = Ctr{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
res["user"] = that.Db.Get("user", "id,name,nickname,company_id", Map{"user_id": res.GetCeilInt64("user_id")})
|
res["user"] = that.Db.Get("user", "id,name,nickname,company_id", Map{"id": res.GetCeilInt64("user_id")})
|
||||||
if res.GetMap("user") != nil && res.GetMap("user").GetCeilInt64("company_id") != 0 {
|
if res.GetMap("user") != nil && res.GetMap("user").GetCeilInt64("company_id") != 0 {
|
||||||
res["company"] = that.Db.Get("company", "id,name", Map{"company_id": res.GetMap("user").GetCeilInt64("company_id")})
|
res["company"] = that.Db.Get("company", "id,name", Map{"id": res.GetMap("user").GetCeilInt64("company_id")})
|
||||||
}
|
}
|
||||||
that.Display(0, res)
|
that.Display(0, res)
|
||||||
},
|
},
|
||||||
|
@ -22,6 +22,15 @@ var Salesman = Ctr{
|
|||||||
that.Display(4, "找不到该业务员")
|
that.Display(4, "找不到该业务员")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if salesman.GetString("nickname") == "" {
|
||||||
|
wechat := that.Db.Get("wechat", "*", Map{"salesman_id": salesman.GetCeilInt64("id")})
|
||||||
|
if wechat != nil {
|
||||||
|
salesman["nickname"] = wechat.GetString("nickname")
|
||||||
|
salesman["avatar"] = wechat.GetString("avatar")
|
||||||
|
that.Db.Update("salesman", Map{"nickname": wechat.GetString("nickname"), "avatar": wechat.GetString("avatar")}, Map{"id": salesman.GetCeilInt64("id")})
|
||||||
|
}
|
||||||
|
}
|
||||||
salesman["user"] = that.Db.Count("user", Map{"AND": Map{"salesman_id": that.Session("salesman_id").Data, "del_flag": 0}})
|
salesman["user"] = that.Db.Count("user", Map{"AND": Map{"salesman_id": that.Session("salesman_id").Data, "del_flag": 0}})
|
||||||
salesman["matters"] = that.Db.Count("matters", Map{"AND": Map{"salesman_id": that.Session("salesman_id").Data, "del_flag": 0}})
|
salesman["matters"] = that.Db.Count("matters", Map{"AND": Map{"salesman_id": that.Session("salesman_id").Data, "del_flag": 0}})
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package provider
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
. "code.hoteas.com/golang/hotime"
|
. "code.hoteas.com/golang/hotime"
|
||||||
|
"code.hoteas.com/golang/hotime/common"
|
||||||
"code.hoteas.com/golang/hotime/dri/ddsms"
|
"code.hoteas.com/golang/hotime/dri/ddsms"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,6 +21,12 @@ var Sms = Ctr{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
salesman := that.Db.Get("salesman", "id", common.Map{"phone": phone})
|
||||||
|
if salesman == nil {
|
||||||
|
that.Display(3, "你还不是企服人员,请联系管理员")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
code := getCode()
|
code := getCode()
|
||||||
that.Session("phone", phone)
|
that.Session("phone", phone)
|
||||||
that.Session("code", code)
|
that.Session("code", code)
|
||||||
|
@ -29,7 +29,7 @@ var Wechat = Ctr{
|
|||||||
"retoken": resToken.RefreshToken,
|
"retoken": resToken.RefreshToken,
|
||||||
"appid": appid,
|
"appid": appid,
|
||||||
"unionid": userInfo.Unionid,
|
"unionid": userInfo.Unionid,
|
||||||
"nickname": userInfo.Nickname,
|
"nickname": FilterEmoji(userInfo.Nickname),
|
||||||
"avatar": userInfo.HeadImgURL,
|
"avatar": userInfo.HeadImgURL,
|
||||||
//"create_time[#]":"now()",
|
//"create_time[#]":"now()",
|
||||||
"modify_time[#]": "now()",
|
"modify_time[#]": "now()",
|
||||||
|
32
example/tpt/pc.html
Normal file
32
example/tpt/pc.html
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>微信登录</title>
|
||||||
|
<script type="text/javascript" src="js/hotime.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
function run() {
|
||||||
|
var data={"timestamp": window.H.getParam("timestamp"),"sn":window.H.getParam("sn")}
|
||||||
|
// if(data.code==null){
|
||||||
|
// location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4d97696b9ecb49fc&redirect_uri='+location.href+'&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect'
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
window.H.post("app/upan/login", data, function (res) {
|
||||||
|
if (res.status != 0) {
|
||||||
|
alert(res.result.msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// let res = { "result": { "acttoken": "56_ogEfWa4mglG-Ilf2kD50FfekZWimJXUouZ4gMKmkVP2CwcLwv2lHO35LOn5NSLOQ-yEAZcIs3FvgIBhk2uF9CA", "appid": "wx4d97696b9ecb49fc", "avatar": "https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLNj0yKXe77H8C60ic2lUFIx5hkibf0FluNCRfTkiazrBfuqclqRhm4nDug9Hx3nsXQhtzNdfchAvJTQ/132", "nickname": "候鸟半夏", "openid": "oPoZT6juCkF6fvnMHrCFI6SK_vK8", "retoken": "56_tjuJPobvbLVvOPtqPRZjTzQHR7i3Vmx_aGXOy9j0WsNTFS_JRnb4ArmUGhWtq6e7eCpUnPNKulIQ44CPiBnYEA", "unionid": "ofKK36PEkbIt0xMMUgch4H-bVaFI" }, "status": 0 }
|
||||||
|
location.href="/#/home"
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
run()
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user