|
|
@@ -26,6 +26,19 @@ func CreateUserGroup(c *middleware.Context, cmd m.CreateUserGroupCommand) Respon
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+// PUT /api/user-groups/:userGroupId
|
|
|
+func UpdateUserGroup(c *middleware.Context, cmd m.UpdateUserGroupCommand) Response {
|
|
|
+ cmd.Id = c.ParamsInt64(":userGroupId")
|
|
|
+ if err := bus.Dispatch(&cmd); err != nil {
|
|
|
+ if err == m.ErrUserGroupNameTaken {
|
|
|
+ return ApiError(400, "User Group name taken", err)
|
|
|
+ }
|
|
|
+ return ApiError(500, "Failed to update User Group", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ return ApiSuccess("User Group updated")
|
|
|
+}
|
|
|
+
|
|
|
// DELETE /api/user-groups/:userGroupId
|
|
|
func DeleteUserGroupById(c *middleware.Context) Response {
|
|
|
if err := bus.Dispatch(&m.DeleteUserGroupCommand{Id: c.ParamsInt64(":userGroupId")}); err != nil {
|
|
|
@@ -64,3 +77,18 @@ func SearchUserGroups(c *middleware.Context) Response {
|
|
|
|
|
|
return Json(200, query.Result)
|
|
|
}
|
|
|
+
|
|
|
+// GET /api/user-groups/:userGroupId
|
|
|
+func GetUserGroupById(c *middleware.Context) Response {
|
|
|
+ query := m.GetUserGroupByIdQuery{Id: c.ParamsInt64(":userGroupId")}
|
|
|
+
|
|
|
+ if err := bus.Dispatch(&query); err != nil {
|
|
|
+ if err == m.ErrUserGroupNotFound {
|
|
|
+ return ApiError(404, "User Group not found", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ return ApiError(500, "Failed to get User Group", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ return Json(200, &query.Result)
|
|
|
+}
|