package com.hotel.action;



import java.util.List;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.hotel.model.Log;
import com.hotel.model.Manage;
import com.hotel.service.LogService;
import com.hotel.service.ManageService;
import com.hotel.utils.Pager;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

@Controller("logAction")
@Scope("prototype")
public class LogAction extends ActionSupport implements ModelDriven<Log>{

    private Log log;
    
    private int logId;
    
    @Override
	public Log getModel() {
		if(log==null) log = new Log();
		return log;
	}
	
    @Autowired
    private LogService  logService;
    
    @Autowired
    private ManageService manageService;
    

    public int getLogId() {
        return logId;
    }

    
    public void setLogId(int logId) {
        this.logId = logId;
    }

    /**
     * 获取日志列表
     * @return
     */
    public String logList(){
      Pager<Log> pagers = logService.listAll();
     ActionContext.getContext().put("pagers", pagers);
    return SUCCESS;
    }
    
    /**
     * 日志初始化新增页面
     * @Description (TODO这里用一句话描述这个方法的作用)
     * @return
     */
    public String addLog() {
        List<Manage> manageList=manageService.list();
        ActionContext.getContext().put("manageList", manageList);
        return "success";
    }
    
    /**
     * 新增日志
     * @Description (TODO这里用一句话描述这个方法的作用)
     * @return
     */
    public String logAdd(){
        logService.add(log);
        String content="新增日志";
        HttpSession session =ServletActionContext.getRequest().getSession();
        int userId = Integer.parseInt( session.getAttribute("userId").toString());
        //插入日志
        logService.addLog(content,userId);
        ActionContext.getContext().put("url", "/log_logList.do");
        return "redirect";
    }
    
    /**
     * 删除日志
     * @return
     */
    public String delLog(){
        logService.delLog(logId);
        String content="删除日志";
        HttpSession session =ServletActionContext.getRequest().getSession();
        int userId = Integer.parseInt( session.getAttribute("userId").toString());
        //插入日志
        logService.addLog(content,userId);
        ActionContext.getContext().put("url", "/log_logList.do");
        return "redirect";
    }
    
    /**
     * 初始化修改页面
     * @Description (TODO这里用一句话描述这个方法的作用)
     * @return
     */
    public String updateLog(){
        Log log =logService.logDetail(logId);
        List<Manage> manageList=manageService.list();
        ActionContext.getContext().put("manageList", manageList);
        ActionContext.getContext().put("log", log);
         return "success";
     }
    
    /**
     * 修改日志
     * @Description (TODO这里用一句话描述这个方法的作用)
     * @return
     */
    public String logUpdate(){
        logService.update(log);
        String content="修改日志";
        HttpSession session =ServletActionContext.getRequest().getSession();
        int userId = Integer.parseInt( session.getAttribute("userId").toString());
        //插入日志
        logService.addLog(content,userId);
        ActionContext.getContext().put("url", "/log_logList.do");
        return "redirect";
     }
}
最近下载更多
xiao小果  LV13 2024年8月27日
微信网友_6177587776049152  LV1 2023年4月23日
打野只抓上  LV2 2023年4月12日
 LV6 2023年3月12日
sweetlove  LV20 2022年11月2日
jimodeai  LV15 2022年10月31日
微信网友_5952527027507200  LV1 2022年6月20日
12koko  LV3 2022年6月5日
1690356080  LV38 2022年5月28日
zhuxxiaoh  LV8 2022年5月19日
最近浏览更多
zolscy  LV24 2024年11月28日
xiao小果  LV13 2024年8月27日
荣》Cowboy  LV12 2024年4月11日
qq1357574774  LV2 2024年3月28日
Gin19960217  LV4 2024年3月18日
皇甫科昊 2024年3月7日
暂无贡献等级
akkye_7  LV1 2024年1月11日
WBelong  LV8 2023年12月25日
pokerf  LV5 2023年12月19日
wdw2444156008 2023年11月13日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友