Java tutorial
/* * Copyright 2014-2015 snakerflow.com * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * */ package com.jfaker.app.modules.web; import java.util.HashMap; import java.util.Map; import org.apache.commons.lang.StringUtils; import org.snaker.engine.entity.Order; import com.jfaker.framework.flow.web.SnakerController; import com.jfaker.app.modules.model.Borrow; import com.jfaker.framework.security.shiro.ShiroUtils; import com.jfaker.framework.utils.DateUtils; import com.jfinal.aop.Before; import com.jfinal.plugin.activerecord.tx.Tx; /** * ?controller * ?:??decision?->${result} * ?: * ?flow_borrow?orderId?? * ?flow_approval?orderId?taskName? * @author yuqs * @since 0.1 */ public class BorrowController extends SnakerController { /** * */ public void apply() { //?? keepPara(); String orderId = getPara(PARA_ORDERID); String taskId = getPara(PARA_TASKID); if (StringUtils.isNotEmpty(orderId)) { //???orderId?? setAttr("borrow", Borrow.dao.findByOrderId(orderId)); } //?taskId?????? if (StringUtils.isEmpty(orderId) || StringUtils.isNotEmpty(taskId)) { setAttr("operateTime", DateUtils.getCurrentDay()); //idapply.jsp render("apply.jsp"); } else { //? render("applyView.jsp"); } } /** * ??? */ @Before(Tx.class) public void applySave() { /** ?? */ Map<String, Object> params = new HashMap<String, Object>(); params.put("apply.operator", ShiroUtils.getUsername()); params.put("approval.operator", ShiroUtils.getUsername()); /** ??? */ /** * ?? */ String orderId = getPara(PARA_ORDERID); String taskId = getPara(PARA_TASKID); if (StringUtils.isEmpty(orderId) && StringUtils.isEmpty(taskId)) { Order order = startAndExecute(getPara(PARA_PROCESSID), ShiroUtils.getUsername(), params); /** ??*/ Borrow model = getModel(Borrow.class); model.set("orderId", order.getId()); model.set("operateTime", DateUtils.getCurrentDay()); model.set("operator", ShiroUtils.getFullname()); model.save(); } else { execute(taskId, ShiroUtils.getUsername(), params); /** ??*/ getModel(Borrow.class).update(); } /** ??? */ redirectActiveTask(); } }