/.settings/ChurchPM/src/com/church/action/Register.java

http://cp3046team03bj.codeplex.com · Java · 173 lines · 134 code · 36 blank · 3 comment · 2 complexity · 8fd36b378bc463c227a37aceb723f8a9 MD5 · raw file

  1. package com.church.action;
  2. import java.util.Date;
  3. import com.church.db.User;
  4. import com.church.services.UserServices;
  5. import com.opensymphony.xwork2.ActionSupport;
  6. public class Register extends ActionSupport {
  7. /**
  8. *
  9. */
  10. private static final long serialVersionUID = 1L;
  11. private UserServices userServices;
  12. private String name;
  13. private String password;
  14. private String passwordAgain;
  15. private boolean sex;
  16. private Date birthday;
  17. private String graduated;
  18. private String address;
  19. private String mobile;
  20. private String telephone;
  21. private String email;
  22. private String workingOrgans;
  23. private String workPosition;
  24. private String artisticSkills;
  25. public UserServices getUserServices() {
  26. return userServices;
  27. }
  28. public void setUserServices(UserServices userServices) {
  29. this.userServices = userServices;
  30. }
  31. public String getName() {
  32. return name;
  33. }
  34. public void setName(String name) {
  35. this.name = name;
  36. }
  37. public String getPassword() {
  38. return password;
  39. }
  40. public void setPassword(String password) {
  41. this.password = password;
  42. }
  43. public String getPasswordAgain() {
  44. return passwordAgain;
  45. }
  46. public void setPasswordAgain(String passwordAgain) {
  47. this.passwordAgain = passwordAgain;
  48. }
  49. public boolean isSex() {
  50. return sex;
  51. }
  52. public void setSex(boolean sex) {
  53. this.sex = sex;
  54. }
  55. public Date getBirthday() {
  56. return birthday;
  57. }
  58. public void setBirthday(Date birthday) {
  59. this.birthday = birthday;
  60. }
  61. public String getGraduated() {
  62. return graduated;
  63. }
  64. public void setGraduated(String graduated) {
  65. this.graduated = graduated;
  66. }
  67. public String getAddress() {
  68. return address;
  69. }
  70. public void setAddress(String address) {
  71. this.address = address;
  72. }
  73. public String getMobile() {
  74. return mobile;
  75. }
  76. public void setMobile(String mobile) {
  77. this.mobile = mobile;
  78. }
  79. public String getTelephone() {
  80. return telephone;
  81. }
  82. public void setTelephone(String telephone) {
  83. this.telephone = telephone;
  84. }
  85. public String getEmail() {
  86. return email;
  87. }
  88. public void setEmail(String email) {
  89. this.email = email;
  90. }
  91. public String getWorkingOrgans() {
  92. return workingOrgans;
  93. }
  94. public void setWorkingOrgans(String workingOrgans) {
  95. this.workingOrgans = workingOrgans;
  96. }
  97. public String getWorkPosition() {
  98. return workPosition;
  99. }
  100. public void setWorkPosition(String workPosition) {
  101. this.workPosition = workPosition;
  102. }
  103. public String getArtisticSkills() {
  104. return artisticSkills;
  105. }
  106. public void setArtisticSkills(String artisticSkills) {
  107. this.artisticSkills = artisticSkills;
  108. }
  109. public void validate() {
  110. if (!password.equals(passwordAgain)) {
  111. addFieldError("passwordAgain", "second password error!");
  112. }
  113. User user = userServices.findUserByName(name);
  114. if(user!=null)
  115. {
  116. addFieldError("name", "user name exist!");
  117. }
  118. }
  119. public String execute() {
  120. User user=new User();
  121. user.setAddress(address);
  122. user.setArtisticSkills(artisticSkills);
  123. user.setBirthday(birthday);
  124. Date datetime = new Date(System.currentTimeMillis());
  125. user.setCreateDate(datetime);
  126. user.setEmail(email);
  127. user.setGraduated(graduated);
  128. user.setMobile(mobile);
  129. user.setName(name);
  130. user.setPassword(password);
  131. user.setSex(sex);
  132. user.setState("0");
  133. user.setType("user");
  134. user.setGroup("user");
  135. return userServices.register(user);
  136. }
  137. }