|
|
@@ -12,25 +12,26 @@ type GroupCatController struct {
|
|
|
}
|
|
|
|
|
|
func (c *GroupCatController) BeforeActivation(b mvc.BeforeActivation) {
|
|
|
- b.Handle("GET", "/", "GetList")
|
|
|
- b.Handle("GET", "/page", "GetPage")
|
|
|
- b.Handle("GET", "/{groupCatId:int64}", "GetById")
|
|
|
- b.Handle("POST", "/add", "Create")
|
|
|
- b.Handle("PUT", "/update", "Update")
|
|
|
- b.Handle("DELETE", "/{groupCatId:int64}", "DeleteByID")
|
|
|
+ b.Handle("GET", "/", "GetList" )
|
|
|
+ b.Handle("GET", "/page", "GetPage" )
|
|
|
+ b.Handle("GET", "/{groupCatId:int64}", "GetById" )
|
|
|
+ b.Handle("POST", "/add", "Create" )
|
|
|
+ b.Handle("PUT", "/update", "Update" )
|
|
|
+ b.Handle("DELETE", "/{groupCatId:int64}", "DeleteByID")
|
|
|
}
|
|
|
|
|
|
func (c *GroupCatController) GetList() *JsonResult {
|
|
|
- params := c.buildParams()
|
|
|
+ params := c.buildParams()
|
|
|
data, err := c.Service.GetList(params)
|
|
|
if err != nil {
|
|
|
return ResultErr(err.Error(), nil)
|
|
|
+ } else {
|
|
|
+ return ResultOk("获取成功", data)
|
|
|
}
|
|
|
- return ResultOk("获取成功", data)
|
|
|
}
|
|
|
|
|
|
func (c *GroupCatController) GetPage() *JsonResult {
|
|
|
- params := c.buildParams()
|
|
|
+ params := c.buildParams()
|
|
|
data, err := c.Service.GetPage(params)
|
|
|
if err != nil {
|
|
|
return ResultErr(err.Error(), nil)
|
|
|
@@ -40,7 +41,7 @@ func (c *GroupCatController) GetPage() *JsonResult {
|
|
|
}
|
|
|
|
|
|
func (c *GroupCatController) GetById(groupCatId int64) *JsonResult {
|
|
|
- ocId := c.GetCurOcId()
|
|
|
+ ocId := c.GetCurOcId()
|
|
|
data, err := c.Service.GetById(ocId, groupCatId)
|
|
|
if err != nil {
|
|
|
return ResultErr(err.Error(), nil)
|
|
|
@@ -52,7 +53,6 @@ func (c *GroupCatController) GetById(groupCatId int64) *JsonResult {
|
|
|
func (c *GroupCatController) Create() *JsonResult {
|
|
|
ocId := c.GetCurOcId()
|
|
|
userId := c.GetCurUserId()
|
|
|
-
|
|
|
groupCat := datamodels.GroupCat{}
|
|
|
err := c.Ctx.ReadJSON(&groupCat)
|
|
|
if err != nil {
|
|
|
@@ -72,7 +72,6 @@ func (c *GroupCatController) Create() *JsonResult {
|
|
|
func (c *GroupCatController) Update() *JsonResult {
|
|
|
ocId := c.GetCurOcId()
|
|
|
userId := c.GetCurUserId()
|
|
|
-
|
|
|
groupCat := datamodels.GroupCat{}
|
|
|
if err := c.Ctx.ReadJSON(&groupCat); err != nil {
|
|
|
return ResultErr("读取数据失败", nil)
|
|
|
@@ -92,7 +91,7 @@ func (c *GroupCatController) DeleteByID(groupCatId int64) *JsonResult {
|
|
|
ocId := c.GetCurOcId()
|
|
|
userId := c.GetCurUserId()
|
|
|
|
|
|
- var m = make(map[string]interface{})
|
|
|
+ m := make(map[string]interface{})
|
|
|
m["ocId"] = ocId
|
|
|
m["groupCatId"]= groupCatId
|
|
|
m["deletedBy"] = userId
|