首页>代码>ssh框架开发的个人博客系统源码下载,基于mysql数据库>/博客/博客/myblog/src/com/qm/action/DiaryAction.java
package com.qm.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.qm.entity.Diary;
import com.qm.service.IDiaryService;

/**
 * 日记控制层
 * @author quanmin
 *
 */
public class DiaryAction extends ActionSupport implements SessionAware {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Diary diary;
	private IDiaryService diaryService;
	private Map<String, Object> sessionMap;
	/**
	 * 添加
	 * @return
	 * @throws Exception
	 */
	public String add() throws Exception{
		if(diary.getDiaryId()==null){
			diaryService.add(diary);
		}else{
			diaryService.update(diary);
		}
		return "add";
	}
	/**
	 * 查找所有
	 * @return
	 * @throws Exception
	 */
	public String findAll() throws Exception{
		List<Diary> diaryList=diaryService.findAll();
		sessionMap.put("diaryList", diaryList);
		return "findAll";
	}
	/**
	 * 通过id查找
	 * @return
	 * @throws Exception
	 */
	public String findById() throws Exception{
		this.diary=diaryService.findById(diary.getDiaryId());
		return "findById";
	}
	/**
	 * 删除
	 * @return
	 * @throws Exception
	 */
	public String delete() throws Exception{
		diaryService.delete(diary.getDiaryId());
		return "delete";
	}
	public void setSession(Map<String, Object> sessionMap) {
		this.sessionMap=sessionMap;
	}
	public Diary getDiary() {
		return diary;
	}
	public void setDiary(Diary diary) {
		this.diary = diary;
	}
	public void setDiaryService(IDiaryService diaryService) {
		this.diaryService = diaryService;
	}
	
}
最近下载更多
wanglinddad  LV54 2022年3月18日
adim10912  LV2 2022年3月5日
and123456  LV11 2022年2月7日
977903096  LV10 2021年12月23日
15966848095  LV22 2021年11月15日
SOLEIL.  LV3 2021年6月19日
15525425383  LV6 2021年5月23日
rongfan  LV14 2021年4月6日
yyy777  LV5 2021年2月4日
ExamplesDYC  LV13 2020年11月21日
最近浏览更多
WBelong  LV7 2023年12月11日
拜托你仔细听  LV3 2023年9月21日
zj20020510  LV5 2023年9月18日
周敏国  LV9 2023年8月21日
xuxin2000 2023年8月17日
暂无贡献等级
暂无贡献等级
刘洋66666  LV1 2023年7月14日
3416059514  LV1 2023年6月23日
陆程江  LV2 2023年5月28日
星辰xc  LV2 2023年5月8日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友