|
@@ -9,7 +9,6 @@ import (
|
|
|
"math"
|
|
|
)
|
|
|
|
|
|
-
|
|
|
type DeviceClassController struct {
|
|
|
beego.Controller
|
|
|
}
|
|
@@ -17,9 +16,9 @@ type DeviceClassController struct {
|
|
|
// 列表 -
|
|
|
func (c *DeviceClassController) List() {
|
|
|
// 验证登录 User_is, User_r
|
|
|
- User_r,User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
+ User_r, User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
if !User_is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -37,7 +36,7 @@ func (c *DeviceClassController) List() {
|
|
|
T_name := c.GetString("T_name")
|
|
|
|
|
|
var cnt int64
|
|
|
- List, cnt := Device.Read_DeviceClass_List(User_r.T_uuid,T_name, page, page_z)
|
|
|
+ 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
|
|
@@ -49,12 +48,13 @@ func (c *DeviceClassController) List() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
// 获取-
|
|
|
func (c *DeviceClassController) Get() {
|
|
|
// 验证登录 User_is, User_r
|
|
|
- User_r,User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
+ User_r, User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
if !User_is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -66,7 +66,7 @@ func (c *DeviceClassController) Get() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- r, is := Device.Read_DeviceClass_ById(Id);
|
|
|
+ r, is := Device.Read_DeviceClass_ById(Id)
|
|
|
if !is {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
|
|
|
c.ServeJSON()
|
|
@@ -77,7 +77,7 @@ func (c *DeviceClassController) Get() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!",Data: r}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -85,9 +85,9 @@ func (c *DeviceClassController) Get() {
|
|
|
// 添加-
|
|
|
func (c *DeviceClassController) Add() {
|
|
|
// 验证登录 User_is, User_r
|
|
|
- User_r,User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
+ User_r, User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
if !User_is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -95,36 +95,35 @@ func (c *DeviceClassController) Add() {
|
|
|
T_name := c.GetString("T_name")
|
|
|
|
|
|
var_ := Device.DeviceClass{
|
|
|
- T_uuid: User_r.T_uuid,
|
|
|
+ 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: 301, Msg: "添加失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- System.Add_UserLogs_T(User_r.T_uuid,"分类管理", "添加", var_)
|
|
|
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!",Data: Id}
|
|
|
+ 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 := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
+ User_r, User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
if !User_is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
|
|
|
+ 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: 201, Msg: "Id 错误!"}
|
|
@@ -132,7 +131,7 @@ func (c *DeviceClassController) Up() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- r, is := Device.Read_DeviceClass_ById(Id);
|
|
|
+ r, is := Device.Read_DeviceClass_ById(Id)
|
|
|
if !is {
|
|
|
c.Data["json"] = lib.JSONS{Code: 201, Msg: "Id 错误!"}
|
|
|
c.ServeJSON()
|
|
@@ -145,27 +144,28 @@ func (c *DeviceClassController) Up() {
|
|
|
return
|
|
|
}
|
|
|
// .......
|
|
|
- if len(T_name) > 0{
|
|
|
+ if len(T_name) > 0 {
|
|
|
r.T_name = T_name
|
|
|
}
|
|
|
|
|
|
// .......
|
|
|
- if !Device.Update_DeviceClass(r,"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)
|
|
|
+ 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 := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
+ User_r, User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
if !User_is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -190,7 +190,7 @@ func (c *DeviceClassController) Del() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- System.Add_UserLogs_T(User_r.T_uuid,"分类管理", "删除", r)
|
|
|
+ System.Add_UserLogs_T(User_r.T_uuid, "分类管理", "删除", r)
|
|
|
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
c.ServeJSON()
|
|
@@ -207,9 +207,9 @@ func (c *DeviceClassController) Del() {
|
|
|
// 列表 -
|
|
|
func (c *DeviceClassController) List_List() {
|
|
|
// 验证登录 User_is, User_r
|
|
|
- User_r,User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
+ User_r, User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
if !User_is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -224,10 +224,10 @@ func (c *DeviceClassController) List_List() {
|
|
|
page_z = conf.Page_size
|
|
|
}
|
|
|
|
|
|
- T_class,_ := c.GetInt("T_class")
|
|
|
+ T_class, _ := c.GetInt("T_class")
|
|
|
T_sn := c.GetString("T_sn")
|
|
|
|
|
|
- r, is := Device.Read_DeviceClass_ById(T_class);
|
|
|
+ r, is := Device.Read_DeviceClass_ById(T_class)
|
|
|
if !is {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class 错误!"}
|
|
|
c.ServeJSON()
|
|
@@ -239,9 +239,8 @@ func (c *DeviceClassController) List_List() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
var cnt int64
|
|
|
- List, cnt := Device.Read_DeviceClassList_List(T_class,T_sn, page, page_z)
|
|
|
+ List, cnt := Device.Read_DeviceClassList_List(T_class, T_sn, page, page_z)
|
|
|
page_size := math.Ceil(float64(cnt) / float64(page_z))
|
|
|
r_jsons.List = List
|
|
|
r_jsons.Page = page
|
|
@@ -254,22 +253,21 @@ func (c *DeviceClassController) List_List() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 添加-
|
|
|
func (c *DeviceClassController) List_Add() {
|
|
|
// 验证登录 User_is, User_r
|
|
|
- User_r,User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
+ User_r, User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
if !User_is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- T_class,_ := c.GetInt("T_class")
|
|
|
- T_id,_ := c.GetInt("T_id")
|
|
|
+ T_class, _ := c.GetInt("T_class")
|
|
|
+ T_id, _ := c.GetInt("T_id")
|
|
|
T_sn := c.GetString("T_sn")
|
|
|
|
|
|
- r, is := Device.Read_DeviceClass_ById(T_class);
|
|
|
+ r, is := Device.Read_DeviceClass_ById(T_class)
|
|
|
if !is {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class 错误!"}
|
|
|
c.ServeJSON()
|
|
@@ -282,7 +280,7 @@ func (c *DeviceClassController) List_Add() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if _, is := Device.Read_Device(T_sn);!is{
|
|
|
+ if _, is := Device.Read_Device(T_sn); !is {
|
|
|
c.Data["json"] = lib.JSONS{Code: 201, Msg: "T_sn 不存在!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
@@ -290,34 +288,34 @@ func (c *DeviceClassController) List_Add() {
|
|
|
|
|
|
var_ := Device.DeviceClassList{
|
|
|
T_class: T_class,
|
|
|
- T_id: T_id,
|
|
|
- T_sn: T_sn,
|
|
|
+ T_id: T_id,
|
|
|
+ T_sn: T_sn,
|
|
|
T_State: 1,
|
|
|
}
|
|
|
|
|
|
-
|
|
|
Id, is := Device.Add_DeviceClassList(var_)
|
|
|
if !is {
|
|
|
c.Data["json"] = lib.JSONS{Code: 301, Msg: "添加失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- System.Add_UserLogs_T(User_r.T_uuid,"分类设备管理", "添加", var_)
|
|
|
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!",Data: Id}
|
|
|
+ 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) List_Up() {
|
|
|
// 验证登录 User_is, User_r
|
|
|
- User_r,User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
+ User_r, User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
if !User_is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- T_id,_ := c.GetInt("T_id")
|
|
|
+ T_id, _ := c.GetInt("T_id")
|
|
|
|
|
|
Id, err := c.GetInt("Id")
|
|
|
if err != nil {
|
|
@@ -326,14 +324,14 @@ func (c *DeviceClassController) List_Up() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- r, is := Device.Read_DeviceClassList_ById(Id);
|
|
|
+ r, is := Device.Read_DeviceClassList_ById(Id)
|
|
|
if !is {
|
|
|
c.Data["json"] = lib.JSONS{Code: 201, Msg: "Id 错误!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- Cr, is := Device.Read_DeviceClass_ById(r.T_class);
|
|
|
+ Cr, is := Device.Read_DeviceClass_ById(r.T_class)
|
|
|
if !is {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class 错误!"}
|
|
|
c.ServeJSON()
|
|
@@ -349,22 +347,23 @@ func (c *DeviceClassController) List_Up() {
|
|
|
r.T_id = T_id
|
|
|
|
|
|
// .......
|
|
|
- if !Device.Update_DeviceClassList(r,"T_id") {
|
|
|
+ if !Device.Update_DeviceClassList(r, "T_id") {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- System.Add_UserLogs_T(User_r.T_uuid,"分类设备管理", "修改", r)
|
|
|
+ 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 := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
+ User_r, User_is := lib.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
if !User_is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 302, Msg: "请重新登录!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -378,7 +377,7 @@ func (c *DeviceClassController) List_Del() {
|
|
|
|
|
|
if r, is := Device.Read_DeviceClassList_ById(Id); is {
|
|
|
|
|
|
- Cr, is := Device.Read_DeviceClass_ById(r.T_class);
|
|
|
+ Cr, is := Device.Read_DeviceClass_ById(r.T_class)
|
|
|
if !is {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class 错误!"}
|
|
|
c.ServeJSON()
|
|
@@ -395,8 +394,7 @@ func (c *DeviceClassController) List_Del() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- System.Add_UserLogs_T(User_r.T_uuid,"分类设备管理", "删除", r)
|
|
|
-
|
|
|
+ System.Add_UserLogs_T(User_r.T_uuid, "分类设备管理", "删除", r)
|
|
|
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
c.ServeJSON()
|