Package wbbs.web.admin

Source Code of wbbs.web.admin.category

package wbbs.web.admin;

import cn.webwheel.Action;
import cn.webwheel.results.ErrorResult;
import cn.webwheel.results.TemplateResult;
import com.google.inject.Inject;
import wbbs.domain.BoardCategory;
import wbbs.service.BoardService;

import java.sql.SQLException;

public class category extends BaseAction {

    public BoardCategory category;

    @Inject
    BoardService boardService;

    @Action
    public Object html(int id) throws SQLException {

        ensureLoginPage();

        if (id == 0) {
            category = new BoardCategory();
        } else {
            category = boardService.findCategory(id);
            if (category == null) {
                return new ErrorResult(404);
            }
        }
        return new TemplateResult(this);
    }

    @Action
    public Object update() throws SQLException {

        ensureLoginAction();

        range(notNull(nospace(trim(category.name))), 1, 32);
        range(notNull(trim(category.remark)), 1, 512);

        if (category.id == 0) {
            boardService.insertCategory(category);
        } else {
            boardService.updateCategory(category);
        }
        return ok().set("id", category.id);
    }

}
TOP

Related Classes of wbbs.web.admin.category

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.