diff --git a/app/user.go b/app/user.go index fb66386..8bcde80 100644 --- a/app/user.go +++ b/app/user.go @@ -187,8 +187,11 @@ var User = Ctr{ return } } - - user := this.Db.Get("user", "*", Map{"phone": phone}) + uWhere := Map{"phone": phone} + if this.Session("user_id").ToCeilInt() != 0 { + uWhere = Map{"id": this.Session("user_id").ToCeilInt()} + } + user := this.Db.Get("user", "*", uWhere) data := Map{"name": name, "phone": phone, //"org_id": orgId, diff --git a/app/wechat.go b/app/wechat.go index e42de0e..7c9991b 100644 --- a/app/wechat.go +++ b/app/wechat.go @@ -45,38 +45,104 @@ var Wechat = Ctr{ }, //微信注册,0已经完整的注册了,1还没有注册 "codebase": func(this *Context) { + //wx := Weixin(this) + ////auth := wx.GetOauth(this.Req, this.Resp) + //auth := wx.GetOauth() + //resToken, err := auth.GetUserAccessToken(this.Req.FormValue("code")) + //if err != nil { + // this.Display(6, "code错误") + // return + //} + // + ////判断用户是否已经注册 + //user := this.Db.Get("wechat", Map{"[><]user": "wechat.user_id=user.id"}, "user.id,user.state", Map{"openid": resToken.OpenID}) + //if user != nil { + // this.Session("user_id", user.Get("id")) + // this.Display(0, 0) + // return + //} + // + //user_id := this.Db.Insert("user", Map{"create_time": time.Now().Unix(), "modify_time": time.Now().Unix(), "state": 2}) + //if user_id == 0 { + // this.Display(4, "创建用户失败") + // return + //} + // + //wid := this.Db.Insert("wechat", Map{"openid": resToken.OpenID, "appid": this.Config.GetString("wechatAppID"), "state": 1, "user_id": user_id}) + //if wid == 0 { + // this.Display(4, "关联微信失败!") + // return + //} + // + //this.Session("user_id", user.Get("id")) + // + //this.Display(0, 1) + + orgId := ObjToInt(this.Req.FormValue("org_id")) + //if orgId==0{ + // this.Display(3, "缺少组织id") + // return + //} + wx := Weixin(this) //auth := wx.GetOauth(this.Req, this.Resp) auth := wx.GetOauth() resToken, err := auth.GetUserAccessToken(this.Req.FormValue("code")) if err != nil { - this.Display(6, "code错误") + this.Display(5, "code错误") return } //判断用户是否已经注册 user := this.Db.Get("wechat", Map{"[><]user": "wechat.user_id=user.id"}, "user.id,user.state", Map{"openid": resToken.OpenID}) - if user != nil { + if user != nil && user.GetCeilInt("id") != 0 && user.GetCeilInt("state") == 0 { this.Session("user_id", user.Get("id")) - this.Display(0, 0) + this.Display(0, Map{"type": 0, "token": this.SessionId}) + return + } + //getUserInfo + userInfo, err := auth.GetUserInfo(resToken.AccessToken, resToken.OpenID) + if err != nil { + this.Display(6, "微信个人信息无法获取") return } - user_id := this.Db.Insert("user", Map{"create_time": time.Now().Unix(), "modify_time": time.Now().Unix(), "state": 2}) - if user_id == 0 { - this.Display(4, "创建用户失败") - return + fmt.Println(userInfo) + + //wechatInfo := ObjToMap(userInfo) + t := time.Now().Unix() + wechatInfo := Map{ + "openid": userInfo.OpenID, + "acttoken": resToken.AccessToken, + "retoken": resToken.RefreshToken, + "appid": this.Config.GetString("wechatAppID"), + "unionid": userInfo.Unionid, + "nickname": userInfo.Nickname, + "avatar": userInfo.HeadImgURL, + } + if orgId != 0 { + wechatInfo["org_id"] = orgId + wechatInfo["status"] = 0 } - wid := this.Db.Insert("wechat", Map{"openid": resToken.OpenID, "appid": this.Config.GetString("wechatAppID"), "state": 1, "user_id": user_id}) - if wid == 0 { - this.Display(4, "关联微信失败!") - return + wechatDb := this.Db.Get("wechat", "*", Map{"openid": wechatInfo.GetString("openid")}) + + if wechatDb != nil { + + this.Db.Update("wechat", wechatInfo, Map{"id": wechatDb.GetCeilInt("id")}) + //userInfo["wid"]=wechatDb.GetCeilInt("wid") + } else { + wechatInfo["create_time"] = t + wechatInfo["id"] = this.Db.Insert("wechat", wechatInfo) } + wechatDb = this.Db.Get("wechat", "*", Map{"openid": wechatInfo.GetString("openid")}) - this.Session("user_id", user.Get("id")) + this.Session("wechatInfo", wechatDb) + fmt.Println(wechatDb) + fmt.Println(this.Session("wechatInfo")) + //this.Display(0, 1) + this.Display(0, Map{"type": 1, "token": this.SessionId}) - this.Display(0, 1) }, //微信注册,0已经完整的注册了,1还没有注册 "code": func(this *Context) { diff --git a/config/adminDB.json b/config/adminDB.json index a784205..f76b8a8 100644 --- a/config/adminDB.json +++ b/config/adminDB.json @@ -144,210 +144,6 @@ "show": "开启" }, "menus": [ - { - "auth": [ - "show" - ], - "icon": "Setting", - "label": "企业调整", - "menus": [ - { - "auth": [ - "show", - "add", - "delete", - "edit", - "info", - "download" - ], - "label": "企业调整", - "table": "company_tune" - }, - { - "auth": [ - "show", - "add", - "delete", - "edit", - "info", - "download" - ], - "label": "历史信息", - "table": "company_history" - }, - { - "auth": [ - "show", - "add", - "delete", - "edit", - "info", - "download" - ], - "label": "企业管理", - "table": "company" - } - ], - "name": "sys:company" - }, - { - "auth": [ - "show" - ], - "icon": "Setting", - "label": "产业分类", - "menus": [ - { - "auth": [ - "show", - "add", - "delete", - "edit", - "info", - "download" - ], - "label": "产业分类", - "table": "industry" - }, - { - "auth": [ - "show", - "add", - "delete", - "edit", - "info", - "download" - ], - "label": "产业分析", - "table": "industry_analyse" - } - ], - "name": "sys:industry" - }, - { - "auth": [ - "show" - ], - "icon": "Setting", - "label": "指标分类", - "menus": [ - { - "auth": [ - "show", - "add", - "delete", - "edit", - "info", - "download" - ], - "label": "指标分类", - "table": "tag_ctg" - }, - { - "auth": [ - "show", - "add", - "delete", - "edit", - "info", - "download" - ], - "label": "指标管理", - "table": "tag" - } - ], - "name": "sys:tag" - }, - { - "auth": [ - "show" - ], - "icon": "Setting", - "label": "系统管理", - "menus": [ - { - "auth": [ - "show", - "add", - "delete", - "edit", - "info", - "download" - ], - "label": "角色管理", - "table": "role" - }, - { - "auth": [ - "show", - "add", - "delete", - "edit", - "info", - "download" - ], - "label": "企业用户", - "table": "user" - }, - { - "auth": [ - "show", - "add", - "delete", - "edit", - "info", - "download" - ], - "label": "地区管理", - "table": "area" - }, - { - "auth": [ - "show", - "add", - "delete", - "edit", - "info", - "download" - ], - "label": "人员管理", - "table": "admin" - }, - { - "auth": [ - "show", - "download" - ], - "label": "日志管理", - "table": "logs" - }, - { - "auth": [ - "show", - "add", - "delete", - "edit", - "info", - "download" - ], - "label": "微信信息", - "table": "wechat" - }, - { - "auth": [ - "show", - "add", - "delete", - "edit", - "info", - "download" - ], - "label": "城市管理", - "table": "city" - } - ], - "name": "sys" - }, { "auth": [ "show" @@ -416,6 +212,142 @@ ], "name": "sys:org" }, + { + "auth": [ + "show" + ], + "icon": "Setting", + "label": "系统管理", + "menus": [ + { + "auth": [ + "show", + "add", + "delete", + "edit", + "info", + "download" + ], + "label": "微信信息", + "table": "wechat" + }, + { + "auth": [ + "show", + "add", + "delete", + "edit", + "info", + "download" + ], + "label": "人员管理", + "table": "admin" + }, + { + "auth": [ + "show", + "add", + "delete", + "edit", + "info", + "download" + ], + "label": "城市管理", + "table": "city" + }, + { + "auth": [ + "show", + "add", + "delete", + "edit", + "info", + "download" + ], + "label": "企业用户", + "table": "user" + }, + { + "auth": [ + "show", + "download" + ], + "label": "日志管理", + "table": "logs" + }, + { + "auth": [ + "show", + "add", + "delete", + "edit", + "info", + "download" + ], + "label": "角色管理", + "table": "role" + }, + { + "auth": [ + "show", + "add", + "delete", + "edit", + "info", + "download" + ], + "label": "地区管理", + "table": "area" + } + ], + "name": "sys" + }, + { + "auth": [ + "show" + ], + "icon": "Setting", + "label": "历史信息", + "menus": [ + { + "auth": [ + "show", + "add", + "delete", + "edit", + "info", + "download" + ], + "label": "历史信息", + "table": "company_history" + }, + { + "auth": [ + "show", + "add", + "delete", + "edit", + "info", + "download" + ], + "label": "企业调整", + "table": "company_tune" + }, + { + "auth": [ + "show", + "add", + "delete", + "edit", + "info", + "download" + ], + "label": "企业管理", + "table": "company" + } + ], + "name": "sys:company" + }, { "auth": [ "show" @@ -449,6 +381,74 @@ } ], "name": "sys:question" + }, + { + "auth": [ + "show" + ], + "icon": "Setting", + "label": "指标管理", + "menus": [ + { + "auth": [ + "show", + "add", + "delete", + "edit", + "info", + "download" + ], + "label": "指标管理", + "table": "tag" + }, + { + "auth": [ + "show", + "add", + "delete", + "edit", + "info", + "download" + ], + "label": "指标分类", + "table": "tag_ctg" + } + ], + "name": "sys:tag" + }, + { + "auth": [ + "show" + ], + "icon": "Setting", + "label": "产业分类", + "menus": [ + { + "auth": [ + "show", + "add", + "delete", + "edit", + "info", + "download" + ], + "label": "产业分类", + "table": "industry" + }, + { + "auth": [ + "show", + "add", + "delete", + "edit", + "info", + "download" + ], + "label": "产业分析", + "table": "industry_analyse" + } + ], + "name": "sys:industry" } ], "name": "admin", @@ -896,16 +896,16 @@ "value": null }, { - "name": "名称", - "value": "name" + "name": "ID", + "value": "id" }, { "name": "行业代码", "value": "code" }, { - "name": "ID", - "value": "id" + "name": "名称", + "value": "name" } ], "type": "search", @@ -1072,14 +1072,14 @@ "name": "无", "value": null }, - { - "name": "ID", - "value": "id" - }, { "name": "名称", "value": "name" }, + { + "name": "ID", + "value": "id" + }, { "name": "分析结果", "value": "data" @@ -1593,37 +1593,29 @@ "name": "无", "value": null }, - { - "name": "企业名称", - "value": "name" - }, { "name": "id", "value": "id" }, - { - "name": "占地面积", - "value": "zdmj" - }, - { - "name": "研发经费", - "value": "yfjf" - }, - { - "name": "职工人数", - "value": "zgrs" - }, { "name": "综合能耗", "value": "zhnh" }, { - "name": "上传数据", - "value": "upload_data" + "name": "研发经费", + "value": "yfjf" }, { - "name": "企业地址", - "value": "address" + "name": "企业画像", + "value": "analyse" + }, + { + "name": "企业名称", + "value": "name" + }, + { + "name": "属地名称", + "value": "unit" }, { "name": "利润总额", @@ -1633,18 +1625,6 @@ "name": "主要污染物排放当量", "value": "zywrwpfdl" }, - { - "name": "属地名称", - "value": "unit" - }, - { - "name": "企业画像", - "value": "analyse" - }, - { - "name": "采集数据", - "value": "collect_data" - }, { "name": "统一社会信用代码", "value": "sn" @@ -1653,9 +1633,29 @@ "name": "营业收入", "value": "yysr" }, + { + "name": "采集数据", + "value": "collect_data" + }, { "name": "应缴税金", "value": "yjsj" + }, + { + "name": "职工人数", + "value": "zgrs" + }, + { + "name": "上传数据", + "value": "upload_data" + }, + { + "name": "企业地址", + "value": "address" + }, + { + "name": "占地面积", + "value": "zdmj" } ], "type": "search", @@ -1716,26 +1716,23 @@ "value": null }, { - "label": "认证状态", - "name": "status", + "label": "企业规模", + "name": "gs", "options": [ { - "name": "未认证", + "name": "规下", "value": "0" }, { - "name": "已认证", + "name": "规上", "value": "1" }, - { - "name": "异常", - "value": "2" - }, { "name": "全部", "value": null } ], + "sortable": true, "type": "select", "value": null }, @@ -1772,30 +1769,33 @@ "value": null }, { - "label": "企业规模", - "name": "gs", + "label": "认证状态", + "name": "status", "options": [ { - "name": "规下", + "name": "未认证", "value": "0" }, { - "name": "规上", + "name": "已认证", "value": "1" }, + { + "name": "异常", + "value": "2" + }, { "name": "全部", "value": null } ], - "sortable": true, "type": "select", "value": null }, { - "label": "城市", - "link": "city", - "name": "city_id", + "label": "归属组织", + "link": "org", + "name": "org_id", "type": "tree", "value": "name" }, @@ -1807,9 +1807,9 @@ "value": "name" }, { - "label": "归属组织", - "link": "org", - "name": "org_id", + "label": "城市", + "link": "city", + "name": "city_id", "type": "tree", "value": "name" } @@ -2067,45 +2067,13 @@ "name": "无", "value": null }, - { - "name": "营业收入", - "value": "yysr" - }, - { - "name": "利润总额", - "value": "lrze" - }, - { - "name": "采集数据", - "value": "collect_data" - }, - { - "name": "属地名称", - "value": "unit" - }, - { - "name": "统一社会信用代码", - "value": "sn" - }, { "name": "主要污染物排放当量", "value": "zywrwpfdl" }, { - "name": "id", - "value": "id" - }, - { - "name": "研发经费", - "value": "yfjf" - }, - { - "name": "企业画像", - "value": "analyse" - }, - { - "name": "企业名称", - "value": "name" + "name": "上传数据", + "value": "upload_data" }, { "name": "企业地址", @@ -2116,20 +2084,52 @@ "value": "zdmj" }, { - "name": "职工人数", - "value": "zgrs" + "name": "研发经费", + "value": "yfjf" + }, + { + "name": "利润总额", + "value": "lrze" + }, + { + "name": "企业名称", + "value": "name" + }, + { + "name": "统一社会信用代码", + "value": "sn" }, { "name": "综合能耗", "value": "zhnh" }, { - "name": "上传数据", - "value": "upload_data" + "name": "id", + "value": "id" + }, + { + "name": "营业收入", + "value": "yysr" + }, + { + "name": "属地名称", + "value": "unit" + }, + { + "name": "职工人数", + "value": "zgrs" }, { "name": "应缴税金", "value": "yjsj" + }, + { + "name": "企业画像", + "value": "analyse" + }, + { + "name": "采集数据", + "value": "collect_data" } ], "type": "search", @@ -2165,6 +2165,27 @@ "type": "search", "value": null }, + { + "label": "企业规模", + "name": "gs", + "options": [ + { + "name": "规下", + "value": "0" + }, + { + "name": "规上", + "value": "1" + }, + { + "name": "全部", + "value": null + } + ], + "sortable": true, + "type": "select", + "value": null + }, { "label": "状态", "name": "state", @@ -2189,27 +2210,6 @@ "type": "select", "value": null }, - { - "label": "企业规模", - "name": "gs", - "options": [ - { - "name": "规下", - "value": "0" - }, - { - "name": "规上", - "value": "1" - }, - { - "name": "全部", - "value": null - } - ], - "sortable": true, - "type": "select", - "value": null - }, { "add": false, "edit": false, @@ -2376,20 +2376,20 @@ "value": null }, { - "name": "ID", - "value": "id" + "name": "调整级别", + "value": "level" }, { "name": "调整理由", "value": "content" }, { - "name": "名称", - "value": "name" + "name": "ID", + "value": "id" }, { - "name": "调整级别", - "value": "level" + "name": "名称", + "value": "name" } ], "type": "search", @@ -2701,10 +2701,6 @@ "name": "无", "value": null }, - { - "name": "分析结果", - "value": "data" - }, { "name": "名称", "value": "name" @@ -2712,6 +2708,10 @@ { "name": "ID", "value": "id" + }, + { + "name": "分析结果", + "value": "data" } ], "type": "search", @@ -2895,16 +2895,16 @@ "value": null }, { - "name": "其他内容", - "value": "name" + "name": "ID", + "value": "id" }, { "name": "IP地址", "value": "ip" }, { - "name": "ID", - "value": "id" + "name": "其他内容", + "value": "name" } ], "type": "search", @@ -2944,30 +2944,6 @@ "type": "search", "value": null }, - { - "label": "状态", - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, { "label": "操作类型", "name": "type", @@ -2996,6 +2972,30 @@ "sortable": true, "type": "select", "value": null + }, + { + "label": "状态", + "name": "state", + "options": [ + { + "name": "已启用", + "value": "0" + }, + { + "name": "未启用", + "value": "1" + }, + { + "name": "异常", + "value": "2" + }, + { + "name": "全部", + "value": null + } + ], + "type": "select", + "value": null } ], "table": "logs" @@ -3279,14 +3279,6 @@ "name": "“6”项量化", "value": "six_item_data" }, - { - "name": "分析名称", - "value": "name" - }, - { - "name": "首页分析", - "value": "home_data" - }, { "name": "“3”项定性", "value": "three_item_data" @@ -3295,9 +3287,17 @@ "name": "“N”项特色", "value": "n_item_data" }, + { + "name": "首页分析", + "value": "home_data" + }, { "name": "ID", "value": "id" + }, + { + "name": "分析名称", + "value": "name" } ], "type": "search", @@ -3458,6 +3458,10 @@ "name": "无", "value": null }, + { + "name": "名称", + "value": "name" + }, { "name": "内容", "value": "question_data" @@ -3465,10 +3469,6 @@ { "name": "ID", "value": "id" - }, - { - "name": "名称", - "value": "name" } ], "type": "search", @@ -3670,14 +3670,14 @@ "name": "无", "value": null }, - { - "name": "ID", - "value": "id" - }, { "name": "名称", "value": "name" }, + { + "name": "ID", + "value": "id" + }, { "name": "填报内容", "value": "question_data" @@ -4075,18 +4075,14 @@ "name": "无", "value": null }, - { - "name": "ID", - "value": "id" - }, - { - "name": "指标名", - "value": "name" - }, { "name": "指标标志", "value": "sn" }, + { + "name": "ID", + "value": "id" + }, { "name": "单位", "value": "unit" @@ -4098,6 +4094,10 @@ { "name": "运行命令", "value": "cmd" + }, + { + "name": "指标名", + "value": "name" } ], "type": "search", @@ -4133,6 +4133,30 @@ "type": "search", "value": null }, + { + "label": "状态", + "name": "state", + "options": [ + { + "name": "已启用", + "value": "0" + }, + { + "name": "未启用", + "value": "1" + }, + { + "name": "异常", + "value": "2" + }, + { + "name": "全部", + "value": null + } + ], + "type": "select", + "value": null + }, { "label": "类型", "name": "type", @@ -4167,28 +4191,11 @@ "value": null }, { - "label": "状态", - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null + "label": "组织名称", + "link": "org", + "name": "org_id", + "type": "tree", + "value": "name" }, { "label": "指标分类", @@ -4196,13 +4203,6 @@ "name": "tag_ctg_id", "type": "tree", "value": "name" - }, - { - "label": "组织名称", - "link": "org", - "name": "org_id", - "type": "tree", - "value": "name" } ], "table": "tag" @@ -4318,13 +4318,13 @@ "name": "无", "value": null }, - { - "name": "ID", - "value": "id" - }, { "name": "分类名称", "value": "name" + }, + { + "name": "ID", + "value": "id" } ], "type": "search", @@ -4385,16 +4385,16 @@ "value": null }, { - "label": "上级分类", - "link": "tag_ctg", - "name": "parent_id", + "label": "组织", + "link": "org", + "name": "org_id", "type": "tree", "value": "name" }, { - "label": "组织", - "link": "org", - "name": "org_id", + "label": "上级分类", + "link": "tag_ctg", + "name": "parent_id", "type": "tree", "value": "name" } @@ -4564,14 +4564,14 @@ "name": "手机号码", "value": "phone" }, - { - "name": "邮箱", - "value": "email" - }, { "name": "用户姓名", "value": "name" }, + { + "name": "邮箱", + "value": "email" + }, { "name": "身份证号码", "value": "idcard" @@ -4614,30 +4614,6 @@ "type": "search", "value": null }, - { - "label": "认证状态", - "name": "status", - "options": [ - { - "name": "未认证", - "value": "0" - }, - { - "name": "已认证", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, { "label": "状态", "name": "state", @@ -4662,6 +4638,30 @@ "type": "select", "value": null }, + { + "label": "认证状态", + "name": "status", + "options": [ + { + "name": "未认证", + "value": "0" + }, + { + "name": "已认证", + "value": "1" + }, + { + "name": "异常", + "value": "2" + }, + { + "name": "全部", + "value": null + } + ], + "type": "select", + "value": null + }, { "label": "组织", "link": "org", @@ -4811,24 +4811,24 @@ "value": "nickname" }, { - "name": "微信组id", - "value": "unionid" - }, - { - "name": "refresh_token", - "value": "retoken" + "name": "access_token", + "value": "acttoken" }, { "name": "openid", "value": "openid" }, + { + "name": "微信组id", + "value": "unionid" + }, { "name": "ID", "value": "id" }, { - "name": "access_token", - "value": "acttoken" + "name": "refresh_token", + "value": "retoken" } ], "type": "search", @@ -4864,26 +4864,6 @@ "type": "search", "value": null }, - { - "label": "组织传递", - "name": "status", - "options": [ - { - "name": "未传递", - "value": "0" - }, - { - "name": "已传递", - "value": "1" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, { "label": "状态", "name": "state", @@ -4908,6 +4888,26 @@ "type": "select", "value": null }, + { + "label": "组织传递", + "name": "status", + "options": [ + { + "name": "未传递", + "value": "0" + }, + { + "name": "已传递", + "value": "1" + }, + { + "name": "全部", + "value": null + } + ], + "type": "select", + "value": null + }, { "label": "关联组织", "link": "org", diff --git a/iedc_go.exe b/iedc_go.exe index 3dd4910..ec20765 100644 Binary files a/iedc_go.exe and b/iedc_go.exe differ