package org.binwang.bard.example;

import org.binwang.bard.basic.marker.Doc;
import org.binwang.bard.basic.marker.Required;
import org.binwang.bard.core.Handler;

import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import java.io.IOException;

@Produces("application/json")
@Path("/myapp")
public class SimpleHandler extends Handler {

    @Path("/get/{id}/{name}")
    @Doc("A simple handler just return what you give")
    public User printParams(
        @PathParam("id") Integer id,
        @PathParam("name") String name
    ) throws IOException {
        User user = new User();
        user.id = id;
        user.name = name;
        return user;
    }

    @Path("/add")
    @Doc("Add two numbers")
    public Integer add(
        @QueryParam("a") @Required @Doc("first number") Integer a,
        @QueryParam("b") @Required @Doc("second number") Integer b) throws IOException {
        return a + b;
    }
}

@@ -32,50 +32,8 @@
 e;%0A%0A
-import org.binwang.bard.basic.marker.Doc;%0A
 impo
@@ -133,20 +133,17 @@
 x.ws.rs.
-Path
+*
 ;%0Aimport
@@ -151,113 +151,43 @@
 java
-x.ws.rs.PathParam;%0Aimport javax.ws.rs.Produces;%0Aimport javax.ws.rs.QueryParam;%0Aimport java.io.IOException
+.util.HashMap;%0Aimport java.util.Map
 ;%0A%0A@
@@ -227,13 +227,12 @@
 h(%22/
-myapp
+user
 %22)%0Ap
@@ -284,88 +284,213 @@
     
-@Path(%22/get/%7Bid%7D/%7Bname%7D%22)%0A    @Doc(%22A simple handler just return what you give%22)
+public static Map%3CInteger, User%3E UserStorage = new HashMap%3C%3E();%0A%0A    @GET%0A    @Path(%22/%7Bid%7D%22)%0A    public User getUser(@PathParam(%22id%22) @Required int id) %7B%0A        return UserStorage.get(id);%0A    %7D%0A%0A    @PUT
 %0A   
@@ -506,19 +506,18 @@
 ser 
-printParams
+insertUser
 (%0A  
@@ -519,28 +519,28 @@
 r(%0A        @
-Path
+Form
 Param(%22id%22) 
@@ -539,23 +539,29 @@
 m(%22id%22) 
-Integer
+@Required int
  id,%0A   
@@ -566,20 +566,20 @@
        @
-Path
+Form
 Param(%22n
@@ -599,33 +599,9 @@
 name
-%0A    ) throws IOException
+)
  %7B%0A 
@@ -691,274 +691,54 @@
     
-return user;%0A    %7D%0A%0A    @Path(%22/add%22)%0A    @Doc(%22Add two numbers%22)%0A    public Integer add(%0A        @QueryParam(%22a%22) @Required @Doc(%22first number%22) Integer a,%0A        @QueryParam(%22b%22) @Required @Doc(%22second number%22) Integer b) throws IOException %7B%0A        return a + b
+UserStorage.put(id, user);%0A        return user
 ;%0A  

update example