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";
     }
}
最近下载更多
微信网友_6177587776049152  LV1 2023年4月23日
打野只抓上  LV2 2023年4月12日
 LV6 2023年3月12日
sweetlove  LV17 2022年11月2日
jimodeai  LV14 2022年10月31日
微信网友_5952527027507200  LV1 2022年6月20日
12koko  LV3 2022年6月5日
1690356080  LV37 2022年5月28日
zhuxxiaoh  LV8 2022年5月19日
xiex909  LV27 2022年5月11日
最近浏览更多
荣》Cowboy  LV12 4月11日
qq1357574774  LV2 3月28日
Gin19960217  LV4 3月18日
皇甫科昊 3月7日
暂无贡献等级
akkye_7  LV1 1月11日
WBelong  LV7 2023年12月25日
pokerf  LV5 2023年12月19日
wdw2444156008 2023年11月13日
暂无贡献等级
kisooo 2023年11月8日
暂无贡献等级
jiemomo  LV12 2023年11月5日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友