func (c *DqsjController) GuangGao() { if c.Ctx.Input.IsGet() { beego.Debug("GuangGao Get") } if c.Ctx.Input.IsPost() { beego.Debug("GuangGao Post") } //微信分享 token := getDqsjToken() if len(token) > 0 { beego.Debug("http_dqsj_token :", token) } appId := "" isdebug := "flase" iniconf, err := config.NewConfig("json", "conf/myconfig.json") if err != nil { beego.Debug(err) } else { appId = iniconf.String("qax580::appid") isdebug = iniconf.String("qax580::isdebug") } url := "http://www.baoguangguang.cn/dqsj/guanggao" if isdebug == "true" { url = "http://localhost:8080/dqsj/guanggao" } timestamp := time.Now().Unix() noncestr := getNonceStr(16, KC_RAND_KIND_ALL) ticket := getDqsjTicket(token) c.Data["AppId"] = appId c.Data["TimesTamp"] = timestamp c.Data["NonceStr"] = noncestr c.Data["Ticket"] = signatureWxJs(ticket, noncestr, timestamp, url) wxShareCon := models.WxShareCon{} wxShareCon.Title = "大签世界火盆烤肉欢迎您的到来!" wxShareCon.Link = url wxShareCon.ImgUrl = "http://182.92.167.29:8080/static/img/dqsjicon.jpg" c.Data["WxShareCon"] = wxShareCon // beego.Debug(wxShareCon) op := c.Input().Get("op") switch op { case "con": id := c.Input().Get("id") if len(id) == 0 { break } guangao, err := models.GetOneDqsjGuanggao(id) if err != nil { beego.Error(err) } c.Data["Guanggao"] = guangao beego.Debug("guangao :", guangao) c.TplName = "dqsjguanggao.html" return } c.TplName = "dqsjguanggao.html" }
func (c *DqsjController) AdminUpGgCon() { bool, _ := chackDqsjAccount(c.Ctx) if bool { } else { c.Redirect("/dqsj/adminlogin", 302) return } if c.Ctx.Input.IsGet() { beego.Debug("AdminUpGgCon Get") id := c.Input().Get("id") if len(id) != 0 { gg, err := models.GetOneDqsjGuanggao(id) if err != nil { beego.Error(err) } c.Data["Guanggao"] = gg beego.Debug("gg :", gg) } } if c.Ctx.Input.IsPost() { beego.Debug("AdminUpGgCon Post") title := c.Input().Get("title") info := c.Input().Get("info") blink := c.Input().Get("blink") link := c.Input().Get("link") id := c.Input().Get("id") if len(id) != 0 && len(title) != 0 && len(info) != 0 { b_link := false s_link := "" if blink == "true" { b_link = true s_link = link } err := models.UpdateDqsjGuanggaoInfo(id, title, info, b_link, s_link) if err != nil { beego.Error(err) } c.Redirect("/dqsj/admingg", 302) } } c.TplName = "dqsjadminupggcon.html" }
func (c *DqsjController) AdminUpGgImg() { bool, _ := chackDqsjAccount(c.Ctx) if bool { } else { c.Redirect("/dqsj/adminlogin", 302) return } if c.Ctx.Input.IsGet() { beego.Debug("AdminUpGgImg Get") id := c.Input().Get("id") if len(id) != 0 { gg, err := models.GetOneDqsjGuanggao(id) if err != nil { beego.Error(err) } c.Data["Guanggao"] = gg beego.Debug("gg :", gg) } } if c.Ctx.Input.IsPost() { id := c.Input().Get("id") originalimg := c.Input().Get("originalimg") originalitem0 := c.Input().Get("originalitem0") originalitem1 := c.Input().Get("originalitem1") originalitem2 := c.Input().Get("originalitem2") bimg := c.Input().Get("bimg") image_name := originalimg item0_name := originalitem0 item1_name := originalitem1 item2_name := originalitem2 if len(id) != 0 { // 获取附件 _, fh, err := c.GetFile("image") // beego.Debug("上传图片:", fh) if err != nil { beego.Error(err) } var attachment string if fh != nil { // 保存附件 attachment = fh.Filename t := time.Now().Unix() str2 := fmt.Sprintf("%d", t) s := []string{attachment, str2} h := md5.New() h.Write([]byte(strings.Join(s, ""))) // 需要加密的字符串 image_name = hex.EncodeToString(h.Sum(nil)) beego.Info(image_name) // 输出加密结果 err = c.SaveToFile("image", path.Join("imagehosting", image_name)) if err != nil { beego.Error(err) image_name = originalimg } } // 上传图片0 _, fh, err = c.GetFile("imageitem0") beego.Debug("上传图片imageitem0:", fh) if err != nil { beego.Error(err) } if fh != nil { // 保存附件 attachment = fh.Filename t := time.Now().Unix() str2 := fmt.Sprintf("%d%s", t, "imageitem0") s := []string{attachment, str2} h := md5.New() h.Write([]byte(strings.Join(s, ""))) // 需要加密的字符串 item0_name = hex.EncodeToString(h.Sum(nil)) beego.Info(item0_name) // 输出加密结果 err = c.SaveToFile("imageitem0", path.Join("imagehosting", item0_name)) if err != nil { beego.Error(err) item0_name = originalitem0 } } // 上传图片1 _, fh, err = c.GetFile("imageitem1") beego.Debug("上传图片imageitem1:", fh) if err != nil { beego.Error(err) } if fh != nil { // 保存附件 attachment = fh.Filename t := time.Now().Unix() str2 := fmt.Sprintf("%d%s", t, "imageitem1") s := []string{attachment, str2} h := md5.New() h.Write([]byte(strings.Join(s, ""))) // 需要加密的字符串 item1_name = hex.EncodeToString(h.Sum(nil)) beego.Info(item1_name) // 输出加密结果 err = c.SaveToFile("imageitem1", path.Join("imagehosting", item1_name)) if err != nil { beego.Error(err) item1_name = originalitem1 } } // 上传图片2 _, fh, err = c.GetFile("imageitem2") beego.Debug("上传图片imageitem2:", fh) if err != nil { beego.Error(err) } if fh != nil { // 保存附件 attachment = fh.Filename t := time.Now().Unix() str2 := fmt.Sprintf("%d%s", t, "imageitem2") s := []string{attachment, str2} h := md5.New() h.Write([]byte(strings.Join(s, ""))) // 需要加密的字符串 item2_name = hex.EncodeToString(h.Sum(nil)) beego.Info(item2_name) // 输出加密结果 err = c.SaveToFile("imageitem2", path.Join("imagehosting", item2_name)) if err != nil { beego.Error(err) item2_name = originalitem2 } } b_img := false if bimg == "true" { b_img = true } beego.Debug("上传前图片", originalitem0, "上传后图片", item0_name) if len(image_name) != 0 || len(item0_name) != 0 || len(item1_name) != 0 || len(item2_name) != 0 { err := models.UpdateDqsjGuanggaoImg(id, image_name, b_img, item0_name, item1_name, item2_name) if err != nil { beego.Error(err) } else { c.Redirect("/dqsj/admingg", 302) return } } } } c.TplName = "dqsjadminupggimg.html" }