123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954 |
- package controllers
- import (
- "ColdVerify_server/conf"
- "ColdVerify_server/lib"
- "ColdVerify_server/models/Account"
- "ColdVerify_server/models/System"
- "ColdVerify_server/models/Task"
- "ColdVerify_server/models/VerifyTemplate"
- "encoding/json"
- "fmt"
- beego "github.com/beego/beego/v2/server/web"
- "math"
- "strconv"
- )
- type VerifyTemplateController struct {
- beego.Controller
- }
- // 列表 -
- func (c *VerifyTemplateController) 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 := VerifyTemplate.Read_VerifyTemplate_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 *VerifyTemplateController) 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_ := VerifyTemplate.VerifyTemplate{
- T_class: T_class,
- T_name: T_name,
- T_sort: T_sort,
- }
- Id, is := VerifyTemplate.Add_VerifyTemplate(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 *VerifyTemplateController) 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_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
- T_scheme := c.GetString("T_scheme")
- T_reporting := c.GetString("T_reporting")
- T_inspect := c.GetString("T_inspect")
- T_marking := c.GetString("T_marking")
- T_cover := c.GetString("T_cover")
- r, is := VerifyTemplate.Read_VerifyTemplate(T_VerifyTemplate_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_scheme) > 0 {
- r.T_scheme = T_scheme
- }
- if len(T_reporting) > 0 {
- r.T_reporting = T_reporting
- }
- if len(T_inspect) > 0 {
- r.T_inspect = T_inspect
- }
- if len(T_marking) > 0 {
- r.T_marking = T_marking
- }
- if len(T_cover) > 0 {
- r.T_cover = T_cover
- }
- if T_sort_err == nil {
- r.T_sort = T_sort
- }
- // .......
- if !VerifyTemplate.Update_VerifyTemplate(r, "T_name", "T_sort", "T_scheme", "T_reporting", "T_inspect", "T_marking", "T_cover") {
- 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 *VerifyTemplateController) 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_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
- r, is := VerifyTemplate.Read_VerifyTemplate(T_VerifyTemplate_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- if !VerifyTemplate.Delete_VerifyTemplate(r) {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
- c.ServeJSON()
- return
- }
- mapList, _ := VerifyTemplate.Read_VerifyTemplateMap_List(T_VerifyTemplate_id, 0, 0)
- for _, v := range mapList {
- if vtm, is := VerifyTemplate.Read_VerifyTemplateMap(v.T_id); is {
- VerifyTemplate.Delete_VerifyTemplateMap(vtm)
- }
- }
- System.Add_UserLogs_T(User_r.T_uuid, "验证模板", "删除", r)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- // 复制-
- func (c *VerifyTemplateController) 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_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
- T_name := c.GetString("T_name")
- r, is := VerifyTemplate.Read_VerifyTemplate(T_VerifyTemplate_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- var_ := VerifyTemplate.VerifyTemplate{
- T_class: r.T_class,
- T_name: T_name,
- T_sort: r.T_sort,
- }
- new_id, is := VerifyTemplate.Add_VerifyTemplate(var_)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "复制失败!"}
- c.ServeJSON()
- return
- }
- mapList, _ := VerifyTemplate.Read_VerifyTemplateMap_List(T_VerifyTemplate_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 = VerifyTemplate.Read_VerifyTemplateMap(T_id)
- if !is {
- if _, ok := tempMap[T_id]; !ok {
- break
- }
- }
- rand_x += 1
- }
- tempMap[T_id] = struct{}{}
- idList[i] = T_id
- }
- mapInsertList := make([]VerifyTemplate.VerifyTemplateMap, 0)
- for i, v := range mapList {
- vtm := VerifyTemplate.VerifyTemplateMap{
- T_id: idList[i],
- T_VerifyTemplate_id: new_id,
- T_name: v.T_name,
- T_text: v.T_text,
- T_label: v.T_label,
- T_source: v.T_source,
- T_sort: v.T_sort,
- T_flow_sort: v.T_flow_sort,
- T_max_time: v.T_max_time,
- T_min_time: v.T_min_time,
- }
- mapInsertList = append(mapInsertList, vtm)
- }
- _, is = VerifyTemplate.Add_VerifyTemplateMapMulti(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 *VerifyTemplateController) 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
- // 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_sort, _ := c.GetInt("T_sort") // 排序
- T_flow_sort, _ := c.GetInt("T_flow_sort") // 验证流程排序
- T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
- var cnt int64
- List, cnt := VerifyTemplate.Read_VerifyTemplateMap_List(T_VerifyTemplate_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 *VerifyTemplateController) 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_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
- T_name := c.GetString("T_name")
- T_text := c.GetString("T_text")
- T_label, _ := c.GetInt("T_label")
- T_source, _ := c.GetInt("T_source")
- T_sort, _ := c.GetInt("T_sort")
- T_flow_sort, _ := c.GetInt("T_flow_sort")
- T_max_time, _ := c.GetInt("T_max_time")
- T_min_time, _ := c.GetInt("T_min_time")
- var_ := VerifyTemplate.VerifyTemplateMap{
- T_VerifyTemplate_id: T_VerifyTemplate_id,
- T_name: T_name,
- T_text: T_text,
- T_label: T_label,
- T_source: T_source,
- T_sort: T_sort,
- T_flow_sort: T_flow_sort,
- T_max_time: T_max_time,
- T_min_time: T_min_time,
- }
- Id, is := VerifyTemplate.Add_VerifyTemplateMap(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 *VerifyTemplateController) 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_source, T_source_err := c.GetInt("T_source")
- T_min_time, T_min_time_err := c.GetInt("T_min_time")
- T_max_time, T_max_time_err := c.GetInt("T_max_time")
- T_flow_sort, T_flow_sort_err := c.GetInt("T_flow_sort")
- T_id := c.GetString("T_id")
- r, is := VerifyTemplate.Read_VerifyTemplateMap(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 T_source_err == nil {
- r.T_source = T_source
- }
- if T_min_time_err == nil {
- r.T_min_time = T_min_time
- }
- if T_max_time_err == nil {
- r.T_max_time = T_max_time
- }
- if T_flow_sort_err == nil {
- r.T_flow_sort = T_flow_sort
- }
- if !VerifyTemplate.Update_VerifyTemplateMap(r, "T_name", "T_label", "T_text", "T_sort", "T_source", "T_min_time", "T_max_time", "T_flow_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 *VerifyTemplateController) 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 := VerifyTemplate.Read_VerifyTemplateMap(T_id); is {
- if !VerifyTemplate.Delete_VerifyTemplateMap(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 *VerifyTemplateController) 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_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
- T_source, _ := c.GetInt("T_source")
- T_flow, _ := c.GetInt("T_flow") // app 时间流程
- if T_flow == 0 && T_source == 0 {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_source Err!"}
- c.ServeJSON()
- return
- }
- T_task_id := c.GetString("T_task_id")
- task, is := Task.Read_Task(T_task_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
- c.ServeJSON()
- return
- }
- Map_List := VerifyTemplate.Read_VerifyTemplateMap_List_For_Data(T_VerifyTemplate_id, T_source, T_flow)
- Data := VerifyTemplate.Read_VerifyTemplateMapData_List(T_source, T_task_id, T_VerifyTemplate_id, Map_List)
- type JSONS struct {
- //必须的大写开头
- Code int16
- Msg string
- Data interface{} // 泛型
- T_step int
- }
- c.Data["json"] = JSONS{Code: 200, Msg: "ok!", Data: Data, T_step: task.T_step}
- c.ServeJSON()
- return
- }
- // 添加标签数据
- func (c *VerifyTemplateController) 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_source int
- T_task_id string
- T_VerifyTemplate_id string
- T_step int // 进行步骤下标
- VerifyTemplateMapData []VerifyTemplate.VerifyTemplateMapData_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
- }
- task, is := Task.Read_Task(body.T_task_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
- c.ServeJSON()
- return
- }
- task.T_step = body.T_step
- if !Task.Update_Task(task, "T_step") {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改任务步骤失败!"}
- c.ServeJSON()
- return
- }
- MapDataList := make([]VerifyTemplate.VerifyTemplateMapData, 0)
- for _, v := range body.VerifyTemplateMapData {
- val := VerifyTemplate.VerifyTemplateMapData{
- T_source: v.T_source,
- T_task_id: body.T_task_id,
- T_VerifyTemplate_id: body.T_VerifyTemplate_id,
- T_VerifyTemplateMap_id: v.T_VerifyTemplateMap_id,
- T_flow_sort: v.T_flow_sort,
- T_max_time: v.T_max_time,
- T_min_time: v.T_min_time,
- T_value: v.T_value,
- T_start_time: v.T_start_time,
- }
- MapDataList = append(MapDataList, val)
- }
- ids, is := VerifyTemplate.AddOrUpdate_VerifyTemplateMapData_ADD_History(MapDataList, body.T_source, User_r.T_uuid)
- 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 *VerifyTemplateController) 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_source, _ := c.GetInt("T_source")
- T_flow, _ := c.GetInt("T_flow")
- if T_flow == 0 && T_source == 0 {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_source Err!"}
- c.ServeJSON()
- return
- }
- T_copy_task_id := c.GetString("T_copy_task_id")
- copy_task, is := Task.Read_Task(T_copy_task_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_copy_task_id 错误!"}
- c.ServeJSON()
- return
- }
- T_paste_task_id := c.GetString("T_paste_task_id")
- paste_task, is := Task.Read_Task(T_paste_task_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_paste_task_id 错误!"}
- c.ServeJSON()
- return
- }
- if copy_task.T_VerifyTemplate_id != paste_task.T_VerifyTemplate_id {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "仅支持相同模板间复制!"}
- c.ServeJSON()
- return
- }
- list := VerifyTemplate.Read_MapData_List(T_source, T_copy_task_id, copy_task.T_VerifyTemplate_id)
- MapDataList := make([]VerifyTemplate.VerifyTemplateMapData, 0)
- for _, v := range list {
- val := VerifyTemplate.VerifyTemplateMapData{
- T_source: T_source,
- T_task_id: paste_task.T_task_id,
- T_VerifyTemplate_id: paste_task.T_VerifyTemplate_id,
- T_VerifyTemplateMap_id: v.T_VerifyTemplateMap_id,
- T_flow_sort: v.T_flow_sort,
- T_max_time: v.T_max_time,
- T_min_time: v.T_min_time,
- T_value: v.T_value,
- }
- MapDataList = append(MapDataList, val)
- }
- var ids []int64
- ids, is = VerifyTemplate.AddOrUpdate_VerifyTemplateMapData_ADD_History(MapDataList, T_source, User_r.T_uuid)
- 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 *VerifyTemplateController) Map_Data_History_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_task_id := c.GetString("T_task_id")
- T_source, _ := c.GetInt("T_source")
- _, is := Task.Read_Task(T_task_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
- c.ServeJSON()
- return
- }
- AdminMap := Account.AdminListToMap(Account.Read_Admin_List_ALL_1())
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: VerifyTemplate.Read_VerifyTemplateMapDataHistory_History_List(T_task_id, T_source, AdminMap)}
- c.ServeJSON()
- return
- }
- // 标签数据列表 -
- func (c *VerifyTemplateController) Map_Data_History_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_time := c.GetString("T_time")
- if len(T_time) == 0 {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "请选择时间点!"}
- c.ServeJSON()
- return
- }
- T_source, _ := c.GetInt("T_source")
- if T_source == 0 {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_source Err!"}
- c.ServeJSON()
- return
- }
- T_task_id := c.GetString("T_task_id")
- task, is := Task.Read_Task(T_task_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
- c.ServeJSON()
- return
- }
- Map_List := VerifyTemplate.Read_VerifyTemplateMap_List_For_Data(task.T_VerifyTemplate_id, T_source, 0)
- Data := VerifyTemplate.Read_VerifyTemplateMapDataHistory_List(T_source, T_task_id, task.T_VerifyTemplate_id, T_time, Map_List)
- type JSONS struct {
- //必须的大写开头
- Code int16
- Msg string
- Data interface{} // 泛型
- T_step int
- }
- c.Data["json"] = JSONS{Code: 200, Msg: "ok!", Data: Data, T_step: task.T_step}
- c.ServeJSON()
- return
- }
- // 清除数据
- func (c *VerifyTemplateController) Map_Data_Clear_Value() {
- // 验证登录 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_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
- T_VerifyTemplateMap_id := c.GetString("T_VerifyTemplateMap_id")
- T_task_id := c.GetString("T_task_id")
- _, is := Task.Read_Task(T_task_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
- c.ServeJSON()
- return
- }
- VerifyTemplate.Clear_VerifyTemplateMapData_T_value(T_task_id, T_VerifyTemplate_id, T_VerifyTemplateMap_id)
- System.Add_UserLogs_T(User_r.T_uuid, "验证模版标签数据", "清除数据", fmt.Sprintf("T_task_id:%s T_VerifyTemplate_id:%s T_VerifyTemplateMap_id:%s", T_task_id, T_VerifyTemplate_id, T_VerifyTemplateMap_id))
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- // 历史数据恢复
- func (c *VerifyTemplateController) Map_Data_History_Recover() {
- // 验证登录 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_time := c.GetString("T_time")
- if len(T_time) == 0 {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "请选择时间点!"}
- c.ServeJSON()
- return
- }
- T_source, _ := c.GetInt("T_source")
- if T_source == 0 {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_source Err!"}
- c.ServeJSON()
- return
- }
- T_task_id := c.GetString("T_task_id")
- task, is := Task.Read_Task(T_task_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
- c.ServeJSON()
- return
- }
- HistoryList := VerifyTemplate.Read_MapDataHistory_List(T_source, T_task_id, task.T_VerifyTemplate_id, T_time)
- list := VerifyTemplate.Read_MapData_List(T_source, T_task_id, task.T_VerifyTemplate_id)
- HistoryListMap := make(map[string]VerifyTemplate.VerifyTemplateMapDataHistory)
- for _, data := range HistoryList {
- HistoryListMap[data.T_VerifyTemplateMap_id] = data
- }
- MapDataList := make([]VerifyTemplate.VerifyTemplateMapData, 0)
- for _, v := range list {
- if len(v.T_value) > 0 {
- continue
- }
- if HistoryListMap[v.T_VerifyTemplateMap_id].T_value == "" {
- continue
- }
- val := VerifyTemplate.VerifyTemplateMapData{
- T_source: T_source,
- T_task_id: task.T_task_id,
- T_VerifyTemplate_id: task.T_VerifyTemplate_id,
- T_VerifyTemplateMap_id: v.T_VerifyTemplateMap_id,
- T_flow_sort: v.T_flow_sort,
- T_max_time: v.T_max_time,
- T_min_time: v.T_min_time,
- T_value: HistoryListMap[v.T_VerifyTemplateMap_id].T_value,
- }
- MapDataList = append(MapDataList, val)
- }
- var ids []int64
- ids, is = VerifyTemplate.AddOrUpdate_VerifyTemplateMapData(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 *VerifyTemplateController) 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: VerifyTemplate.Read_VerifyTemplateClass_List()}
- c.ServeJSON()
- return
- }
- func (c *VerifyTemplateController) 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_ := VerifyTemplate.VerifyTemplateClass{
- T_name: T_name,
- T_fid: T_fid,
- T_State: 1,
- }
- Id, err := VerifyTemplate.Add_VerifyTemplateClass(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 *VerifyTemplateController) 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_VerifyTemplateToolClass, err := VerifyTemplate.Read_VerifyTemplateClass_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_VerifyTemplateToolClass.T_name = T_name
- }
- if is := VerifyTemplate.Update_VerifyTemplateClass(R_VerifyTemplateToolClass, "T_name"); !is {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
- c.ServeJSON()
- return
- }
- System.Add_UserLogs_T(User_r.T_uuid, "模板分类", "修改", R_VerifyTemplateToolClass)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
- func (c *VerifyTemplateController) 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_VerifyTemplateToolClass, err := VerifyTemplate.Read_VerifyTemplateClass_ById(T_id)
- if err != nil {
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
- c.ServeJSON()
- return
- }
- ids := VerifyTemplate.ReadVerifyTemplateClassIds_T_path(R_VerifyTemplateToolClass.T_path)
- if is := VerifyTemplate.Delete_VerifyTemplateClass_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
- }
|