forked from golang/hotime
Merge branch 'zct-v2-dengluyang' of https://code.hoteas.com/golang/hotime into zhoupengwei
This commit is contained in:
commit
d656faf915
23
context.go
23
context.go
@ -13,19 +13,18 @@ type Context struct {
|
|||||||
*Application
|
*Application
|
||||||
Resp http.ResponseWriter
|
Resp http.ResponseWriter
|
||||||
Req *http.Request
|
Req *http.Request
|
||||||
Log Map//日志有则创建
|
Log Map //日志有则创建
|
||||||
RouterString []string
|
RouterString []string
|
||||||
Config Map
|
Config Map
|
||||||
Db *HoTimeDB
|
Db *HoTimeDB
|
||||||
RespData Map
|
RespData Map
|
||||||
RespFunc func()
|
RespFunc func()
|
||||||
CacheIns
|
CacheIns
|
||||||
SessionIns
|
SessionIns
|
||||||
DataSize int
|
DataSize int
|
||||||
HandlerStr string //复写请求url
|
HandlerStr string //复写请求url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Mtd 唯一标志
|
// Mtd 唯一标志
|
||||||
func (that *Context) Mtd(router [3]string) Map {
|
func (that *Context) Mtd(router [3]string) Map {
|
||||||
that.Application.Router[router[0]][router[1]][router[2]](that)
|
that.Application.Router[router[0]][router[1]][router[2]](that)
|
||||||
@ -61,26 +60,28 @@ func (that *Context) Display(statu int, data interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (that *Context) View() {
|
func (that *Context) View() {
|
||||||
if that.RespFunc!=nil {
|
if that.RespFunc != nil {
|
||||||
that.RespFunc()
|
that.RespFunc()
|
||||||
}
|
}
|
||||||
if that.RespData == nil {
|
if that.RespData == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//创建日志
|
//创建日志
|
||||||
if that.Log!=nil{
|
if that.Log != nil {
|
||||||
that.Log["time"]=time.Now().Unix()
|
that.Log["time"] = time.Now().Unix()
|
||||||
if that.Session("admin_id").Data!=nil{
|
if that.Session("admin_id").Data != nil {
|
||||||
that.Log["admin_id"]=that.Session("admin_id").ToCeilInt()
|
that.Log["admin_id"] = that.Session("admin_id").ToCeilInt()
|
||||||
}
|
}
|
||||||
if that.Session("user_id").Data!=nil{
|
if that.Session("user_id").Data != nil {
|
||||||
that.Log["user_id"]=that.Session("user_id").ToCeilInt()
|
that.Log["user_id"] = that.Session("user_id").ToCeilInt()
|
||||||
}
|
}
|
||||||
that.Db.Insert("logs",that.Log)
|
that.Db.Insert("logs", that.Log)
|
||||||
}
|
}
|
||||||
|
|
||||||
d, err := json.Marshal(that.RespData)
|
d, err := json.Marshal(that.RespData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
that.Display(1, err.Error())
|
||||||
|
that.View()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
that.DataSize = len(d)
|
that.DataSize = len(d)
|
||||||
|
@ -24,8 +24,8 @@ func (that *tencent) Init(secretId, secretKey string) {
|
|||||||
that.secretId = secretId
|
that.secretId = secretId
|
||||||
that.secretKey = secretKey
|
that.secretKey = secretKey
|
||||||
that.credential = common.NewCredential(
|
that.credential = common.NewCredential(
|
||||||
"AKIDOgT8cKCQksnY7yKATaYO7j9ORJzSYohP",
|
that.secretId,
|
||||||
"GNXgjdN4czA9ya0FNMApVJzTmsmU0KSN",
|
that.secretKey,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -893,7 +893,7 @@ var DeclareCtr = Ctr{
|
|||||||
RecommendDeclare = declare
|
RecommendDeclare = declare
|
||||||
}
|
}
|
||||||
|
|
||||||
matchingDegreePercent := ObjToFloat64(matchingDegree) / ObjToFloat64(matchingDegreeCount)
|
matchingDegreePercent := ObjToFloat64(ObjToFloat64(matchingDegree) / ObjToFloat64(matchingDegreeCount))
|
||||||
|
|
||||||
if matchingDegreePercent < 0.5 {
|
if matchingDegreePercent < 0.5 {
|
||||||
matchingDegreePercent = 0.5 + matchingDegreePercent
|
matchingDegreePercent = 0.5 + matchingDegreePercent
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
"sessionName": "HOTIME",
|
"sessionName": "HOTIME",
|
||||||
"smsKey": "b0eb4bf0198b9983cffcb85b69fdf4fa",
|
"smsKey": "b0eb4bf0198b9983cffcb85b69fdf4fa",
|
||||||
"smsLogin": "【政策通】您的验证码为:{code},请在5分钟内使用,切勿将验证码泄露于他人,如非本人操作请忽略。",
|
"smsLogin": "【政策通】您的验证码为:{code},请在5分钟内使用,切勿将验证码泄露于他人,如非本人操作请忽略。",
|
||||||
|
"tencentId": "AKIDOgT8cKCQksnY7yKATaYO7j9ORJzSYohP",
|
||||||
|
"tencentKey": "GNXgjdN4czA9ya0FNMApVJzTmsmU0KSN",
|
||||||
"tpt": "tpt",
|
"tpt": "tpt",
|
||||||
"wechatAppID": "wxdcc8d6360661a179",
|
"wechatAppID": "wxdcc8d6360661a179",
|
||||||
"wechatAppNotifyUrl": "https://zcth5.kct.cn/app/vip_order/callback",
|
"wechatAppNotifyUrl": "https://zcth5.kct.cn/app/vip_order/callback",
|
||||||
|
@ -2,14 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
. "code.hoteas.com/golang/hotime"
|
. "code.hoteas.com/golang/hotime"
|
||||||
"code.hoteas.com/golang/hotime/common"
|
|
||||||
"code.hoteas.com/golang/hotime/dri/aliyun"
|
"code.hoteas.com/golang/hotime/dri/aliyun"
|
||||||
"code.hoteas.com/golang/hotime/dri/ddsms"
|
"code.hoteas.com/golang/hotime/dri/ddsms"
|
||||||
|
"code.hoteas.com/golang/hotime/dri/tencent"
|
||||||
"code.hoteas.com/golang/hotime/dri/wechat"
|
"code.hoteas.com/golang/hotime/dri/wechat"
|
||||||
"code.hoteas.com/golang/hotime/example/app"
|
"code.hoteas.com/golang/hotime/example/app"
|
||||||
"code.hoteas.com/golang/hotime/example/provider"
|
"code.hoteas.com/golang/hotime/example/provider"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
//. "code.hoteas.com/golang/hotime/common"
|
//. "code.hoteas.com/golang/hotime/common"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
@ -35,17 +33,18 @@ func main() {
|
|||||||
appIns.Config.GetString("wechatPaySerialNo"),
|
appIns.Config.GetString("wechatPaySerialNo"),
|
||||||
appIns.Config.GetString("wechatPayMApiV3Key"),
|
appIns.Config.GetString("wechatPayMApiV3Key"),
|
||||||
appIns.Config.GetString("wechatPayPrivateKey"))
|
appIns.Config.GetString("wechatPayPrivateKey"))
|
||||||
|
tencent.Tencent.Init(appIns.Config.GetString("tencentId"), appIns.Config.GetString("tencentKey"))
|
||||||
|
|
||||||
//用户侧访问前设置
|
//用户侧访问前设置
|
||||||
appIns.SetConnectListener(func(that *Context) (isFinished bool) {
|
appIns.SetConnectListener(func(that *Context) (isFinished bool) {
|
||||||
//发送短信校验
|
//发送短信校验
|
||||||
that.RespFunc = func() {
|
//that.RespFunc = func() {
|
||||||
go func(Form url.Values, RespData common.Map) {
|
// go func(Form url.Values, RespData common.Map) {
|
||||||
fmt.Println(Form)
|
// fmt.Println(Form)
|
||||||
fmt.Println(RespData)
|
// fmt.Println(RespData)
|
||||||
}(that.Req.Form, that.RespData)
|
// }(that.Req.Form, that.RespData)
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
||||||
return isFinished
|
return isFinished
|
||||||
})
|
})
|
||||||
|
@ -3,9 +3,71 @@ 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/common"
|
||||||
|
"code.hoteas.com/golang/hotime/dri/aliyun"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var CompanyCtr = Ctr{
|
var CompanyCtr = Ctr{
|
||||||
|
|
||||||
|
"search": func(that *Context) {
|
||||||
|
if that.Session("user_id").Data == nil {
|
||||||
|
that.Display(2, "没有登录")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
keywords := that.Req.FormValue("keywords")
|
||||||
|
if keywords == "" {
|
||||||
|
keywords = that.Req.FormValue("company_name")
|
||||||
|
}
|
||||||
|
if keywords == "" {
|
||||||
|
keywords = that.Req.FormValue("name")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(keywords) < 2 {
|
||||||
|
that.Display(0, Slice{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := aliyun.Company.GetCompanyList(keywords)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
that.Display(0, Slice{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if res.GetCeilInt64("status") != 200 {
|
||||||
|
fmt.Println(err)
|
||||||
|
that.Display(0, Slice{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
that.Display(0, res.GetMap("data").GetSlice("list"))
|
||||||
|
},
|
||||||
|
"search_info": func(that *Context) {
|
||||||
|
if that.Session("user_id").Data == nil {
|
||||||
|
that.Display(2, "没有登录")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
name := that.Req.FormValue("name")
|
||||||
|
|
||||||
|
if len(name) < 2 {
|
||||||
|
that.Display(3, "找不到企业")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := aliyun.Company.GetCompanyBaseInfo(name)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
that.Display(4, "查询失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if res.GetBool("status") != true {
|
||||||
|
fmt.Println(err)
|
||||||
|
that.Display(4, "查询失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
that.Display(0, res.GetMap("data"))
|
||||||
|
},
|
||||||
|
|
||||||
"info": func(that *Context) {
|
"info": func(that *Context) {
|
||||||
if that.Session("salesman_id").Data == nil {
|
if that.Session("salesman_id").Data == nil {
|
||||||
that.Display(2, "没有登录")
|
that.Display(2, "没有登录")
|
||||||
@ -74,7 +136,7 @@ var CompanyCtr = Ctr{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
that.Db.Update("company", company, Map{"id": id})
|
that.Db.Update("company", data, Map{"id": id})
|
||||||
|
|
||||||
that.Display(0, "更新成功")
|
that.Display(0, "更新成功")
|
||||||
|
|
||||||
|
@ -132,6 +132,8 @@ var Salesman = Ctr{
|
|||||||
}
|
}
|
||||||
|
|
||||||
that.Db.Update("wechat", Map{"salesman_id": salesman.GetCeilInt64("id")}, Map{"id": wechat.GetInt64("id")})
|
that.Db.Update("wechat", Map{"salesman_id": salesman.GetCeilInt64("id")}, Map{"id": wechat.GetInt64("id")})
|
||||||
|
that.Db.Update("salesman", Map{"login_time[#]": "now()", "modify_time[#]": "now()"},
|
||||||
|
Map{"id": salesman.GetCeilInt("id")})
|
||||||
|
|
||||||
wechat["salesman_id"] = salesman.GetCeilInt64("id")
|
wechat["salesman_id"] = salesman.GetCeilInt64("id")
|
||||||
that.Session("salesman_id", salesman.GetCeilInt64("id"))
|
that.Session("salesman_id", salesman.GetCeilInt64("id"))
|
||||||
|
@ -43,6 +43,8 @@ var Wechat = Ctr{
|
|||||||
//有用户直接返回
|
//有用户直接返回
|
||||||
if wechat.GetCeilInt("salesman_id") != 0 {
|
if wechat.GetCeilInt("salesman_id") != 0 {
|
||||||
|
|
||||||
|
that.Db.Update("salesman", Map{"login_time[#]": "now()"},
|
||||||
|
Map{"id": wechat.GetCeilInt("salesman_id")})
|
||||||
that.Session("salesman_id", wechat.GetCeilInt("salesman_id"))
|
that.Session("salesman_id", wechat.GetCeilInt("salesman_id"))
|
||||||
|
|
||||||
that.Display(0, "登录成功")
|
that.Display(0, "登录成功")
|
||||||
|
Loading…
Reference in New Issue
Block a user