123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- package controllers
- import (
- "bzd_server/lib"
- "bzd_server/models/VerifyTemplate"
- beego "github.com/beego/beego/v2/server/web"
- )
- type VerifyTemplateController struct {
- beego.Controller
- }
- // 列表 -
- func (c *VerifyTemplateController) List() {
- // 验证登录 User_is, User_r
- //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- //if !User_is {
- // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
- // c.ServeJSON()
- // return
- //}
- T_name := c.GetString("T_name")
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: VerifyTemplate.Read_VerifyTemplate_List(T_name)}
- c.ServeJSON()
- return
- }
- // 添加-
- func (c *VerifyTemplateController) Add() {
- // 验证登录 User_is, User_r
- //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- //if !User_is {
- // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
- // c.ServeJSON()
- // return
- //}
- T_name := c.GetString("T_name")
- T_sort, _ := c.GetInt("T_sort")
- var_ := VerifyTemplate.VerifyTemplate{
- T_name: T_name,
- T_sort: T_sort,
- }
- Id, is := VerifyTemplate.Add_VerifyTemplate(var_)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 301, Msg: "添加失败!"}
- c.ServeJSON()
- return
- }
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!",Data: Id}
- c.ServeJSON()
- return
- }
- // 修改-
- func (c *VerifyTemplateController) Up() {
- // 验证登录 User_is, User_r
- //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- //if !User_is {
- // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
- // c.ServeJSON()
- // return
- //}
- T_name := c.GetString("T_name")
- T_sort, T_sort_err := c.GetInt("T_sort")
- T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
- r, is := VerifyTemplate.Read_VerifyTemplate(T_VerifyTemplate_id);
- if !is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- // .......
- if len(T_name) > 0{
- r.T_name = T_name
- }
- if T_sort_err == nil {
- r.T_sort = T_sort
- }
- // .......
- if !VerifyTemplate.Update_VerifyTemplate(r,"T_name","T_sort") {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
- c.ServeJSON()
- return
- }
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- // 删除-
- func (c *VerifyTemplateController) Del() {
- // 验证登录 User_is, User_r
- //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- //if !User_is {
- // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
- // c.ServeJSON()
- // return
- //}
- T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
- if r, is := VerifyTemplate.Read_VerifyTemplate(T_VerifyTemplate_id); is {
- if !VerifyTemplate.Delete_VerifyTemplate(r) {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
- c.ServeJSON()
- return
- }
- }
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- /// -----------------------------------------------------------------------------
- // 列表 -
- func (c *VerifyTemplateController) Map_List() {
- // 验证登录 User_is, User_r
- //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- //if !User_is {
- // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
- // c.ServeJSON()
- // return
- //}
- T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: VerifyTemplate.Read_VerifyTemplateMap_List(T_VerifyTemplate_id)}
- c.ServeJSON()
- return
- }
- // 添加-
- func (c *VerifyTemplateController) Map_Add() {
- // 验证登录 User_is, User_r
- //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- //if !User_is {
- // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
- // c.ServeJSON()
- // return
- //}
- T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
- T_name := c.GetString("T_name")
- T_field := c.GetString("T_field")
- T_text := c.GetString("T_text")
- T_label, _ := c.GetInt("T_label")
- var_ := VerifyTemplate.VerifyTemplateMap{
- T_VerifyTemplate_id: T_VerifyTemplate_id,
- T_name: T_name,
- T_field: T_field,
- T_text: T_text,
- T_label: T_label,
- }
- Id, is := VerifyTemplate.Add_VerifyTemplateMap(var_)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 301, Msg: "添加失败!"}
- c.ServeJSON()
- return
- }
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!",Data: Id}
- c.ServeJSON()
- return
- }
- // 修改-
- func (c *VerifyTemplateController) Map_Up() {
- // 验证登录 User_is, User_r
- //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- //if !User_is {
- // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
- // c.ServeJSON()
- // return
- //}
- T_name := c.GetString("T_name")
- T_field := c.GetString("T_field")
- T_text := c.GetString("T_text")
- T_label, T_label_err := c.GetInt("T_label")
- T_id := c.GetString("T_id")
- r, is := VerifyTemplate.Read_VerifyTemplateMap(T_id);
- if !is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- // .......
- if len(T_name) > 0{
- r.T_name = T_name
- }
- if len(T_field) > 0{
- r.T_field = T_field
- }
- if len(T_text) > 0{
- r.T_text = T_text
- }
- if T_label_err == nil {
- r.T_label = T_label
- }
- // .......
- if !VerifyTemplate.Update_VerifyTemplateMap(r,"T_name","T_label","T_text","T_field") {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
- c.ServeJSON()
- return
- }
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- // 删除-
- func (c *VerifyTemplateController) Map_Del() {
- // 验证登录 User_is, User_r
- //User_r,User_is := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- //if !User_is {
- // c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
- // c.ServeJSON()
- // return
- //}
- T_id := c.GetString("T_id")
- if r, is := VerifyTemplate.Read_VerifyTemplateMap(T_id); is {
- if !VerifyTemplate.Delete_VerifyTemplateMap(r) {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
- c.ServeJSON()
- return
- }
- }
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
|