// Path: src/com/cjlu/newspublish/actions/BaseAction.java
// @SuppressWarnings("unchecked")
// public abstract class BaseAction<T> extends ActionSupport implements
// 		ModelDriven<T>, Preparable, RequestAware, SessionAware ,ApplicationAware{
// 
// 	private static final long serialVersionUID = 1L;
// 	public T model;
// 	protected Map<String, Object> sessionMap;
// 	protected Map<String, Object> requestMap;
// 	@SuppressWarnings("unused")
// 	private Map<String, Object> applicationMap;
// 	protected HttpSession httpSession = ServletActionContext.getRequest().getSession();
// 	protected HttpServletRequest httpRequest = ServletActionContext.getRequest();
// 	protected HttpServletResponse httpResponse = ServletActionContext.getResponse();
// 	protected ServletContext application = ServletActionContext.getRequest().getSession().getServletContext();
// 	protected InputStream inputStream;
// 	protected VerificationCodeUtils vcu = VerificationCodeUtils.Instance();
// 	
// 	
// 	public InputStream getInputStream() {
// 		return inputStream;
// 	}
// 
// 	public void setInputStream(InputStream inputStream) {
// 		this.inputStream = inputStream;
// 	}
// 
// 	public BaseAction() {
// 		try {
// 			model = (T) ReflectionUtils.getSuperGenericType(this.getClass())
// 					.newInstance();
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 		}
// 	}
// 
// 	@Override
// 	public void prepare() throws Exception {
// 
// 	}
// 	
// 	public void writeJSON(Object obj) throws IOException{
// 		ObjectMapper om = new ObjectMapper();
// 		String str = null;
// 		try {
// 			str = om.writeValueAsString(obj);
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 		}
// 		ServletActionContext.getResponse().setContentType("text/html");
// 		ServletActionContext.getResponse().setCharacterEncoding("utf-8");
// 		try {
// 			ServletActionContext.getResponse().getWriter().printf(str);
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 		}
// 		ServletActionContext.getResponse().getWriter().flush();
// 		ServletActionContext.getResponse().getWriter().close();
// 	}
// 
// 	@Override
// 	public T getModel() {
// 		return model;
// 	}
// 
// 	@Override
// 	public void setSession(Map<String, Object> sessionMap){
// 		this.sessionMap = sessionMap;
// 	}
// 
// 	@Override
// 	public void setRequest(Map<String, Object> requestMap){
// 		this.requestMap = requestMap;
// 	}
// 
// 	@Override
// 	public void setApplication(Map<String, Object> applicationMap) {
// 		this.applicationMap = applicationMap;
// 	}
// 
// }
// 
// Path: src/com/cjlu/newspublish/models/User.java
// public class User extends BaseEntity {
// 
// 	private static final long serialVersionUID = 6923757046786572615L;
// 	private String username;
// 	private String password;
// 	private String email;
// 	private Date createTime = new Date();
// 
// 	public String getUsername() {
// 		return username;
// 	}
// 
// 	public void setUsername(String username) {
// 		this.username = username;
// 	}
// 
// 	public String getPassword() {
// 		return password;
// 	}
// 
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// 
// 	public String getEmail() {
// 		return email;
// 	}
// 
// 	public void setEmail(String email) {
// 		this.email = email;
// 	}
// 
// 	public Date getCreateTime() {
// 		return createTime;
// 	}
// 
// 	public void setCreateTime(Date createTime) {
// 		this.createTime = createTime;
// 	}
// 	
// }
// 
// Path: src/com/cjlu/newspublish/services/UserService.java
// public interface UserService extends BaseService<User>{
// 	
// 	public boolean isTokenUp(String str);
// 	
// 	public User isUser(String username,String password);
// 
// 	public void deleteUser(Integer id);
// 
// }


