houyaf 3 년 전
부모
커밋
64e9b69f5c

+ 2 - 2
pkg/system/controller/art_cat_controller.go

@@ -60,7 +60,7 @@ func (c *ArtCatController) Create() *JsonResult {
         return ResultErr("读取数据失败", nil)
     }
 
-    artCat.OcId = ocId
+    artCat.OcId      = ocId
     artCat.CreatedBy = userId
     if err := c.Service.Create(artCat); err != nil {
         return ResultErr(err.Error(), nil)
@@ -78,7 +78,7 @@ func (c *ArtCatController) Update() *JsonResult {
         return ResultErr("读取数据失败", nil)
     }
 
-    artCat.OcId = ocId
+    artCat.OcId      = ocId
     artCat.UpdatedBy = userId
     if err := c.Service.Update(artCat); err != nil {
         return ResultErr(err.Error(), nil)

+ 1 - 1
pkg/system/controller/art_controller.go

@@ -76,7 +76,7 @@ func (c *ArtController) Update() *JsonResult {
         return ResultErr("读取数据失败", nil)
     }
 
-    art.OcId = ocId
+    art.OcId      = ocId
     art.UpdatedBy = userId
     if err := c.Service.Update(art); err != nil {
         return ResultErr(err.Error(), nil)

+ 1 - 1
pkg/system/controller/group_cat_controller.go

@@ -86,7 +86,7 @@ func (c *GroupCatController) Update() *JsonResult {
 }
 
 func (c *GroupCatController) DeleteByID(groupCatId int64) *JsonResult {
-    ocId := c.GetCurOcId()
+    ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
 
     m := make(map[string]interface{})

+ 9 - 11
pkg/system/controller/group_controller.go

@@ -21,8 +21,7 @@ func (c *GroupController) BeforeActivation(b mvc.BeforeActivation) {
 }
 
 func (c *GroupController) GetList() *JsonResult {
-    ocId := c.GetCurOcId()
-
+    ocId   := c.GetCurOcId()
     params := c.buildParams()
     params["ocId"] = ocId
     data, err := c.Service.GetList(params)
@@ -54,15 +53,14 @@ func (c *GroupController) GetById(groupId int64) *JsonResult {
 }
 
 func (c *GroupController) Create() *JsonResult {
-    ocId := c.GetCurOcId()
+    ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
-    group := datamodel.Group{}
-
+    group  := datamodel.Group{}
     if err := c.Ctx.ReadJSON(&group); err != nil {
         return ResultErr("读取数据失败", nil)
     }
 
-    group.OcId = ocId
+    group.OcId      = ocId
     group.CreatedBy = userId
     if err := c.Service.Create(&group); err != nil {
         return ResultErr(err.Error(), nil)
@@ -72,7 +70,7 @@ func (c *GroupController) Create() *JsonResult {
 }
 
 func (c *GroupController) Update() *JsonResult {
-    ocId := c.GetCurOcId()
+    ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
 
     group := datamodel.Group{}
@@ -80,7 +78,7 @@ func (c *GroupController) Update() *JsonResult {
         return ResultErr("读取数据失败", nil)
     }
 
-    group.OcId = ocId
+    group.OcId      = ocId
     group.UpdatedBy = userId
     if err := c.Service.Update(&group); err != nil {
         return ResultErr(err.Error(), nil)
@@ -90,12 +88,12 @@ func (c *GroupController) Update() *JsonResult {
 }
 
 func (c *GroupController) DeleteById(groupId int64) *JsonResult {
-    ocId := c.GetCurOcId()
+    ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
 
     m := make(map[string]interface{})
-    m["ocId"] = ocId
-    m["groupId"] = groupId
+    m["ocId"]      = ocId
+    m["groupId"]   = groupId
     m["deletedBy"] = userId
     if err := c.Service.Delete(m); err != nil {
         return ResultErr(err.Error(), nil)

+ 7 - 8
pkg/system/controller/msg_cat_controller.go

@@ -51,15 +51,14 @@ func (c *MsgCatController) GetById(msgCatId int64) *JsonResult {
 }
 
 func (c *MsgCatController) Create() *JsonResult {
-    ocId := c.GetCurOcId()
+    ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
     msgCat := datamodel.MsgCat{}
-
     if err := c.Ctx.ReadJSON(&msgCat); err != nil {
         return ResultErr("读取数据失败", nil)
     }
 
-    msgCat.OcId = ocId
+    msgCat.OcId      = ocId
     msgCat.CreatedBy = userId
     if err := c.Service.Create(&msgCat); err != nil {
         return ResultErr(err.Error(), nil)
@@ -69,7 +68,7 @@ func (c *MsgCatController) Create() *JsonResult {
 }
 
 func (c *MsgCatController) Update() *JsonResult {
-    ocId := c.GetCurOcId()
+    ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
 
     msgCat := datamodel.MsgCat{}
@@ -77,7 +76,7 @@ func (c *MsgCatController) Update() *JsonResult {
         return ResultErr("读取数据失败", nil)
     }
 
-    msgCat.OcId = ocId
+    msgCat.OcId      = ocId
     msgCat.UpdatedBy = userId
     if err := c.Service.Update(&msgCat); err != nil {
         return ResultErr(err.Error(), nil)
@@ -87,12 +86,12 @@ func (c *MsgCatController) Update() *JsonResult {
 }
 
 func (c *MsgCatController) DeleteByID(msgCatId int64) *JsonResult {
-    ocId := c.GetCurOcId()
+    ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
 
     m := make(map[string]interface{})
-    m["ocId"] = ocId
-    m["msgCatId"] = msgCatId
+    m["ocId"]      = ocId
+    m["msgCatId"]  = msgCatId
     m["deletedBy"] = userId
     if err := c.Service.Delete(m); err != nil {
         return ResultErr(err.Error(), nil)

+ 6 - 6
pkg/system/controller/msg_controller.go

@@ -51,14 +51,14 @@ func (c *MsgController) GetById(msgId int64) *JsonResult {
 }
 
 func (c *MsgController) Create() *JsonResult {
-    ocId := c.GetCurOcId()
+    ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
 
     msg := datamodel.Msg{}
     if err := c.Ctx.ReadJSON(&msg); err != nil {
         return ResultErr("读取数据失败", nil)
     }
-    msg.OcId = ocId
+    msg.OcId      = ocId
     msg.CreatedBy = userId
     if err := c.Service.Create(&msg); err != nil {
         return ResultErr(err.Error(), nil)
@@ -68,14 +68,14 @@ func (c *MsgController) Create() *JsonResult {
 }
 
 func (c *MsgController) Update() *JsonResult {
-    ocId := c.GetCurOcId()
+    ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
 
     msg := datamodel.Msg{}
     if err := c.Ctx.ReadJSON(&msg); err != nil {
         return ResultErr("读取数据失败", nil)
     }
-    msg.OcId = ocId
+    msg.OcId      = ocId
     msg.UpdatedBy = userId
     if err := c.Service.Update(&msg); err != nil {
         return ResultErr(err.Error(), nil)
@@ -89,8 +89,8 @@ func (c *MsgController) DeleteByID(msgId int64) *JsonResult {
     userId := c.GetCurUserId()
 
     m := make(map[string]interface{})
-    m["ocId"] = ocId
-    m["msgId"] = msgId
+    m["ocId"]      = ocId
+    m["msgId"]     = msgId
     m["deletedBy"] = userId
     if err := c.Service.Delete(m); err != nil {
         return ResultErr(err.Error(), nil)

+ 3 - 3
pkg/system/controller/oc_cat_controller.go

@@ -63,11 +63,11 @@ func (c *OcCatController) Create() *JsonResult {
     userId := c.GetCurUserId()
 
     mod := datamodel.OcCat{}
-    mod.CreatedBy = userId
     if err := c.Ctx.ReadJSON(&mod); err != nil {
         return ResultErr("读取数据失败", nil)
     }
 
+    mod.CreatedBy = userId
     if err := c.Service.Create(&mod); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
@@ -95,8 +95,8 @@ func (c *OcCatController) DeleteByID(ocTypeId, ocCatId int64) *JsonResult {
     userId := c.GetCurUserId()
 
     m := make(map[string]interface{})
-    m["ocTypeId"] = ocTypeId
-    m["ocCatId"] = ocCatId
+    m["ocTypeId"]  = ocTypeId
+    m["ocCatId"]   = ocCatId
     m["deletedBy"] = userId
     if err := c.Service.Delete(m); err != nil {
         return ResultErr(err.Error(), nil)

+ 12 - 12
pkg/system/controller/oc_controller.go

@@ -13,17 +13,17 @@ type OcController struct {
 }
 
 func (c *OcController) BeforeActivation(b mvc.BeforeActivation) {
-    b.Handle("GET",     "/",                                            "GetList")
-    b.Handle("GET",     "/page",                                        "GetPage")
-    b.Handle("GET",     "/{ocId:int64}",                                "GetById")
-    b.Handle("POST",    "/add",                                         "Create")
-    b.Handle("PUT",     "/update",                                      "Update")
-    b.Handle("DELETE",  "/{ocId:int64}",                                "DeleteByID")
-    b.Handle("GET",     "/getAdmin/{ocId:int64}",                       "GetAdmin")
-    b.Handle("POST",    "/addAdmin",                                    "CreateAdmin")
-    b.Handle("PUT",     "/updateAdmin",                                 "UpdateAdmin")
-    b.Handle("PUT",     "/resetAdminPwd/{ocId:int64}/{adminId:int64}",  "ResetAdminPwd")
-    b.Handle("PUT",     "/updateStatus/{ocId:int64}/{status:int64}",    "UpdateStatus")
+    b.Handle("GET",     "/",                                            "GetList"       )
+    b.Handle("GET",     "/page",                                        "GetPage"       )
+    b.Handle("GET",     "/{ocId:int64}",                                "GetById"       )
+    b.Handle("POST",    "/add",                                         "Create"        )
+    b.Handle("PUT",     "/update",                                      "Update"        )
+    b.Handle("DELETE",  "/{ocId:int64}",                                "DeleteByID"    )
+    b.Handle("GET",     "/getAdmin/{ocId:int64}",                       "GetAdmin"      )
+    b.Handle("POST",    "/addAdmin",                                    "CreateAdmin"   )
+    b.Handle("PUT",     "/updateAdmin",                                 "UpdateAdmin"   )
+    b.Handle("PUT",     "/resetAdminPwd/{ocId:int64}/{adminId:int64}",  "ResetAdminPwd" )
+    b.Handle("PUT",     "/updateStatus/{ocId:int64}/{status:int64}",    "UpdateStatus"  )
     b.Handle("PUT",     "/updateLicStatus/{ocId:int64}/{status:int64}", "UpdateLicStatus")
 }
 
@@ -78,11 +78,11 @@ func (c *OcController) Create() *JsonResult {
     userId := c.GetCurUserId()
 
     o := datamodel.Oc{}
-    o.CreatedBy = userId
     if err := c.Ctx.ReadJSON(&o); err != nil {
         return ResultErr("读取数据失败", nil)
     }
 
+    o.CreatedBy = userId
     if err := c.Service.Create(&o); err != nil {
         return ResultErr(err.Error(), nil)
     } else {

+ 1 - 1
pkg/system/controller/oc_type_controller.go

@@ -53,11 +53,11 @@ func (c *OcTypeController) Create() *JsonResult {
     userId := c.GetCurUserId()
 
     mod := datamodel.OcType{}
-    mod.CreatedBy = userId
     if err := c.Ctx.ReadJSON(&mod); err != nil {
         return ResultErr("读取数据失败", nil)
     }
 
+    mod.CreatedBy = userId
     if err := c.Service.Create(&mod); err != nil {
         return ResultErr(err.Error(), nil)
     } else {

+ 4 - 6
pkg/system/controller/position_controller.go

@@ -54,13 +54,12 @@ func (c *PositionController) Create() *JsonResult {
     userId := c.GetCurUserId()
 
     position := datamodel.Position{}
-    position.OcId      = ocId
-    position.CreatedBy = userId
     if err := c.Ctx.ReadJSON(&position); err != nil {
         return ResultErr("读取数据失败", nil)
     }
 
-    position.OcId = ocId
+    position.OcId      = ocId
+    position.CreatedBy = userId
     if err := c.Service.Create(&position); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
@@ -69,9 +68,8 @@ func (c *PositionController) Create() *JsonResult {
 }
 
 func (c *PositionController) Update() *JsonResult {
-    ocId   := c.GetCurOcId()
-    userId := c.GetCurUserId()
-
+    ocId     := c.GetCurOcId()
+    userId   := c.GetCurUserId()
     position := datamodel.Position{}
     if err := c.Ctx.ReadJSON(&position); err != nil {
         return ResultErr("读取数据失败", nil)

+ 0 - 1
pkg/system/controller/role_controller.go

@@ -81,7 +81,6 @@ func (c *RoleController) Update() *JsonResult {
 
 func (c *RoleController) DeleteById(roleId int64) *JsonResult {
     userId := c.GetCurUserId()
-
     m := make(map[string]interface{})
     m["roleId"]    = roleId
     m["deletedBy"] = userId

+ 2 - 2
pkg/system/controller/task_cat_controller.go

@@ -59,7 +59,7 @@ func (c *TaskCatController) Create() *JsonResult {
         return ResultErr("读取数据失败", nil)
     }
 
-    taskCat.OcId = ocId
+    taskCat.OcId      = ocId
     taskCat.CreatedBy = userId
     if err := c.Service.Create(&taskCat); err != nil {
         return ResultErr(err.Error(), nil)
@@ -77,7 +77,7 @@ func (c *TaskCatController) Update() *JsonResult {
         return ResultErr("读取数据失败", nil)
     }
 
-    taskCat.OcId = ocId
+    taskCat.OcId      = ocId
     taskCat.UpdatedBy = userId
     if err := c.Service.Update(&taskCat); err != nil {
         return ResultErr(err.Error(), nil)

+ 1 - 1
pkg/system/controller/task_controller.go

@@ -59,7 +59,7 @@ func (c *TaskController) Create() *JsonResult {
         return ResultErr("读取数据失败", nil)
     }
 
-    task.OcId = ocId
+    task.OcId      = ocId
     task.CreatedBy = userId
     if err := c.Service.Create(task); err != nil {
         return ResultErr(err.Error(), nil)

+ 2 - 3
pkg/system/controller/upload_controller.go

@@ -37,7 +37,7 @@ func (c *UploadController) BeforeActivation(b mvc.BeforeActivation) {
 
 // UploadFile :Single Upload
 func (c *UploadController) UploadFile() *JsonResult {
-    ocId := c.GetCurOcId()
+    ocId   := c.GetCurOcId()
     userId := c.GetCurUserId()
     f, fh, err := c.Ctx.FormFile("uploadfile")
     if err != nil {
@@ -45,9 +45,8 @@ func (c *UploadController) UploadFile() *JsonResult {
     }
     defer f.Close()
 
-    oldFileName := fh.Filename
+    oldFileName    := fh.Filename
     targetFileName := c.GenerateNewFileName(oldFileName)
-
     out, err := os.OpenFile(targetFileName, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0666)
     if err != nil {
         return ResultErr(err.Error(), nil)

+ 1 - 2
pkg/system/controller/user_controller.go

@@ -178,11 +178,11 @@ func (c *UserController) IsStaffNoExist(staffNo string) *JsonResult {
 
 func (c *UserController) IsEmailExist(email string) *JsonResult {
     ocId := c.GetCurOcId()
-
     bExist, err := c.Service.IsEmailExist(ocId, email)
     if err != nil {
         return ResultErr(err.Error(), nil)
     }
+
     if bExist {
         return ResultErr("email已存在", nil)
     } else {
@@ -192,7 +192,6 @@ func (c *UserController) IsEmailExist(email string) *JsonResult {
 
 func (c *UserController) SelectUser() *JsonResult {
     ocId := c.GetCurOcId()
-
     data, err := c.Service.SelectUser(ocId)
     if err != nil {
         return ResultErr(err.Error(), nil)