func GetCommunity(w http.ResponseWriter, r *http.Request) { if ok, _ := authentication.RequireTokenAuthentication(w, r); !ok { return } vars := mux.Vars(r) communityId := util.StringToInt(vars["community_id"]) community := &model.Community{ CommunityId: communityId, } if exists, err := community.Get(); err != nil { packError(w, err, ERROR_CODE, "") return } else if !exists { packResult(w, "") return } packResult(w, community) }
func DeleteCommunity(w http.ResponseWriter, r *http.Request) { var loggedUser *model.User var ok bool if ok, loggedUser = authentication.RequireTokenAuthentication(w, r); !ok { return } vars := mux.Vars(r) communityId := util.StringToInt(vars["community_id"]) community := &model.Community{ CommunityId: communityId, } community.DeletedUserId = loggedUser.UserId if err := community.Delete(); err != nil { packError(w, err, ERROR_CODE, "") return } packResult(w, "ok") }