import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.util.List;
import javassist.bytecode.stackmap.TypeData.ClassName;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.cjlu.newspublish.actions.BaseAction;
import com.cjlu.newspublish.models.User;
import com.cjlu.newspublish.services.UserService;
	private List<User> allUsers = null;
	private static Logger logger = Logger.getLogger(ClassName.class);

	public String loginout() {
		sessionMap.put("user", null);
		httpSession.invalidate();
		return "to_NewsAction_getAllPassedNews";
	}

	public String getAllUsers() {
		allUsers = userService.findAllEntities();
		requestMap.put("allUsers", allUsers);
		return "to_userListPage";
	}

	public String deleteUser() {
		try {
			if (model.getId() != null && model.getId() > 0) {
				userService.deleteUser(model.getId());
				inputStream = new ByteArrayInputStream("1".getBytes("UTF-8"));
				logger.info("¹ÜÀíÔ±É¾³ýÓÃ»§£º" + model.getUsername());
			}
		} catch (Exception e) {
			try {
				inputStream = new ByteArrayInputStream("0".getBytes("UTF-8"));
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
		}

// Path: src/com/cjlu/newspublish/actions/BaseAction.java
// @SuppressWarnings("unchecked")
// public abstract class BaseAction<T> extends ActionSupport implements
// 		ModelDriven<T>, Preparable, RequestAware, SessionAware ,ApplicationAware{
// 
// 	private static final long serialVersionUID = 1L;
// 	public T model;
// 	protected Map<String, Object> sessionMap;
// 	protected Map<String, Object> requestMap;
// 	@SuppressWarnings("unused")
// 	private Map<String, Object> applicationMap;
// 	protected HttpSession httpSession = ServletActionContext.getRequest().getSession();
// 	protected HttpServletRequest httpRequest = ServletActionContext.getRequest();
// 	protected HttpServletResponse httpResponse = ServletActionContext.getResponse();
// 	protected ServletContext application = ServletActionContext.getRequest().getSession().getServletContext();
// 	protected InputStream inputStream;
// 	protected VerificationCodeUtils vcu = VerificationCodeUtils.Instance();
// 	
// 	
// 	public InputStream getInputStream() {
// 		return inputStream;
// 	}
// 
// 	public void setInputStream(InputStream inputStream) {
// 		this.inputStream = inputStream;
// 	}
// 
// 	public BaseAction() {
// 		try {
// 			model = (T) ReflectionUtils.getSuperGenericType(this.getClass())
// 					.newInstance();
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 		}
// 	}
// 
// 	@Override
// 	public void prepare() throws Exception {
// 
// 	}
// 	
// 	public void writeJSON(Object obj) throws IOException{
// 		ObjectMapper om = new ObjectMapper();
// 		String str = null;
// 		try {
// 			str = om.writeValueAsString(obj);
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 		}
// 		ServletActionContext.getResponse().setContentType("text/html");
// 		ServletActionContext.getResponse().setCharacterEncoding("utf-8");
// 		try {
// 			ServletActionContext.getResponse().getWriter().printf(str);
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 		}
// 		ServletActionContext.getResponse().getWriter().flush();
// 		ServletActionContext.getResponse().getWriter().close();
// 	}
// 
// 	@Override
// 	public T getModel() {
// 		return model;
// 	}
// 
// 	@Override
// 	public void setSession(Map<String, Object> sessionMap){
// 		this.sessionMap = sessionMap;
// 	}
// 
// 	@Override
// 	public void setRequest(Map<String, Object> requestMap){
// 		this.requestMap = requestMap;
// 	}
// 
// 	@Override
// 	public void setApplication(Map<String, Object> applicationMap) {
// 		this.applicationMap = applicationMap;
// 	}
// 
// }
// 
// Path: src/com/cjlu/newspublish/models/User.java
// public class User extends BaseEntity {
// 
// 	private static final long serialVersionUID = 6923757046786572615L;
// 	private String username;
// 	private String password;
// 	private String email;
// 	private Date createTime = new Date();
// 
// 	public String getUsername() {
// 		return username;
// 	}
// 
// 	public void setUsername(String username) {
// 		this.username = username;
// 	}
// 
// 	public String getPassword() {
// 		return password;
// 	}
// 
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// 
// 	public String getEmail() {
// 		return email;
// 	}
// 
// 	public void setEmail(String email) {
// 		this.email = email;
// 	}
// 
// 	public Date getCreateTime() {
// 		return createTime;
// 	}
// 
// 	public void setCreateTime(Date createTime) {
// 		this.createTime = createTime;
// 	}
// 	
// }
// 
// Path: src/com/cjlu/newspublish/services/UserService.java
// public interface UserService extends BaseService<User>{
// 	
// 	public boolean isTokenUp(String str);
// 	
// 	public User isUser(String username,String password);
// 
// 	public void deleteUser(Integer id);
// 
// }


// Path: src/com/cjlu/newspublish/actions/impl/UserAction.java
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.util.List;
import javassist.bytecode.stackmap.TypeData.ClassName;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.cjlu.newspublish.actions.BaseAction;
import com.cjlu.newspublish.models.User;
import com.cjlu.newspublish.services.UserService;

	private List<User> allUsers = null;
	private static Logger logger = Logger.getLogger(ClassName.class);

	public String loginout() {
		sessionMap.put("user", null);
		httpSession.invalidate();
		return "to_NewsAction_getAllPassedNews";
	}

	public String getAllUsers() {
		allUsers = userService.findAllEntities();
		requestMap.put("allUsers", allUsers);
		return "to_userListPage";
	}

	public String deleteUser() {
		try {
			if (model.getId() != null && model.getId() > 0) {
				userService.deleteUser(model.getId());
				inputStream = new ByteArrayInputStream("1".getBytes("UTF-8"));
				logger.info("¹ÜÀíÔ±É¾³ýÓÃ»§£º" + model.getUsername());
			}
		} catch (Exception e) {
			try {
				inputStream = new ByteArrayInputStream("0".getBytes("UTF-8"));
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
		}

		return "ajax_success";