123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678 |
- package controllers
- import (
- "ColdVerify_server/conf"
- "ColdVerify_server/lib"
- "ColdVerify_server/models/Account"
- "ColdVerify_server/models/InfoCollection"
- "ColdVerify_server/models/System"
- "encoding/json"
- beego "github.com/beego/beego/v2/server/web"
- "math"
- "strconv"
- "time"
- )
- type InfoTemplateController struct {
- beego.Controller
- }
- // 列表 -
- func (c *InfoTemplateController) List() {
- // 验证登录 User_is, User_r
- _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- var r_jsons lib.R_JSONS
- page, _ := c.GetInt("page")
- if page < 1 {
- page = 1
- }
- page_z, _ := c.GetInt("page_z")
- if page_z < 1 {
- page_z = conf.Page_size
- }
- T_class, _ := c.GetInt("T_class")
- if T_class <= 0 {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class Err!"}
- c.ServeJSON()
- return
- }
- T_name := c.GetString("T_name")
- var cnt int64
- List, cnt := InfoCollection.Read_InfoTemplate_List(T_class, T_name, page, page_z)
- page_size := math.Ceil(float64(cnt) / float64(page_z))
- r_jsons.List = List
- r_jsons.Page = page
- r_jsons.Page_size = int(page_size)
- r_jsons.Pages = lib.Func_page(int64(page), int64(page_size))
- r_jsons.Num = int(cnt)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
- c.ServeJSON()
- return
- }
- // 添加-
- func (c *InfoTemplateController) Add() {
- // 验证登录 User_is, User_r
- User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- T_name := c.GetString("T_name")
- T_sort, _ := c.GetInt("T_sort")
- T_class, _ := c.GetInt("T_class")
- var_ := InfoCollection.InfoTemplate{
- T_class: T_class,
- T_name: T_name,
- T_sort: T_sort,
- }
- Id, is := InfoCollection.Add_InfoTemplate(var_)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
- c.ServeJSON()
- return
- }
- System.Add_UserLogs_T(User_r.T_uuid, "信息采集模板", "添加", var_)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
- c.ServeJSON()
- return
- }
- // 修改-
- func (c *InfoTemplateController) Up() {
- // 验证登录 User_is, User_r
- User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- T_name := c.GetString("T_name")
- T_sort, T_sort_err := c.GetInt("T_sort")
- T_InfoTemplate_id := c.GetString("T_InfoTemplate_id")
- r, is := InfoCollection.Read_InfoTemplate(T_InfoTemplate_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, 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 !InfoCollection.Update_InfoTemplate(r, "T_name", "T_sort") {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
- c.ServeJSON()
- return
- }
- System.Add_UserLogs_T(User_r.T_uuid, "信息采集模板", "修改", r)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- // 删除-
- func (c *InfoTemplateController) Del() {
- // 验证登录 User_is, User_r
- User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- T_InfoTemplate_id := c.GetString("T_InfoTemplate_id")
- r, is := InfoCollection.Read_InfoTemplate(T_InfoTemplate_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- if !InfoCollection.Delete_InfoTemplate(r) {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
- c.ServeJSON()
- return
- }
- mapList, _ := InfoCollection.Read_InfoTemplateMap_List(T_InfoTemplate_id, 0, 0)
- for _, v := range mapList {
- if vtm, is := InfoCollection.Read_InfoTemplateMap(v.T_id); is {
- InfoCollection.Delete_InfoTemplateMap(vtm)
- }
- }
- System.Add_UserLogs_T(User_r.T_uuid, "信息采集模板", "删除", r)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- // 复制-
- func (c *InfoTemplateController) Copy() {
- // 验证登录 User_is, User_r
- User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- T_InfoTemplate_id := c.GetString("T_InfoTemplate_id")
- T_name := c.GetString("T_name")
- r, is := InfoCollection.Read_InfoTemplate(T_InfoTemplate_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- var_ := InfoCollection.InfoTemplate{
- T_class: r.T_class,
- T_name: T_name,
- T_sort: r.T_sort,
- }
- new_id, is := InfoCollection.Add_InfoTemplate(var_)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "复制失败!"}
- c.ServeJSON()
- return
- }
- mapList, _ := InfoCollection.Read_InfoTemplateMap_List(T_InfoTemplate_id, 0, 0)
- tempMap := make(map[string]struct{})
- idList := make([]string, len(mapList))
- // 生成mapList长度的T_id
- for i := 0; i < len(mapList); i++ {
- // 生成编号
- rand_x := 0
- T_id := ""
- for true {
- T_id = lib.GetRandstring(4, "", int64(rand_x))
- _, is = InfoCollection.Read_InfoTemplateMap(T_id)
- if !is {
- if _, ok := tempMap[T_id]; !ok {
- break
- }
- }
- rand_x += 1
- }
- tempMap[T_id] = struct{}{}
- idList[i] = T_id
- }
- mapInsertList := make([]InfoCollection.InfoTemplateMap, 0)
- for i, v := range mapList {
- vtm := InfoCollection.InfoTemplateMap{
- T_id: idList[i],
- T_InfoTemplate_id: new_id,
- T_name: v.T_name,
- T_text: v.T_text,
- T_label: v.T_label,
- T_sort: v.T_sort,
- }
- mapInsertList = append(mapInsertList, vtm)
- }
- _, is = InfoCollection.Add_InfoTemplateMapMulti(mapInsertList)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "复制失败!"}
- c.ServeJSON()
- return
- }
- System.Add_UserLogs_T(User_r.T_uuid, "信息采集模板", "复制", var_)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: new_id}
- c.ServeJSON()
- return
- }
- /// -----------------------------------------------------------------------------
- // 标签列表 -
- func (c *InfoTemplateController) Map_List() {
- // 验证登录 User_is, User_r
- _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- var r_jsons lib.R_JSONS
- T_sort, _ := c.GetInt("T_sort") // 排序
- T_flow_sort, _ := c.GetInt("T_flow_sort") // 验证流程排序
- T_InfoTemplate_id := c.GetString("T_InfoTemplate_id")
- var cnt int64
- List, cnt := InfoCollection.Read_InfoTemplateMap_List(T_InfoTemplate_id, T_sort, T_flow_sort)
- r_jsons.List = List
- r_jsons.Num = int(cnt)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
- c.ServeJSON()
- return
- }
- // 标签添加-
- func (c *InfoTemplateController) Map_Add() {
- // 验证登录 User_is, User_r
- User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- T_InfoTemplate_id := c.GetString("T_InfoTemplate_id")
- T_name := c.GetString("T_name")
- T_text := c.GetString("T_text")
- T_label, _ := c.GetInt("T_label")
- T_sort, _ := c.GetInt("T_sort")
- var_ := InfoCollection.InfoTemplateMap{
- T_InfoTemplate_id: T_InfoTemplate_id,
- T_name: T_name,
- T_text: T_text,
- T_label: T_label,
- T_sort: T_sort,
- }
- Id, is := InfoCollection.Add_InfoTemplateMap(var_)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
- c.ServeJSON()
- return
- }
- System.Add_UserLogs_T(User_r.T_uuid, "信息采集模板标签", "添加", var_)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
- c.ServeJSON()
- return
- }
- // 标签修改-
- func (c *InfoTemplateController) Map_Up() {
- // 验证登录 User_is, User_r
- User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- T_name := c.GetString("T_name")
- T_text := c.GetString("T_text")
- T_label, T_label_err := c.GetInt("T_label")
- T_sort, T_sort_err := c.GetInt("T_sort")
- T_id := c.GetString("T_id")
- r, is := InfoCollection.Read_InfoTemplateMap(T_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- // .......
- if len(T_name) > 0 {
- r.T_name = T_name
- }
- if len(T_text) > 0 {
- r.T_text = T_text
- }
- if T_label_err == nil {
- r.T_label = T_label
- }
- if T_sort_err == nil {
- r.T_sort = T_sort
- }
- if !InfoCollection.Update_InfoTemplateMap(r, "T_name", "T_label", "T_text", "T_sort") {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
- c.ServeJSON()
- return
- }
- System.Add_UserLogs_T(User_r.T_uuid, "信息采集模板标签", "修改", r)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- // 标签删除-
- func (c *InfoTemplateController) Map_Del() {
- // 验证登录 User_is, User_r
- User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- T_id := c.GetString("T_id")
- if r, is := InfoCollection.Read_InfoTemplateMap(T_id); is {
- if !InfoCollection.Delete_InfoTemplateMap(r) {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
- c.ServeJSON()
- return
- }
- System.Add_UserLogs_T(User_r.T_uuid, "信息采集模板标签", "删除", r)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- /// -----------------------------------------------------------------------------
- // 标签数据列表 -
- func (c *InfoTemplateController) Map_Data_List() {
- // 验证登录 User_is, User_r
- _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- T_InfoTemplate_id := c.GetString("T_InfoTemplate_id")
- T_InfoCollection_id := c.GetString("T_InfoCollection_id")
- _, is := InfoCollection.Read_InfoCollection(T_InfoCollection_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_InfoCollection_id 错误!"}
- c.ServeJSON()
- return
- }
- Map_List := InfoCollection.Read_InfoTemplateMap_List_For_Data(T_InfoTemplate_id)
- Data := InfoCollection.Read_InfoTemplateMapData_List(T_InfoCollection_id, T_InfoTemplate_id, Map_List)
- type JSONS struct {
- //必须的大写开头
- Code int16
- Msg string
- Data interface{} // 泛型
- }
- c.Data["json"] = JSONS{Code: 200, Msg: "ok!", Data: Data}
- c.ServeJSON()
- return
- }
- // 添加标签数据
- func (c *InfoTemplateController) Map_Data_Pu() {
- //验证登录 User_is, User_r
- //token := c.Ctx.Request.Header.Get("user_tokey")
- //User_r, User_is := Account.Verification_Admin(token, "")
- //if !User_is {
- // c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- // c.ServeJSON()
- // return
- //}
- type RequestBody struct {
- User_tokey string
- T_InfoCollection_id string
- T_InfoTemplate_id string
- InfoTemplateMapData []InfoCollection.InfoTemplateMapData_R
- }
- var body RequestBody
- data := c.Ctx.Input.RequestBody
- err := json.Unmarshal(data, &body)
- if err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "json返序列化失败:" + err.Error()}
- c.ServeJSON()
- }
- User_r, User_is := Account.Verification_Admin(body.User_tokey, "")
- if !User_is {
- System.Add_UserLogs_T(User_r.T_uuid, "信息采集模版标签数据", "未登录-保存", body)
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- infoCollection, is := InfoCollection.Read_InfoCollection(body.T_InfoCollection_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_InfoCollection_id 错误!"}
- c.ServeJSON()
- return
- }
- // 如果信息采集开始时间为空,则设置为当前时间
- if len(infoCollection.T_start_time) == 0 {
- infoCollection.T_start_time = time.Now().Format("2006-01-02 15:04:05")
- if !InfoCollection.Update_InfoCollection(infoCollection, "T_start_time") {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改信息采集开始时间失败!"}
- c.ServeJSON()
- return
- }
- }
- MapDataList := make([]InfoCollection.InfoTemplateMapData, 0)
- for _, v := range body.InfoTemplateMapData {
- val := InfoCollection.InfoTemplateMapData{
- T_InfoCollection_id: body.T_InfoCollection_id,
- T_InfoTemplate_id: body.T_InfoTemplate_id,
- T_InfoTemplateMap_id: v.T_InfoTemplateMap_id,
- T_value: v.T_value,
- }
- MapDataList = append(MapDataList, val)
- }
- ids, is := InfoCollection.AddOrUpdate_InfoTemplateMapData(MapDataList)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "保存失败"}
- c.ServeJSON()
- return
- }
- System.Add_UserLogs_T(User_r.T_uuid, "信息采集模版标签数据", "保存", body)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: ids}
- c.ServeJSON()
- return
- }
- func (c *InfoTemplateController) Map_Data_Copy() {
- // 验证登录 User_is, User_r
- User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- T_copy_InfoCollection_id := c.GetString("T_copy_InfoCollection_id")
- copy_InfoCollection, is := InfoCollection.Read_InfoCollection(T_copy_InfoCollection_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_copy_InfoCollection_id 错误!"}
- c.ServeJSON()
- return
- }
- T_paste_InfoCollection_id := c.GetString("T_paste_InfoCollection_id")
- paste_InfoCollection, is := InfoCollection.Read_InfoCollection(T_paste_InfoCollection_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_paste_InfoCollection_id 错误!"}
- c.ServeJSON()
- return
- }
- if copy_InfoCollection.T_InfoTemplate_id != paste_InfoCollection.T_InfoTemplate_id {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "仅支持相同模板间复制!"}
- c.ServeJSON()
- return
- }
- list := InfoCollection.Read_MapData_List(T_copy_InfoCollection_id, copy_InfoCollection.T_InfoTemplate_id)
- MapDataList := make([]InfoCollection.InfoTemplateMapData, 0)
- for _, v := range list {
- val := InfoCollection.InfoTemplateMapData{
- T_InfoCollection_id: paste_InfoCollection.T_InfoCollection_id,
- T_InfoTemplate_id: paste_InfoCollection.T_InfoTemplate_id,
- T_InfoTemplateMap_id: v.T_InfoTemplateMap_id,
- T_value: v.T_value,
- }
- MapDataList = append(MapDataList, val)
- }
- var ids []int64
- ids, is = InfoCollection.AddOrUpdate_InfoTemplateMapData(MapDataList)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "保存失败"}
- c.ServeJSON()
- return
- }
- System.Add_UserLogs_T(User_r.T_uuid, "信息采集模版标签数据", "复制", MapDataList)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: ids}
- c.ServeJSON()
- return
- }
- func (c *InfoTemplateController) Class_List() {
- // 验证登录 User_is, User_r
- _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: InfoCollection.Read_InfoTemplateClass_List()}
- c.ServeJSON()
- return
- }
- func (c *InfoTemplateController) Class_Add() {
- // 验证登录 User_is, User_r
- User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- T_name := c.GetString("T_name")
- T_fid, _ := c.GetInt("T_fid")
- var_ := InfoCollection.InfoTemplateClass{
- T_name: T_name,
- T_fid: T_fid,
- T_State: 1,
- }
- Id, err := InfoCollection.Add_InfoTemplateClass(var_)
- if err != nil {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
- c.ServeJSON()
- return
- }
- System.Add_UserLogs_T(User_r.T_uuid, "模板分类", "添加", var_)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
- c.ServeJSON()
- return
- }
- func (c *InfoTemplateController) Class_Up() {
- User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- T_id, _ := c.GetInt("T_id")
- T_name := c.GetString("T_name")
- R_InfoTemplateToolClass, err := InfoCollection.Read_InfoTemplateClass_ById(T_id)
- if err != nil {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
- c.ServeJSON()
- return
- }
- if len(T_name) > 0 {
- R_InfoTemplateToolClass.T_name = T_name
- }
- if is := InfoCollection.Update_InfoTemplateClass(R_InfoTemplateToolClass, "T_name"); !is {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
- c.ServeJSON()
- return
- }
- System.Add_UserLogs_T(User_r.T_uuid, "模板分类", "修改", R_InfoTemplateToolClass)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- func (c *InfoTemplateController) Class_Del() {
- User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !User_is {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
- c.ServeJSON()
- return
- }
- T_id, _ := c.GetInt("T_id")
- R_InfoTemplateToolClass, err := InfoCollection.Read_InfoTemplateClass_ById(T_id)
- if err != nil {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
- c.ServeJSON()
- return
- }
- ids := InfoCollection.ReadInfoTemplateClassIds_T_path(R_InfoTemplateToolClass.T_path)
- if is := InfoCollection.Delete_InfoTemplateClass_ByIds(ids); !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
- c.ServeJSON()
- return
- }
- System.Add_UserLogs(User_r.T_uuid, "模板分类", "删除", strconv.Itoa(T_id))
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
|