日期:2014-05-17 浏览次数:20950 次
<!-- 配置事务特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="deploy*" propagation="REQUIRED" />
<tx:method name="submit*" propagation="REQUIRED" />
<tx:method name="get*" read-only="true" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="daoMethods"
expression="execution(* net.hlj.kj.dao.*.*.*(..))" />
<!-- 定义了将采用何种拦截操作,这里引用到 txAdvice -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="daoMethods" />
</aop:config>
<tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true" />
action
public void activeUser(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
long id = UtilTool.str2Long(request.getParameter("id"));
TdUser tu = userService.getUserById(id);
if (tu.getState() == 0) {// 判断是否激活
try {
bouns(tu.getId(), tu.getSuperid(), 1);
TdUser agent = userService.getUserById(tu.getAgentid());
agent.setMb(5d);
userService.update(agent);
//激活账户
userService.activeUser(id);
//购买股票
userService.buyStock(tu);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
response.sendRedirect("doUser.do?method=getUserListByAgent");
}