package com.inspur.action;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.json.annotations.JSON;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.inspur.model.User;
import com.inspur.service.UserService;
import com.opensymphony.xwork2.ActionSupport;
@Component("userAction")
@Scope("prototype")
public class UserAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
private boolean success;
private String message;
private String randCode;
private User user;
private UserService userService;
public String userLogin() {
HttpSession session = ServletActionContext.getRequest().getSession();
String randCode = (String) session.getAttribute("rand");
boolean flag1 = randCode.trim().equals(this.getRandCode().trim()) ? true
: false;
boolean flag2 = userService.login(user);
if (!flag1) {
this.success = false;
this.message = "你输入的验证码错误!";
} else if (!(flag1 && flag2)) {
this.success = false;
this.message = "你输入的账号或密码错误!";
} else {
this.success = true;
this.message = "登录成功!";
}
return SUCCESS;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@JSON(serialize = false)
public UserService getUserService() {
return userService;
}
@Resource
public void setUserService(UserService userService) {
this.userService = userService;
}
@JSON(serialize = false)
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getRandCode() {
return randCode;
}
public void setRandCode(String randCode) {
this.randCode = randCode;
}
}
最近下载更多
lironggang LV38
2022年8月8日
3106001395 LV1
2021年12月19日
wangzile1994 LV12
2020年3月26日
newnu88 LV12
2020年2月17日
何秀好 LV13
2019年11月19日
wacxin LV10
2019年6月25日
yrfoogd LV5
2019年6月21日
_stary LV1
2019年5月31日
wknyhu LV2
2019年1月14日
chikin333 LV11
2018年11月27日
最近浏览更多
随便取个名字_哈哈 LV27
2024年11月23日
chongminzheng LV1
2024年7月13日
WBelong LV8
2023年12月11日
微信网友_6549826556514304 LV2
2023年7月6日
18103847055 LV8
2023年4月25日
haoyi198 LV3
2023年1月11日
uni-code_0123 LV1
2022年11月16日
唐老鸭 LV26
2022年6月23日
getset LV8
2022年4月17日
3106001395 LV1
2021年12月19日

