Package com.example.controller.http

Source Code of com.example.controller.http.TagController

package com.example.controller.http;

import com.example.model.Tag;
import net.csdn.annotation.rest.At;
import net.csdn.modules.http.ApplicationController;
import net.csdn.modules.http.RestRequest;
import net.csdn.modules.http.ViewType;

/**
* 12/25/13 WilliamZhu(allwefantasy@gmail.com)
*/
public class TagController extends ApplicationController {

    @At(path = "/tag", types = {RestRequest.Method.POST})
    public void save() {
        Tag tag = Tag.create(params());
        if (tag.save()) {
            render(200, "成功", ViewType.string);
        }
        render(400, "失败", ViewType.string);
    }

    @At(path = "/tag/{id}", types = {RestRequest.Method.GET})
    public void find() {
        Tag tag = Tag.where(map("name", param("id"))).singleFetch();
        if (tag == null) {
            render(404, map());
        }
        render(404, list(tag));

    }

}
TOP

Related Classes of com.example.controller.http.TagController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.