政企超链接开始集成
This commit is contained in:
+125
-31
@@ -3,11 +3,11 @@ package app
|
||||
import (
|
||||
. "../../../hotime"
|
||||
. "../../../hotime/common"
|
||||
"../../../hotime/dri/download"
|
||||
"encoding/base64"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"../../../hotime/dri/download"
|
||||
"strings"
|
||||
"time"
|
||||
//"strings"
|
||||
)
|
||||
@@ -24,17 +24,63 @@ var User = Ctr{
|
||||
this.Display(2, "还没有登录")
|
||||
return
|
||||
}
|
||||
if this.Session("user_id").Data == nil {
|
||||
this.Display(2, "还没有登录")
|
||||
return
|
||||
}
|
||||
|
||||
user := this.Db.Get("user", "*", Map{"id": this.Session("user_id").Data})
|
||||
if user == nil {
|
||||
this.Display(4, "找不到该用户")
|
||||
return
|
||||
}
|
||||
company := this.Db.Get("company", "id,name,status", Map{"id": user.GetCeilInt("company_id")})
|
||||
user["company"] = company
|
||||
|
||||
t := time.Now().Unix()
|
||||
|
||||
questions := this.Db.Select("question", "*", Map{"AND": Map{"org_id": user.GetCeilInt("org_id"), "start_time[<=]": t, "end_time[>=]": t, "state": 0}})
|
||||
re := []Map{}
|
||||
|
||||
for _, v := range questions {
|
||||
questionCompany := this.Db.Get("question_company", "*", Map{"AND": Map{"question_id": v.GetCeilInt("id"), "company_id": user.GetCeilInt("company_id")}})
|
||||
if questionCompany == nil {
|
||||
questionCompany = Map{
|
||||
"name": v.GetString("name"),
|
||||
"question_data": v.GetString("question_data"),
|
||||
"org_id": v.GetString("org_id"),
|
||||
"question_id": v.GetString("id"),
|
||||
"company_id": user.GetCeilInt("company_id"),
|
||||
"user_id": user.GetString("id"),
|
||||
"create_time": t,
|
||||
"modify_time": t,
|
||||
"status": 0,
|
||||
"state": 0,
|
||||
}
|
||||
questionCompany["id"] = this.Db.Insert("question_company", questionCompany)
|
||||
if questionCompany.GetCeilInt("id") == 0 {
|
||||
this.Display(4, "无法创建调查数据")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
delete(v, "question_data")
|
||||
questionCompany["question"] = v
|
||||
questionCompany["question_data"] = questionCompany.GetSlice("question_data")
|
||||
re = append(re, questionCompany)
|
||||
}
|
||||
user["questions"] = re
|
||||
|
||||
this.Display(0, user)
|
||||
|
||||
},
|
||||
//身份认证
|
||||
"auth": func(this *Context) {
|
||||
|
||||
if this.Session("wechatInfo").Data == nil {
|
||||
this.Display(2, "尚未登录")
|
||||
return
|
||||
}
|
||||
//if this.Session("wechatInfo").Data == nil {
|
||||
// this.Display(2, "尚未登录")
|
||||
// return
|
||||
//}
|
||||
|
||||
//if this.Session("code").Data == nil {
|
||||
// this.Display(8, "验证码没有获取")
|
||||
@@ -85,7 +131,8 @@ var User = Ctr{
|
||||
company["modify_time"] = t
|
||||
company["img"] = companyImg
|
||||
company["org_id"] = orgId
|
||||
|
||||
company["name"] = companyName
|
||||
//company["img"] = companyImg
|
||||
re := this.Db.Update("company", company, Map{"id": company.GetCeilInt("id")})
|
||||
if re == 0 {
|
||||
this.Display(4, "无法更新企业")
|
||||
@@ -114,13 +161,15 @@ var User = Ctr{
|
||||
return
|
||||
}
|
||||
} else {
|
||||
data["nickname"] = userInfo.GetString("nickname")
|
||||
data["create_time"] = t
|
||||
path := time.Now().Format(this.Config.GetString("uimgPath"))
|
||||
filename := Md5(ObjToStr(t)) + ".jpg"
|
||||
down := download.Down(userInfo.GetString("avatar"), this.Config.GetString("tpt")+"/"+path, filename)
|
||||
if down {
|
||||
data["avatar"] = path + filename
|
||||
if userInfo != nil {
|
||||
data["nickname"] = userInfo.GetString("nickname")
|
||||
path := time.Now().Format(this.Config.GetString("imgPath"))
|
||||
filename := Md5(ObjToStr(t)) + ".jpg"
|
||||
down := download.Down(userInfo.GetString("avatar"), this.Config.GetString("tpt")+"/"+path, filename)
|
||||
if down {
|
||||
data["avatar"] = path + filename
|
||||
}
|
||||
}
|
||||
user = data
|
||||
user["id"] = this.Db.Insert("user", data)
|
||||
@@ -129,25 +178,25 @@ var User = Ctr{
|
||||
return
|
||||
}
|
||||
}
|
||||
if userInfo != nil {
|
||||
delete(userInfo, "avatar")
|
||||
delete(userInfo, "nickname")
|
||||
userInfo["modify_time"] = t
|
||||
userInfo["user_id"] = user.GetCeilInt("id")
|
||||
|
||||
delete(userInfo, "avatar")
|
||||
delete(userInfo, "nickname")
|
||||
userInfo["modify_time"] = t
|
||||
userInfo["user_id"] = user.GetCeilInt("id")
|
||||
wechatDb := this.Db.Get("wechat", "*", Map{"openid": userInfo.GetString("openid")})
|
||||
|
||||
wechatDb := this.Db.Get("wechat", "*", Map{"openid": userInfo.GetString("openid")})
|
||||
if wechatDb != nil {
|
||||
|
||||
if wechatDb != nil {
|
||||
|
||||
this.Db.Update("wechat", userInfo, Map{"id": wechatDb.GetCeilInt("id")})
|
||||
//userInfo["wid"]=wechatDb.GetCeilInt("wid")
|
||||
} else {
|
||||
userInfo["create_time"] = t
|
||||
userInfo["id"] = this.Db.Insert("wechat", userInfo)
|
||||
this.Db.Update("wechat", userInfo, Map{"id": wechatDb.GetCeilInt("id")})
|
||||
//userInfo["wid"]=wechatDb.GetCeilInt("wid")
|
||||
} else {
|
||||
userInfo["create_time"] = t
|
||||
userInfo["id"] = this.Db.Insert("wechat", userInfo)
|
||||
}
|
||||
}
|
||||
|
||||
this.Session("user_id", user.GetCeilInt("id"))
|
||||
this.Display(0, "认证成功!")
|
||||
this.Display(0, this.SessionId)
|
||||
|
||||
},
|
||||
|
||||
@@ -191,15 +240,15 @@ var User = Ctr{
|
||||
return
|
||||
}
|
||||
//fmt.Println(uimg)
|
||||
|
||||
btes, e := base64.StdEncoding.DecodeString(file) //成图片文件并把文件写入到buffer
|
||||
btes, e := base64.StdEncoding.DecodeString(file[strings.Index(file, ",")+1:]) //成图片文件并把文件写入到buffer
|
||||
//btes, e := base64.StdEncoding.DecodeString(file) //成图片文件并把文件写入到buffer
|
||||
if e != nil {
|
||||
this.Display(3, "无法解析图片")
|
||||
return
|
||||
}
|
||||
|
||||
//uimgPath:=time.Now().Format(this.Config.GetString("uimgPath"))
|
||||
path := time.Now().Format(this.Config.GetString("imgPath"))
|
||||
path := time.Now().Format(this.Config.GetString("wxFilePath"))
|
||||
os.MkdirAll(this.Config.GetString("tpt")+"/"+path, os.ModeDir)
|
||||
filePath := path + Md5(ObjToStr(time.Now().Unix())) + ".jpg"
|
||||
|
||||
@@ -211,7 +260,52 @@ var User = Ctr{
|
||||
}
|
||||
this.Display(0, filePath)
|
||||
},
|
||||
|
||||
//"upload": func(this *Context) {
|
||||
//
|
||||
// //读取网络文件
|
||||
// fi, fheader, err := this.Req.FormFile("file")
|
||||
// if err != nil {
|
||||
// this.Display(3, err)
|
||||
// return
|
||||
//
|
||||
// }
|
||||
// filePath := this.Config.GetString("wxFilePath")
|
||||
// if filePath == "" {
|
||||
// filePath = "file/2006/01/02/"
|
||||
// }
|
||||
//
|
||||
// path := time.Now().Format(filePath)
|
||||
// e := os.MkdirAll(this.Config.GetString("tpt")+"/"+path, os.ModeDir)
|
||||
//
|
||||
// if e != nil {
|
||||
// this.Display(3, e)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// filePath = path + Md5(ObjToStr(RandX(100000, 9999999))) + fheader.Filename[strings.LastIndex(fheader.Filename, "."):]
|
||||
// newFile, e := os.Create(this.Config.GetString("tpt") + "/" + filePath)
|
||||
//
|
||||
// if e != nil {
|
||||
// this.Display(3, e)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// _, e = io.Copy(newFile, fi)
|
||||
//
|
||||
// if e != nil {
|
||||
// this.Display(3, e)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// //this.Display(0, filePath)
|
||||
//
|
||||
// //读取excel
|
||||
// //fmt.Println(Org[orgId],OrgId)
|
||||
//
|
||||
//
|
||||
// this.Display(0, filePath)
|
||||
//
|
||||
//},
|
||||
//更新个人资料
|
||||
//"update": func(this *Context) {
|
||||
// if this.Req.Form["unickname"] == nil ||
|
||||
|
||||
Reference in New Issue
Block a user