123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736 |
- package controllers
- import (
- "ColdVerify_server/conf"
- "ColdVerify_server/lib"
- "ColdVerify_server/models/Account"
- "ColdVerify_server/models/Certificate"
- "ColdVerify_server/models/Device"
- "ColdVerify_server/models/System"
- "ColdVerify_server/models/Task"
- "fmt"
- beego "github.com/beego/beego/v2/server/web"
- "math"
- "strings"
- )
- type DeviceClassController struct {
- beego.Controller
- }
- // 列表 -
- func (c *DeviceClassController) List() {
- // 验证登录 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
- }
- 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_name := c.GetString("T_name")
- var cnt int64
- List, cnt := Device.Read_DeviceClass_List(User_r.T_uuid, 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 *DeviceClassController) Get() {
- // 验证登录 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
- }
- Id, err := c.GetInt("Id")
- if err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- r, is := Device.Read_DeviceClass_ById(Id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r}
- c.ServeJSON()
- return
- }
- // 添加-
- func (c *DeviceClassController) 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")
- var_ := Device.DeviceClass{
- T_uuid: User_r.T_uuid,
- T_name: T_name,
- T_State: 1,
- }
- Id, is := Device.Add_DeviceClass(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 *DeviceClassController) 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")
- Id, err := c.GetInt("Id")
- if err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- r, is := Device.Read_DeviceClass_ById(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 !Device.Update_DeviceClass(r, "T_name") {
- 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 *DeviceClassController) 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
- }
- Id, err := c.GetInt("Id")
- if err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- if r, is := Device.Read_DeviceClass_ById(Id); is {
- if !Device.Delete_DeviceClass_(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 *DeviceClassController) List_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")
- T_sn := c.GetString("T_sn")
- T_remark := c.GetString("T_remark")
- _, is := Device.Read_DeviceClass_ById(T_class)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class 错误!"}
- c.ServeJSON()
- return
- }
- var cnt int64
- //List, cnt := Device.Read_DeviceClassList_List(T_class, T_sn, page, 9999)
- List, cnt := Device.Read_DeviceClassList_OrderList(T_class, T_sn, "", T_remark, page, 9999)
- 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 *DeviceClassController) List_Add1() {
- // 验证登录 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_class, _ := c.GetInt("T_class")
- //方式1:001,002,003,004,005,008
- //方式2:001~005,008
- T_layout_no_list := c.GetString("T_layout_no_list")
- //T_sn := c.GetString("T_sn")
- T_remark := c.GetString("T_remark")
- _, is := Device.Read_DeviceClass_ById(T_class)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class 错误"}
- c.ServeJSON()
- return
- }
- list := strings.Split(strings.TrimRight(T_layout_no_list, ","), ",")
- snMap := make(map[string]string)
- excludeId := make(map[string]struct{})
- errList := []string{}
- var successNum int // 成功数量
- for _, v := range list {
- if strings.Contains(v, "!") {
- excludeId[fmt.Sprintf("%03d", lib.To_int(strings.TrimLeft(strings.Trim(v, "!"), "0")))] = struct{}{}
- continue
- }
- // 001~005
- if strings.Contains(v, "~") {
- vlist := strings.Split(v, "~")
- if len(vlist) != 2 {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "布局编号格式错误!"}
- c.ServeJSON()
- return
- }
- vstart, vend := lib.To_int(strings.TrimLeft(vlist[0], "0")), lib.To_int(strings.TrimLeft(vlist[1], "0"))
- for i := vstart; i < vend+1; i++ {
- T_id := fmt.Sprintf("%03d", i)
- cert, is := Certificate.Read_Certificate_ByT_layout_no(T_id)
- if !is {
- //c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("%s布局编号不存在!", T_id)}
- //c.ServeJSON()
- //return
- errList = append(errList, fmt.Sprintf("%s布局编号不存在!", T_id))
- continue
- }
- snMap[T_id] = cert.T_sn
- }
- } else {
- // 001,002
- cert, is := Certificate.Read_Certificate_ByT_layout_no(v)
- if !is {
- //c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("%s布局编号不存在!", v)}
- //c.ServeJSON()
- //return
- errList = append(errList, v)
- continue
- }
- snMap[v] = cert.T_sn
- }
- }
- errList2 := []string{}
- succesId := []string{}
- for T_id, T_sn := range snMap {
- if _, ok := excludeId[T_id]; ok {
- continue
- }
- //if _, is = Device.Read_Device(T_sn); !is {
- // c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn 不存在!"}
- // c.ServeJSON()
- // return
- //}
- if dc, is := Device.Read_DeviceClassList_T_class_T_sn(T_class, T_sn); is && dc.Id > 0 {
- successNum += 1
- continue
- }
- var pdf Certificate.CertificatePdf
- pdfList, _ := Certificate.Read_CertificatePdf_Newest(T_id)
- if len(pdfList) > 0 {
- pdf = pdfList[0]
- }
- var_ := Device.DeviceClassList{
- T_class: T_class,
- T_id: T_id,
- T_sn: T_sn,
- T_failure_time: pdf.T_failure_time,
- T_pdf: pdf.T_pdf,
- T_remark: T_remark,
- T_State: 1,
- }
- _, is = Device.Add_DeviceClassList(var_)
- if !is {
- //c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
- //c.ServeJSON()
- //return
- errList2 = append(errList2, T_id)
- continue
- }
- successNum += 1
- succesId = append(succesId, T_id)
- System.Add_UserLogs_T(User_r.T_uuid, "分类设备管理", "添加", var_)
- }
- if len(errList) == 0 && len(errList2) == 0 {
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: successNum}
- c.ServeJSON()
- return
- }
- var errStr string
- if len(errList) > 0 {
- errStr += strings.Join(errList, ",") + "编号不存在"
- }
- if len(errList2) > 0 {
- if len(errStr) > 0 {
- errStr += ","
- }
- errStr += strings.Join(errList2, ",") + "添加失败"
- }
- //if len(succesId) > 0 {
- // if len(errStr) > 0 {
- // errStr += ","
- // }
- // errStr += strings.Join(succesId, ",") + "添加成功"
- //}
- c.Data["json"] = lib.JSONS{Code: 210, Msg: errStr, Data: successNum}
- c.ServeJSON()
- return
- }
- func (c *DeviceClassController) List_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_class, _ := c.GetInt("T_class")
- T_sn_id_list := c.GetString("T_sn_id_list")
- list := strings.Split(strings.TrimRight(T_sn_id_list, "|"), "|")
- T_remark := c.GetString("T_remark")
- _, is := Device.Read_DeviceClass_ById(T_class)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class 错误"}
- c.ServeJSON()
- return
- }
- var successNum int // 成功数量
- errList := []string{}
- errList2 := []string{}
- succesId := []string{}
- for _, sn_id := range list {
- T_sn := strings.Split(sn_id, ",")[0]
- T_id := strings.Split(sn_id, ",")[1]
- if len(T_sn) == 0 || len(T_id) == 0 {
- errList = append(errList, sn_id)
- continue
- }
- // 判断是否已存在sn
- dc, is := Device.Read_DeviceClassList_T_class_T_sn(T_class, T_sn)
- // 添加的id和数据库已存在id相同
- if is && dc.T_id == T_id {
- successNum += 1
- continue
- }
- // 添加的id和数据库已存在id不同
- if is && dc.T_id != T_id {
- _, is = Device.Read_DeviceClassList_T_class_T_id(T_class, T_id)
- if is {
- errList2 = append(errList2, sn_id)
- continue
- }
- dc.T_id = T_id
- dc.T_remark = T_remark
- if !Device.Update_DeviceClassList(dc, "T_id", "T_remark") {
- errList = append(errList, sn_id)
- } else {
- successNum += 1
- }
- continue
- }
- if !is {
- _, is = Device.Read_DeviceClassList_T_class_T_id(T_class, T_id)
- if is {
- errList2 = append(errList2, sn_id)
- continue
- }
- }
- var pdf Certificate.CertificatePdf
- //pdfList, _ := Certificate.Read_CertificatePdf_Newest(T_sn)
- pdfList, _ := Certificate.Read_CertificatePdf_T_layout_no(T_id, "")
- if len(pdfList) > 0 {
- pdf = pdfList[0]
- }
- var_ := Device.DeviceClassList{
- T_class: T_class,
- T_id: T_id,
- T_sn: T_sn,
- T_failure_time: pdf.T_failure_time,
- T_pdf: pdf.T_pdf,
- T_Certificate_sn: pdf.T_Certificate_sn,
- T_remark: T_remark,
- T_State: 1,
- }
- _, is = Device.Add_DeviceClassList(var_)
- if !is {
- errList = append(errList, sn_id)
- continue
- }
- successNum += 1
- succesId = append(succesId, sn_id)
- System.Add_UserLogs_T(User_r.T_uuid, "分类设备管理", "添加", var_)
- }
- if len(errList) == 0 && len(errList2) == 0 {
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: successNum}
- c.ServeJSON()
- return
- }
- var errStr string
- if len(errList2) > 0 {
- errStr += strings.Join(errList2, ",") + "编号已存在"
- }
- if len(errList) > 0 {
- if len(errStr) > 0 {
- errStr += ","
- }
- errStr += strings.Join(errList, ",") + "添加失败"
- }
- c.Data["json"] = lib.JSONS{Code: 210, Msg: errStr, Data: successNum}
- c.ServeJSON()
- return
- }
- func (c *DeviceClassController) List_Copy() {
- // 验证登录 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_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
- }
- copyList, cnt := Device.Read_DeviceClassList_OrderList(copy_task.T_class, "", "", "", 0, 9999)
- var successNum int // 成功数量
- errList := []string{}
- for _, v := range copyList {
- ds, is2 := Device.Read_DeviceClassList_T_class_T_id(paste_task.T_class, v.T_id)
- // id存在 更新
- if is2 {
- ds.T_sn = v.T_sn
- ds.T_remark = v.T_remark
- if !Device.Update_DeviceClassList(ds, "T_sn", "T_remark") {
- errList = append(errList, v.T_id)
- continue
- }
- } else {
- // 判断是否已存在sn
- _, is3 := Device.Read_DeviceClassList_T_class_T_sn(paste_task.T_class, v.T_sn)
- // 删除要粘贴的任务里重复的sn
- if is3 {
- if !Device.Delete_DeviceClassList_(ds) {
- errList = append(errList, v.T_id)
- continue
- }
- }
- // 不存在则添加
- var pdf Certificate.CertificatePdf
- pdfList, _ := Certificate.Read_CertificatePdf_T_layout_no(v.T_id, "")
- if len(pdfList) > 0 {
- pdf = pdfList[0]
- }
- var_ := Device.DeviceClassList{
- T_class: paste_task.T_class,
- T_id: v.T_id,
- T_sn: v.T_sn,
- T_failure_time: pdf.T_failure_time,
- T_pdf: pdf.T_pdf,
- T_Certificate_sn: pdf.T_Certificate_sn,
- T_remark: v.T_remark,
- T_State: 1,
- }
- _, is = Device.Add_DeviceClassList(var_)
- if !is {
- errList = append(errList, v.T_id)
- continue
- }
- }
- }
- if len(errList) == 0 {
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: cnt}
- c.ServeJSON()
- return
- }
- var errStr string
- if len(errList) > 0 {
- if len(errStr) > 0 {
- errStr += ","
- }
- errStr += strings.Join(errList, ",") + "粘贴失败"
- }
- c.Data["json"] = lib.JSONS{Code: 210, Msg: errStr, Data: successNum}
- c.ServeJSON()
- return
- }
- // 修改-
- func (c *DeviceClassController) List_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_id := c.GetString("T_id")
- T_remark := c.GetString("T_remark")
- Id, err := c.GetInt("Id")
- if err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- r, is := Device.Read_DeviceClassList_ById(Id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- _, is = Device.Read_DeviceClass_ById(r.T_class)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class 错误!"}
- c.ServeJSON()
- return
- }
- _, is = Device.Read_DeviceClassList_T_class_T_id(r.T_class, T_id)
- if is && T_id != r.T_id {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: T_id + "编号已存在!"}
- c.ServeJSON()
- return
- }
- if len(T_id) > 0 {
- r.T_id = T_id
- // 修改布局编号对应的证书
- var pdf Certificate.CertificatePdf
- pdfList, _ := Certificate.Read_CertificatePdf_T_layout_no(T_id, r.CreateTime.Format("2006-01-02"))
- if len(pdfList) > 0 {
- pdf = pdfList[0]
- }
- r.T_failure_time = pdf.T_failure_time
- r.T_pdf = pdf.T_pdf
- r.T_Certificate_sn = pdf.T_Certificate_sn
- }
- if len(T_remark) > 0 {
- r.T_remark = T_remark
- }
- if !Device.Update_DeviceClassList(r, "T_id", "T_remark", "T_failure_time", "T_pdf", "T_Certificate_sn") {
- 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 *DeviceClassController) List_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
- }
- Id, err := c.GetInt("Id")
- if err != nil {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
- c.ServeJSON()
- return
- }
- if r, is := Device.Read_DeviceClassList_ById(Id); is {
- _, is = Device.Read_DeviceClass_ById(r.T_class)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class 错误!"}
- c.ServeJSON()
- return
- }
- if !Device.Delete_DeviceClassList_(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 *DeviceClassController) List_Template_Download() {
- // 返回生成的 Excel 文件
- c.Ctx.Output.Download("ofile/添加设备列表模板.xlsx")
- }
- func (c *DeviceClassController) List_Del_Duplication() {
- // 验证登录 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")
- r, is := Task.Read_Task(T_task_id)
- if !is {
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "任务id 错误!"}
- c.ServeJSON()
- return
- }
- Device.Del_DeviceClassList_Duplication(r.T_class)
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
- c.ServeJSON()
- return
- }
|