|
@@ -21,6 +21,21 @@ import (
|
|
|
// Handle
|
|
|
type GoodsOrderController struct {
|
|
|
beego.Controller
|
|
|
+ User_r Account.User // 登陆的用户
|
|
|
+ T_pid int // 公司id
|
|
|
+}
|
|
|
+
|
|
|
+func (c *GoodsOrderController) Prepare() {
|
|
|
+ GetCookie := c.Ctx.GetCookie("User_tokey")
|
|
|
+ GetString := c.GetString("User_tokey")
|
|
|
+
|
|
|
+ User_tokey := GetCookie
|
|
|
+ if len(User_tokey) == 0 {
|
|
|
+ User_tokey = GetString
|
|
|
+ }
|
|
|
+
|
|
|
+ c.User_r = Account.User_r
|
|
|
+ c.T_pid = Account.T_pid
|
|
|
}
|
|
|
|
|
|
func (c *GoodsOrderController) GoodsOrder_List() {
|
|
@@ -35,7 +50,6 @@ func (c *GoodsOrderController) GoodsOrder_List() {
|
|
|
var r_jsons R_JSONS
|
|
|
|
|
|
page, _ := c.GetInt("page")
|
|
|
- println(page)
|
|
|
if page < 1 {
|
|
|
page = 1
|
|
|
}
|
|
@@ -44,15 +58,10 @@ func (c *GoodsOrderController) GoodsOrder_List() {
|
|
|
page_z = conf.Page_size
|
|
|
}
|
|
|
|
|
|
- T_pid := Account.User_r.T_pid
|
|
|
- if T_pid == 0 {
|
|
|
- T_pid, _ = strconv.Atoi(c.Ctx.Request.Header.Get("T_pid"))
|
|
|
- }
|
|
|
-
|
|
|
Name := c.GetString("T_name")
|
|
|
c.Data["Name"] = Name
|
|
|
|
|
|
- r_jsons.Data, r_jsons.Num = Function.Read_GoodsOrder_List(T_pid, page, page_z, Name)
|
|
|
+ r_jsons.Data, r_jsons.Num = Function.Read_GoodsOrder_List(c.T_pid, page, page_z, Name)
|
|
|
r_jsons.Page = page
|
|
|
r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
|
|
|
|
|
@@ -63,19 +72,15 @@ func (c *GoodsOrderController) GoodsOrder_List() {
|
|
|
func (c *GoodsOrderController) GoodsOrder_Get() {
|
|
|
|
|
|
id, _ := c.GetInt("T_id")
|
|
|
- T_pid := Account.User_r.T_pid
|
|
|
- if T_pid == 0 {
|
|
|
- T_pid, _ = strconv.Atoi(c.Ctx.Request.Header.Get("T_pid"))
|
|
|
- }
|
|
|
-
|
|
|
r := Function.Read_GoodsOrder_ById(id)
|
|
|
-
|
|
|
+ // 记录不存在
|
|
|
if r.Id == 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 204, Msg: "T_id !"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 204, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- if T_pid != r.T_pid {
|
|
|
+
|
|
|
+ if c.T_pid != r.T_pid {
|
|
|
c.Data["json"] = lib.JSONS{Code: 205, Msg: "没有权限!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
@@ -101,10 +106,6 @@ func (c *GoodsOrderController) GoodsOrder_Add() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- T_pid := Account.User_r.T_pid
|
|
|
- if T_pid == 0 {
|
|
|
- T_pid, _ = strconv.Atoi(c.Ctx.Request.Header.Get("T_pid"))
|
|
|
- }
|
|
|
|
|
|
T_start_Ut_, err := time.ParseInLocation("2006-01-02 15:04:05", T_time_s[0], time.Local)
|
|
|
T_end_Ut_, err := time.ParseInLocation("2006-01-02 15:04:05", T_time_s[1], time.Local)
|
|
@@ -114,7 +115,7 @@ func (c *GoodsOrderController) GoodsOrder_Add() {
|
|
|
return
|
|
|
}
|
|
|
var_ := Function.GoodsOrder{
|
|
|
- T_pid: T_pid,
|
|
|
+ T_pid: c.T_pid,
|
|
|
T_orderid: T_orderid,
|
|
|
T_outorderid: T_outorderid,
|
|
|
T_sn: T_sn,
|
|
@@ -143,11 +144,6 @@ func (c *GoodsOrderController) GoodsOrder_Edit() {
|
|
|
|
|
|
id, _ := c.GetInt("T_id")
|
|
|
|
|
|
- T_pid := Account.User_r.T_pid
|
|
|
- if T_pid == 0 {
|
|
|
- T_pid, _ = strconv.Atoi(c.Ctx.Request.Header.Get("T_pid"))
|
|
|
- }
|
|
|
-
|
|
|
r := Function.Read_GoodsOrder_ById(id)
|
|
|
|
|
|
if r.Id == 0 {
|
|
@@ -155,7 +151,7 @@ func (c *GoodsOrderController) GoodsOrder_Edit() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- if T_pid != r.T_pid {
|
|
|
+ if c.T_pid != r.T_pid {
|
|
|
c.Data["json"] = lib.JSONS{Code: 205, Msg: "没有权限!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
@@ -225,10 +221,6 @@ func (c *GoodsOrderController) GoodsOrder_Edit() {
|
|
|
func (c *GoodsOrderController) GoodsOrder_Del() {
|
|
|
|
|
|
Id, _ := c.GetInt("T_id")
|
|
|
- T_pid := Account.User_r.T_pid
|
|
|
- if T_pid == 0 {
|
|
|
- T_pid, _ = strconv.Atoi(c.Ctx.Request.Header.Get("T_pid"))
|
|
|
- }
|
|
|
r := Function.Read_GoodsOrder_ById(Id)
|
|
|
|
|
|
if r.Id == 0 {
|
|
@@ -236,7 +228,7 @@ func (c *GoodsOrderController) GoodsOrder_Del() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- if T_pid != r.T_pid {
|
|
|
+ if c.T_pid != r.T_pid {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
@@ -260,14 +252,14 @@ func (c *GoodsOrderController) GoodsOrder_PDF() {
|
|
|
var err error
|
|
|
Id, _ := c.GetInt("T_id")
|
|
|
if Id == 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id e!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
GoodsOrder_r := Function.Read_GoodsOrder_ById(Id)
|
|
|
if GoodsOrder_r.Id == 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 207, Msg: "Id e!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 207, Msg: "Id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|