Newer
Older
CactusServer / src / main / java / cactusServer / resources / AccountsRest.java
package cactusServer.resources;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

import cactusServer.entities.Account;
import cactusServer.models.Accounts;

@Path("/AccountsRest")
public class AccountsRest {
	@POST
	@Path("/login")
	@Produces(MediaType.APPLICATION_JSON)
	public Account loginAccount(@FormParam("userID") String userID, @FormParam("userPass") String userPass) {
		return Accounts.getInstance().loginAccount(userID, userPass);
	}
 
	@POST
	@Path("/logout")
	@Produces(MediaType.APPLICATION_JSON)
	public String logoutAccount(@FormParam("userID") String userID) {
		return Accounts.getInstance().logoutAccount(userID);
	}

	@POST
	@Path("/createAccount")
	@Produces(MediaType.APPLICATION_JSON)
	public Account create(@FormParam("userID") String userID, @FormParam("userName") String userName,
			@FormParam("userPass") String userPass) {
		return Accounts.getInstance().createAcount(userID, userName, userPass);
	}
	@GET
	@Path("/{userID}")
	@Produces(MediaType.APPLICATION_JSON)
	public Account getAccount(@PathParam("userID") String userID) {
		return Accounts.getInstance().getAccount(userID);
	}
	@DELETE
	@Path("/deleteAccount")
	@Produces(MediaType.TEXT_PLAIN)
	public String deleteAccount(@FormParam("userID") String userID) {
		return Accounts.getInstance().deleteAccount(userID);
	}
}